Erste Version des Paketerstellers.
[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 berkeley-DB
656   ipcopmake xampp
657   ipcopmake pam
658   ipcopmake pammysql
659   ipcopmake saslauthd
660   ipcopmake postfix
661   ipcopmake stund
662   ipcopmake lpd
663   ipcopmake pwlib
664   ipcopmake openh323
665
666 }
667
668 buildinstaller() {
669   # Run installer scripts one by one
670   LOGFILE="$BASEDIR/log/_build.installer.log"
671   export LOGFILE
672   echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" | tee -a $LOGFILE
673   if [ 'i386' = $MACHINE ]; then 
674         ipcopmake syslinux
675         ipcopmake as86
676         ipcopmake mbr
677         ipcopmake uClibc
678   fi
679   installmake busybox
680   installmake sysvinit
681   installmake e2fsprogs
682   installmake misc-progs
683   installmake slang
684   installmake util-linux
685   installmake newt
686   installmake pciutils
687   installmake pcmcia-cs
688   installmake kbd
689   installmake installer
690   installmake scsi.img
691   installmake driver.img
692   installmake initrd
693   installmake boot.img
694 }
695
696 buildpackages() {
697   LOGFILE="$BASEDIR/log/_build.packages.log"
698   export LOGFILE
699   echo "... see detailed log in _build.*.log files" >> $LOGFILE
700   echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" | tee -a $LOGFILE
701   # Strip files
702   echo "`date -u '+%b %e %T'`: Stripping files" | tee -a $LOGFILE
703   find $LFS/lib $LFS/usr/lib $LFS/usr/share/rrdtool-* $LFS/install ! -type l \( -name '*.so' -o -name '*.so[\.0-9]*' \) \
704         ! -name 'libc.so' ! -name 'libpthread.so' ! -name 'libcrypto.so.0.9.7.sha1' \
705         -ls -exec $LFS/tools/bin/strip --strip-all {} \; >> $LOGFILE 2>&1
706   # add -ls before -exec if you want to verify what files are stripped
707
708   find $LFS/{,s}bin $LFS/usr/{,s}bin $LFS/usr/local/{,s}bin ! -type l \
709         -exec file {} \; | grep " ELF " | cut -f1 -d ':' | xargs $LFS/tools/bin/strip --strip-all >> $LOGFILE 2>&1
710   # there add -v to strip to verify
711
712   if [ 'i386' = $MACHINE ]; then
713         # Create fcdsl packages
714         echo "`date -u '+%b %e %T'`: Building fcdsl tgz" | tee -a $LOGFILE
715         cp $LFS/install/images/fcdsl/license.txt $LFS  >> $LOGFILE 2>&1
716         touch $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
717         cd $LFS && tar cvfz $LFS/install/images/$SNAME-fcdsl-$VERSION.$MACHINE.tgz \
718                 lib/modules/$KVER/misc/fcdsl*.o.gz \
719                 lib/modules/$KVER-smp/misc/fcdsl*.o.gz \
720                 usr/lib/isdn/{fds?base.bin,fd?ubase.frm} \
721                 etc/fcdsl/fcdsl*.conf \
722                 etc/drdsl/{drdsl,drdsl.ini} \
723                 license.txt \
724                 var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} >> $LOGFILE 2>&1
725         rm -f $LFS/license.txt >> $LOGFILE 2>&1
726         cd $BASEDIR
727   fi
728
729 #  Create update for this version
730 #  echo "`date -u '+%b %e %T'`: Building update $VERSION tgz" | tee -a $LOGFILE
731 #  tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/$VERSION/ROOTFILES.$MACHINE-$VERSION -f $BASEDIR/updates/$VERSION/patch.tar.gz --exclude='#*'; 
732 #  chmod 755 $BASEDIR/updates/$VERSION/setup
733 #  tar -cz -C $BASEDIR/updates/$VERSION -f $LFS/install/images/$SNAME-update-$VERSION.$MACHINE.tgz patch.tar.gz setup information
734 #  rm -f $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
735   
736   # Generating list of packages used
737   echo "`date -u '+%b %e %T'`: Generating packages list from logs" | tee -a $LOGFILE
738   rm -f $BASEDIR/doc/packages-list
739   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
740         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
741                 echo "  * `basename $i`" >>$BASEDIR/doc/packages-list
742         fi
743   done
744   echo "====== List of softwares used to build $NAME Version: $VERSION ======" > $BASEDIR/doc/packages-list.txt
745   grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|ipcop$\|setup$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \
746         $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
747   rm -f $BASEDIR/doc/packages-list
748   # packages-list.txt is ready to be displayed for wiki page IPCopSoftwares
749
750   # Create ISO for CDRom and USB-superfloppy
751   ipcopmake cdrom
752   cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1
753   
754   # Build IPFire packages
755   ipfiredist postfix
756
757   # Cleanup
758   stdumount
759   rm -rf $BASEDIR/build/tmp/*
760
761   # Generating total list of files
762   echo "`date -u '+%b %e %T'`: Generating files list from logs" | tee -a $LOGFILE
763   rm -f $BASEDIR/log/FILES
764   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
765         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
766                 echo "##" >>$BASEDIR/log/FILES
767                 echo "## `basename $i`" >>$BASEDIR/log/FILES
768                 echo "##" >>$BASEDIR/log/FILES
769                 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
770         fi
771   done
772
773   cd $PWD
774
775 }
776
777 # See what we're supposed to do
778 case "$1" in 
779 build)
780         BUILDMACHINE=`uname -m`
781         PACKAGE=`ls -v -r $BASEDIR/cache/$SNAME-1.4.*-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
782         #only restore on a clean disk
783         if [ ! -f log/perl-*-tools ]; then
784                 if [ ! -n "$PACKAGE" ]; then
785                         echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE
786                         prepareenv
787                         buildtoolchain
788                 else
789                         PACKAGENAME=${PACKAGE%.tar.gz}
790                         echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" | tee -a $LOGFILE
791                         if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
792                                 tar zxf $PACKAGE
793                                 prepareenv
794                         else
795                                 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
796                         fi
797                 fi
798         else
799                 echo "`date -u '+%b %e %T'`: Using installed toolchain" | tee -a $LOGFILE
800                 prepareenv
801         fi
802         buildbase
803         buildipcop
804         buildinstaller
805         buildpackages
806         ;;
807 shell)
808         # enter a shell inside LFS chroot
809         # may be used to changed kernel settings
810         prepareenv
811         entershell
812         ;;
813 changelog)
814         echo "Building doc/Changelog from CVS"
815         # cv2cl script come from http://www.red-bean.com/cvs2cl/
816         if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
817                 BRANCHOPTS=""
818         else
819                 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
820                 BRANCH=${BRANCH:1}
821                 BRANCHOPTS="--follow-only $BRANCH"
822         fi
823         
824         $BASEDIR/tools/cvs2cl.pl --gmt --show-dead $BRANCHOPTS -f $BASEDIR/doc/ChangeLog
825         rm -f $BASEDIR/doc/ChangeLog.bak
826         echo
827         echo "Commit the change now to update CVS"
828         ;;
829 check)
830         echo "Checking sources files availability on the web"
831         if [ ! -d $DIR_CHK ]; then
832                 mkdir -p $DIR_CHK
833         fi
834         FINISHED=0
835         cd $BASEDIR/lfs
836         for c in `seq $MAX_RETRIES`; do
837                 if (( FINISHED==1 )); then
838                         break
839                 fi
840                 FINISHED=1
841                 cd $BASEDIR/lfs
842                 for i in *; do
843                         if [ -f "$i" -a "$i" != "Config" ]; then
844                                 make -s -f $i MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR ROOT=$BASEDIR/build \
845                                         MESSAGE="$i\t ($c/$MAX_RETRIES)" check
846                                 if [ $? -ne 0 ]; then
847                                         echo "Check : wget error in lfs/$i"
848                                         FINISHED=0
849                                 fi
850                         fi
851                 done
852         done
853         cd -
854         ;;
855 checkclean)
856         echo "Erasing sources files availability tags"
857         rm -rf $DIR_CHK/*
858         ;;
859 clean)
860         for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
861                 $LOSETUP -d $i 2>/dev/null
862         done
863         for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
864                 umount $i
865         done
866         stdumount
867         for i in `seq 0 7`; do
868             if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
869                 umount /dev/loop${i}     2>/dev/null;
870                 losetup -d /dev/loop${i} 2>/dev/null;
871             fi;
872         done
873         rm -rf $BASEDIR/build
874         rm -rf $BASEDIR/cdrom
875         rm -rf $BASEDIR/log
876         rm -f $BASEDIR/updates/$VERSION/patch.tar.gz;
877         if [ -h /tools ]; then
878                 rm -f /tools
879         fi
880         ;;
881 dist)
882         echo "Building source package from CVS, list of changed files, MD5 of release files"
883         if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
884                 BRANCH=""
885                 BRANCHOPTS="-D `date +'%Y-%m-%d'`"
886         else
887                 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
888                 BRANCH=${BRANCH:1}
889                 BRANCHOPTS="-r $BRANCH"
890         fi
891
892         rm -rf $BASEDIR/build/tmp/$SNAME-$VERSION $BASEDIR/doc/release.txt
893         cd $BASEDIR/build/tmp
894         # build sources tgz
895         echo "Export tree $BRANCH $SNAME-$VERSION"
896         cvs -z3 -d `cat $BASEDIR/CVS/Root` export $BRANCHOPTS ipcop
897         if [ $? -eq 0 ]; then
898                 mv ipcop $SNAME-$VERSION
899                 tar cfz $BASEDIR/$SNAME-sources-$VERSION.tgz $SNAME-$VERSION
900                 cd $BASEDIR
901
902                 if [ ! -d $BASEDIR/build/tmp/$PREVIOUSTAG ]; then
903                         # export previous version to be compared with actual, this help to check wich files need to go in update
904                         cd $BASEDIR/build/tmp
905                         echo "Export tree $PREVIOUSTAG"
906                         cvs -z3 -d `cat $BASEDIR/CVS/Root` export -r $PREVIOUSTAG ipcop
907                         mv ipcop $PREVIOUSTAG
908                 fi
909                 if [ -d $BASEDIR/build/tmp/$PREVIOUSTAG -o -d $BASEDIR/build/tmp/$SNAME-$VERSION ]; then
910                         cd $BASEDIR/build/tmp
911                         echo "diff $PREVIOUSTAG <> $BRANCH $SNAME-$VERSION >doc/updated-sources.txt"
912                         diff -rq $PREVIOUSTAG $SNAME-$VERSION > $BASEDIR/doc/updated-sources.txt
913                         mv $BASEDIR/doc/updated-sources.txt $BASEDIR/doc/updated-sources.bak
914                         sed -e "s+Files $PREVIOUSTAG\/++" \
915                                 -e "s+ and .*$++" \
916                                 -e "s+src/rc.d+etc/rc.d+" \
917                                 -e "s+^langs/+var/ipcop/langs/+" \
918                                 -e "s+html/cgi-bin+home/httpd/cgi-bin+" $BASEDIR/doc/updated-sources.bak \
919                                 > $BASEDIR/doc/updated-sources.txt
920                         rm -f $BASEDIR/doc/updated-sources.bak
921                 fi
922         fi
923         ;;
924 newupdate)
925         # create structure for $VERSION update
926         if [ ! -f "updates/$VERSION" ]; then
927                 mkdir -p updates/$VERSION
928                 cd updates/$VERSION
929                 touch information
930                 echo 'etc/issue' > ROOTFILES.alpha-$VERSION
931                 echo 'etc/issue' > ROOTFILES.i386-$VERSION
932                 echo 'patch.tar.gz' > .cvsignore
933                 sed -e "s+^UPGRADEVERSION.*$+UPGRADEVERSION=$VERSION+" $BASEDIR/src/scripts/updatesetup > setup
934                 chmod 755 setup
935                 cd ..
936                 echo "Adding directory $VERSION to cvs"
937                 cvs add $VERSION
938                 echo "Adding files to cvs"
939                 cvs add $VERSION/ROOTFILES.alpha-$VERSION \
940                         $VERSION/ROOTFILES.i386-$VERSION \
941                         $VERSION/information \
942                         $VERSION/setup \
943                         $VERSION/.cvsignore
944         else
945                 echo "update/$VERSION already exist"
946         fi
947         cd -
948         exit 0
949         ;;
950 prefetch)
951         if [ ! -d $BASEDIR/cache ]; then
952                 mkdir $BASEDIR/cache
953         fi
954         mkdir -p $BASEDIR/log
955         echo "`date -u '+%b %e %T'`:Preload all source files" | tee -a $LOGFILE
956         FINISHED=0
957         cd $BASEDIR/lfs
958         for c in `seq $MAX_RETRIES`; do
959                 if (( FINISHED==1 )); then 
960                         break
961                 fi
962                 FINISHED=1
963                 cd $BASEDIR/lfs
964                 for i in *; do
965                         if [ -f "$i" -a "$i" != "Config" ]; then
966                                 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
967                                 if [ $? -ne 0 ]; then
968                                         echo "Prefetch : wget error in lfs/$i"
969                                         FINISHED=0
970                                 else
971                                         if [ $c -eq 1 ]; then
972                                                 echo "Prefetch : lfs/$i files loaded"
973                                         fi
974                                 fi
975                         fi
976                 done
977         done
978         echo "Prefetch : verifying md5sum"
979         ERROR=0
980         for i in *; do
981                 if [ -f "$i" -a "$i" != "Config" ]; then
982                         make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
983                         if [ $? -ne 0 ]; then
984                                 echo "md5 difference in lfs/$i"
985                                 ERROR=1
986                         fi
987                 fi
988         done
989         if [ $ERROR -eq 0 ]; then
990                 echo "Prefetch : all files md5sum match"
991         fi
992         cd -
993         ;;
994 rootfiles)
995         PREVIOUSVERSION=`echo $PREVIOUSTAG | sed -e 's/IPCOP_v//' -e 's/_FINAL//' -e 's/_/\./g'`
996         # make md5 list of actual build
997         # some packages include a timestamp (kernel/perl/python/vim and more), so md5 vary at each build
998         # anyway, it is sometime usable after a patch or a minor upgrade to know wich files include in update
999         if [ ! -f "$BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz" ]; then
1000                 echo "need cdrom be build to read include files list, use ./make.sh build before."
1001         else
1002                 tar tzf $BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz > $BASEDIR/updates/$VERSION/FILES.tmp
1003                 cd $BASEDIR/build
1004                 rm -f $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
1005                 for line in `cat $BASEDIR/updates/$VERSION/FILES.tmp`; do
1006                         if [ -f "$line" -a ! -L "$line" ]; then
1007                                 md5sum "$line" >> $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
1008                         fi
1009                 done
1010                 diff $BASEDIR/updates/$PREVIOUSVERSION/FILES-$MACHINE-$PREVIOUSVERSION.md5 \
1011                         $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 \
1012                         > $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff
1013                 awk '$1==">" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
1014                         > $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE
1015                 awk '$1=="<" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
1016                         > $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp
1017                 rm -f $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
1018                 for line in `cat $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp`; do
1019                         # a file is only removed when not in add file
1020                         if ( ! grep -q "^$line$" $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE ); then
1021                                 echo $line >> $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
1022                         fi
1023                 done
1024                 rm -f $BASEDIR/updates/$VERSION/{FILES.tmp,FILES-*.diff,ROOTFILES.remove.*.tmp}
1025         fi
1026         exit 0
1027         ;;
1028 toolchain)
1029         prepareenv
1030         buildtoolchain
1031         BUILDMACHINE=`uname -m`
1032         echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1033         cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1034                 build/{bin,etc,usr/bin,usr/local} \
1035                 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
1036                 log >> $LOGFILE
1037         md5sum cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1038                 > cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.md5
1039         stdumount
1040         ;;
1041 gettoolchain)
1042         BUILDMACHINE=`uname -m`
1043         # arbitrary name to be updated in case of new toolchain package upload
1044         PACKAGE=$SNAME-1.4.11-toolchain-$BUILDMACHINE
1045         URL_SFNET=`grep URL_SFNET lfs/Config | awk '{ print $3 }'`
1046         echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1047         cd $BASEDIR/cache
1048         wget -c $URL_SFNET/ipcop/$PACKAGE.tar.gz $URL_SFNET/ipcop/$PACKAGE.md5
1049         if [ $? -ne 0 ]; then
1050                 echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
1051         else
1052                 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1053                         echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1054                 else
1055                         exiterror "$PACKAGE.md5 did not match, check downloaded package"
1056                 fi
1057         fi
1058         ;;
1059 *)
1060         echo "Usage: $0 {build|changelog|check|checkclean|clean|dist|gettoolchain|newupdate|prefetch|rootfiles|shell|toolchain}"
1061         cat doc/make.sh-usage
1062         exit 1
1063         ;;
1064 esac