]> git.ipfire.org Git - ipfire-2.x.git/blob - make.sh
Updated v4l-dvb (2010-05-20).
[ipfire-2.x.git] / make.sh
1 #!/bin/bash
2 ############################################################################
3 # #
4 # This file is part of the IPFire Firewall. #
5 # #
6 # IPFire is free software; you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation; either version 2 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # IPFire is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with IPFire; if not, write to the Free Software #
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
19 # #
20 # Copyright (C) 2007 IPFire-Team <info@ipfire.org>. #
21 # #
22 ############################################################################
23 #
24
25 NAME="IPFire" # Software name
26 SNAME="ipfire" # Short name
27 VERSION="2.6" # Version number
28 CORE="38" # Core Level (Filename)
29 PAKFIRE_CORE="38" # Core Level (PAKFIRE)
30 GIT_BRANCH=`git status | head -n1 | cut -d" " -f4` # Git Branch
31 SLOGAN="www.ipfire.org" # Software slogan
32 CONFIG_ROOT=/var/ipfire # Configuration rootdir
33 NICE=10 # Nice level
34 MAX_RETRIES=1 # prefetch/check loop
35 BUILD_IMAGES=1 # Build USB, Flash and Xen Images
36 KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
37 MACHINE=`uname -m`
38 GIT_TAG=$(git tag | tail -1) # Git Tag
39 GIT_LASTCOMMIT=$(git log | head -n1 | cut -d" " -f2 |head -c8) # Last commit
40 TOOLCHAINVER=2
41 IPFVER="full" # Which versions should be compiled? (full|devel)
42
43 # Debian specific settings
44 if [ ! -e /etc/debian_version ]; then
45 FULLPATH=`which $0`
46 else
47 if [ -x /usr/bin/realpath ]; then
48 FULLPATH=`/usr/bin/realpath $0`
49 else
50 echo "ERROR: Need to do apt-get install realpath"
51 exit 1
52 fi
53 fi
54
55 PWD=`pwd`
56 BASENAME=`basename $0`
57 BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
58 LOGFILE=$BASEDIR/log/_build.preparation.log
59 export BASEDIR LOGFILE
60 DIR_CHK=$BASEDIR/cache/check
61 mkdir $BASEDIR/log/ 2>/dev/null
62
63 # Include funtions
64 . tools/make-functions
65
66 if [ -f .config ]; then
67 . .config
68 else
69 echo -e "${BOLD}No configuration found!${NORMAL}"
70 echo -ne "Do you want to create one (y/N)?"
71 read CREATE_CONFIG
72 echo ""
73 if [ "$CREATE_CONFIG" == "y" ]; then
74 make_config
75 fi
76 fi
77
78 if [ -z $EDITOR ]; then
79 for i in nano emacs vi; do
80 EDITOR=$(which $i 2>/dev/null)
81 if ! [ -z $EDITOR ]; then
82 export EDITOR=$EDITOR
83 break
84 fi
85 done
86 [ -z $EDITOR ] && exiterror "You should have installed an editor."
87 fi
88
89 prepareenv() {
90 ############################################################################
91 # #
92 # Are we running the right shell? #
93 # #
94 ############################################################################
95 if [ ! "$BASH" ]; then
96 exiterror "BASH environment variable is not set. You're probably running the wrong shell."
97 fi
98
99 if [ -z "${BASH_VERSION}" ]; then
100 exiterror "Not running BASH shell."
101 fi
102
103
104 ############################################################################
105 # #
106 # Trap on emergency exit #
107 # #
108 ############################################################################
109 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
110
111
112 ############################################################################
113 # #
114 # Resetting our nice level #
115 # #
116 ############################################################################
117 echo -ne "Resetting our nice level to $NICE" | tee -a $LOGFILE
118 renice $NICE $$ > /dev/null
119 if [ `nice` != "$NICE" ]; then
120 beautify message FAIL
121 exiterror "Failed to set correct nice level"
122 else
123 beautify message DONE
124 fi
125
126
127 ############################################################################
128 # #
129 # Checking if running as root user #
130 # #
131 ############################################################################
132 echo -ne "Checking if we're running as root user" | tee -a $LOGFILE
133 if [ `id -u` != 0 ]; then
134 beautify message FAIL
135 exiterror "Not building as root"
136 else
137 beautify message DONE
138 fi
139
140
141 ############################################################################
142 # #
143 # Checking for necessary temporary space #
144 # #
145 ############################################################################
146 echo -ne "Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
147 BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
148 BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
149 if (( 2048000 > $BASE_ASPACE )); then
150 BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
151 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
152 beautify message FAIL
153 exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
154 fi
155 else
156 beautify message DONE
157 fi
158
159 ############################################################################
160 # #
161 # Building Linux From Scratch system #
162 # #
163 ############################################################################
164 # Set umask
165 umask 022
166
167 # Set LFS Directory
168 LFS=$BASEDIR/build
169
170 # Check /tools symlink
171 if [ -h /tools ]; then
172 rm -f /tools
173 fi
174 if [ ! -a /tools ]; then
175 ln -s $BASEDIR/build/tools /
176 fi
177 if [ ! -h /tools ]; then
178 exiterror "Could not create /tools symbolic link."
179 fi
180
181 # Setup environment
182 set +h
183 LC_ALL=POSIX
184 if [ -z $MAKETUNING ]; then
185 MAKETUNING="-j6"
186 fi
187 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
188 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
189
190 # Make some extra directories
191 mkdir -p $BASEDIR/build/{tools,etc,usr/src} 2>/dev/null
192 mkdir -p $BASEDIR/build/{dev/{shm,pts},proc,sys}
193 mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
194 mkdir -p $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
195
196 mknod -m 600 $BASEDIR/build/dev/console c 5 1 2>/dev/null
197 mknod -m 666 $BASEDIR/build/dev/null c 1 3 2>/dev/null
198
199 # Make all sources and proc available under lfs build
200 mount --bind /dev $BASEDIR/build/dev
201 mount --bind /dev/pts $BASEDIR/build/dev/pts
202 mount --bind /dev/shm $BASEDIR/build/dev/shm
203 mount --bind /proc $BASEDIR/build/proc
204 mount --bind /sys $BASEDIR/build/sys
205 mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache
206 mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
207 mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
208 mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc
209 mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html
210 mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs
211 mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs
212 mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log
213 mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src
214
215 # This is a temporary hack!!!
216 if [ ! -f /tools/bin/hostname ]; then
217 cp -f /bin/hostname /tools/bin/hostname 2>/dev/null
218 fi
219
220 # Run LFS static binary creation scripts one by one
221 export CCACHE_DIR=$BASEDIR/ccache
222 export CCACHE_HASHDIR=1
223
224 # Remove pre-install list of installed files in case user erase some files before rebuild
225 rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
226 }
227
228 buildtoolchain() {
229 LOGFILE="$BASEDIR/log/_build.toolchain.log"
230 export LOGFILE
231 ORG_PATH=$PATH
232 NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}`
233 export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
234 lfsmake1 ccache
235 lfsmake1 binutils PASS=1
236 lfsmake1 gcc PASS=1
237 export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
238 lfsmake1 linux-libc-header
239 lfsmake1 glibc
240 lfsmake1 cleanup-toolchain PASS=1
241 lfsmake1 tcl
242 lfsmake1 expect
243 lfsmake1 dejagnu
244 lfsmake1 gcc PASS=2
245 lfsmake1 binutils PASS=2
246 lfsmake1 ncurses
247 lfsmake1 bash
248 lfsmake1 bzip2
249 lfsmake1 coreutils
250 lfsmake1 diffutils
251 lfsmake1 findutils
252 lfsmake1 gawk
253 lfsmake1 gettext
254 lfsmake1 grep
255 lfsmake1 gzip
256 lfsmake1 m4
257 lfsmake1 make
258 lfsmake1 patch
259 lfsmake1 perl
260 lfsmake1 sed
261 lfsmake1 tar
262 lfsmake1 texinfo
263 lfsmake1 util-linux
264 lfsmake1 cleanup-toolchain PASS=2
265 export PATH=$ORG_PATH
266 }
267
268 buildbase() {
269 LOGFILE="$BASEDIR/log/_build.base.log"
270 export LOGFILE
271 lfsmake2 stage2
272 lfsmake2 linux-libc-header
273 lfsmake2 man-pages
274 lfsmake2 glibc
275 lfsmake2 cleanup-toolchain PASS=3
276 lfsmake2 binutils
277 lfsmake2 gcc
278 lfsmake2 berkeley
279 lfsmake2 coreutils
280 lfsmake2 iana-etc
281 lfsmake2 m4
282 lfsmake2 bison
283 lfsmake2 ncurses
284 lfsmake2 procps
285 lfsmake2 sed
286 lfsmake2 libtool
287 lfsmake2 perl
288 lfsmake2 readline
289 lfsmake2 zlib
290 lfsmake2 autoconf
291 lfsmake2 automake
292 lfsmake2 bash
293 lfsmake2 bzip2
294 lfsmake2 diffutils
295 lfsmake2 e2fsprogs
296 lfsmake2 ed
297 lfsmake2 file
298 lfsmake2 findutils
299 lfsmake2 flex
300 lfsmake2 gawk
301 lfsmake2 gettext
302 lfsmake2 grep
303 lfsmake2 groff
304 lfsmake2 gzip
305 lfsmake2 inetutils
306 lfsmake2 iproute2
307 lfsmake2 kbd
308 lfsmake2 less
309 lfsmake2 libaal
310 lfsmake2 make
311 lfsmake2 man
312 lfsmake2 mktemp
313 lfsmake2 module-init-tools
314 lfsmake2 mtd
315 lfsmake2 net-tools
316 lfsmake2 patch
317 lfsmake2 psmisc
318 lfsmake2 reiser4progs
319 lfsmake2 shadow
320 lfsmake2 sysklogd
321 lfsmake2 sysvinit
322 lfsmake2 tar
323 lfsmake2 texinfo
324 lfsmake2 udev
325 lfsmake2 util-linux
326 lfsmake2 vim
327 lfsmake2 grub
328 }
329
330 buildipfire() {
331 LOGFILE="$BASEDIR/log/_build.ipfire.log"
332 export LOGFILE
333 ipfiremake configroot
334 ipfiremake backup
335 ipfiremake dhcp
336 ipfiremake dhcpcd
337 ipfiremake libusb
338 ipfiremake libpcap
339 ipfiremake ppp
340 ipfiremake rp-pppoe
341 ipfiremake pptp
342 ipfiremake unzip
343 ipfiremake which
344 ipfiremake xz
345 ipfiremake linux-firmware
346 ipfiremake linux XEN=1
347 ipfiremake kqemu XEN=1
348 ipfiremake v4l-dvb XEN=1
349 ipfiremake madwifi XEN=1
350 ipfiremake dahdi XEN=1 KMOD=1
351 ipfiremake cryptodev XEN=1
352 ipfiremake linux
353 ipfiremake kqemu
354 ipfiremake kvm-kmod
355 ipfiremake v4l-dvb
356 ipfiremake madwifi
357 ipfiremake alsa KMOD=1
358 ipfiremake dahdi KMOD=1
359 ipfiremake cryptodev
360 ipfiremake pkg-config
361 ipfiremake linux-atm
362 ipfiremake cpio
363 ipfiremake klibc
364 ipfiremake mkinitcpio
365 ipfiremake udev KLIBC=1
366 ipfiremake expat
367 ipfiremake gdbm
368 ipfiremake gmp
369 ipfiremake pam
370 ipfiremake openssl
371 ipfiremake curl
372 ipfiremake python
373 ipfiremake libnet
374 ipfiremake libnl
375 ipfiremake libidn
376 ipfiremake libjpeg
377 ipfiremake libpng
378 ipfiremake libtiff
379 ipfiremake libart
380 ipfiremake freetype
381 ipfiremake gd
382 ipfiremake popt
383 ipfiremake pcre
384 ipfiremake slang
385 ipfiremake newt
386 ipfiremake libcap
387 ipfiremake pciutils
388 ipfiremake usbutils
389 ipfiremake libxml2
390 ipfiremake libxslt
391 ipfiremake BerkeleyDB
392 ipfiremake mysql
393 ipfiremake cyrus-sasl
394 ipfiremake openldap
395 ipfiremake apache2
396 ipfiremake php
397 ipfiremake apache2 PASS=C
398 ipfiremake arping
399 ipfiremake beep
400 ipfiremake bind
401 ipfiremake cdrtools
402 ipfiremake dnsmasq
403 ipfiremake dosfstools
404 ipfiremake squashfstools
405 ipfiremake reiserfsprogs
406 ipfiremake xfsprogs
407 ipfiremake sysfsutils
408 ipfiremake fuse
409 ipfiremake ntfs-3g
410 ipfiremake ethtool
411 ipfiremake ez-ipupdate
412 ipfiremake fcron
413 ipfiremake perl-GD
414 ipfiremake GD-Graph
415 ipfiremake GD-TextUtil
416 ipfiremake gnupg
417 ipfiremake hdparm
418 ipfiremake sdparm
419 ipfiremake mtools
420 ipfiremake initscripts
421 ipfiremake whatmask
422 ipfiremake iptables
423 ipfiremake libupnp
424 ipfiremake ipaddr
425 ipfiremake iptstate
426 ipfiremake iputils
427 ipfiremake l7-protocols
428 ipfiremake mISDNuser
429 ipfiremake capi4k-utils
430 ipfiremake hwdata
431 ipfiremake kudzu
432 ipfiremake logrotate
433 ipfiremake logwatch
434 ipfiremake misc-progs
435 ipfiremake nano
436 ipfiremake nasm
437 ipfiremake URI
438 ipfiremake HTML-Tagset
439 ipfiremake HTML-Parser
440 ipfiremake Compress-Zlib
441 ipfiremake Digest
442 ipfiremake Digest-SHA1
443 ipfiremake Digest-HMAC
444 ipfiremake libwww-perl
445 ipfiremake Net-DNS
446 ipfiremake Net-IPv4Addr
447 ipfiremake Net_SSLeay
448 ipfiremake IO-Stringy
449 ipfiremake Unix-Syslog
450 ipfiremake Mail-Tools
451 ipfiremake MIME-Tools
452 ipfiremake Net-Server
453 ipfiremake Convert-TNEF
454 ipfiremake Convert-UUlib
455 ipfiremake Archive-Tar
456 ipfiremake Archive-Zip
457 ipfiremake Text-Tabs+Wrap
458 ipfiremake Locale-Country
459 ipfiremake XML-Parser
460 ipfiremake python-setuptools
461 ipfiremake python-clientform
462 ipfiremake python-mechanize
463 ipfiremake python-feedparser
464 ipfiremake python-rssdler
465 ipfiremake glib
466 ipfiremake GeoIP
467 ipfiremake fwhits
468 ipfiremake noip_updater
469 ipfiremake ntp
470 ipfiremake openssh
471 ipfiremake rrdtool
472 ipfiremake setserial
473 ipfiremake setup
474 ipfiremake snort
475 ipfiremake oinkmaster
476 ipfiremake squid
477 ipfiremake squidguard
478 ipfiremake calamaris
479 ipfiremake tcpdump
480 ipfiremake traceroute
481 ipfiremake vlan
482 ipfiremake wireless
483 ipfiremake libsafe
484 ipfiremake pakfire
485 ipfiremake java
486 ipfiremake spandsp
487 ipfiremake lzo
488 ipfiremake openvpn
489 ipfiremake pammysql
490 ipfiremake cups
491 ipfiremake ghostscript
492 ipfiremake foomatic
493 ipfiremake hplip
494 ipfiremake samba
495 ipfiremake sudo
496 ipfiremake mc
497 ipfiremake wget
498 ipfiremake bridge-utils
499 ipfiremake screen
500 ipfiremake hddtemp
501 ipfiremake smartmontools
502 ipfiremake htop
503 ipfiremake postfix
504 ipfiremake fetchmail
505 ipfiremake cyrus-imapd
506 ipfiremake openmailadmin
507 ipfiremake clamav
508 ipfiremake spamassassin
509 ipfiremake amavisd
510 ipfiremake alsa
511 ipfiremake mpfire
512 ipfiremake guardian
513 ipfiremake libid3tag
514 ipfiremake libmad
515 ipfiremake libogg
516 ipfiremake libvorbis
517 ipfiremake libdvbpsi
518 ipfiremake lame
519 ipfiremake sox
520 ipfiremake libshout
521 ipfiremake xvid
522 ipfiremake libmpeg2
523 ipfiremake cmake
524 ipfiremake gnump3d
525 ipfiremake libsigc++
526 ipfiremake applejuice
527 ipfiremake ocaml
528 ipfiremake mldonkey
529 ipfiremake libtorrent
530 ipfiremake rtorrent
531 ipfiremake ipfireseeder
532 ipfiremake rsync
533 ipfiremake tcpwrapper
534 ipfiremake portmap
535 ipfiremake nfs
536 ipfiremake nmap
537 ipfiremake ncftp
538 ipfiremake etherwake
539 ipfiremake bwm-ng
540 ipfiremake tripwire
541 ipfiremake sysstat
542 ipfiremake vsftpd
543 ipfiremake strongswan
544 ipfiremake lsof
545 ipfiremake centerim
546 ipfiremake br2684ctl
547 ipfiremake pcmciautils
548 ipfiremake lm_sensors
549 ipfiremake liboping
550 ipfiremake collectd
551 ipfiremake lcd4linux
552 ipfiremake teamspeak
553 ipfiremake elinks
554 ipfiremake igmpproxy
555 ipfiremake fbset
556 ipfiremake sdl
557 ipfiremake qemu
558 ipfiremake qemu-kqemu
559 ipfiremake sane
560 ipfiremake netpbm
561 ipfiremake phpSANE
562 ipfiremake tunctl
563 ipfiremake nagios
564 ipfiremake ebtables
565 ipfiremake fontconfig
566 ipfiremake freefont
567 ipfiremake directfb
568 ipfiremake dfb++
569 ipfiremake faad2
570 ipfiremake ffmpeg
571 ipfiremake videolan
572 ipfiremake vdr
573 ipfiremake w_scan
574 ipfiremake icecast
575 ipfiremake icegenerator
576 ipfiremake mpd
577 ipfiremake libmpdclient
578 ipfiremake mpc
579 ipfiremake git
580 ipfiremake squidclamav
581 ipfiremake bc
582 ipfiremake vnstat
583 ipfiremake vnstati
584 ipfiremake iw
585 ipfiremake wpa_supplicant
586 ipfiremake hostapd
587 ipfiremake urlgrabber
588 ipfiremake syslinux
589 ipfiremake tftpd
590 ipfiremake cpufrequtils
591 ipfiremake dbus
592 ipfiremake bluetooth
593 ipfiremake gutenprint
594 ipfiremake apcupsd
595 ipfiremake iperf
596 ipfiremake netcat
597 ipfiremake 7zip
598 ipfiremake lynis
599 ipfiremake splix
600 ipfiremake streamripper
601 ipfiremake sshfs
602 ipfiremake sqlite
603 ipfiremake taglib
604 ipfiremake mediatomb
605 ipfiremake sslh
606 ipfiremake perl-gettext
607 ipfiremake vdradmin
608 ipfiremake miau
609 ipfiremake netsnmpd
610 ipfiremake perl-DBI
611 ipfiremake perl-DBD-mysql
612 ipfiremake cacti
613 ipfiremake icecc
614 ipfiremake open-vm-tools
615 ipfiremake nagiosql
616 ipfiremake iftop
617 ipfiremake motion
618 ipfiremake joe
619 ipfiremake nut
620 ipfiremake watchdog
621 ipfiremake libpri
622 ipfiremake dahdi
623 ipfiremake asterisk
624 ipfiremake lcr
625 ipfiremake usb_modeswitch
626 ipfiremake zerofree
627 ipfiremake mdadm
628 ipfiremake eject
629 ipfiremake pound
630 echo Build on $HOSTNAME > $BASEDIR/build/var/ipfire/firebuild
631 cat /proc/version >> $BASEDIR/build/var/ipfire/firebuild
632 echo >> $BASEDIR/build/var/ipfire/firebuild
633 git log -1 >> $BASEDIR/build/var/ipfire/firebuild
634 echo >> $BASEDIR/build/var/ipfire/firebuild
635 git status >> $BASEDIR/build/var/ipfire/firebuild
636 echo >> $BASEDIR/build/var/ipfire/firebuild
637 cat /proc/cpuinfo >> $BASEDIR/build/var/ipfire/firebuild
638 echo $PAKFIRE_CORE > $BASEDIR/build/opt/pakfire/db/core/mine
639 if [ "$GIT_BRANCH" = "master" ]; then
640 echo "$NAME $VERSION - (Development Build: $GIT_LASTCOMMIT)" > $BASEDIR/build/etc/system-release
641 else
642 echo "$NAME $VERSION - $GIT_BRANCH" > $BASEDIR/build/etc/system-release
643 fi
644 }
645
646 buildinstaller() {
647 # Run installer scripts one by one
648 LOGFILE="$BASEDIR/log/_build.installer.log"
649 export LOGFILE
650 ipfiremake as86
651 ipfiremake mbr
652 ipfiremake memtest
653 installmake linux-libc-header
654 installmake binutils
655 ipfiremake uClibc PASS=1
656 ipfiremake gcc INST=1
657 installmake uClibc PASS=2
658 installmake gcc INST=2
659 installmake uClibc PASS=3
660 installmake busybox
661 installmake udev
662 installmake slang
663 installmake newt
664 installmake gettext
665 installmake kbd
666 installmake popt
667 installmake sysvinit
668 installmake misc-progs
669 installmake libaal
670 installmake reiser4progs
671 installmake reiserfsprogs
672 installmake sysfsutils
673 installmake util-linux
674 installmake pciutils
675 installmake zlib
676 installmake mtd
677 installmake wget
678 installmake hwdata
679 installmake kudzu
680 installmake pcmciautils
681 installmake installer
682 installmake initrd
683 }
684
685 buildpackages() {
686 LOGFILE="$BASEDIR/log/_build.packages.log"
687 export LOGFILE
688 echo "... see detailed log in _build.*.log files" >> $LOGFILE
689
690 installmake strip
691
692 # Generating list of packages used
693 echo -n "Generating packages list from logs" | tee -a $LOGFILE
694 rm -f $BASEDIR/doc/packages-list
695 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
696 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
697 echo "* `basename $i`" >>$BASEDIR/doc/packages-list
698 fi
699 done
700 echo "== List of softwares used to build $NAME Version: $VERSION ==" > $BASEDIR/doc/packages-list.txt
701 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|setup$\|pakfire$\|stage2$\|smp$\|tools$\|tools1$\|tools2$\|.tgz$\|-config$\|_missing_rootfile$\|install1$\|install2$\|pass1$\|pass2$\|pass3$' \
702 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
703 rm -f $BASEDIR/doc/packages-list
704 # packages-list.txt is ready to be displayed for wiki page
705 beautify message DONE
706
707 # Update changelog
708 cd $BASEDIR
709 $0 git log
710
711 # Create images for install
712 ipfiremake cdrom ED=$IPFVER
713
714 # Check if there is a loop device for building in virtual environments
715 if [ $BUILD_IMAGES == 1 ] && ([ -e /dev/loop/0 ] || [ -e /dev/loop0 ]); then
716 ipfiremake usb-stick ED=$IPFVER
717 ipfiremake flash-images ED=$IPFVER
718 fi
719
720 mv $LFS/install/images/{*.iso,*.tgz,*.img.gz,*.bz2} $BASEDIR >> $LOGFILE 2>&1
721
722 ipfirepackages
723
724 # Check if there is a loop device for building in virtual environments
725 if [ $BUILD_IMAGES == 1 ] && ([ -e /dev/loop/0 ] || [ -e /dev/loop0 ]); then
726 cp -f $BASEDIR/packages/linux-xen-*.ipfire $LFS/install/packages/
727 cp -f $BASEDIR/packages/meta-linux-xen $LFS/install/packages/
728 ipfiremake xen-image ED=$IPFVER
729 rm -rf $LFS/install/packages/linux-xen-*.ipfire
730 rm -rf $LFS/install/packages/meta-linux-xen
731 fi
732 mv $LFS/install/images/*.bz2 $BASEDIR >> $LOGFILE 2>&1
733
734 # Cleanup
735 stdumount
736 rm -rf $BASEDIR/build/tmp/*
737
738 # Generating total list of files
739 echo -n "Generating files list from logs" | tee -a $LOGFILE
740 rm -f $BASEDIR/log/FILES
741 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
742 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
743 echo "##" >>$BASEDIR/log/FILES
744 echo "## `basename $i`" >>$BASEDIR/log/FILES
745 echo "##" >>$BASEDIR/log/FILES
746 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
747 fi
748 done
749 beautify message DONE
750
751 cd $PWD
752 }
753
754 ipfirepackages() {
755 ipfiremake core-updates
756 for i in $(ls -1 $BASEDIR/config/rootfiles/packages); do
757 if [ -e $BASEDIR/lfs/$i ]; then
758 ipfiredist $i
759 else
760 echo -n $i
761 beautify message SKIP
762 fi
763 done
764 test -d $BASEDIR/packages || mkdir $BASEDIR/packages
765 mv -f $LFS/install/packages/* $BASEDIR/packages >> $LOGFILE 2>&1
766 rm -rf $BASEDIR/build/install/packages/*
767 }
768
769 # See what we're supposed to do
770 case "$1" in
771 build)
772 clear
773 BUILDMACHINE=`uname -m`
774 PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
775 #only restore on a clean disk
776 if [ ! -f log/cleanup-toolchain-2-tools ]; then
777 if [ ! -n "$PACKAGE" ]; then
778 beautify build_stage "Full toolchain compilation - Native GCC: `gcc --version | grep GCC | awk {'print $3'}`"
779 prepareenv
780 buildtoolchain
781 else
782 PACKAGENAME=${PACKAGE%.tar.gz}
783 beautify build_stage "Packaged toolchain compilation"
784 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
785 tar zxf $PACKAGE
786 prepareenv
787 else
788 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
789 fi
790 fi
791 else
792 echo -n "Using installed toolchain" | tee -a $LOGFILE
793 beautify message SKIP
794 prepareenv
795 fi
796
797 beautify build_start
798 beautify build_stage "Building LFS"
799 buildbase
800
801 beautify build_stage "Building IPFire"
802 buildipfire
803
804 beautify build_stage "Building installer"
805 buildinstaller
806
807 beautify build_stage "Building packages"
808 buildpackages
809
810 beautify build_stage "Checking Logfiles for new Files"
811 cd ..
812 tools/checknewlog.pl
813
814 beautify build_end
815 ;;
816 shell)
817 # enter a shell inside LFS chroot
818 # may be used to changed kernel settings
819 prepareenv
820 entershell
821 ;;
822 clean)
823 echo -en "${BOLD}Cleaning build directory...${NORMAL}"
824 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
825 $LOSETUP -d $i 2>/dev/null
826 done
827 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
828 umount $i
829 done
830 stdumount
831 for i in `seq 0 7`; do
832 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
833 umount /dev/loop${i} 2>/dev/null;
834 losetup -d /dev/loop${i} 2>/dev/null;
835 fi;
836 done
837 rm -rf $BASEDIR/build
838 rm -rf $BASEDIR/cdrom
839 rm -rf $BASEDIR/packages
840 rm -rf $BASEDIR/log
841 if [ -h /tools ]; then
842 rm -f /tools
843 fi
844 beautify message DONE
845 ;;
846 downloadsrc)
847 if [ ! -d $BASEDIR/cache ]; then
848 mkdir $BASEDIR/cache
849 fi
850 mkdir -p $BASEDIR/log
851 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
852 FINISHED=0
853 cd $BASEDIR/lfs
854 for c in `seq $MAX_RETRIES`; do
855 if (( FINISHED==1 )); then
856 break
857 fi
858 FINISHED=1
859 cd $BASEDIR/lfs
860 for i in *; do
861 if [ -f "$i" -a "$i" != "Config" ]; then
862 echo -ne "Loading $i"
863 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
864 if [ $? -ne 0 ]; then
865 beautify message FAIL
866 FINISHED=0
867 else
868 if [ $c -eq 1 ]; then
869 beautify message DONE
870 fi
871 fi
872 fi
873 done
874 done
875 echo -e "${BOLD}***Verifying md5sums${NORMAL}"
876 ERROR=0
877 for i in *; do
878 if [ -f "$i" -a "$i" != "Config" ]; then
879 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
880 if [ $? -ne 0 ]; then
881 echo -ne "MD5 difference in lfs/$i"
882 beautify message FAIL
883 ERROR=1
884 fi
885 fi
886 done
887 if [ $ERROR -eq 0 ]; then
888 echo -ne "${BOLD}all files md5sum match${NORMAL}"
889 beautify message DONE
890 else
891 echo -ne "${BOLD}not all files were correctly download${NORMAL}"
892 beautify message FAIL
893 fi
894 cd - >/dev/null 2>&1
895 ;;
896 toolchain)
897 clear
898 prepareenv
899 beautify build_stage "Toolchain compilation - Native GCC: `gcc --version | grep GCC | awk {'print $3'}`"
900 buildtoolchain
901 BUILDMACHINE=`uname -m`
902 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
903 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
904 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.tar.gz \
905 build/{bin,etc,usr/bin,usr/local} \
906 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
907 log >> $LOGFILE
908 md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.tar.gz \
909 > cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.md5
910 stdumount
911 ;;
912 gettoolchain)
913 BUILDMACHINE=`uname -m`
914 # arbitrary name to be updated in case of new toolchain package upload
915 PACKAGE=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE
916 if [ ! -f $BASEDIR/cache/toolchains/$PACKAGE.tar.gz ]; then
917 URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
918 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
919 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
920 cd $BASEDIR/cache/toolchains
921 wget -U "IPFireSourceGrabber/2.x" $URL_TOOLCHAIN/$PACKAGE.tar.gz $URL_TOOLCHAIN/$PACKAGE.md5 >& /dev/null
922 if [ $? -ne 0 ]; then
923 echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
924 else
925 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
926 echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
927 else
928 exiterror "$PACKAGE.md5 did not match, check downloaded package"
929 fi
930 fi
931 else
932 echo "Toolchain is already downloaded. Exiting..."
933 fi
934 ;;
935 othersrc)
936 prepareenv
937 echo -ne "`date -u '+%b %e %T'`: Build sources iso for $MACHINE" | tee -a $LOGFILE
938 chroot $LFS /tools/bin/env -i HOME=/root \
939 TERM=$TERM PS1='\u:\w\$ ' \
940 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
941 VERSION=$VERSION NAME="$NAME" SNAME="$SNAME" MACHINE=$MACHINE \
942 /bin/bash -x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
943 mv $LFS/install/images/ipfire-* $BASEDIR >> $LOGFILE 2>&1
944 if [ $? -eq "0" ]; then
945 beautify message DONE
946 else
947 beautify message FAIL
948 fi
949 stdumount
950 ;;
951 git)
952 case "$2" in
953 update|up)
954 ## REMOVES ALL UNCOMMITTED CHANGES!
955 [ "$3" == "--force" ] && git checkout -f
956 git pull
957 ;;
958 commit|ci)
959 shift 2
960 git commit $*
961
962 [ "$?" -eq "0" ] || exiterror "git commit $* failed."
963
964 echo -e "${BOLD}Do you want to push, too? [y/N]${NORMAL}"
965 read
966 [ -z $REPLY ] && exit 0
967 for i in y Y j J; do
968 if [ "$i" == "$REPLY" ]; then
969 $0 git push
970 exit $?
971 fi
972 done
973 exiterror "\"$REPLY\" is not a valid answer."
974 ;;
975 dist)
976 git archive HEAD | gzip -9 > ${SNAME}-${VERSION}.tar.gz
977 ;;
978 diff|di)
979 echo -ne "Make a local diff to last revision"
980 git diff HEAD > ipfire-diff-$(date +'%Y-%m-%d-%H:%M').diff
981 evaluate 1
982 echo "Diff was successfully saved to ipfire-diff-$(date +'%Y-%m-%d-%H:%M').diff"
983 git diff --stat
984 ;;
985 push)
986 [ -z $GIT_USER ] && exiterror "You have to setup GIT_USER first."
987 GIT_URL="ssh://${GIT_USER}@git.ipfire.org/pub/git/ipfire-2.x"
988
989 git push ${GIT_URL} $3
990 ;;
991 log)
992 [ -z $GIT_TAG ] || LAST_TAG=$GIT_TAG
993 [ -z $LAST_TAG ] || EXT="$LAST_TAG..HEAD"
994
995 git log -n 500 --no-merges --pretty=medium --shortstat $EXT > $BASEDIR/doc/ChangeLog
996 ;;
997 esac
998 ;;
999 uploadsrc)
1000 PWD=`pwd`
1001 if [ -z $IPFIRE_USER ]; then
1002 echo -n "You have to setup IPFIRE_USER first. See .config for details."
1003 beautify message FAIL
1004 exit 1
1005 fi
1006 URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
1007 REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
1008
1009 cd $BASEDIR/cache/
1010 for file in $(ls -1); do
1011 grep -q "$file" <<<$REMOTE_FILES && continue
1012 NEW_FILES="$NEW_FILES $file"
1013 done
1014 [ -n "$NEW_FILES" ] && scp -2 $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
1015 cd $BASEDIR
1016 cd $PWD
1017 exit 0
1018 ;;
1019 batch)
1020 if [ "$2" = "--background" ]; then
1021 batch_script
1022 exit $?
1023 fi
1024 if [ `screen -ls | grep -q ipfire` ]; then
1025 echo "Build is already running, sorry!"
1026 exit 1
1027 else
1028 if [ "$2" = "--rebuild" ]; then
1029 export IPFIRE_REBUILD=1
1030 echo "REBUILD!"
1031 else
1032 export IPFIRE_REBUILD=0
1033 fi
1034 echo -en "${BOLD}***IPFire-Batch-Build is starting...${NORMAL}"
1035 screen -dmS ipfire $0 batch --background
1036 evaluate 1
1037 exit 0
1038 fi
1039 ;;
1040 watch)
1041 watch_screen
1042 ;;
1043 pxe)
1044 case "$2" in
1045 start)
1046 start_tftpd
1047 ;;
1048 stop)
1049 stop_tftpd
1050 ;;
1051 reload|restart)
1052 reload_tftpd
1053 ;;
1054 esac
1055 exit 0
1056 ;;
1057 lang)
1058 update_langs
1059 ;;
1060 "")
1061 clear
1062 select name in "Exit" "IPFIRE: Downloadsrc" "IPFIRE: Build (silent)" "IPFIRE: Watch Build" "IPFIRE: Batch" "IPFIRE: Clean" "LOG: Tail" "Help"
1063 do
1064 case $name in
1065 "IPFIRE: Downloadsrc")
1066 $0 downloadsrc
1067 ;;
1068 "IPFIRE: Build (silent)")
1069 $0 build-silent
1070 ;;
1071 "IPFIRE: Watch Build")
1072 $0 watch
1073 ;;
1074 "IPFIRE: Batch")
1075 $0 batch
1076 ;;
1077 "IPFIRE: Clean")
1078 $0 clean
1079 ;;
1080 "Help")
1081 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
1082 cat doc/make.sh-usage
1083 ;;
1084 "LOG: Tail")
1085 tail -f log/_*
1086 ;;
1087 "Exit")
1088 break
1089 ;;
1090 esac
1091 done
1092 ;;
1093 config)
1094 make_config
1095 ;;
1096 *)
1097 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
1098 cat doc/make.sh-usage
1099 ;;
1100 esac