#!/bin/bash # ############################################################################ # # # This file is part of the IPCop Firewall. # # # # IPCop is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation; either version 2 of the License, or # # (at your option) any later version. # # # # IPCop is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with IPCop; if not, write to the Free Software # # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # # # Copyright (C) 2001 Mark Wormgoor . # # # # (c) 2001 Eric S. Johansson Check for Bash # # (c) 2002 Thorsten Fischer MD5Sum checking # # # ############################################################################ # # $Id: make.sh,v 1.129.2.210 2007/11/16 22:14:16 gespinasse Exp $ # NAME="IPCop" # Software name SNAME="ipcop" # Short name VERSION="1.4.18" # Version number PREVIOUSTAG=IPCOP_v1_4_16_FINAL # CVS tag on previous release TOOLCHAINVERSION="1.4.11" # Arbitrary name that need to be updated if previous toolchain fail OTHERSRC="$SNAME-$VERSION-othersrc.tar.bz2" # All external packages gathered in one tar.bz2 SLOGAN="The Bad Packets Stop Here" # Software slogan CONFIG_ROOT=/var/ipcop # Configuration rootdir NICE=10 MAX_RETRIES=3 # prefetch/check loop KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'` MACHINE=`uname -m` # Debian specific settings if [ ! -e /etc/debian_version ]; then FULLPATH=`which $0` else if [ -x /usr/bin/realpath ]; then FULLPATH=`/usr/bin/realpath $0` else echo "ERROR: Need to do apt-get install realpath" exit 1 fi fi PWD=`pwd` BASENAME=`basename $0` BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"` LOGFILE=$BASEDIR/log/_build.preparation.log export BASEDIR LOGFILE DIR_CHK=$BASEDIR/cache/check mkdir $BASEDIR/log/ 2>/dev/null if [ 'x86_64' = $MACHINE -o 'i686' = $MACHINE -o 'i586' = $MACHINE -o 'i486' = $MACHINE -o 'i386' = $MACHINE ]; then echo "`date -u '+%b %e %T'`: Machine is ix86 (or equivalent)" | tee -a $LOGFILE MACHINE=i386 BUILDTARGET=i386-pc-linux-gnu CFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer" CXXFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer" elif [ 'alpha' = $MACHINE ]; then echo "`date -u '+%b %e %T'`: Machine is Alpha AXP" | tee -a $LOGFILE BUILDTARGET=alpha-unknown-linux-gnu CFLAGS="-O2 -mcpu=ev4 -mieee -pipe" CXXFLAGS="-O2 -mcpu=ev4 -mieee -pipe" else echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" | tee -a $LOGFILE exit 1 fi # Define immediately stdumount() { umount $BASEDIR/build/dev/pts 2>/dev/null; umount $BASEDIR/build/proc 2>/dev/null; umount $BASEDIR/build/install/mnt 2>/dev/null; umount $BASEDIR/build/usr/src/cache 2>/dev/null; umount $BASEDIR/build/usr/src/ccache 2>/dev/null; umount $BASEDIR/build/usr/src/config 2>/dev/null; umount $BASEDIR/build/usr/src/doc 2>/dev/null; umount $BASEDIR/build/usr/src/html 2>/dev/null; umount $BASEDIR/build/usr/src/langs 2>/dev/null; umount $BASEDIR/build/usr/src/lfs 2>/dev/null; umount $BASEDIR/build/usr/src/log 2>/dev/null; umount $BASEDIR/build/usr/src/src 2>/dev/null; } exiterror() { stdumount for i in `seq 0 7`; do if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then losetup -d /dev/loop${i} 2>/dev/null fi; done echo "ERROR: $*" echo " Check $LOGFILE for errors if applicable" exit 1 } entershell() { if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/" fi echo "Entering to a shell inside LFS chroot, go out with exit" chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' \ PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ INPUTRC=/etc/inputrc \ VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \ NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \ CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \ CCACHE_DIR=/usr/src/ccache \ CCACHE_HASHDIR=1 \ KVER=$KVER \ BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \ KGCC="ccache /usr/bin/gcc" \ /tools/bin/bash if [ $? -ne 0 ]; then exiterror "chroot error" else stdumount fi } prepareenv() { ############################################################################ # # # Are we running the right shell? # # # ############################################################################ if [ ! "$BASH" ]; then exiterror "BASH environment variable is not set. You're probably running the wrong shell." fi if [ -z "${BASH_VERSION}" ]; then exiterror "Not running BASH shell." fi ############################################################################ # # # Trap on emergency exit # # # ############################################################################ trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT ############################################################################ # # # Resetting our nice level # # # ############################################################################ echo "`date -u '+%b %e %T'`: Resetting our nice level to $NICE" | tee -a $LOGFILE renice $NICE $$ > /dev/null if [ `nice` != "$NICE" ]; then exiterror "Failed to set correct nice level" fi ############################################################################ # # # Checking if running as root user # # # ############################################################################ echo "`date -u '+%b %e %T'`: Checking if we're running as root user" | tee -a $LOGFILE if [ `id -u` != 0 ]; then exiterror "Not building as root" fi ############################################################################ # # # Checking for necessary temporary space # # # ############################################################################ echo "`date -u '+%b %e %T'`: Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'` BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'` if (( 2202000 > $BASE_ASPACE )); then BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'` if (( 2202000 - $BASE_USPACE > $BASE_ASPACE )); then exiterror "Not enough temporary space available, need at least 2.1GB on $BASE_DEV" fi fi ############################################################################ # # # Building Linux From Scratch system # # # ############################################################################ echo "`date -u '+%b %e %T'`: Building Linux From Scratch system" | tee -a $LOGFILE # Set umask umask 022 # Set LFS Directory LFS=$BASEDIR/build # Check /tools symlink if [ -h /tools ]; then rm -f /tools fi if [ ! -a /tools ]; then ln -s $BASEDIR/build/tools / fi if [ ! -h /tools ]; then exiterror "Could not create /tools symbolic link." fi # Setup environment set +h LC_ALL=POSIX export LFS LC_ALL CFLAGS CXXFLAGS unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD # Make some extra directories mkdir -p $BASEDIR/build/{tools,etc,usr/src,tmp} 2>/dev/null mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null mkdir -p $BASEDIR/build/dev/pts $BASEDIR/build/proc $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache} # Make all sources and proc available under lfs build mount --bind /dev/pts $BASEDIR/build/dev/pts mount --bind /proc $BASEDIR/build/proc mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src # Run LFS static binary creation scripts one by one export CCACHE_DIR=$BASEDIR/ccache export CCACHE_HASHDIR=1 # Remove pre-install list of installed files in case user erase some files before rebuild rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null # Replace rootflKernel Version in a temporary file sed "s/KVER/$KVER/g" $BASEDIR/src/ROOTFILES.$MACHINE > $BASEDIR/build/tmp/filelist } ############################################################################ # # # Necessary shell functions # # # ############################################################################ lfsmake1() { if [ -f $BASEDIR/lfs/$1 ]; then echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Download error in $1" fi cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "md5sum error in $1, check file in cache or signature" fi cd $BASEDIR/lfs && make -f $* BUILDTARGET=$BUILDTARGET \ MACHINE=$MACHINE \ LFS_BASEDIR=$BASEDIR \ ROOT=$LFS \ KVER=$KVER \ install >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Building $*"; fi else exiterror "No such file or directory: $BASEDIR/$1" fi return 0 } lfsmake2() { if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Download error in $1" fi cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "md5sum error in $1, check file in cache or signature" fi chroot $LFS /tools/bin/env -i HOME=/root \ TERM=$TERM PS1='\u:\w\$ ' \ PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ VERSION=$VERSION \ CONFIG_ROOT=$CONFIG_ROOT \ NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \ CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \ CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \ KVER=$KVER \ BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \ /tools/bin/bash -x -c "cd /usr/src/lfs && \ make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Building $*" fi else exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1" fi return 0 } ipcopmake() { if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Download error in $1" fi cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "md5sum error in $1, check file in cache or signature" fi chroot $LFS /tools/bin/env -i HOME=/root \ TERM=$TERM PS1='\u:\w\$ ' \ PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \ VERSION=$VERSION \ CONFIG_ROOT=$CONFIG_ROOT \ NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \ CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \ CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \ KVER=$KVER \ BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \ /bin/bash -x -c "cd /usr/src/lfs && \ make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Building $*" fi else exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1" fi return 0 } installmake() { if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Download error in $1" fi cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "md5sum error in $1, check file in cache or signature" fi chroot $LFS /tools/bin/env -i HOME=/root \ TERM=$TERM PS1='\u:\w\$ ' \ PATH=/usr/local/bin:/opt/$MACHINE-uClibc/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin \ VERSION=$VERSION \ CONFIG_ROOT=$CONFIG_ROOT \ LFS_PASS="install" \ NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \ CFLAGS="-Os" CXXFLAGS="-Os" \ CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \ KVER=$KVER \ BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \ /bin/bash -x -c "cd /usr/src/lfs && \ make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1 if [ $? -ne 0 ]; then exiterror "Building $*" fi else exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1" fi return 0 } buildtoolchain() { LOGFILE="$BASEDIR/log/_build.toolchain.log" export LOGFILE echo -ne "`date -u '+%b %e %T'`: Stage1 toolchain build \n" | tee -a $LOGFILE # Build sed now, as we use some extensions ORG_PATH=$PATH NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}` export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1} lfsmake1 ccache lfsmake1 sed LFS_PASS=1 lfsmake1 m4 LFS_PASS=1 lfsmake1 bison LFS_PASS=1 lfsmake1 flex LFS_PASS=1 lfsmake1 binutils LFS_PASS=1 lfsmake1 gcc LFS_PASS=1 export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH lfsmake1 linux lfsmake1 tcl lfsmake1 expect lfsmake1 glibc lfsmake1 dejagnu lfsmake1 gcc LFS_PASS=2 lfsmake1 binutils LFS_PASS=2 lfsmake1 gawk lfsmake1 coreutils lfsmake1 bzip2 lfsmake1 gzip lfsmake1 diffutils lfsmake1 findutils lfsmake1 make lfsmake1 grep lfsmake1 sed LFS_PASS=2 lfsmake1 m4 LFS_PASS=2 lfsmake1 bison LFS_PASS=2 lfsmake1 flex LFS_PASS=2 lfsmake1 gettext lfsmake1 ncurses lfsmake1 patch lfsmake1 tar lfsmake1 texinfo lfsmake1 bash lfsmake1 util-linux lfsmake1 perl export PATH=$ORG_PATH } buildbase() { LOGFILE="$BASEDIR/log/_build.base.log" export LOGFILE echo -ne "`date -u '+%b %e %T'`: Stage2 linux base build \n" | tee -a $LOGFILE # Run LFS dynamic binary creation scripts one by one lfsmake2 stage2 lfsmake2 makedev lfsmake2 linux lfsmake2 man-pages lfsmake2 glibc lfsmake2 binutils lfsmake2 gcc lfsmake2 coreutils lfsmake2 zlib lfsmake2 mktemp lfsmake2 iana-etc lfsmake2 findutils lfsmake2 gawk lfsmake2 ncurses lfsmake2 vim lfsmake2 m4 lfsmake2 bison lfsmake2 less lfsmake2 groff lfsmake2 sed lfsmake2 flex lfsmake2 gettext lfsmake2 net-tools lfsmake2 inetutils lfsmake2 perl lfsmake2 texinfo lfsmake2 autoconf lfsmake2 automake lfsmake2 bash lfsmake2 file lfsmake2 libtool lfsmake2 bzip2 lfsmake2 diffutils lfsmake2 ed lfsmake2 kbd lfsmake2 e2fsprogs lfsmake2 grep if [ 'i386' = $MACHINE ]; then lfsmake2 grub elif [ 'alpha' = $MACHINE ]; then lfsmake2 aboot fi lfsmake2 gzip lfsmake2 man lfsmake2 make lfsmake2 modutils lfsmake2 patch lfsmake2 procinfo lfsmake2 procps lfsmake2 psmisc lfsmake2 shadow lfsmake2 sysklogd lfsmake2 sysvinit lfsmake2 tar lfsmake2 util-linux } buildipcop() { # Run IPCop make scripts one by one LOGFILE="$BASEDIR/log/_build.ipcop.log" export LOGFILE echo -ne "`date -u '+%b %e %T'`: Stage3 $NAME build \n" | tee -a $LOGFILE # Build these first as some of the kernel packages below rely on # these for some of their client program functionality ipcopmake configroot ipcopmake dhcp ipcopmake dhcpcd ipcopmake libusb ipcopmake libpcap ipcopmake linux-atm ipcopmake ppp ipcopmake rp-pppoe ipcopmake unzip # Do SMP now. SMP drivers are built in 'SMP version' because just before # the kernel was SMP. When you rebuild/test/update, to get SMP version for a # driver, you must rebuild linux SMP & linux ! (erase log/linux-ipcop-KVER{,-smp} if [ 'i386' = $MACHINE ]; then # abuse the SMP flag, and make an minimal installer kernel first # so that the boot floppy always works..... ipcopmake linux LFS_PASS=ipcop SMP=installer ipcopmake linux LFS_PASS=ipcop SMP=1 ipcopmake 3cp4218 SMP=1 ipcopmake amedyn SMP=1 ipcopmake bnx2 SMP=1 ipcopmake cxacru SMP=1 ipcopmake eagle SMP=1 ipcopmake e100 SMP=1 ipcopmake e1000 SMP=1 ipcopmake forcedeth SMP=1 ipcopmake r1000 SMP=1 ipcopmake tg3 SMP=1 ipcopmake velocityget SMP=1 ipcopmake 3w-9xxx SMP=1 # These are here because they have i386 only binary libraries # included in the package. ipcopmake cnx_pci SMP=1 ipcopmake fcdsl SMP=1 ipcopmake fcdsl2 SMP=1 ipcopmake fcdslsl SMP=1 ipcopmake fcdslusb SMP=1 ipcopmake fcdslslusb SMP=1 ipcopmake pulsar SMP=1 ipcopmake unicorn SMP=1 ipcopmake wanpipe SMP=1 fi ipcopmake linux LFS_PASS=ipcop ipcopmake 3cp4218 ipcopmake amedyn ipcopmake bnx2 ipcopmake cxacru ipcopmake eciadsl ipcopmake eagle ipcopmake e100 ipcopmake e1000 ipcopmake forcedeth ipcopmake r1000 ipcopmake tg3 ipcopmake velocityget ipcopmake 3w-9xxx ipcopmake speedtouch if [ 'i386' = $MACHINE ]; then # These are here because they have i386 only binary libraries # included in the package. ipcopmake cnx_pci ipcopmake fcdsl ipcopmake fcdsl2 ipcopmake fcdslsl ipcopmake fcdslusb ipcopmake fcdslslusb ipcopmake pulsar ipcopmake unicorn ipcopmake wanpipe fi ipcopmake pcmcia-cs ipcopmake expat ipcopmake gdbm ipcopmake gmp ipcopmake openssl ipcopmake python ipcopmake libnet ipcopmake libpng ipcopmake gd ipcopmake popt ipcopmake slang ipcopmake newt ipcopmake libcap ipcopmake pciutils ipcopmake pcre ipcopmake apache ipcopmake arping ipcopmake beep ipcopmake bind ipcopmake capi4k-utils ipcopmake cdrtools ipcopmake dnsmasq ipcopmake dosfstools ipcopmake ethtool ipcopmake ez-ipupdate ipcopmake fcron ipcopmake GD ipcopmake gnupg ipcopmake hdparm ipcopmake ibod ipcopmake initscripts ipcopmake iptables ipcopmake ipac-ng ipcopmake ipaddr ipcopmake iproute2 ipcopmake iptstate ipcopmake iftop ipcopmake iputils ipcopmake isapnptools ipcopmake isdn4k-utils ipcopmake kudzu ipcopmake logrotate ipcopmake logwatch ipcopmake mingetty ipcopmake misc-progs ipcopmake mtools ipcopmake nano ipcopmake nash ipcopmake nasm ipcopmake URI ipcopmake HTML-Tagset ipcopmake HTML-Parser ipcopmake Compress-Zlib ipcopmake Digest ipcopmake Digest-SHA1 ipcopmake Digest-HMAC ipcopmake libwww-perl ipcopmake Net-IP ipcopmake Net-DNS ipcopmake Net-IPv4Addr ipcopmake Net_SSLeay ipcopmake noip_updater ipcopmake ntp ipcopmake oinkmaster ipcopmake openssh ipcopmake openswan ipcopmake pptpclient ipcopmake rrdtool ipcopmake setserial ipcopmake setup ipcopmake snort #ipcopmake speedycgi ipcopmake squid ipcopmake squid-graph ipcopmake strace ipcopmake tcpdump ipcopmake traceroute ipcopmake vlan ipcopmake wireless ipcopmake libsafe ipcopmake 3c5x9setup ipcopmake wget ipcopmake asterisk } buildinstaller() { # Run installer scripts one by one LOGFILE="$BASEDIR/log/_build.installer.log" export LOGFILE echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" | tee -a $LOGFILE if [ 'i386' = $MACHINE ]; then ipcopmake syslinux ipcopmake as86 ipcopmake mbr ipcopmake uClibc fi installmake busybox installmake sysvinit installmake e2fsprogs installmake misc-progs installmake slang installmake util-linux installmake newt installmake pciutils installmake pcmcia-cs installmake kbd installmake installer } buildpackages() { LOGFILE="$BASEDIR/log/_build.packages.log" export LOGFILE echo "... see detailed log in _build.*.log files" >> $LOGFILE echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" | tee -a $LOGFILE installmake strip installmake scsi.img installmake driver.img installmake initrd installmake boot.img if [ 'i386' = $MACHINE ]; then touch $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} installmake avmdrv fi echo "`date -u '+%b %e %T'`: Building update 1.4.17 tgz" | tee -a $LOGFILE # installpackage decrypt .gpg package to patch-1.tgz and tar zxf patch-1.tgz # This extract setup, information, (possibly some .patch files) and patch.tar.gz tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/1.4.17/ROOTFILES.$MACHINE-1.4.17 -f $BASEDIR/updates/1.4.17/patch.tar.gz --exclude='#*'; chmod 755 $BASEDIR/updates/1.4.17/setup cd $BASEDIR/updates/1.4.17 PL=`ls *.patch 2>/dev/null` cd $BASEDIR tar -C $BASEDIR/updates/1.4.17 -czf $LFS/install/images/$SNAME-1.4.17-update.$MACHINE.tgz patch.tar.gz setup information $PL echo "`date -u '+%b %e %T'`: Building update $VERSION tgz" | tee -a $LOGFILE tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/$VERSION/ROOTFILES.$MACHINE-$VERSION -f $BASEDIR/updates/$VERSION/patch.tar.gz --exclude='#*'; chmod 755 $BASEDIR/updates/$VERSION/setup cd $BASEDIR/updates/$VERSION PL=`ls *.patch 2>/dev/null` cd $BASEDIR tar -C $BASEDIR/updates/$VERSION -czf $LFS/install/images/$SNAME-$VERSION-update.$MACHINE.tgz patch.tar.gz setup information $PL rm -f $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} # Generating list of packages used echo "`date -u '+%b %e %T'`: Generating packages list from logs" | tee -a $LOGFILE rm -f $BASEDIR/doc/packages-list cd $BASEDIR/log for i in `ls -1 [^_]*`; do # two spaces for a list with bullet and between "" to protect against interpretation echo " * \"\"$i\"\"" >>$BASEDIR/doc/packages-list done echo "** List of softwares used to build $NAME Version:$VERSION**" > $BASEDIR/doc/packages-list.txt grep -v 'configroot$\|FILES\|img$\|initrd$\|initscripts$\|install\|ipcop$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \ $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt rm -f $BASEDIR/doc/packages-list # packages-list.txt is ready to be displayed for wiki page IPCopSoftwares # Create ISO for CDRom ipcopmake cdrom # do it after iso as we need 'message' with VERSION if [ 'i386' = $MACHINE ]; then # Create install pxe package as an alternate way to boot during install echo "`date -u '+%b %e %T'`: Building pxe tgz" | tee -a $LOGFILE mkdir -p $LFS/tmp/$VERSION cp $LFS/install/cdrom/boot/isolinux/f*\.txt $LFS/tmp/$VERSION/ cp $LFS/install/cdrom/boot/isolinux/memtest $LFS/tmp/$VERSION/ cp $LFS/install/images/cdinitrd.gz $LFS/tmp/$VERSION/instroot.gz cp $LFS/boot/vmlinuz-installer $LFS/tmp/$VERSION/vmlinuz cp $LFS/usr/lib/syslinux/pxelinux.0 $LFS/tmp cp $LFS/usr/src/doc/README-pxe $LFS/tmp/$VERSION/README-$SNAME-pxe mkdir -p $LFS/tmp/pxelinux.cfg sed -e "s:\(f.*txt\):$VERSION/\1:" \ -e "s|vmlinuz|$VERSION/vmlinuz|" \ -e "s|instroot|$VERSION/instroot|" \ -e "s|KERNEL memtest|KERNEL $VERSION/memtest|" \ $LFS/usr/src/config/kernel/syslinux.cfg \ > $LFS/tmp/pxelinux.cfg/$SNAME-pxe-$VERSION.model sed -i -e "s|: vmlinuz|: $VERSION/vmlinuz|" $LFS/tmp/$VERSION/f2.txt sed -i -e "s|: vmlinuz|: $VERSION/vmlinuz|" $LFS/tmp/$VERSION/f3.txt cd $LFS/tmp && tar cvzf \ $LFS/install/images/$SNAME-$VERSION-install-pxe.$MACHINE.tgz \ * >> $LOGFILE 2>&1 rm -rf $LFS/tmp/* >> $LOGFILE 2>&1 cd $BASEDIR # Create usb packages for install ipcopmake usb-key fi mv $LFS/install/images/ipcop-* $BASEDIR >> $LOGFILE 2>&1 # Cleanup stdumount rm -rf $BASEDIR/build/tmp/* # Generating total list of files echo "`date -u '+%b %e %T'`: Generating files list from logs" | tee -a $LOGFILE rm -f $BASEDIR/log/FILES for i in `ls -1tr $BASEDIR/log/[^_]*`; do if [ "$i" != "$BASEDIR/log/FILES" -a -n $i -a -n scsi.img -a -n driver.img ]; then echo "##" >>$BASEDIR/log/FILES echo "## `basename $i`" >>$BASEDIR/log/FILES echo "##" >>$BASEDIR/log/FILES cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES fi done cd $PWD } loadsrc() { prepareenv echo "`date -u '+%b %e %T'`:Preload all source files" | tee -a $LOGFILE FINISHED=0 cd $BASEDIR/lfs for c in `seq $MAX_RETRIES`; do if (( FINISHED==1 )); then break fi FINISHED=1 cd $BASEDIR/lfs for i in *; do if [ -f "$i" -a "$i" != "Config" ]; then make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then echo "Prefetch : wget error in lfs/$i" FINISHED=0 else if [ $c -eq 1 ]; then echo "Prefetch : lfs/$i files loaded" fi fi fi done done echo "Prefetch : verifying md5sum" ERROR=0 for i in *; do if [ -f "$i" -a "$i" != "Config" ]; then make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1 if [ $? -ne 0 ]; then echo "md5 difference in lfs/$i" ERROR=1 fi fi done if [ $ERROR -eq 0 ]; then echo "Prefetch : all files md5sum match" fi stdumount } # See what we're supposed to do case "$1" in build) BUILDMACHINE=`uname -m` cd $BASEDIR/cache PACKAGE=`ls -v -r $SNAME-1.4.*-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1` #only restore on a clean disk if [ -f $BASEDIR/log/perl-*-tools ]; then echo "`date -u '+%b %e %T'`: Using installed toolchain" | tee -a $LOGFILE prepareenv else if [ -z "$PACKAGE" ]; then echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE prepareenv buildtoolchain else PACKAGENAME=${PACKAGE%.tar.gz} echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" | tee -a $LOGFILE if [ `md5sum $BASEDIR/cache/$PACKAGE | awk '{print $1}'` == `cat $BASEDIR/cache/$PACKAGENAME.md5 | awk '{print $1}'` ]; then cd $BASEDIR && tar zxf $BASEDIR/cache/$PACKAGE prepareenv else exiterror "$PACKAGENAME md5 did not match, check downloaded package" fi fi fi buildbase buildipcop buildinstaller buildpackages ;; shell) # enter a shell inside LFS chroot # may be used to changed kernel settings prepareenv entershell ;; changelog) echo "Building doc/Changelog from CVS" # cv2cl script come from http://www.red-bean.com/cvs2cl/ if [ ! -s $BASEDIR/doc/CVS/Tag ]; then BRANCHOPTS="" else BRANCH=`cat $BASEDIR/doc/CVS/Tag` BRANCH=${BRANCH:1} BRANCHOPTS="--follow-only $BRANCH" fi $BASEDIR/tools/cvs2cl.pl --gmt --show-dead $BRANCHOPTS -f $BASEDIR/doc/ChangeLog rm -f $BASEDIR/doc/ChangeLog.bak echo echo "Commit the change now to update CVS" ;; check) echo "Checking sources files availability on the web" if [ ! -d $DIR_CHK ]; then mkdir -p $DIR_CHK fi FINISHED=0 cd $BASEDIR/lfs for c in `seq $MAX_RETRIES`; do if (( FINISHED==1 )); then break fi FINISHED=1 cd $BASEDIR/lfs for i in *; do if [ -f "$i" -a "$i" != "Config" ]; then make -s -f $i MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR ROOT=$BASEDIR/build \ MESSAGE="$i\t ($c/$MAX_RETRIES)" check if [ $? -ne 0 ]; then echo "Check : wget error in lfs/$i" FINISHED=0 fi fi done done ;; checkclean) echo "Erasing sources files availability tags" rm -rf $DIR_CHK/* ;; clean) for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do $LOSETUP -d $i 2>/dev/null done for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do umount $i done stdumount for i in `seq 0 7`; do if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then umount /dev/loop${i} 2>/dev/null; losetup -d /dev/loop${i} 2>/dev/null; fi; done rm -rf $BASEDIR/build rm -rf $BASEDIR/cdrom rm -rf $BASEDIR/log rm -f $BASEDIR/updates/$VERSION/patch.tar.gz; if [ -h /tools ]; then rm -f /tools fi ;; dist) echo "Building IPCop sources package from CVS, list of changed files" if [ ! -s $BASEDIR/doc/CVS/Tag ]; then BRANCH="" BRANCHOPTS="-D `date +'%Y-%m-%d'`" else BRANCH=`cat $BASEDIR/doc/CVS/Tag` BRANCH=${BRANCH:1} BRANCHOPTS="-r $BRANCH" fi rm -rf $BASEDIR/build/tmp/$SNAME-$VERSION $BASEDIR/doc/release.txt cd $BASEDIR/build/tmp # build sources tgz echo "Export tree $BRANCH $SNAME-$VERSION" cvs -z3 -d `cat $BASEDIR/CVS/Root` export $BRANCHOPTS ipcop if [ $? -eq 0 ]; then mv ipcop $SNAME-$VERSION tar cfz $BASEDIR/$SNAME-$VERSION-sources.tgz $SNAME-$VERSION cd $BASEDIR if [ ! -d $BASEDIR/build/tmp/$PREVIOUSTAG ]; then # export previous version to be compared with actual, this help to check wich files need to go in update cd $BASEDIR/build/tmp echo "Export tree $PREVIOUSTAG" cvs -z3 -d `cat $BASEDIR/CVS/Root` export -r $PREVIOUSTAG ipcop mv ipcop $PREVIOUSTAG fi if [ -d $BASEDIR/build/tmp/$PREVIOUSTAG -o -d $BASEDIR/build/tmp/$SNAME-$VERSION ]; then cd $BASEDIR/build/tmp echo "diff $PREVIOUSTAG <> $BRANCH $SNAME-$VERSION >doc/updated-sources.txt" diff -rq $PREVIOUSTAG $SNAME-$VERSION > $BASEDIR/doc/updated-sources.txt mv $BASEDIR/doc/updated-sources.txt $BASEDIR/doc/updated-sources.bak sed -e "s+Files $PREVIOUSTAG\/++" \ -e "s+ and .*$++" \ -e "s+src/rc.d+etc/rc.d+" \ -e "s+^langs/+var/ipcop/langs/+" \ -e "s+html/cgi-bin+home/httpd/cgi-bin+" $BASEDIR/doc/updated-sources.bak \ > $BASEDIR/doc/updated-sources.txt rm -f $BASEDIR/doc/updated-sources.bak fi fi ;; getothersrc) URL_SFNET=`grep URL_SFNET lfs/Config | awk '{ print $3 }'` echo "`date -u '+%b %e %T'`: Load big package containing other sources" | tee -a $LOGFILE mkdir -p $BASEDIR/cache wget -c $URL_SFNET/$SNAME/$OTHERSRC $URL_SFNET/$SNAME/$OTHERSRC.md5 -P /tmp # unfortunatly wget return code is unusable as always something is loaded # actually this is the sign of the failure if [ -f /tmp/files ]; then echo "`date -u '+%b %e %T'`: error downloading other sources for $VERSION" echo "package is uploaded only just before a release" | tee -a $LOGFILE rm -f /tmp/$OTHERSRC /tmp/$OTHERSRC.md5 /tmp/files else if [ "`md5sum /tmp/$OTHERSRC | awk '{print $1}'`" = "`cat /tmp/$OTHERSRC.md5 | awk '{print $1}'`" ]; then echo "$OTHERSRC md5 ok, move files in cache" | tee -a $LOGFILE cd $BASEDIR/cache && tar jxf /tmp/$OTHERSRC rm -f /tmp/$OTHERSRC /tmp/$OTHERSRC.md5 else exiterror "$OTHERSRC.md5 did not match, check downloaded package in /tmp" fi fi ;; newupdate) # create structure for $VERSION update if [ ! -f "updates/$VERSION" ]; then mkdir -p updates/$VERSION cd updates/$VERSION touch information echo "## please place ipcop files first, then packages sorted by alphabetical order" > ROOTFILES.alpha-$VERSION echo "## please place ipcop files first, then packages sorted by alphabetical order" > ROOTFILES.i386-$VERSION echo 'patch.tar.gz' > .cvsignore sed -e "s+^UPGRADEVERSION.*$+UPGRADEVERSION=$VERSION+" $BASEDIR/src/scripts/updatesetup > setup chmod 755 setup cd .. echo "Adding directory $VERSION to cvs" cvs add $VERSION echo "Adding files to cvs" cvs add $VERSION/ROOTFILES.alpha-$VERSION \ $VERSION/ROOTFILES.i386-$VERSION \ $VERSION/information \ $VERSION/setup \ $VERSION/.cvsignore else echo "update/$VERSION already exist" fi ;; othersrc) rm -f $BASEDIR/log/_build.othersrc-list.log loadsrc RET=$? if [ $RET -ne 0 ]; then echo 'Files in cache check fail' else echo 'Doing the big package...' tar -c -C $BASEDIR/cache \ --files-from=$BASEDIR/log/_build.othersrc-list.log \ -jf $BASEDIR/$SNAME-$VERSION-othersrc.tar.bz2 cd $BASEDIR md5sum $SNAME-$VERSION-othersrc.tar.bz2 \ > $SNAME-$VERSION-othersrc.tar.bz2.md5 fi ;; prefetch) loadsrc ;; rootfiles) PREVIOUSVERSION=`echo $PREVIOUSTAG | sed -e 's/IPCOP_v//' -e 's/_FINAL//' -e 's/_/\./g'` # make md5 list of actual build # some packages include a timestamp (kernel/perl/python/vim and more), so md5 vary at each build if [ ! -f "$BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz" ]; then echo "need cdrom be build to read include files list, use ./make.sh build before." else # sort order depend of the locale tar tzf $BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz | LC_ALL=C sort > $BASEDIR/updates/$VERSION/FILES.tmp # .pyc files are compiled from .py and include a timestamp that we can't remove # instead test md5 from .py source files sed -i -e 's|\.pyc$|.py|g' $BASEDIR/updates/$VERSION/FILES.tmp cd $BASEDIR/build rm -f $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 for line in `cat $BASEDIR/updates/$VERSION/FILES.tmp`; do # not a /dev and not a symlink if [ -f "$line" -a ! -L "$line" ]; then md5sum "$line" >> $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 fi done # and restore .pyc names to the list sed -i -e 's|\.py$|.pyc|g' $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 diff $BASEDIR/updates/$PREVIOUSVERSION/FILES-$MACHINE-$PREVIOUSVERSION.md5 \ $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 \ > $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff awk '$1==">" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \ | sort > $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE awk '$1=="<" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \ | sort > $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp rm -f $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE for line in `cat $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp`; do # a file is only removed when not in add file if ( ! grep -q "^$line$" $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE ); then echo $line >> $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE fi done rm -f $BASEDIR/updates/$VERSION/{FILES.tmp,FILES-*.diff,ROOTFILES.remove.*.tmp} fi exit 0 ;; toolchain) prepareenv buildtoolchain BUILDMACHINE=`uname -m` echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE cd $BASEDIR && tar -zc --exclude='log/_build.*.log' \ -f cache/$SNAME-$TOOLCHAINVERSION-toolchain-$BUILDMACHINE.tar.gz \ build/{bin,etc,usr/bin,usr/local} \ build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \ log >> $LOGFILE md5sum cache/$SNAME-$TOOLCHAINVERSION-toolchain-$BUILDMACHINE.tar.gz \ > cache/$SNAME-$TOOLCHAINVERSION-toolchain-$BUILDMACHINE.md5 stdumount ;; gettoolchain) BUILDMACHINE=`uname -m` PACKAGE=$SNAME-$TOOLCHAINVERSION-toolchain-$BUILDMACHINE URL_SFNET=`grep URL_SFNET lfs/Config | awk '{ print $3 }'` echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE wget -c $URL_SFNET/ipcop/$PACKAGE.tar.gz $URL_SFNET/ipcop/$PACKAGE.md5 -P /tmp # unfortunatly wget return code is unusable as always something is loaded # actually this is the sign of the failure if [ -f /tmp/files ]; then echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE rm -f /tmp/$PACKAGE.tar.gz /tmp/$PACKAGE.md5 /tmp/files else if [ "`md5sum /tmp/$PACKAGE.tar.gz | awk '{print $1}'`" = "`cat /tmp/$PACKAGE.md5 | awk '{print $1}'`" ]; then echo "`date -u '+%b %e %T'`: toolchain md5 ok, move files in cache" | tee -a $LOGFILE mv /tmp/{$PACKAGE.tar.gz,$PACKAGE.md5} $BASEDIR/cache else exiterror "$PACKAGE.md5 did not match, check downloaded package in /tmp" fi fi ;; *) echo "Usage: $0 {build|changelog|check|checkclean|clean|dist|getothersrc|gettoolchain|newupdate|othersrc|prefetch|rootfiles|shell|toolchain}" cat doc/make.sh-usage exit 1 ;; esac