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