3 ############################################################################
5 # This file is part of the IPFire Firewall. #
7 # IPFire is free software; you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation; either version 2 of the License, or #
10 # (at your option) any later version. #
12 # IPFire is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with IPFire; if not, write to the Free Software #
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21 # Copyright (C) 2006 IPFire-Team <entwickler@ipfire.org>. #
23 ############################################################################
26 NAME="IPFire" # Software name
27 SNAME="ipfire" # Short name
28 VERSION="1.4" # Version number
29 SLOGAN="We secure your network" # Software slogan
30 CONFIG_ROOT=/var/ipfire # Configuration rootdir
32 MAX_RETRIES=3 # prefetch/check loop
33 KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
36 # Debian specific settings
37 if [ ! -e /etc/debian_version ]; then
40 if [ -x /usr/bin/realpath ]; then
41 FULLPATH=`/usr/bin/realpath $0`
43 echo "ERROR: Need to do apt-get install realpath"
50 BASENAME=`basename $0`
51 BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
52 LOGFILE=$BASEDIR/log/_build.preparation.log
53 export BASEDIR LOGFILE
54 DIR_CHK=$BASEDIR/cache/check
55 mkdir $BASEDIR/log/ 2>/dev/null
57 if [ 'x86_64' = $MACHINE -o 'i686' = $MACHINE -o 'i586' = $MACHINE -o 'i486' = $MACHINE -o 'i386' = $MACHINE ]; then
58 echo "`date -u '+%b %e %T'`: Machine is ix86 (or equivalent)" | tee -a $LOGFILE
60 BUILDTARGET=i386-pc-linux-gnu
61 CFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
62 CXXFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
63 elif [ 'alpha' = $MACHINE ]; then
64 echo "`date -u '+%b %e %T'`: Machine is Alpha AXP" | tee -a $LOGFILE
65 BUILDTARGET=alpha-unknown-linux-gnu
66 CFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
67 CXXFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
69 echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" | tee -a $LOGFILE
75 umount $BASEDIR/build/dev/pts 2>/dev/null;
76 umount $BASEDIR/build/proc 2>/dev/null;
77 umount $BASEDIR/build/install/mnt 2>/dev/null;
78 umount $BASEDIR/build/usr/src/cache 2>/dev/null;
79 umount $BASEDIR/build/usr/src/ccache 2>/dev/null;
80 umount $BASEDIR/build/usr/src/config 2>/dev/null;
81 umount $BASEDIR/build/usr/src/doc 2>/dev/null;
82 umount $BASEDIR/build/usr/src/html 2>/dev/null;
83 umount $BASEDIR/build/usr/src/langs 2>/dev/null;
84 umount $BASEDIR/build/usr/src/lfs 2>/dev/null;
85 umount $BASEDIR/build/usr/src/log 2>/dev/null;
86 umount $BASEDIR/build/usr/src/src 2>/dev/null;
91 for i in `seq 0 7`; do
92 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
93 losetup -d /dev/loop${i} 2>/dev/null
97 echo " Check $LOGFILE for errors if applicable"
102 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
103 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
105 echo "Entering to a shell inside LFS chroot, go out with exit"
106 chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
107 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
108 VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
109 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
110 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
111 CCACHE_DIR=/usr/src/ccache \
114 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
115 KGCC="ccache /usr/bin/gcc" \
117 if [ $? -ne 0 ]; then
118 exiterror "chroot error"
125 ############################################################################
127 # Are we running the right shell? #
129 ############################################################################
130 if [ ! "$BASH" ]; then
131 exiterror "BASH environment variable is not set. You're probably running the wrong shell."
134 if [ -z "${BASH_VERSION}" ]; then
135 exiterror "Not running BASH shell."
139 ############################################################################
141 # Trap on emergency exit #
143 ############################################################################
144 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
147 ############################################################################
149 # Resetting our nice level #
151 ############################################################################
152 echo "`date -u '+%b %e %T'`: Resetting our nice level to $NICE" | tee -a $LOGFILE
153 renice $NICE $$ > /dev/null
154 if [ `nice` != "$NICE" ]; then
155 exiterror "Failed to set correct nice level"
158 ############################################################################
160 # Checking if running as root user #
162 ############################################################################
163 echo "`date -u '+%b %e %T'`: Checking if we're running as root user" | tee -a $LOGFILE
164 if [ `id -u` != 0 ]; then
165 exiterror "Not building as root"
169 ############################################################################
171 # Checking for necessary temporary space #
173 ############################################################################
174 echo "`date -u '+%b %e %T'`: Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
175 BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
176 BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
177 if (( 2202000 > $BASE_ASPACE )); then
178 BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
179 if (( 2202000 - $BASE_USPACE > $BASE_ASPACE )); then
180 exiterror "Not enough temporary space available, need at least 2.1GB on $BASE_DEV"
184 ############################################################################
186 # Building Linux From Scratch system #
188 ############################################################################
189 echo "`date -u '+%b %e %T'`: Building Linux From Scratch system" | tee -a $LOGFILE
197 # Check /tools symlink
198 if [ -h /tools ]; then
201 if [ ! -a /tools ]; then
202 ln -s $BASEDIR/build/tools /
204 if [ ! -h /tools ]; then
205 exiterror "Could not create /tools symbolic link."
211 export LFS LC_ALL CFLAGS CXXFLAGS
212 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
214 # Make some extra directories
215 mkdir -p $BASEDIR/build/{tools,etc,usr/src} 2>/dev/null
216 mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
217 mkdir -p $BASEDIR/build/dev/pts $BASEDIR/build/proc $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
219 # Make all sources and proc available under lfs build
220 mount --bind /dev/pts $BASEDIR/build/dev/pts
221 mount --bind /proc $BASEDIR/build/proc
222 mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache
223 mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
224 mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
225 mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc
226 mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html
227 mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs
228 mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs
229 mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log
230 mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src
232 # Run LFS static binary creation scripts one by one
233 export CCACHE_DIR=$BASEDIR/ccache
234 export CCACHE_HASHDIR=1
236 # Remove pre-install list of installed files in case user erase some files before rebuild
237 rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
241 ############################################################################
243 # Necessary shell functions #
245 ############################################################################
247 if [ -f $BASEDIR/lfs/$1 ]; then
248 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
249 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1
250 if [ $? -ne 0 ]; then
251 exiterror "Download error in $1"
253 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
254 if [ $? -ne 0 ]; then
255 exiterror "md5sum error in $1, check file in cache or signature"
257 cd $BASEDIR/lfs && make -f $* BUILDTARGET=$BUILDTARGET \
259 LFS_BASEDIR=$BASEDIR \
262 install >> $LOGFILE 2>&1
263 if [ $? -ne 0 ]; then
264 exiterror "Building $*";
267 exiterror "No such file or directory: $BASEDIR/$1"
273 if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
274 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
275 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1
276 if [ $? -ne 0 ]; then
277 exiterror "Download error in $1"
279 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
280 if [ $? -ne 0 ]; then
281 exiterror "md5sum error in $1, check file in cache or signature"
283 chroot $LFS /tools/bin/env -i HOME=/root \
284 TERM=$TERM PS1='\u:\w\$ ' \
285 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
287 CONFIG_ROOT=$CONFIG_ROOT \
288 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
289 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
290 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
292 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
293 /tools/bin/bash -x -c "cd /usr/src/lfs && \
294 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
295 if [ $? -ne 0 ]; then
296 exiterror "Building $*"
299 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
305 if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
306 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
307 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1
308 if [ $? -ne 0 ]; then
309 exiterror "Download error in $1"
311 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
312 if [ $? -ne 0 ]; then
313 exiterror "md5sum error in $1, check file in cache or signature"
315 chroot $LFS /tools/bin/env -i HOME=/root \
316 TERM=$TERM PS1='\u:\w\$ ' \
317 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
319 CONFIG_ROOT=$CONFIG_ROOT \
320 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
321 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
322 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
324 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
325 /bin/bash -x -c "cd /usr/src/lfs && \
326 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
327 if [ $? -ne 0 ]; then
328 exiterror "Building $*"
331 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
337 if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
338 echo "`date -u '+%b %e %T'`: Packaging $1" | tee -a $LOGFILE
339 cp -f $BASEDIR/src/scripts/make-packages.sh $BASEDIR/build/usr/local/bin
340 chroot $LFS /tools/bin/env -i HOME=/root \
341 TERM=$TERM PS1='\u:\w\$ ' \
342 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
344 CONFIG_ROOT=$CONFIG_ROOT \
345 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
346 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
347 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
349 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
350 /bin/bash -x -c "cd /usr/src/lfs && \
351 make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
352 if [ $? -ne 0 ]; then
353 exiterror "Packaging $1"
356 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
358 # test -d $BASEDIR/packages || mkdir $BASEDIR/packages
359 # mv -f $BASEDIR/build/paks/* $BASEDIR/packages/
365 if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
366 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
367 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1
368 if [ $? -ne 0 ]; then
369 exiterror "Download error in $1"
371 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
372 if [ $? -ne 0 ]; then
373 exiterror "md5sum error in $1, check file in cache or signature"
375 chroot $LFS /tools/bin/env -i HOME=/root \
376 TERM=$TERM PS1='\u:\w\$ ' \
377 PATH=/usr/local/bin:/opt/$MACHINE-uClibc/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin \
379 CONFIG_ROOT=$CONFIG_ROOT \
381 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
382 CFLAGS="-Os" CXXFLAGS="-Os" \
383 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
385 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
386 /bin/bash -x -c "cd /usr/src/lfs && \
387 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
388 if [ $? -ne 0 ]; then
389 exiterror "Building $*"
392 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
398 LOGFILE="$BASEDIR/log/_build.toolchain.log"
400 echo -ne "`date -u '+%b %e %T'`: Stage1 toolchain build \n" | tee -a $LOGFILE
401 # Build sed now, as we use some extensions
403 NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}`
404 export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
406 lfsmake1 sed LFS_PASS=1
407 lfsmake1 m4 LFS_PASS=1
408 lfsmake1 bison LFS_PASS=1
409 lfsmake1 flex LFS_PASS=1
410 lfsmake1 binutils LFS_PASS=1
411 lfsmake1 gcc LFS_PASS=1
412 export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
419 lfsmake1 gcc LFS_PASS=2
420 lfsmake1 binutils LFS_PASS=2
429 lfsmake1 sed LFS_PASS=2
430 lfsmake1 m4 LFS_PASS=2
431 lfsmake1 bison LFS_PASS=2
432 lfsmake1 flex LFS_PASS=2
441 export PATH=$ORG_PATH
445 LOGFILE="$BASEDIR/log/_build.base.log"
447 echo -ne "`date -u '+%b %e %T'`: Stage2 linux base build \n" | tee -a $LOGFILE
448 # Run LFS dynamic binary creation scripts one by one
486 if [ 'i386' = $MACHINE ]; then
488 elif [ 'alpha' = $MACHINE ]; then
507 # Run IPFire make scripts one by one
508 LOGFILE="$BASEDIR/log/_build.ipfire.log"
510 echo -ne "`date -u '+%b %e %T'`: Stage3 $NAME build \n" | tee -a $LOGFILE
512 # Build these first as some of the kernel packages below rely on
513 # these for some of their client program functionality
524 if [ 'i386' = $MACHINE ]; then
525 # abuse the SMP flag, and make an minimal installer kernel first
526 # so that the boot floppy always works.....
527 ipcopmake linux LFS_PASS=ipcop SMP=installer
528 ipcopmake linux LFS_PASS=ipcop SMP=1
529 ipcopmake 3cp4218 SMP=1
530 ipcopmake amedyn SMP=1
531 ipcopmake cxacru SMP=1
532 ipcopmake eagle SMP=1
534 # These are here because they have i386 only binary libraries
535 # included in the package.
536 ipcopmake cnx_pci SMP=1
537 ipcopmake fcdsl SMP=1
538 ipcopmake fcdsl2 SMP=1
539 ipcopmake fcdslsl SMP=1
540 ipcopmake fcdslusb SMP=1
541 ipcopmake fcdslslusb SMP=1
542 ipcopmake fcpci SMP=1
543 ipcopmake pulsar SMP=1
544 ipcopmake unicorn SMP=1
547 ipcopmake linux LFS_PASS=ipcop
554 if [ 'i386' = $MACHINE ]; then
555 # These are here because they have i386 only binary libraries
556 # included in the package.
587 ipcopmake capi4k-utils
592 ipcopmake ez-ipupdate
598 ipcopmake initscripts
605 ipcopmake isapnptools
606 ipcopmake isdn4k-utils
617 ipcopmake HTML-Tagset
618 ipcopmake HTML-Parser
619 ipcopmake Compress-Zlib
621 ipcopmake Digest-SHA1
622 ipcopmake Digest-HMAC
623 ipcopmake libwww-perl
625 ipcopmake Net-IPv4Addr
628 ipcopmake Unix-Syslog
632 ipcopmake Convert-TNEF
633 ipcopmake Convert-UUlib
634 ipcopmake Archive-Tar
635 ipcopmake Archive-Zip
637 ipcopmake noip_updater
649 ipcopmake squid-graph
656 echo -ne "`date -u '+%b %e %T'`: Building ### IPFire modules ### \n" | tee -a $LOGFILE
658 ## Zuerst die Libs und dann die Programme. Ordnung muss sein!
660 ipcopmake BerkeleyDB ## The Perl module
671 ipcopmake saslauthd PASS=1
673 ipcopmake saslauthd PASS=2
675 ipcopmake ghostscript
677 # ipcopmake lpd ## Im Moment aus, da CUPS vorhanden ist.
684 ipcopmake bridge-utils
685 echo -ne "`date -u '+%b %e %T'`: Building ### Mailserver ### \n" | tee -a $LOGFILE
693 ipcopmake spamassassin
695 echo -ne "`date -u '+%b %e %T'`: Building ### VoIP-Server ### \n" | tee -a $LOGFILE
698 echo -ne "`date -u '+%b %e %T'`: Building ### MP3-Server ### \n" | tee -a $LOGFILE
711 # wget http://www.guzu.net/linux/hddtemp.db && mv hddtemp.db $BASEDIR/build/etc/hddtemp.db
713 # ipcopmake stunnel # Ausgeschaltet, weil wir es doch nicht nutzen
717 # Run installer scripts one by one
718 LOGFILE="$BASEDIR/log/_build.installer.log"
720 echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" | tee -a $LOGFILE
721 if [ 'i386' = $MACHINE ]; then
729 installmake e2fsprogs
730 installmake misc-progs
732 installmake util-linux
735 installmake pcmcia-cs
737 installmake installer
739 installmake driver.img
745 LOGFILE="$BASEDIR/log/_build.packages.log"
747 echo "... see detailed log in _build.*.log files" >> $LOGFILE
748 echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" | tee -a $LOGFILE
750 echo "`date -u '+%b %e %T'`: Stripping files" | tee -a $LOGFILE
751 find $LFS/lib $LFS/usr/lib $LFS/usr/share/rrdtool-* $LFS/install ! -type l \( -name '*.so' -o -name '*.so[\.0-9]*' \) \
752 ! -name 'libc.so' ! -name 'libpthread.so' ! -name 'libcrypto.so.0.9.7.sha1' \
753 -ls -exec $LFS/tools/bin/strip --strip-all {} \; >> $LOGFILE 2>&1
754 # add -ls before -exec if you want to verify what files are stripped
756 find $LFS/{,s}bin $LFS/usr/{,s}bin $LFS/usr/local/{,s}bin ! -type l \
757 -exec file {} \; | grep " ELF " | cut -f1 -d ':' | xargs $LFS/tools/bin/strip --strip-all >> $LOGFILE 2>&1
758 # there add -v to strip to verify
760 if [ 'i386' = $MACHINE ]; then
761 # Create fcdsl packages
762 echo "`date -u '+%b %e %T'`: Building fcdsl tgz" | tee -a $LOGFILE
763 cp $LFS/install/images/fcdsl/license.txt $LFS >> $LOGFILE 2>&1
764 touch $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
765 cd $LFS && tar cvfz $LFS/install/images/$SNAME-fcdsl-$VERSION.$MACHINE.tgz \
766 lib/modules/$KVER/misc/fcdsl*.o.gz \
767 lib/modules/$KVER-smp/misc/fcdsl*.o.gz \
768 usr/lib/isdn/{fds?base.bin,fd?ubase.frm} \
769 etc/fcdsl/fcdsl*.conf \
770 etc/drdsl/{drdsl,drdsl.ini} \
772 var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} >> $LOGFILE 2>&1
773 rm -f $LFS/license.txt >> $LOGFILE 2>&1
777 # Create update for this version
778 # echo "`date -u '+%b %e %T'`: Building update $VERSION tgz" | tee -a $LOGFILE
779 # tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/$VERSION/ROOTFILES.$MACHINE-$VERSION -f $BASEDIR/updates/$VERSION/patch.tar.gz --exclude='#*';
780 # chmod 755 $BASEDIR/updates/$VERSION/setup
781 # tar -cz -C $BASEDIR/updates/$VERSION -f $LFS/install/images/$SNAME-update-$VERSION.$MACHINE.tgz patch.tar.gz setup information
782 # rm -f $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
784 # Generating list of packages used
785 echo "`date -u '+%b %e %T'`: Generating packages list from logs" | tee -a $LOGFILE
786 rm -f $BASEDIR/doc/packages-list
787 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
788 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
789 echo " * `basename $i`" >>$BASEDIR/doc/packages-list
792 echo "====== List of softwares used to build $NAME Version: $VERSION ======" > $BASEDIR/doc/packages-list.txt
793 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|ipcop$\|setup$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \
794 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
795 rm -f $BASEDIR/doc/packages-list
796 # packages-list.txt is ready to be displayed for wiki page
798 # Create ISO for CDRom and USB-superfloppy
800 cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1
802 # Build IPFire packages
817 test -d $BASEDIR/packages || mkdir $BASEDIR/packages
818 cp -f $LFS/paks/*.tar.gz $LFS/paks/*.md5 $BASEDIR/packages >> $LOGFILE 2>&1
822 rm -rf $BASEDIR/build/tmp/*
824 # Generating total list of files
825 echo "`date -u '+%b %e %T'`: Generating files list from logs" | tee -a $LOGFILE
826 rm -f $BASEDIR/log/FILES
827 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
828 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
829 echo "##" >>$BASEDIR/log/FILES
830 echo "## `basename $i`" >>$BASEDIR/log/FILES
831 echo "##" >>$BASEDIR/log/FILES
832 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
840 # See what we're supposed to do
843 BUILDMACHINE=`uname -m`
844 PACKAGE=`ls -v -r $BASEDIR/cache/$SNAME-1.4.*-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
845 #only restore on a clean disk
846 if [ ! -f log/perl-*-tools ]; then
847 if [ ! -n "$PACKAGE" ]; then
848 echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE
852 PACKAGENAME=${PACKAGE%.tar.gz}
853 echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" | tee -a $LOGFILE
854 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
858 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
862 echo "`date -u '+%b %e %T'`: Using installed toolchain" | tee -a $LOGFILE
871 # enter a shell inside LFS chroot
872 # may be used to changed kernel settings
877 echo -n "Loading new Changelog from SVN: "
878 svn log http://svn.ipfire.eu/svn/ipfire > doc/ChangeLog
882 echo "Checking sources files availability on the web"
883 if [ ! -d $DIR_CHK ]; then
888 for c in `seq $MAX_RETRIES`; do
889 if (( FINISHED==1 )); then
895 if [ -f "$i" -a "$i" != "Config" ]; then
896 make -s -f $i MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR ROOT=$BASEDIR/build \
897 MESSAGE="$i\t ($c/$MAX_RETRIES)" check
898 if [ $? -ne 0 ]; then
899 echo "Check : wget error in lfs/$i"
908 echo "Erasing sources files availability tags"
912 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
913 $LOSETUP -d $i 2>/dev/null
915 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
919 for i in `seq 0 7`; do
920 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
921 umount /dev/loop${i} 2>/dev/null;
922 losetup -d /dev/loop${i} 2>/dev/null;
925 rm -rf $BASEDIR/build
926 rm -rf $BASEDIR/cdrom
927 rm -rf $BASEDIR/packages
929 if [ -h /tools ]; then
934 echo -ne "Updating & building source package from SVN: "
936 svn export http://svn.ipfire.eu/svn/ipfire ipfire-source/ --force > /dev/null
937 tar cfz ipfire-source-`date +'%Y-%m-%d'`-r`svn info | grep Revision | cut -c 11-`.tar.gz ipfire-source
942 # create structure for a new package
943 echo -e "Name of the new package: $2"
944 if [ ! -f "lfs/$2" ]; then
945 echo "`date -u '+%b %e %T'`: Creating directory src/paks/$2"
948 echo "`date -u '+%b %e %T'`: Creating files"
949 cp $BASEDIR/lfs/postfix $BASEDIR/lfs/$2
953 touch {,un}install.sh
955 echo '#!/bin/bash' > install.sh
956 echo '#' >> install.sh
957 echo '#################################################################' >> install.sh
958 echo '# #' >> install.sh
959 echo '# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #' >> install.sh
960 echo '# #' >> install.sh
961 echo '#################################################################' >> install.sh
962 echo '#' >> install.sh
963 echo '# Extract the files' >> install.sh
964 echo 'tar xfz files.tgz -C /' >> install.sh
965 echo 'cp -f ROOTFILES /opt/pakfire/installed/ROOTFILES.$2' >> install.sh
967 echo '#!/bin/bash' > uninstall.sh
968 echo '#################################################################' >> uninstall.sh
969 echo '# #' >> uninstall.sh
970 echo '# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #' >> uninstall.sh
971 echo '# #' >> uninstall.sh
972 echo '#################################################################' >> uninstall.sh
973 echo '#' >> uninstall.sh
974 echo '# Delete the files' >> uninstall.sh
975 echo '## Befehl fehlt noch' >> uninstall.sh
976 echo 'rm -f /opt/pakfire/installed/ROOTFILES.$2' >> uninstall.sh
977 echo "`date -u '+%b %e %T'`: Adding files to SVN"
978 cd - && svn add lfs/$2 && svn add src/paks/$2
980 echo -n "Do you want to remove the folders? [y/n]"
982 if [ "$REM" == "y" ]; then
983 echo "Removing the folders..."
984 svn del src/paks/$2 --force
986 echo "Folders are kept."
989 echo "$2 already exists"
994 if [ ! -d $BASEDIR/cache ]; then
997 mkdir -p $BASEDIR/log
998 echo "`date -u '+%b %e %T'`:Preload all source files" | tee -a $LOGFILE
1001 for c in `seq $MAX_RETRIES`; do
1002 if (( FINISHED==1 )); then
1008 if [ -f "$i" -a "$i" != "Config" ]; then
1009 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
1010 if [ $? -ne 0 ]; then
1011 echo "Prefetch : wget error in lfs/$i"
1014 if [ $c -eq 1 ]; then
1015 echo "Prefetch : lfs/$i files loaded"
1021 echo "Prefetch : verifying md5sum"
1024 if [ -f "$i" -a "$i" != "Config" ]; then
1025 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
1026 if [ $? -ne 0 ]; then
1027 echo "md5 difference in lfs/$i"
1032 if [ $ERROR -eq 0 ]; then
1033 echo "Prefetch : all files md5sum match"
1040 BUILDMACHINE=`uname -m`
1041 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1042 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1043 build/{bin,etc,usr/bin,usr/local} \
1044 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
1046 md5sum cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1047 > cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.md5
1051 BUILDMACHINE=`uname -m`
1052 # arbitrary name to be updated in case of new toolchain package upload
1053 PACKAGE=$SNAME-1.4-toolchain-$BUILDMACHINE
1054 URL_IPFIRE=`grep URL_IPFIRE lfs/Config | awk '{ print $3 }'`
1055 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1057 wget $URL_IPFIRE/toolchains/$PACKAGE.tar.gz $URL_IPFIRE/toolchains/$PACKAGE.md5
1058 if [ $? -ne 0 ]; then
1059 echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
1061 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1062 echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1063 echo "`date -u '+%b %e %T'`: Uncompressing toolchain" | tee -a $LOGFILE
1064 cd $BASEDIR && tar xvfz cache/$PACKAGE.tar.gz -C .
1065 rm -vf $BASEDIR/cache/$PACKAGE.{tar.gz,md5}
1067 exiterror "$PACKAGE.md5 did not match, check downloaded package"
1072 echo "Load the latest source-files:"
1076 echo "Upload the changed files:"
1081 echo "Do a complete compile:"
1082 ./make.sh prefetch && ./make.sh build
1085 echo -ne "Make a local diff to last SVN revision: "
1086 svn diff > ipfire-diff-`date +'%Y-%m-%d-%H:%M'`-r`svn info | grep Revision | cut -c 11-`.diff
1088 echo "Diff was successfully saved to ipfire-diff-`date +'%Y-%m-%d-%H:%M'`-r`svn info | grep Revision | cut -c 11-`.diff"
1091 echo -e "Syncing Cache to FTP:"
1092 echo -ne "Password for mirror.ipfire.org: "; read PASS
1093 rm -f doc/packages-to-remove-from-ftp
1094 ncftpls -u web3 -p $PASS ftp://mirror.ipfire.org/html/source-packages/source/ > ftplist
1095 for i in `ls -w1 cache/`; do
1097 if [ "$?" -ne "0" ]; then
1098 ncftpput -u web3 -p $PASS mirror.ipfire.org /html/source-packages/source cache/$i
1099 if [ "$?" -eq "0" ]; then
1100 echo -e "$i was successfully uploaded to the ftp server."
1102 echo -e "There was an error while uploading $i to the ftp server."
1106 for i in `cat ftplist`; do
1107 ls -w1 cache/ | grep $i
1108 if [ "$?" -eq "1" ]; then
1109 echo $i | grep -v toolchain >> doc/packages-to-remove-from-ftp
1115 echo "Usage: $0 {build|changelog|check|checkclean|clean|commit|diff|dist|gettoolchain|make|newpak|prefetch|shell|sync|toolchain|update}"
1116 cat doc/make.sh-usage