Update Squid to 2.5STABLE13.
[ipfire-2.x.git] / make.sh
1 #!/bin/bash
2 #
3 ############################################################################
4 #                                                                          #
5 # This file is part of the IPCop Firewall.                                 #
6 #                                                                          #
7 # IPCop 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.                                      #
11 #                                                                          #
12 # IPCop 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.                             #
16 #                                                                          #
17 # You should have received a copy of the GNU General Public License        #
18 # along with IPCop; if not, write to the Free Software                     #
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
20 #                                                                          #
21 # Copyright (C) 2001 Mark Wormgoor <mark@wormgoor.com>.                    #
22 #                                                                          #
23 # (c) 2001 Eric S. Johansson <esj@harvee.billerica.ma.us> Check for Bash   #
24 # (c) 2002 Thorsten Fischer <frosch@cs.tu-berlin.de> MD5Sum checking       #
25 #                                                                          #
26 ############################################################################
27 #
28 # $Id: make.sh,v 1.129.2.145 2006/02/01 07:04:09 gespinasse Exp $
29 #
30
31   NAME="IPFire"                         # Software name
32   SNAME="ipfire"                        # Short name
33   VERSION="1.4"                         # Version number
34 # PREVIOUSTAG=IPCOP_v1_4_10_FINAL
35   SLOGAN="We secure your network"       # Software slogan
36   CONFIG_ROOT=/var/ipfire               # Configuration rootdir
37   NICE=10
38   MAX_RETRIES=3                         # prefetch/check loop
39   KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
40   MACHINE=`uname -m`
41
42   # Debian specific settings
43   if [ ! -e /etc/debian_version ]; then
44         FULLPATH=`which $0`
45   else
46         if [ -x /usr/bin/realpath ]; then
47                 FULLPATH=`/usr/bin/realpath $0`
48         else
49                 echo "ERROR: Need to do apt-get install realpath"
50                 exit 1
51         fi
52   fi
53
54
55   PWD=`pwd`
56   BASENAME=`basename $0`
57   BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
58   LOGFILE=$BASEDIR/log/_build.preparation.log
59   export BASEDIR LOGFILE
60   DIR_CHK=$BASEDIR/cache/check
61   mkdir $BASEDIR/log/ 2>/dev/null
62
63   if [ 'x86_64' = $MACHINE -o 'i686' = $MACHINE -o 'i586' = $MACHINE -o 'i486' = $MACHINE -o 'i386' = $MACHINE ]; then
64         echo "`date -u '+%b %e %T'`: Machine is ix86 (or equivalent)" | tee -a $LOGFILE
65         MACHINE=i386
66         BUILDTARGET=i386-pc-linux-gnu
67         CFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
68         CXXFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
69   elif [ 'alpha' = $MACHINE ]; then
70         echo "`date -u '+%b %e %T'`: Machine is Alpha AXP" | tee -a $LOGFILE
71         BUILDTARGET=alpha-unknown-linux-gnu
72         CFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
73         CXXFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
74   else
75         echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" | tee -a $LOGFILE
76         exit 1
77   fi
78
79 # Define immediately
80 stdumount() {
81         umount $BASEDIR/build/dev/pts           2>/dev/null;
82         umount $BASEDIR/build/proc                      2>/dev/null;
83         umount $BASEDIR/build/install/mnt               2>/dev/null;
84         umount $BASEDIR/build/usr/src/cache     2>/dev/null;
85         umount $BASEDIR/build/usr/src/ccache    2>/dev/null;
86         umount $BASEDIR/build/usr/src/config    2>/dev/null;
87         umount $BASEDIR/build/usr/src/doc               2>/dev/null;
88         umount $BASEDIR/build/usr/src/html              2>/dev/null;
89         umount $BASEDIR/build/usr/src/langs     2>/dev/null;
90         umount $BASEDIR/build/usr/src/lfs               2>/dev/null;
91         umount $BASEDIR/build/usr/src/log               2>/dev/null;
92         umount $BASEDIR/build/usr/src/src               2>/dev/null;
93 }
94
95 exiterror() {
96         stdumount
97         for i in `seq 0 7`; do
98             if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
99                 losetup -d /dev/loop${i} 2>/dev/null
100             fi;
101         done
102         echo "ERROR: $*"
103         echo "       Check $LOGFILE for errors if applicable"
104         exit 1
105 }
106
107 entershell() {
108         if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
109                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
110         fi
111         echo "Entering to a shell inside LFS chroot, go out with exit"
112         chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
113                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
114                 VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
115                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
116                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
117                 CCACHE_DIR=/usr/src/ccache \
118                 CCACHE_HASHDIR=1 \
119                 KVER=$KVER \
120                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
121                 KGCC="ccache /usr/bin/gcc" \
122                 /tools/bin/bash
123         if [ $? -ne 0 ]; then
124                         exiterror "chroot error"
125         else
126                 stdumount
127         fi
128 }
129
130 prepareenv() {
131     ############################################################################
132     #                                                                          #
133     # Are we running the right shell?                                          #
134     #                                                                          #
135     ############################################################################
136     if [ ! "$BASH" ]; then
137         exiterror "BASH environment variable is not set.  You're probably running the wrong shell."
138     fi
139
140     if [ -z "${BASH_VERSION}" ]; then
141         exiterror "Not running BASH shell."
142     fi
143
144
145     ############################################################################
146     #                                                                          #
147     # Trap on emergency exit                                                   #
148     #                                                                          #
149     ############################################################################
150     trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
151
152
153     ############################################################################
154     #                                                                          #
155     # Resetting our nice level                                                 #
156     #                                                                          #
157     ############################################################################
158     echo "`date -u '+%b %e %T'`: Resetting our nice level to $NICE" | tee -a $LOGFILE
159     renice $NICE $$ > /dev/null
160     if [ `nice` != "$NICE" ]; then
161         exiterror "Failed to set correct nice level"
162     fi
163
164     ############################################################################
165     #                                                                          #
166     # Checking if running as root user                                         #
167     #                                                                          #
168     ############################################################################
169     echo "`date -u '+%b %e %T'`: Checking if we're running as root user" | tee -a $LOGFILE
170     if [ `id -u` != 0 ]; then
171         exiterror "Not building as root"
172     fi
173
174
175     ############################################################################
176     #                                                                          #
177     # Checking for necessary temporary space                                   #
178     #                                                                          #
179     ############################################################################
180     echo "`date -u '+%b %e %T'`: Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
181     BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
182     BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
183     if (( 2202000 > $BASE_ASPACE )); then
184         BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
185         if (( 2202000 - $BASE_USPACE > $BASE_ASPACE )); then
186                 exiterror "Not enough temporary space available, need at least 2.1GB on $BASE_DEV"
187         fi
188     fi
189
190     ############################################################################
191     #                                                                          #
192     # Building Linux From Scratch system                                       #
193     #                                                                          #
194     ############################################################################
195     echo "`date -u '+%b %e %T'`: Building Linux From Scratch system" | tee -a $LOGFILE
196
197     # Set umask
198     umask 022
199
200     # Set LFS Directory
201     LFS=$BASEDIR/build
202
203     # Check /tools symlink
204     if [ -h /tools ]; then
205         rm -f /tools
206     fi
207     if [ ! -a /tools ]; then
208         ln -s $BASEDIR/build/tools /
209     fi
210     if [ ! -h /tools ]; then
211         exiterror "Could not create /tools symbolic link."
212     fi
213
214     # Setup environment
215     set +h
216     LC_ALL=POSIX
217     export LFS LC_ALL CFLAGS CXXFLAGS
218     unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
219
220     # Make some extra directories
221     mkdir -p $BASEDIR/build/{tools,etc,usr/src} 2>/dev/null
222     mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
223     mkdir -p $BASEDIR/build/dev/pts $BASEDIR/build/proc $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
224
225     # Make all sources and proc available under lfs build
226     mount --bind /dev/pts        $BASEDIR/build/dev/pts
227     mount --bind /proc           $BASEDIR/build/proc
228     mount --bind $BASEDIR/cache  $BASEDIR/build/usr/src/cache
229     mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
230     mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
231     mount --bind $BASEDIR/doc    $BASEDIR/build/usr/src/doc
232     mount --bind $BASEDIR/html   $BASEDIR/build/usr/src/html
233     mount --bind $BASEDIR/langs  $BASEDIR/build/usr/src/langs
234     mount --bind $BASEDIR/lfs    $BASEDIR/build/usr/src/lfs
235     mount --bind $BASEDIR/log    $BASEDIR/build/usr/src/log
236     mount --bind $BASEDIR/src    $BASEDIR/build/usr/src/src
237
238     # Run LFS static binary creation scripts one by one
239     export CCACHE_DIR=$BASEDIR/ccache
240     export CCACHE_HASHDIR=1
241
242     # Remove pre-install list of installed files in case user erase some files before rebuild
243     rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
244 }
245
246
247 ############################################################################
248 #                                                                          #
249 # Necessary shell functions                                                #
250 #                                                                          #
251 ############################################################################
252 lfsmake1() {
253         if [ -f $BASEDIR/lfs/$1 ]; then
254                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
255                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
256                 if [ $? -ne 0 ]; then
257                         exiterror "Download error in $1"
258                 fi
259                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
260                 if [ $? -ne 0 ]; then
261                         exiterror "md5sum error in $1, check file in cache or signature"
262                 fi
263                 cd $BASEDIR/lfs && make -f $*   BUILDTARGET=$BUILDTARGET \
264                                                 MACHINE=$MACHINE \
265                                                 LFS_BASEDIR=$BASEDIR \
266                                                 ROOT=$LFS \
267                                                 KVER=$KVER \
268                                                 install >> $LOGFILE 2>&1
269                 if [ $? -ne 0 ]; then
270                         exiterror "Building $*";
271                 fi
272         else
273                 exiterror "No such file or directory: $BASEDIR/$1"
274         fi
275         return 0
276 }
277
278 lfsmake2() {
279         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
280                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
281                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
282                 if [ $? -ne 0 ]; then
283                         exiterror "Download error in $1"
284                 fi
285                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
286                 if [ $? -ne 0 ]; then
287                         exiterror "md5sum error in $1, check file in cache or signature"
288                 fi
289                 chroot $LFS /tools/bin/env -i   HOME=/root \
290                                                 TERM=$TERM PS1='\u:\w\$ ' \
291                                                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
292                                                 VERSION=$VERSION \
293                                                 CONFIG_ROOT=$CONFIG_ROOT \
294                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
295                                                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
296                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
297                                                 KVER=$KVER \
298                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
299                     /tools/bin/bash -x -c "cd /usr/src/lfs && \
300                     make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
301                 if [ $? -ne 0 ]; then
302                         exiterror "Building $*"
303                 fi
304         else
305                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
306         fi
307         return 0
308 }
309
310 ipcopmake() {
311         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
312                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
313                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
314                 if [ $? -ne 0 ]; then
315                         exiterror "Download error in $1"
316                 fi
317                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
318                 if [ $? -ne 0 ]; then
319                         exiterror "md5sum error in $1, check file in cache or signature"
320                 fi
321                 chroot $LFS /tools/bin/env -i   HOME=/root \
322                                                 TERM=$TERM PS1='\u:\w\$ ' \
323                                                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
324                                                 VERSION=$VERSION \
325                                                 CONFIG_ROOT=$CONFIG_ROOT \
326                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
327                                                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
328                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
329                                                 KVER=$KVER \
330                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
331                     /bin/bash -x -c "cd /usr/src/lfs && \
332                     make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
333                 if [ $? -ne 0 ]; then
334                         exiterror "Building $*"
335                 fi
336         else
337                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
338         fi
339         return 0
340 }
341
342 ipfiredist() {
343         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
344                 echo "`date -u '+%b %e %T'`: Packaging $1" | tee -a $LOGFILE
345                 cp -f $BASEDIR/src/scripts/make-packages.sh $BASEDIR/build/usr/sbin/
346                 chroot $LFS /tools/bin/env -i   HOME=/root \
347                                                 TERM=$TERM PS1='\u:\w\$ ' \
348                                                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
349                                                 VERSION=$VERSION \
350                                                 CONFIG_ROOT=$CONFIG_ROOT \
351                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
352                                                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
353                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
354                                                 KVER=$KVER \
355                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
356                     /bin/bash -x -c "cd /usr/src/lfs && \
357                     make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
358                 if [ $? -ne 0 ]; then
359                         exiterror "Packaging $1"
360                 fi
361         else
362                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
363         fi
364         if [ -e $BASEDIR/packages ]; then
365                 mv -f $BASEDIR/build/paks/* $BASEDIR/packages/
366         else
367                 mkdir -p $BASEDIR/packages
368                 mv -f $BASEDIR/build/paks/* $BASEDIR/packages/
369         fi
370         return 0
371 }
372
373
374 installmake() {
375         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
376                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
377                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
378                 if [ $? -ne 0 ]; then
379                         exiterror "Download error in $1"
380                 fi
381                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
382                 if [ $? -ne 0 ]; then
383                         exiterror "md5sum error in $1, check file in cache or signature"
384                 fi
385                 chroot $LFS /tools/bin/env -i   HOME=/root \
386                                                 TERM=$TERM PS1='\u:\w\$ ' \
387                                                 PATH=/usr/local/bin:/opt/$MACHINE-uClibc/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin \
388                                                 VERSION=$VERSION \
389                                                 CONFIG_ROOT=$CONFIG_ROOT \
390                                                 LFS_PASS="install" \
391                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
392                                                 CFLAGS="-Os" CXXFLAGS="-Os" \
393                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
394                                                 KVER=$KVER \
395                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
396                     /bin/bash -x -c "cd /usr/src/lfs && \
397                     make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
398                 if [ $? -ne 0 ]; then
399                         exiterror "Building $*"
400                 fi
401         else
402                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
403         fi
404         return 0
405 }
406
407 buildtoolchain() {
408     LOGFILE="$BASEDIR/log/_build.toolchain.log"
409     export LOGFILE
410     echo -ne "`date -u '+%b %e %T'`: Stage1 toolchain build \n" | tee -a $LOGFILE
411     # Build sed now, as we use some extensions
412     ORG_PATH=$PATH
413     NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}`
414     export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
415     lfsmake1 ccache
416     lfsmake1 sed        LFS_PASS=1
417     lfsmake1 m4         LFS_PASS=1
418     lfsmake1 bison      LFS_PASS=1
419     lfsmake1 flex       LFS_PASS=1
420     lfsmake1 binutils   LFS_PASS=1
421     lfsmake1 gcc        LFS_PASS=1
422     export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
423     
424     lfsmake1 linux
425     lfsmake1 tcl
426     lfsmake1 expect
427     lfsmake1 glibc
428     lfsmake1 dejagnu
429     lfsmake1 gcc        LFS_PASS=2
430     lfsmake1 binutils   LFS_PASS=2
431     lfsmake1 gawk
432     lfsmake1 coreutils
433     lfsmake1 bzip2
434     lfsmake1 gzip
435     lfsmake1 diffutils
436     lfsmake1 findutils
437     lfsmake1 make
438     lfsmake1 grep
439     lfsmake1 sed        LFS_PASS=2
440     lfsmake1 m4         LFS_PASS=2
441     lfsmake1 bison      LFS_PASS=2
442     lfsmake1 flex       LFS_PASS=2
443     lfsmake1 gettext
444     lfsmake1 ncurses
445     lfsmake1 patch
446     lfsmake1 tar
447     lfsmake1 texinfo
448     lfsmake1 bash
449     lfsmake1 util-linux
450     lfsmake1 perl
451     export PATH=$ORG_PATH
452 }
453
454 buildbase() {
455     LOGFILE="$BASEDIR/log/_build.base.log"
456     export LOGFILE
457     echo -ne "`date -u '+%b %e %T'`: Stage2 linux base build \n" | tee -a $LOGFILE
458     # Run LFS dynamic binary creation scripts one by one
459     lfsmake2 stage2
460     lfsmake2 makedev
461     lfsmake2 linux
462     lfsmake2 man-pages
463     lfsmake2 glibc
464     lfsmake2 binutils
465     lfsmake2 gcc
466     lfsmake2 coreutils
467     lfsmake2 zlib
468     lfsmake2 mktemp
469     lfsmake2 iana-etc
470     lfsmake2 findutils
471     lfsmake2 gawk
472     lfsmake2 ncurses
473     lfsmake2 vim
474     lfsmake2 m4
475     lfsmake2 bison
476     lfsmake2 less
477     lfsmake2 groff
478     lfsmake2 sed
479     lfsmake2 flex
480     lfsmake2 gettext
481     lfsmake2 net-tools
482     lfsmake2 inetutils
483     lfsmake2 perl
484     lfsmake2 texinfo
485     lfsmake2 autoconf
486     lfsmake2 automake
487     lfsmake2 bash
488     lfsmake2 file
489     lfsmake2 libtool
490     lfsmake2 bzip2
491     lfsmake2 diffutils
492     lfsmake2 ed
493     lfsmake2 kbd
494     lfsmake2 e2fsprogs
495     lfsmake2 grep
496     if [ 'i386' = $MACHINE ]; then 
497         lfsmake2 grub
498     elif [ 'alpha' = $MACHINE ]; then 
499         lfsmake2 aboot
500     fi
501     lfsmake2 gzip
502     lfsmake2 man
503     lfsmake2 make
504     lfsmake2 modutils
505     lfsmake2 patch
506     lfsmake2 procinfo
507     lfsmake2 procps
508     lfsmake2 psmisc
509     lfsmake2 shadow
510     lfsmake2 sysklogd
511     lfsmake2 sysvinit
512     lfsmake2 tar
513     lfsmake2 util-linux
514 }
515
516 buildipcop() {
517   # Run IPCop make scripts one by one
518   LOGFILE="$BASEDIR/log/_build.ipcop.log"
519   export LOGFILE
520   echo -ne "`date -u '+%b %e %T'`: Stage3 $NAME build \n" | tee -a $LOGFILE
521
522   # Build these first as some of the kernel packages below rely on 
523   # these for some of their client program functionality 
524   ipcopmake configroot
525   ipcopmake dhcp
526   ipcopmake dhcpcd
527   ipcopmake libusb
528   ipcopmake libpcap
529   ipcopmake linux-atm
530   ipcopmake ppp
531   ipcopmake rp-pppoe
532   ipcopmake unzip
533   # Do SMP now
534   if [ 'i386' = $MACHINE ]; then 
535         # abuse the SMP flag, and make an minimal installer kernel first
536         # so that the boot floppy always works.....
537         ipcopmake linux         LFS_PASS=ipcop SMP=installer
538         ipcopmake linux         LFS_PASS=ipcop SMP=1
539         ipcopmake 3cp4218       SMP=1
540         ipcopmake amedyn        SMP=1
541         ipcopmake cxacru        SMP=1
542         ipcopmake eagle         SMP=1
543
544         # These are here because they have i386 only binary libraries
545         # included in the package.
546         ipcopmake cnx_pci       SMP=1
547         ipcopmake fcdsl         SMP=1
548         ipcopmake fcdsl2        SMP=1
549         ipcopmake fcdslsl       SMP=1
550         ipcopmake fcdslusb      SMP=1
551         ipcopmake fcdslslusb    SMP=1
552         ipcopmake pulsar        SMP=1
553         ipcopmake unicorn       SMP=1
554   fi
555
556   ipcopmake linux       LFS_PASS=ipcop
557   ipcopmake 3cp4218     
558   ipcopmake amedyn      
559   ipcopmake cxacru      
560   ipcopmake eciadsl     
561   ipcopmake eagle       
562   ipcopmake speedtouch  
563   if [ 'i386' = $MACHINE ]; then 
564         # These are here because they have i386 only binary libraries
565         # included in the package.
566         ipcopmake cnx_pci       
567         ipcopmake fcdsl         
568         ipcopmake fcdsl2        
569         ipcopmake fcdslsl       
570         ipcopmake fcdslusb      
571         ipcopmake fcdslslusb    
572         ipcopmake pulsar        
573         ipcopmake unicorn       
574   fi
575
576   ipcopmake pcmcia-cs
577   ipcopmake expat
578   ipcopmake gdbm
579   ipcopmake gmp
580   ipcopmake openssl
581   ipcopmake python
582   ipcopmake libnet
583   ipcopmake libpng
584   ipcopmake gd
585   ipcopmake popt
586   ipcopmake slang
587   ipcopmake newt
588   ipcopmake libcap
589   ipcopmake pciutils
590   ipcopmake pcre
591   ipcopmake apache
592   ipcopmake arping
593   ipcopmake beep
594   ipcopmake bind
595   ipcopmake capi4k-utils
596   ipcopmake cdrtools
597   ipcopmake dnsmasq
598   ipcopmake dosfstools
599   ipcopmake ethtool
600   ipcopmake ez-ipupdate
601   ipcopmake fcron
602   ipcopmake perl-GD
603   ipcopmake gnupg
604   ipcopmake hdparm
605   ipcopmake ibod
606   ipcopmake initscripts
607   ipcopmake iptables
608   ipcopmake ipac-ng
609   ipcopmake ipaddr
610   ipcopmake iproute2
611   ipcopmake iptstate
612   ipcopmake iputils
613   ipcopmake isapnptools
614   ipcopmake isdn4k-utils
615   ipcopmake kudzu
616   ipcopmake logrotate
617   ipcopmake logwatch
618   ipcopmake mingetty
619   ipcopmake misc-progs
620   ipcopmake mtools
621   ipcopmake nano
622   ipcopmake nash
623   ipcopmake nasm
624   ipcopmake URI
625   ipcopmake HTML-Tagset
626   ipcopmake HTML-Parser
627   ipcopmake Compress-Zlib
628   ipcopmake Digest
629   ipcopmake Digest-SHA1
630   ipcopmake Digest-HMAC
631   ipcopmake libwww-perl
632   ipcopmake Net-DNS
633   ipcopmake Net-IPv4Addr
634   ipcopmake Net_SSLeay
635   ipcopmake noip_updater
636   ipcopmake ntp
637   ipcopmake oinkmaster
638   ipcopmake openssh
639   ipcopmake openswan
640   ipcopmake pptpclient
641   ipcopmake rrdtool
642   ipcopmake setserial
643   ipcopmake setup
644   ipcopmake snort
645   #ipcopmake speedycgi
646   ipcopmake squid
647   ipcopmake squid-graph
648   ipcopmake tcpdump
649   ipcopmake traceroute
650   ipcopmake vlan
651   ipcopmake wireless
652   ipcopmake libsafe
653   ipcopmake 3c5x9setup
654   echo -ne "`date -u '+%b %e %T'`: Building IPFire modules \n" | tee -a $LOGFILE
655   ipcopmake wget
656   ipcopmake berkeley-DB
657   ipcopmake xampp
658   ipcopmake bridge-utils
659   ipcopmake pam
660   ipcopmake pammysql
661   ipcopmake saslauthd
662   ipcopmake postfix
663   ipcopmake stund
664   ipcopmake lpd
665   ipcopmake pwlib
666   ipcopmake openh323
667   wget http://www.guzu.net/linux/hddtemp.db && mv hddtemp.db $BASEDIR/build/etc/hddtemp.db
668   ipcopmake hddtemp
669
670 }
671
672 buildinstaller() {
673   # Run installer scripts one by one
674   LOGFILE="$BASEDIR/log/_build.installer.log"
675   export LOGFILE
676   echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" | tee -a $LOGFILE
677   if [ 'i386' = $MACHINE ]; then 
678         ipcopmake syslinux
679         ipcopmake as86
680         ipcopmake mbr
681         ipcopmake uClibc
682   fi
683   installmake busybox
684   installmake sysvinit
685   installmake e2fsprogs
686   installmake misc-progs
687   installmake slang
688   installmake util-linux
689   installmake newt
690   installmake pciutils
691   installmake pcmcia-cs
692   installmake kbd
693   installmake installer
694   installmake scsi.img
695   installmake driver.img
696   installmake initrd
697   installmake boot.img
698 }
699
700 buildpackages() {
701   LOGFILE="$BASEDIR/log/_build.packages.log"
702   export LOGFILE
703   echo "... see detailed log in _build.*.log files" >> $LOGFILE
704   echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" | tee -a $LOGFILE
705   # Strip files
706   echo "`date -u '+%b %e %T'`: Stripping files" | tee -a $LOGFILE
707   find $LFS/lib $LFS/usr/lib $LFS/usr/share/rrdtool-* $LFS/install ! -type l \( -name '*.so' -o -name '*.so[\.0-9]*' \) \
708         ! -name 'libc.so' ! -name 'libpthread.so' ! -name 'libcrypto.so.0.9.7.sha1' \
709         -ls -exec $LFS/tools/bin/strip --strip-all {} \; >> $LOGFILE 2>&1
710   # add -ls before -exec if you want to verify what files are stripped
711
712   find $LFS/{,s}bin $LFS/usr/{,s}bin $LFS/usr/local/{,s}bin ! -type l \
713         -exec file {} \; | grep " ELF " | cut -f1 -d ':' | xargs $LFS/tools/bin/strip --strip-all >> $LOGFILE 2>&1
714   # there add -v to strip to verify
715
716   if [ 'i386' = $MACHINE ]; then
717         # Create fcdsl packages
718         echo "`date -u '+%b %e %T'`: Building fcdsl tgz" | tee -a $LOGFILE
719         cp $LFS/install/images/fcdsl/license.txt $LFS  >> $LOGFILE 2>&1
720         touch $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
721         cd $LFS && tar cvfz $LFS/install/images/$SNAME-fcdsl-$VERSION.$MACHINE.tgz \
722                 lib/modules/$KVER/misc/fcdsl*.o.gz \
723                 lib/modules/$KVER-smp/misc/fcdsl*.o.gz \
724                 usr/lib/isdn/{fds?base.bin,fd?ubase.frm} \
725                 etc/fcdsl/fcdsl*.conf \
726                 etc/drdsl/{drdsl,drdsl.ini} \
727                 license.txt \
728                 var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} >> $LOGFILE 2>&1
729         rm -f $LFS/license.txt >> $LOGFILE 2>&1
730         cd $BASEDIR
731   fi
732
733 #  Create update for this version
734 #  echo "`date -u '+%b %e %T'`: Building update $VERSION tgz" | tee -a $LOGFILE
735 #  tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/$VERSION/ROOTFILES.$MACHINE-$VERSION -f $BASEDIR/updates/$VERSION/patch.tar.gz --exclude='#*'; 
736 #  chmod 755 $BASEDIR/updates/$VERSION/setup
737 #  tar -cz -C $BASEDIR/updates/$VERSION -f $LFS/install/images/$SNAME-update-$VERSION.$MACHINE.tgz patch.tar.gz setup information
738 #  rm -f $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
739   
740   # Generating list of packages used
741   echo "`date -u '+%b %e %T'`: Generating packages list from logs" | tee -a $LOGFILE
742   rm -f $BASEDIR/doc/packages-list
743   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
744         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
745                 echo "  * `basename $i`" >>$BASEDIR/doc/packages-list
746         fi
747   done
748   echo "====== List of softwares used to build $NAME Version: $VERSION ======" > $BASEDIR/doc/packages-list.txt
749   grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|ipcop$\|setup$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \
750         $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
751   rm -f $BASEDIR/doc/packages-list
752   # packages-list.txt is ready to be displayed for wiki page IPCopSoftwares
753
754   # Create ISO for CDRom and USB-superfloppy
755   ipcopmake cdrom
756   cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1
757   
758   # Build IPFire packages
759   ipfiredist postfix
760
761   # Cleanup
762   stdumount
763   rm -rf $BASEDIR/build/tmp/*
764
765   # Generating total list of files
766   echo "`date -u '+%b %e %T'`: Generating files list from logs" | tee -a $LOGFILE
767   rm -f $BASEDIR/log/FILES
768   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
769         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
770                 echo "##" >>$BASEDIR/log/FILES
771                 echo "## `basename $i`" >>$BASEDIR/log/FILES
772                 echo "##" >>$BASEDIR/log/FILES
773                 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
774         fi
775   done
776
777   cd $PWD
778
779 }
780
781 # See what we're supposed to do
782 case "$1" in 
783 build)
784         BUILDMACHINE=`uname -m`
785         PACKAGE=`ls -v -r $BASEDIR/cache/$SNAME-1.4.*-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
786         #only restore on a clean disk
787         if [ ! -f log/perl-*-tools ]; then
788                 if [ ! -n "$PACKAGE" ]; then
789                         echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE
790                         prepareenv
791                         buildtoolchain
792                 else
793                         PACKAGENAME=${PACKAGE%.tar.gz}
794                         echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" | tee -a $LOGFILE
795                         if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
796                                 tar zxf $PACKAGE
797                                 prepareenv
798                         else
799                                 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
800                         fi
801                 fi
802         else
803                 echo "`date -u '+%b %e %T'`: Using installed toolchain" | tee -a $LOGFILE
804                 prepareenv
805         fi
806         buildbase
807         buildipcop
808         buildinstaller
809         buildpackages
810         ;;
811 shell)
812         # enter a shell inside LFS chroot
813         # may be used to changed kernel settings
814         prepareenv
815         entershell
816         ;;
817 changelog)
818         echo "Building doc/Changelog from CVS"
819         # cv2cl script come from http://www.red-bean.com/cvs2cl/
820         if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
821                 BRANCHOPTS=""
822         else
823                 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
824                 BRANCH=${BRANCH:1}
825                 BRANCHOPTS="--follow-only $BRANCH"
826         fi
827         
828         $BASEDIR/tools/cvs2cl.pl --gmt --show-dead $BRANCHOPTS -f $BASEDIR/doc/ChangeLog
829         rm -f $BASEDIR/doc/ChangeLog.bak
830         echo
831         echo "Commit the change now to update CVS"
832         ;;
833 check)
834         echo "Checking sources files availability on the web"
835         if [ ! -d $DIR_CHK ]; then
836                 mkdir -p $DIR_CHK
837         fi
838         FINISHED=0
839         cd $BASEDIR/lfs
840         for c in `seq $MAX_RETRIES`; do
841                 if (( FINISHED==1 )); then
842                         break
843                 fi
844                 FINISHED=1
845                 cd $BASEDIR/lfs
846                 for i in *; do
847                         if [ -f "$i" -a "$i" != "Config" ]; then
848                                 make -s -f $i MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR ROOT=$BASEDIR/build \
849                                         MESSAGE="$i\t ($c/$MAX_RETRIES)" check
850                                 if [ $? -ne 0 ]; then
851                                         echo "Check : wget error in lfs/$i"
852                                         FINISHED=0
853                                 fi
854                         fi
855                 done
856         done
857         cd -
858         ;;
859 checkclean)
860         echo "Erasing sources files availability tags"
861         rm -rf $DIR_CHK/*
862         ;;
863 clean)
864         for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
865                 $LOSETUP -d $i 2>/dev/null
866         done
867         for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
868                 umount $i
869         done
870         stdumount
871         for i in `seq 0 7`; do
872             if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
873                 umount /dev/loop${i}     2>/dev/null;
874                 losetup -d /dev/loop${i} 2>/dev/null;
875             fi;
876         done
877         rm -rf $BASEDIR/build
878         rm -rf $BASEDIR/cdrom
879         rm -rf $BASEDIR/log
880         rm -f $BASEDIR/updates/$VERSION/patch.tar.gz;
881         if [ -h /tools ]; then
882                 rm -f /tools
883         fi
884         ;;
885 dist)
886         echo "Building source package from CVS, list of changed files, MD5 of release files"
887         if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
888                 BRANCH=""
889                 BRANCHOPTS="-D `date +'%Y-%m-%d'`"
890         else
891                 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
892                 BRANCH=${BRANCH:1}
893                 BRANCHOPTS="-r $BRANCH"
894         fi
895
896         rm -rf $BASEDIR/build/tmp/$SNAME-$VERSION $BASEDIR/doc/release.txt
897         cd $BASEDIR/build/tmp
898         # build sources tgz
899         echo "Export tree $BRANCH $SNAME-$VERSION"
900         cvs -z3 -d `cat $BASEDIR/CVS/Root` export $BRANCHOPTS ipcop
901         if [ $? -eq 0 ]; then
902                 mv ipcop $SNAME-$VERSION
903                 tar cfz $BASEDIR/$SNAME-sources-$VERSION.tgz $SNAME-$VERSION
904                 cd $BASEDIR
905
906                 if [ ! -d $BASEDIR/build/tmp/$PREVIOUSTAG ]; then
907                         # export previous version to be compared with actual, this help to check wich files need to go in update
908                         cd $BASEDIR/build/tmp
909                         echo "Export tree $PREVIOUSTAG"
910                         cvs -z3 -d `cat $BASEDIR/CVS/Root` export -r $PREVIOUSTAG ipcop
911                         mv ipcop $PREVIOUSTAG
912                 fi
913                 if [ -d $BASEDIR/build/tmp/$PREVIOUSTAG -o -d $BASEDIR/build/tmp/$SNAME-$VERSION ]; then
914                         cd $BASEDIR/build/tmp
915                         echo "diff $PREVIOUSTAG <> $BRANCH $SNAME-$VERSION >doc/updated-sources.txt"
916                         diff -rq $PREVIOUSTAG $SNAME-$VERSION > $BASEDIR/doc/updated-sources.txt
917                         mv $BASEDIR/doc/updated-sources.txt $BASEDIR/doc/updated-sources.bak
918                         sed -e "s+Files $PREVIOUSTAG\/++" \
919                                 -e "s+ and .*$++" \
920                                 -e "s+src/rc.d+etc/rc.d+" \
921                                 -e "s+^langs/+var/ipcop/langs/+" \
922                                 -e "s+html/cgi-bin+home/httpd/cgi-bin+" $BASEDIR/doc/updated-sources.bak \
923                                 > $BASEDIR/doc/updated-sources.txt
924                         rm -f $BASEDIR/doc/updated-sources.bak
925                 fi
926         fi
927         ;;
928 newupdate)
929         # create structure for $VERSION update
930         if [ ! -f "updates/$VERSION" ]; then
931                 mkdir -p updates/$VERSION
932                 cd updates/$VERSION
933                 touch information
934                 echo 'etc/issue' > ROOTFILES.alpha-$VERSION
935                 echo 'etc/issue' > ROOTFILES.i386-$VERSION
936                 echo 'patch.tar.gz' > .cvsignore
937                 sed -e "s+^UPGRADEVERSION.*$+UPGRADEVERSION=$VERSION+" $BASEDIR/src/scripts/updatesetup > setup
938                 chmod 755 setup
939                 cd ..
940                 echo "Adding directory $VERSION to cvs"
941                 cvs add $VERSION
942                 echo "Adding files to cvs"
943                 cvs add $VERSION/ROOTFILES.alpha-$VERSION \
944                         $VERSION/ROOTFILES.i386-$VERSION \
945                         $VERSION/information \
946                         $VERSION/setup \
947                         $VERSION/.cvsignore
948         else
949                 echo "update/$VERSION already exist"
950         fi
951         cd -
952         exit 0
953         ;;
954 prefetch)
955         if [ ! -d $BASEDIR/cache ]; then
956                 mkdir $BASEDIR/cache
957         fi
958         mkdir -p $BASEDIR/log
959         echo "`date -u '+%b %e %T'`:Preload all source files" | tee -a $LOGFILE
960         FINISHED=0
961         cd $BASEDIR/lfs
962         for c in `seq $MAX_RETRIES`; do
963                 if (( FINISHED==1 )); then 
964                         break
965                 fi
966                 FINISHED=1
967                 cd $BASEDIR/lfs
968                 for i in *; do
969                         if [ -f "$i" -a "$i" != "Config" ]; then
970                                 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
971                                 if [ $? -ne 0 ]; then
972                                         echo "Prefetch : wget error in lfs/$i"
973                                         FINISHED=0
974                                 else
975                                         if [ $c -eq 1 ]; then
976                                                 echo "Prefetch : lfs/$i files loaded"
977                                         fi
978                                 fi
979                         fi
980                 done
981         done
982         echo "Prefetch : verifying md5sum"
983         ERROR=0
984         for i in *; do
985                 if [ -f "$i" -a "$i" != "Config" ]; then
986                         make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
987                         if [ $? -ne 0 ]; then
988                                 echo "md5 difference in lfs/$i"
989                                 ERROR=1
990                         fi
991                 fi
992         done
993         if [ $ERROR -eq 0 ]; then
994                 echo "Prefetch : all files md5sum match"
995         fi
996         cd -
997         ;;
998 rootfiles)
999         PREVIOUSVERSION=`echo $PREVIOUSTAG | sed -e 's/IPCOP_v//' -e 's/_FINAL//' -e 's/_/\./g'`
1000         # make md5 list of actual build
1001         # some packages include a timestamp (kernel/perl/python/vim and more), so md5 vary at each build
1002         # anyway, it is sometime usable after a patch or a minor upgrade to know wich files include in update
1003         if [ ! -f "$BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz" ]; then
1004                 echo "need cdrom be build to read include files list, use ./make.sh build before."
1005         else
1006                 tar tzf $BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz > $BASEDIR/updates/$VERSION/FILES.tmp
1007                 cd $BASEDIR/build
1008                 rm -f $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
1009                 for line in `cat $BASEDIR/updates/$VERSION/FILES.tmp`; do
1010                         if [ -f "$line" -a ! -L "$line" ]; then
1011                                 md5sum "$line" >> $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
1012                         fi
1013                 done
1014                 diff $BASEDIR/updates/$PREVIOUSVERSION/FILES-$MACHINE-$PREVIOUSVERSION.md5 \
1015                         $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 \
1016                         > $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff
1017                 awk '$1==">" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
1018                         > $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE
1019                 awk '$1=="<" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
1020                         > $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp
1021                 rm -f $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
1022                 for line in `cat $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp`; do
1023                         # a file is only removed when not in add file
1024                         if ( ! grep -q "^$line$" $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE ); then
1025                                 echo $line >> $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
1026                         fi
1027                 done
1028                 rm -f $BASEDIR/updates/$VERSION/{FILES.tmp,FILES-*.diff,ROOTFILES.remove.*.tmp}
1029         fi
1030         exit 0
1031         ;;
1032 toolchain)
1033         prepareenv
1034         buildtoolchain
1035         BUILDMACHINE=`uname -m`
1036         echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1037         cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1038                 build/{bin,etc,usr/bin,usr/local} \
1039                 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
1040                 log >> $LOGFILE
1041         md5sum cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1042                 > cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.md5
1043         stdumount
1044         ;;
1045 gettoolchain)
1046         BUILDMACHINE=`uname -m`
1047         # arbitrary name to be updated in case of new toolchain package upload
1048         PACKAGE=$SNAME-1.4.11-toolchain-$BUILDMACHINE
1049         URL_SFNET=`grep URL_SFNET lfs/Config | awk '{ print $3 }'`
1050         echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1051         cd $BASEDIR/cache
1052         wget -c $URL_SFNET/ipcop/$PACKAGE.tar.gz $URL_SFNET/ipcop/$PACKAGE.md5
1053         if [ $? -ne 0 ]; then
1054                 echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
1055         else
1056                 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1057                         echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1058                 else
1059                         exiterror "$PACKAGE.md5 did not match, check downloaded package"
1060                 fi
1061         fi
1062         ;;
1063 *)
1064         echo "Usage: $0 {build|changelog|check|checkclean|clean|dist|gettoolchain|newupdate|prefetch|rootfiles|shell|toolchain}"
1065         cat doc/make.sh-usage
1066         exit 1
1067         ;;
1068 esac