Das Build wird jetzt im Browserkopf angezeigt
[ipfire-2.x.git] / make.sh
1 #!/bin/bash
2 #
3 ############################################################################
4 #                                                                          #
5 # This file is part of the IPFire Firewall.                                #
6 #                                                                          #
7 # IPFire is free software; you can redistribute it and/or modify           #
8 # it under the terms of the GNU General Public License as published by     #
9 # the Free Software Foundation; either version 2 of the License, or        #
10 # (at your option) any later version.                                      #
11 #                                                                          #
12 # IPFire is distributed in the hope that it will be useful,                #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of           #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
15 # GNU General Public License for more details.                             #
16 #                                                                          #
17 # You should have received a copy of the GNU General Public License        #
18 # along with IPFire; if not, write to the Free Software                    #
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
20 #                                                                          #
21 # Copyright (C) 2006 IPFire-Team <entwickler@ipfire.org>.                  #
22 #                                                                          #
23 ############################################################################
24 #
25
26   NAME="IPFire"                 # Software name
27   SNAME="ipfire"                        # Short name
28   VERSION="1.4"                 # Version number
29   SLOGAN="We secure your network"       # Software slogan
30   CONFIG_ROOT=/var/ipfire               # Configuration rootdir
31   NICE=10
32   MAX_RETRIES=3                 # prefetch/check loop
33   KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
34   MACHINE=`uname -m`
35
36   # Setzen des IPFire Builds
37   if [ -e ./.svn ]; then
38     FIREBUILD=`cat .svn/entries |sed -n 's/^[ \t]*revision=\"// p' | sed -n 's/\".*$// p'`
39 #    VERSION="$VERSION (Build:$FIREBUILD)"
40   fi
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
65         echo "`date -u '+%b %e %T'`: Machine is ix86 (or equivalent)" | tee -a $LOGFILE
66         MACHINE=i386
67         BUILDTARGET=i386-pc-linux-gnu
68         CFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
69         CXXFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
70   elif [ 'alpha' = $MACHINE ]; then
71         echo "`date -u '+%b %e %T'`: Machine is Alpha AXP" | tee -a $LOGFILE
72         BUILDTARGET=alpha-unknown-linux-gnu
73         CFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
74         CXXFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
75   else
76         echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" | tee -a $LOGFILE
77         exit 1
78   fi
79
80 # Define immediately
81 stdumount() {
82         umount $BASEDIR/build/dev/pts           2>/dev/null;
83         umount $BASEDIR/build/proc                      2>/dev/null;
84         umount $BASEDIR/build/install/mnt               2>/dev/null;
85         umount $BASEDIR/build/usr/src/cache     2>/dev/null;
86         umount $BASEDIR/build/usr/src/ccache    2>/dev/null;
87         umount $BASEDIR/build/usr/src/config    2>/dev/null;
88         umount $BASEDIR/build/usr/src/doc               2>/dev/null;
89         umount $BASEDIR/build/usr/src/html              2>/dev/null;
90         umount $BASEDIR/build/usr/src/langs     2>/dev/null;
91         umount $BASEDIR/build/usr/src/lfs               2>/dev/null;
92         umount $BASEDIR/build/usr/src/log               2>/dev/null;
93         umount $BASEDIR/build/usr/src/src               2>/dev/null;
94 }
95
96 exiterror() {
97         stdumount
98         for i in `seq 0 7`; do
99             if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
100                 losetup -d /dev/loop${i} 2>/dev/null
101             fi;
102         done
103         echo "ERROR: $*"
104         echo "       Check $LOGFILE for errors if applicable"
105         exit 1
106 }
107
108 entershell() {
109         if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
110                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
111         fi
112         echo "Entering to a shell inside LFS chroot, go out with exit"
113         chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
114                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
115                 VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
116                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
117                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
118                 CCACHE_DIR=/usr/src/ccache \
119                 CCACHE_HASHDIR=1 \
120                 KVER=$KVER \
121                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
122                 KGCC="ccache /usr/bin/gcc" \
123                 /tools/bin/bash
124         if [ $? -ne 0 ]; then
125                         exiterror "chroot error"
126         else
127                 stdumount
128         fi
129 }
130
131 prepareenv() {
132     ############################################################################
133     #                                                                          #
134     # Are we running the right shell?                                          #
135     #                                                                          #
136     ############################################################################
137     if [ ! "$BASH" ]; then
138         exiterror "BASH environment variable is not set.  You're probably running the wrong shell."
139     fi
140
141     if [ -z "${BASH_VERSION}" ]; then
142         exiterror "Not running BASH shell."
143     fi
144
145
146     ############################################################################
147     #                                                                          #
148     # Trap on emergency exit                                                   #
149     #                                                                          #
150     ############################################################################
151     trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
152
153
154     ############################################################################
155     #                                                                          #
156     # Resetting our nice level                                                 #
157     #                                                                          #
158     ############################################################################
159     echo "`date -u '+%b %e %T'`: Resetting our nice level to $NICE" | tee -a $LOGFILE
160     renice $NICE $$ > /dev/null
161     if [ `nice` != "$NICE" ]; then
162         exiterror "Failed to set correct nice level"
163     fi
164
165     ############################################################################
166     #                                                                          #
167     # Checking if running as root user                                         #
168     #                                                                          #
169     ############################################################################
170     echo "`date -u '+%b %e %T'`: Checking if we're running as root user" | tee -a $LOGFILE
171     if [ `id -u` != 0 ]; then
172         exiterror "Not building as root"
173     fi
174
175
176     ############################################################################
177     #                                                                          #
178     # Checking for necessary temporary space                                   #
179     #                                                                          #
180     ############################################################################
181     echo "`date -u '+%b %e %T'`: Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
182     BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
183     BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
184     if (( 2202000 > $BASE_ASPACE )); then
185         BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
186         if (( 2202000 - $BASE_USPACE > $BASE_ASPACE )); then
187                 exiterror "Not enough temporary space available, need at least 2.1GB on $BASE_DEV"
188         fi
189     fi
190
191     ############################################################################
192     #                                                                          #
193     # Building Linux From Scratch system                                       #
194     #                                                                          #
195     ############################################################################
196     echo "`date -u '+%b %e %T'`: Building Linux From Scratch system" | tee -a $LOGFILE
197
198     # Set umask
199     umask 022
200
201     # Set LFS Directory
202     LFS=$BASEDIR/build
203
204     # Check /tools symlink
205     if [ -h /tools ]; then
206         rm -f /tools
207     fi
208     if [ ! -a /tools ]; then
209         ln -s $BASEDIR/build/tools /
210     fi
211     if [ ! -h /tools ]; then
212         exiterror "Could not create /tools symbolic link."
213     fi
214
215     # Setup environment
216     set +h
217     LC_ALL=POSIX
218     export LFS LC_ALL CFLAGS CXXFLAGS
219     unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
220
221     # Make some extra directories
222     mkdir -p $BASEDIR/build/{tools,etc,usr/src} 2>/dev/null
223     mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
224     mkdir -p $BASEDIR/build/dev/pts $BASEDIR/build/proc $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
225
226     # Make all sources and proc available under lfs build
227     mount --bind /dev/pts        $BASEDIR/build/dev/pts
228     mount --bind /proc           $BASEDIR/build/proc
229     mount --bind $BASEDIR/cache  $BASEDIR/build/usr/src/cache
230     mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
231     mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
232     mount --bind $BASEDIR/doc    $BASEDIR/build/usr/src/doc
233     mount --bind $BASEDIR/html   $BASEDIR/build/usr/src/html
234     mount --bind $BASEDIR/langs  $BASEDIR/build/usr/src/langs
235     mount --bind $BASEDIR/lfs    $BASEDIR/build/usr/src/lfs
236     mount --bind $BASEDIR/log    $BASEDIR/build/usr/src/log
237     mount --bind $BASEDIR/src    $BASEDIR/build/usr/src/src
238
239     # Run LFS static binary creation scripts one by one
240     export CCACHE_DIR=$BASEDIR/ccache
241     export CCACHE_HASHDIR=1
242
243     # Remove pre-install list of installed files in case user erase some files before rebuild
244     rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
245 }
246
247
248 ############################################################################
249 #                                                                          #
250 # Necessary shell functions                                                #
251 #                                                                          #
252 ############################################################################
253 lfsmake1() {
254         if [ -f $BASEDIR/lfs/$1 ]; then
255                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
256                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
257                 if [ $? -ne 0 ]; then
258                         exiterror "Download error in $1"
259                 fi
260                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
261                 if [ $? -ne 0 ]; then
262                         exiterror "md5sum error in $1, check file in cache or signature"
263                 fi
264                 cd $BASEDIR/lfs && make -f $*   BUILDTARGET=$BUILDTARGET \
265                                                 MACHINE=$MACHINE \
266                                                 LFS_BASEDIR=$BASEDIR \
267                                                 ROOT=$LFS \
268                                                 KVER=$KVER \
269                                                 install >> $LOGFILE 2>&1
270                 if [ $? -ne 0 ]; then
271                         exiterror "Building $*";
272                 fi
273         else
274                 exiterror "No such file or directory: $BASEDIR/$1"
275         fi
276         return 0
277 }
278
279 lfsmake2() {
280         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
281                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
282                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
283                 if [ $? -ne 0 ]; then
284                         exiterror "Download error in $1"
285                 fi
286                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
287                 if [ $? -ne 0 ]; then
288                         exiterror "md5sum error in $1, check file in cache or signature"
289                 fi
290                 chroot $LFS /tools/bin/env -i   HOME=/root \
291                                                 TERM=$TERM PS1='\u:\w\$ ' \
292                                                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
293                                                 VERSION=$VERSION \
294                                                 CONFIG_ROOT=$CONFIG_ROOT \
295                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
296                                                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
297                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
298                                                 KVER=$KVER \
299                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
300                     /tools/bin/bash -x -c "cd /usr/src/lfs && \
301                     make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
302                 if [ $? -ne 0 ]; then
303                         exiterror "Building $*"
304                 fi
305         else
306                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
307         fi
308         return 0
309 }
310
311 ipcopmake() {
312         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
313                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
314                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
315                 if [ $? -ne 0 ]; then
316                         exiterror "Download error in $1"
317                 fi
318                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
319                 if [ $? -ne 0 ]; then
320                         exiterror "md5sum error in $1, check file in cache or signature"
321                 fi
322                 chroot $LFS /tools/bin/env -i   HOME=/root \
323                                                 TERM=$TERM PS1='\u:\w\$ ' \
324                                                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
325                                                 VERSION=$VERSION \
326                                                 CONFIG_ROOT=$CONFIG_ROOT \
327                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
328                                                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
329                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
330                                                 KVER=$KVER \
331                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
332                     /bin/bash -x -c "cd /usr/src/lfs && \
333                     make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
334                 if [ $? -ne 0 ]; then
335                         exiterror "Building $*"
336                 fi
337         else
338                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
339         fi
340         return 0
341 }
342
343 ipfiredist() {
344         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
345 #          if [ ! `ls -w1 $BASEDIR/packages/*.tar.gz | grep $1` ]; then
346                 echo "`date -u '+%b %e %T'`: Packaging $1" | tee -a $LOGFILE
347                 chroot $LFS /tools/bin/env -i   HOME=/root \
348                                                 TERM=$TERM PS1='\u:\w\$ ' \
349                                                 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
350                                                 VERSION=$VERSION \
351                                                 CONFIG_ROOT=$CONFIG_ROOT \
352                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
353                                                 CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" \
354                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
355                                                 KVER=$KVER \
356                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
357                     /bin/bash -x -c "cd /usr/src/lfs && \
358                     make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
359                 if [ $? -ne 0 ]; then
360                         exiterror "Packaging $1"
361                 fi
362 #          else
363 #               echo "`date -u '+%b %e %T'`: Packaging: The package $1 already exists"
364 #          fi
365         else
366                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
367         fi
368         return 0
369 }
370
371
372 installmake() {
373         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
374                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
375                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
376                 if [ $? -ne 0 ]; then
377                         exiterror "Download error in $1"
378                 fi
379                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
380                 if [ $? -ne 0 ]; then
381                         exiterror "md5sum error in $1, check file in cache or signature"
382                 fi
383                 chroot $LFS /tools/bin/env -i   HOME=/root \
384                                                 TERM=$TERM PS1='\u:\w\$ ' \
385                                                 PATH=/usr/local/bin:/opt/$MACHINE-uClibc/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin \
386                                                 VERSION=$VERSION \
387                                                 CONFIG_ROOT=$CONFIG_ROOT \
388                                                 LFS_PASS="install" \
389                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
390                                                 CFLAGS="-Os" CXXFLAGS="-Os" \
391                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
392                                                 KVER=$KVER \
393                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
394                     /bin/bash -x -c "cd /usr/src/lfs && \
395                     make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
396                 if [ $? -ne 0 ]; then
397                         exiterror "Building $*"
398                 fi
399         else
400                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
401         fi
402         return 0
403 }
404
405 buildtoolchain() {
406     LOGFILE="$BASEDIR/log/_build.toolchain.log"
407     export LOGFILE
408     echo -ne "`date -u '+%b %e %T'`: Stage1 toolchain build \n" | tee -a $LOGFILE
409     # Build sed now, as we use some extensions
410     ORG_PATH=$PATH
411     NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}`
412     export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
413     lfsmake1 ccache
414     lfsmake1 sed        LFS_PASS=1
415     lfsmake1 m4         LFS_PASS=1
416     lfsmake1 bison      LFS_PASS=1
417     lfsmake1 flex       LFS_PASS=1
418     lfsmake1 binutils   LFS_PASS=1
419     lfsmake1 gcc        LFS_PASS=1
420     export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
421     
422     lfsmake1 linux
423     lfsmake1 tcl
424     lfsmake1 expect
425     lfsmake1 glibc
426     lfsmake1 dejagnu
427     lfsmake1 gcc        LFS_PASS=2
428     lfsmake1 binutils   LFS_PASS=2
429     lfsmake1 gawk
430     lfsmake1 coreutils
431     lfsmake1 bzip2
432     lfsmake1 gzip
433     lfsmake1 diffutils
434     lfsmake1 findutils
435     lfsmake1 make
436     lfsmake1 grep
437     lfsmake1 sed        LFS_PASS=2
438     lfsmake1 m4         LFS_PASS=2
439     lfsmake1 bison      LFS_PASS=2
440     lfsmake1 flex       LFS_PASS=2
441     lfsmake1 gettext
442     lfsmake1 ncurses
443     lfsmake1 patch
444     lfsmake1 tar
445     lfsmake1 texinfo
446     lfsmake1 bash
447     lfsmake1 util-linux
448     lfsmake1 perl
449     export PATH=$ORG_PATH
450 }
451
452 buildbase() {
453     LOGFILE="$BASEDIR/log/_build.base.log"
454     export LOGFILE
455     echo -ne "`date -u '+%b %e %T'`: Stage2 linux base build \n" | tee -a $LOGFILE
456     # Run LFS dynamic binary creation scripts one by one
457     lfsmake2 stage2
458     lfsmake2 makedev
459     lfsmake2 linux
460     lfsmake2 man-pages
461     lfsmake2 glibc
462     lfsmake2 binutils
463     lfsmake2 gcc
464     lfsmake2 coreutils
465     lfsmake2 zlib
466     lfsmake2 mktemp
467     lfsmake2 iana-etc
468     lfsmake2 findutils
469     lfsmake2 gawk
470     lfsmake2 ncurses
471     lfsmake2 vim
472     lfsmake2 m4
473     lfsmake2 bison
474     lfsmake2 less
475     lfsmake2 groff
476     lfsmake2 sed
477     lfsmake2 flex
478     lfsmake2 gettext
479     lfsmake2 net-tools
480     lfsmake2 inetutils
481     lfsmake2 perl
482     lfsmake2 texinfo
483     lfsmake2 autoconf
484     lfsmake2 automake
485     lfsmake2 bash
486     lfsmake2 file
487     lfsmake2 libtool
488     lfsmake2 bzip2
489     lfsmake2 diffutils
490     lfsmake2 ed
491     lfsmake2 kbd
492     lfsmake2 e2fsprogs
493     lfsmake2 grep
494     if [ 'i386' = $MACHINE ]; then 
495         lfsmake2 grub
496     elif [ 'alpha' = $MACHINE ]; then 
497         lfsmake2 aboot
498     fi
499     lfsmake2 gzip
500     lfsmake2 man
501     lfsmake2 make
502     lfsmake2 modutils
503     lfsmake2 patch
504     lfsmake2 procinfo
505     lfsmake2 procps
506     lfsmake2 psmisc
507     lfsmake2 shadow
508     lfsmake2 sysklogd
509     lfsmake2 sysvinit
510     lfsmake2 tar
511     lfsmake2 util-linux
512 }
513
514 buildipcop() {
515   # Run IPFire make scripts one by one
516   LOGFILE="$BASEDIR/log/_build.ipfire.log"
517   export LOGFILE
518   echo -ne "`date -u '+%b %e %T'`: Stage3 $NAME build \n" | tee -a $LOGFILE
519
520   # Build these first as some of the kernel packages below rely on 
521   # these for some of their client program functionality 
522   ipcopmake configroot
523   ipcopmake dhcp
524   ipcopmake dhcpcd
525   ipcopmake libusb
526   ipcopmake libpcap
527   ipcopmake linux-atm
528   ipcopmake ppp
529   ipcopmake rp-pppoe
530   ipcopmake unzip
531   # Do SMP now
532   if [ 'i386' = $MACHINE ]; then 
533         # abuse the SMP flag, and make an minimal installer kernel first
534         # so that the boot floppy always works.....
535         ipcopmake linux         LFS_PASS=ipfire SMP=installer
536         ipcopmake linux         LFS_PASS=ipfire SMP=1
537         ipcopmake 3cp4218       SMP=1
538         ipcopmake amedyn        SMP=1
539         ipcopmake cxacru        SMP=1
540         ipcopmake eagle         SMP=1
541
542         # These are here because they have i386 only binary libraries
543         # included in the package.
544         ipcopmake cnx_pci       SMP=1
545         ipcopmake fcdsl         SMP=1
546         ipcopmake fcdsl2        SMP=1
547         ipcopmake fcdslsl       SMP=1
548         ipcopmake fcdslusb      SMP=1
549         ipcopmake fcdslslusb    SMP=1
550         ipcopmake fcpci SMP=1
551         ipcopmake fcclassic     SMP=1
552         ipcopmake pulsar        SMP=1
553         ipcopmake unicorn       SMP=1
554   fi
555
556   ipcopmake linux       LFS_PASS=ipfire
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 fcpci
573         ipcopmake fcclassic
574         ipcopmake pulsar        
575         ipcopmake unicorn       
576   fi
577
578   ipcopmake pcmcia-cs
579   ipcopmake expat
580   ipcopmake gdbm
581   ipcopmake gmp
582   ipcopmake openssl
583   ipcopmake python
584   ipcopmake libnet
585   ipcopmake libpng
586   ipcopmake gd
587   ipcopmake popt
588   ipcopmake slang
589   ipcopmake newt
590   ipcopmake libcap
591   ipcopmake pciutils
592   ipcopmake pcre
593   ipcopmake apache
594   ipcopmake arping
595   ipcopmake beep
596   ipcopmake bind
597   ipcopmake capi4k-utils
598   ipcopmake cdrtools
599   ipcopmake dnsmasq
600   ipcopmake dosfstools
601   ipcopmake ethtool
602   ipcopmake ez-ipupdate
603   ipcopmake fcron
604   ipcopmake perl-GD
605   ipcopmake gnupg
606   ipcopmake hdparm
607   ipcopmake ibod
608   ipcopmake initscripts
609   ipcopmake iptables
610   ipcopmake ipac-ng
611   ipcopmake ipaddr
612   ipcopmake iproute2
613   ipcopmake iptstate
614   ipcopmake iputils
615   ipcopmake l7-protocols
616   ipcopmake isapnptools
617   ipcopmake isdn4k-utils
618   ipcopmake kudzu
619   ipcopmake logrotate
620   ipcopmake logwatch
621   ipcopmake mingetty
622   ipcopmake misc-progs
623   ipcopmake mtools
624   ipcopmake nano
625   ipcopmake nash
626   ipcopmake nasm
627   ipcopmake URI
628   ipcopmake HTML-Tagset
629   ipcopmake HTML-Parser
630   ipcopmake Compress-Zlib
631   ipcopmake Digest
632   ipcopmake Digest-SHA1
633   ipcopmake Digest-HMAC
634   ipcopmake libwww-perl
635   ipcopmake Net-DNS
636   ipcopmake Net-IPv4Addr
637   ipcopmake Net_SSLeay
638   ipcopmake IO-Stringy
639   ipcopmake Unix-Syslog
640   ipcopmake Mail-Tools
641   ipcopmake MIME-Tools
642   ipcopmake Net-Server
643   ipcopmake Convert-TNEF
644   ipcopmake Convert-UUlib
645   ipcopmake Archive-Tar
646   ipcopmake Archive-Zip
647   ipcopmake Text-Tabs+Wrap
648   ipcopmake Locale-Country
649   ipcopmake GeoIP
650   ipcopmake fwhits
651   ipcopmake berkeley
652   ipcopmake BerkeleyDB ## The Perl module
653   ipcopmake noip_updater
654   ipcopmake ntp
655   ipcopmake oinkmaster
656   ipcopmake openssh
657   ipcopmake openswan
658   ipcopmake pptpclient
659   ipcopmake rrdtool
660   ipcopmake setserial
661   ipcopmake setup
662   ipcopmake snort
663   #ipcopmake speedycgi
664   ipcopmake saslauthd PASS=1
665   ipcopmake openldap
666   ipcopmake squid
667   ipcopmake squid-graph
668   ipcopmake squidguard
669   ipcopmake tcpdump
670   ipcopmake traceroute
671   ipcopmake vlan
672   #ipcopmake wireless
673   ipcopmake libsafe
674   ipcopmake 3c5x9setup
675 #  echo -ne "`date -u '+%b %e %T'`: Building ### IPFire modules ### \n" | tee -a $LOGFILE
676   ipcopmake pakfire
677   ipcopmake startscripts
678 ## Zuerst die Libs und dann die Programme. Ordnung muss sein!
679   ipcopmake java
680   ipcopmake libtiff
681   ipcopmake libjpeg
682   ipcopmake libxml2
683   ipcopmake spandsp
684   ipcopmake lzo
685   ipcopmake openvpn
686   ipcopmake pkg-config
687   ipcopmake glib
688   ipcopmake xampp
689   ipcopmake pam
690   ipcopmake pammysql
691   ipcopmake saslauthd PASS=2
692   ipcopmake xinetd
693   ipcopmake ghostscript
694   ipcopmake cups
695 #  ipcopmake lpd ## Im Moment aus, da CUPS vorhanden ist.
696   ipcopmake samba
697   ipcopmake sudo
698   ipcopmake mc
699   ipcopmake pwlib
700   ipcopmake openh323
701   ipcopmake wget
702   ipcopmake wput
703   ipcopmake bridge-utils
704   ipcopmake screen
705   ipcopmake hddtemp
706   ipcopmake htop
707   ipcopmake lynx
708   echo -ne "`date -u '+%b %e %T'`: Building ### Mailserver ### \n" | tee -a $LOGFILE
709   ipcopmake postfix
710   ipcopmake procmail
711   ipcopmake fetchmail
712   ipcopmake cyrusimap
713   ipcopmake web-cyradm
714   ipcopmake mailx
715   ipcopmake clamav
716   ipcopmake razor
717   ipcopmake spamassassin
718 #  ipcopmake amavisd
719   echo -ne "`date -u '+%b %e %T'`: Building ### VoIP-Server ### \n" | tee -a $LOGFILE
720   ipcopmake stund
721   ipcopmake asterisk
722   ipcopmake mpg123
723   echo -ne "`date -u '+%b %e %T'`: Building ### MP3-Server ### \n" | tee -a $LOGFILE
724   ipcopmake lame
725   ipcopmake gnump3d
726   echo -ne "`date -u '+%b %e %T'`: Building ### P2P-Clients ### \n" | tee -a $LOGFILE
727   ipcopmake applejuice
728   ipcopmake edonkeyclc
729 #  ipcopmake sane
730   echo -ne "`date -u '+%b %e %T'`: Building ### Net-Tools ### \n" | tee -a $LOGFILE
731   ipcopmake ntop
732 #  ipcopmake rsync
733   ipcopmake tcpwrapper
734   ipcopmake portmap
735   ipcopmake nfs
736   ipcopmake nmap
737   ipcopmake iftop
738   ipcopmake ncftp
739   ipcopmake cftp
740   ipcopmake etherwake
741   ipcopmake ethereal
742 #  ipcopmake stunnel # Ausgeschaltet, weil wir es doch nicht nutzen
743 }
744
745 buildinstaller() {
746   # Run installer scripts one by one
747   LOGFILE="$BASEDIR/log/_build.installer.log"
748   export LOGFILE
749   echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" | tee -a $LOGFILE
750   if [ 'i386' = $MACHINE ]; then 
751         ipcopmake syslinux
752         ipcopmake as86
753         ipcopmake mbr
754         ipcopmake uClibc
755   fi
756   installmake busybox
757   installmake sysvinit
758   installmake e2fsprogs
759   installmake misc-progs
760   installmake slang
761   installmake util-linux
762   installmake newt
763   installmake pciutils
764   installmake pcmcia-cs
765   installmake kbd
766   installmake installer
767   installmake scsi.img
768   installmake driver.img
769   installmake initrd
770   installmake boot.img
771 }
772
773 buildpackages() {
774   LOGFILE="$BASEDIR/log/_build.packages.log"
775   export LOGFILE
776   echo "... see detailed log in _build.*.log files" >> $LOGFILE
777   echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" | tee -a $LOGFILE
778   # Strip files
779   echo "`date -u '+%b %e %T'`: Stripping files" | tee -a $LOGFILE
780   find $LFS/lib $LFS/usr/lib $LFS/usr/share/rrdtool-* $LFS/install ! -type l \( -name '*.so' -o -name '*.so[\.0-9]*' \) \
781         ! -name 'libc.so' ! -name 'libpthread.so' ! -name 'libcrypto.so.0.9.7.sha1' \
782          -exec $LFS/tools/bin/strip --strip-all {} \; >> $LOGFILE 2>&1
783   # add -ls before -exec if you want to verify what files are stripped
784
785   find $LFS/{,s}bin $LFS/usr/{,s}bin $LFS/usr/local/{,s}bin ! -type l \
786         -exec file {} \; | grep " ELF " | cut -f1 -d ':' | xargs $LFS/tools/bin/strip --strip-all >> $LOGFILE 2>&1
787   # there add -v to strip to verify
788
789   if [ 'i386' = $MACHINE ]; then
790         # Create fcdsl packages
791         echo "`date -u '+%b %e %T'`: Building fcdsl tgz" | tee -a $LOGFILE
792         cp $LFS/install/images/fcdsl/license.txt $LFS  >> $LOGFILE 2>&1
793         touch $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
794         cd $LFS && tar cvfz $LFS/install/images/$SNAME-fcdsl-$VERSION.$MACHINE.tgz \
795                 lib/modules/$KVER/misc/fcdsl*.o.gz \
796                 lib/modules/$KVER-smp/misc/fcdsl*.o.gz \
797                 usr/lib/isdn/{fds?base.bin,fd?ubase.frm} \
798                 etc/fcdsl/fcdsl*.conf \
799                 etc/drdsl/{drdsl,drdsl.ini} \
800                 license.txt \
801                 var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} >> $LOGFILE 2>&1
802         rm -f $LFS/license.txt >> $LOGFILE 2>&1
803         cd $BASEDIR
804   fi
805   
806   # Generating list of packages used
807   echo "`date -u '+%b %e %T'`: Generating packages list from logs" | tee -a $LOGFILE
808   rm -f $BASEDIR/doc/packages-list
809   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
810         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
811                 echo "  * `basename $i`" >>$BASEDIR/doc/packages-list
812         fi
813   done
814   echo "====== List of softwares used to build $NAME Version: $VERSION ======" > $BASEDIR/doc/packages-list.txt
815   grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|ipcop$\|setup$\|pakfire$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \
816         $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
817   rm -f $BASEDIR/doc/packages-list
818   # packages-list.txt is ready to be displayed for wiki page
819
820   # Create ISO for CDRom and USB-superfloppy
821   ipcopmake cdrom
822   rm -f $LFS/install/images/*usb*
823   cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1
824
825   ipfirepackages
826
827   # Cleanup
828   stdumount
829   rm -rf $BASEDIR/build/tmp/*
830
831   # Generating total list of files
832   echo "`date -u '+%b %e %T'`: Generating files list from logs" | tee -a $LOGFILE
833   rm -f $BASEDIR/log/FILES
834   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
835         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
836                 echo "##" >>$BASEDIR/log/FILES
837                 echo "## `basename $i`" >>$BASEDIR/log/FILES
838                 echo "##" >>$BASEDIR/log/FILES
839                 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
840         fi
841   done
842
843   cd $PWD
844
845 }
846
847 ipfirepackages() {
848   for i in `ls $BASEDIR/packages`; do
849         touch $BASEDIR/build/install/packages/$i.empty
850   done
851   ipfiredist amavisd
852   ipfiredist applejuice
853   ipfiredist asterisk
854   ipfiredist clamav
855   ipfiredist cups
856   ipfiredist cyrusimap
857   ipfiredist fetchmail
858   ipfiredist gnump3d
859   ipfiredist java
860   ipfiredist lame
861   ipfiredist libtiff
862   ipfiredist libxml2
863   ipfiredist mailx
864   ipfiredist nfs
865   ipfiredist nmap
866   ipfiredist ntop
867   ipfiredist postfix
868   ipfiredist procmail
869   ipfiredist samba
870   ipfiredist spamassassin
871   ipfiredist web-cyradm
872   ipfiredist xampp
873   ipfiredist xinetd
874   test -d $BASEDIR/packages || mkdir $BASEDIR/packages
875   mv -f $LFS/install/packages/*.{tar.gz,md5} $BASEDIR/packages >> $LOGFILE 2>&1
876   rm -rf  $BASEDIR/build/install/packages/*
877 }
878
879 # See what we're supposed to do
880 case "$1" in 
881 build)
882         BUILDMACHINE=`uname -m`
883         PACKAGE=`ls -v -r $BASEDIR/cache/$SNAME-1.4-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
884         #only restore on a clean disk
885         if [ ! -f log/perl-*-tools ]; then
886                 if [ ! -n "$PACKAGE" ]; then
887                         echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE
888                         prepareenv
889                         buildtoolchain
890                 else
891                         PACKAGENAME=${PACKAGE%.tar.gz}
892                         echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" | tee -a $LOGFILE
893                         if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
894                                 tar zxf $PACKAGE
895                                 prepareenv
896                         else
897                                 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
898                         fi
899                 fi
900         else
901                 echo "`date -u '+%b %e %T'`: Using installed toolchain" | tee -a $LOGFILE
902                 prepareenv
903         fi
904
905         buildbase
906         buildipcop
907
908         # Setzen des IPFire Builds
909         if [ $FIREBUILD ]; then
910                 echo "$FIREBUILD" > $CONFIG_ROOT/firebuild
911         else
912                 echo "_(OvO)_" > $CONFIG_ROOT/firebuild
913         fi
914
915         buildinstaller
916         buildpackages
917         ;;
918 shell)
919         # enter a shell inside LFS chroot
920         # may be used to changed kernel settings
921         prepareenv
922         entershell
923         ;;
924 changelog)
925         echo -n "Loading new Changelog from SVN: "
926         svn log http://svn.ipfire.eu/svn/ipfire > doc/ChangeLog
927         echo "Finished!"
928         ;;
929 check)
930         echo "Checking sources files availability on the web"
931         if [ ! -d $DIR_CHK ]; then
932                 mkdir -p $DIR_CHK
933         fi
934         FINISHED=0
935         cd $BASEDIR/lfs
936         for c in `seq $MAX_RETRIES`; do
937                 if (( FINISHED==1 )); then
938                         break
939                 fi
940                 FINISHED=1
941                 cd $BASEDIR/lfs
942                 for i in *; do
943                         if [ -f "$i" -a "$i" != "Config" ]; then
944                                 make -s -f $i MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR ROOT=$BASEDIR/build \
945                                         MESSAGE="$i\t ($c/$MAX_RETRIES)" check
946                                 if [ $? -ne 0 ]; then
947                                         echo "Check : wget error in lfs/$i"
948                                         FINISHED=0
949                                 fi
950                         fi
951                 done
952         done
953         cd -
954         ;;
955 checkclean)
956         echo "Erasing sources files availability tags"
957         rm -rf $DIR_CHK/*
958         ;;
959 clean)
960         for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
961                 $LOSETUP -d $i 2>/dev/null
962         done
963         for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
964                 umount $i
965         done
966         stdumount
967         for i in `seq 0 7`; do
968             if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
969                 umount /dev/loop${i}     2>/dev/null;
970                 losetup -d /dev/loop${i} 2>/dev/null;
971             fi;
972         done
973         rm -rf $BASEDIR/build
974         rm -rf $BASEDIR/cdrom
975         rm -rf $BASEDIR/packages
976         rm -rf $BASEDIR/log
977         if [ -h /tools ]; then
978                 rm -f /tools
979         fi
980         ;;
981 dist)
982         echo -ne "Updating & building source package from SVN: "
983         svn up > /dev/null
984         svn export http://svn.ipfire.eu/svn/ipfire ipfire-source/ --force > /dev/null
985         tar cfz ipfire-source-`date +'%Y-%m-%d'`-r`svn info | grep Revision | cut -c 11-`.tar.gz ipfire-source
986         rm ipfire-source/ -r
987         echo "Finished!"
988         ;;
989 newpak)
990         # create structure for a new package
991         echo -e "Name of the new package: $2"
992         if [ ! -f "lfs/$2" ]; then
993                 echo "`date -u '+%b %e %T'`: Creating directory src/paks/$2"
994                 mkdir -p src/paks/$2
995                 cd src/paks/$2
996                 echo "`date -u '+%b %e %T'`: Creating files"
997                 cp $BASEDIR/lfs/postfix $BASEDIR/lfs/$2
998
999                 touch ROOTFILES
1000                 touch {,un}install.sh
1001         ## install.sh
1002                 echo '#!/bin/bash' > install.sh
1003                 echo '#' >> install.sh
1004                 echo '#################################################################' >> install.sh
1005                 echo '#                                                               #' >> install.sh
1006                 echo '# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #' >> install.sh
1007                 echo '#                                                               #' >> install.sh
1008                 echo '#################################################################' >> install.sh
1009                 echo '#' >> install.sh
1010                 echo '# Extract the files' >> install.sh
1011                 echo 'tar xfz files.tgz -C /' >> install.sh
1012                 echo 'cp -f ROOTFILES /opt/pakfire/installed/ROOTFILES.$2' >> install.sh
1013         ## uninstall.sh
1014                 echo '#!/bin/bash' > uninstall.sh
1015                 echo '#################################################################' >> uninstall.sh
1016                 echo '#                                                               #' >> uninstall.sh
1017                 echo '# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #' >> uninstall.sh
1018                 echo '#                                                               #' >> uninstall.sh
1019                 echo '#################################################################' >> uninstall.sh
1020                 echo '#' >> uninstall.sh
1021                 echo '# Delete the files' >> uninstall.sh
1022                 echo '## Befehl fehlt noch' >> uninstall.sh
1023                 echo 'rm -f /opt/pakfire/installed/ROOTFILES.$2' >> uninstall.sh
1024                 echo "`date -u '+%b %e %T'`: Adding files to SVN"
1025                 cd - && svn add lfs/$2 && svn add src/paks/$2
1026
1027                 echo -n "Do you want to remove the folders? [y/n]"
1028                 read REM
1029                 if  [ "$REM" == "y" ]; then
1030                         echo "Removing the folders..."
1031                         svn del src/paks/$2 --force
1032                 else
1033                         echo "Folders are kept."
1034                 fi
1035         else
1036                 echo "$2 already exists"
1037         fi
1038         exit 0
1039         ;;
1040 prefetch)
1041         if [ ! -d $BASEDIR/cache ]; then
1042                 mkdir $BASEDIR/cache
1043         fi
1044         mkdir -p $BASEDIR/log
1045         echo "`date -u '+%b %e %T'`:Preload all source files" | tee -a $LOGFILE
1046         FINISHED=0
1047         cd $BASEDIR/lfs
1048         for c in `seq $MAX_RETRIES`; do
1049                 if (( FINISHED==1 )); then 
1050                         break
1051                 fi
1052                 FINISHED=1
1053                 cd $BASEDIR/lfs
1054                 for i in *; do
1055                         if [ -f "$i" -a "$i" != "Config" ]; then
1056                                 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
1057                                 if [ $? -ne 0 ]; then
1058                                         echo "Prefetch : wget error in lfs/$i"
1059                                         FINISHED=0
1060                                 else
1061                                         if [ $c -eq 1 ]; then
1062                                                 echo "Prefetch : lfs/$i files loaded"
1063                                         fi
1064                                 fi
1065                         fi
1066                 done
1067         done
1068         echo "Prefetch : verifying md5sum"
1069         ERROR=0
1070         for i in *; do
1071                 if [ -f "$i" -a "$i" != "Config" ]; then
1072                         make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
1073                         if [ $? -ne 0 ]; then
1074                                 echo "md5 difference in lfs/$i"
1075                                 ERROR=1
1076                         fi
1077                 fi
1078         done
1079         if [ $ERROR -eq 0 ]; then
1080                 echo "Prefetch : all files md5sum match"
1081         fi
1082         cd -
1083         ;;
1084 toolchain)
1085         prepareenv
1086         buildtoolchain
1087         BUILDMACHINE=`uname -m`
1088         echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1089         cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1090                 build/{bin,etc,usr/bin,usr/local} \
1091                 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
1092                 log >> $LOGFILE
1093         md5sum cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1094                 > cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.md5
1095         stdumount
1096         ;;
1097 gettoolchain)
1098         BUILDMACHINE=`uname -m`
1099         # arbitrary name to be updated in case of new toolchain package upload
1100         PACKAGE=$SNAME-1.4-toolchain-$BUILDMACHINE
1101         URL_IPFIRE=`grep URL_IPFIRE lfs/Config | awk '{ print $3 }'`
1102         echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1103         cd $BASEDIR/cache
1104         wget $URL_IPFIRE/toolchains/$PACKAGE.tar.gz $URL_IPFIRE/toolchains/$PACKAGE.md5 >& /dev/null
1105         if [ $? -ne 0 ]; then
1106                 echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
1107 #       else
1108 #               if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1109 #                       echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1110 #                       echo "`date -u '+%b %e %T'`: Uncompressing toolchain" | tee -a $LOGFILE
1111 #                       cd $BASEDIR && tar xfz cache/$PACKAGE.tar.gz -C .
1112 #                       rm -f $BASEDIR/cache/$PACKAGE.{tar.gz,md5}
1113 #               else
1114 #                       exiterror "$PACKAGE.md5 did not match, check downloaded package"
1115 #               fi
1116         fi
1117         ;;
1118 paks)
1119         prepareenv
1120         # buildpackages
1121         ipfirepackages
1122         ;;
1123 update)
1124         echo "Load the latest source-files:"
1125         svn update
1126         ;;
1127 commit)
1128         echo "Upload the changed files:"
1129         svn commit
1130         ./make.sh sync
1131         svn up > /dev/null
1132         ;;
1133 make)
1134         echo "Do a complete compile:"   
1135         ./make.sh prefetch && ./make.sh gettoolchain && ./make.sh build
1136         ;;
1137 diff)
1138         echo -ne "Make a local diff to last SVN revision: "
1139         svn diff > ipfire-diff-`date +'%Y-%m-%d-%H:%M'`-r`svn info | grep Revision | cut -c 11-`.diff
1140         echo "Finished!"
1141         echo "Diff was successfully saved to ipfire-diff-`date +'%Y-%m-%d-%H:%M'`-r`svn info | grep Revision | cut -c 11-`.diff"
1142         ;;
1143 sync)
1144         echo -e "Syncing Cache to FTP:"
1145         if [ -f .pass ]; then
1146                 PASS="`cat .pass`"
1147         else
1148                 echo -ne "Password for mirror.ipfire.org: "; read PASS
1149         fi
1150         rm -f doc/packages-to-remove-from-ftp
1151         ncftpls -u web3 -p $PASS ftp://mirror.ipfire.org/html/source-packages/source/ > ftplist
1152         for i in `ls -w1 cache/`; do
1153                 grep $i ftplist
1154                 if [ "$?" -ne "0" ]; then
1155                         ncftpput -u web3 -p $PASS mirror.ipfire.org /html/source-packages/source cache/$i
1156                         if [ "$?" -eq "0" ]; then
1157                                 echo -e "$i was successfully uploaded to the ftp server."
1158                         else
1159                                 echo -e "There was an error while uploading $i to the ftp server."
1160                         fi
1161                 fi
1162         done
1163         for i in `cat ftplist`; do
1164                 ls -w1 cache/ | grep $i
1165                 if [ "$?" -eq "1" ]; then
1166                         echo $i | grep -v toolchain >> doc/packages-to-remove-from-ftp
1167                 fi
1168         done
1169         rm -f ftplist
1170         ;;
1171 pub-iso)
1172         echo -e "Upload the ISO to the beta-mirror!"
1173         if [ -f .pass ]; then
1174                 PASS="`cat .pass`"
1175         else
1176                 echo -ne "Password for mirror.ipfire.org: "; read PASS
1177         fi
1178         ncftpls -u web3 -p $PASS ftp://mirror.ipfire.org/html/source-packages/beta/ | grep `svn info | grep Revision | cut -c 11-`
1179         if [ "$?" -eq "1" ]; then
1180                         cp $BASEDIR/ipfire-install-1.4.i386.iso $BASEDIR/ipfire-install-1.4.i386-r`svn info | grep Revision | cut -c 11-`.iso
1181                         md5sum ipfire-install-1.4.i386-r`svn info | grep Revision | cut -c 11-`.iso > ipfire-install-1.4.i386-r`svn info | grep Revision | cut -c 11-`.iso.md5
1182                         ncftpput -u web3 -p $PASS mirror.ipfire.org /html/source-packages/beta/ ipfire-install-1.4.i386-r`svn info | grep Revision | cut -c 11-`.iso
1183                         ncftpput -u web3 -p $PASS mirror.ipfire.org /html/source-packages/beta/ ipfire-install-1.4.i386-r`svn info | grep Revision | cut -c 11-`.iso.md5
1184                         if [ "$?" -eq "0" ]; then
1185                                 echo -e "The ISO of Revision `svn info | grep Revision | cut -c 11-` was successfully uploaded to the ftp server."
1186                         else
1187                                 echo -e "There was an error while uploading the ISO to the ftp server."
1188                         fi
1189         else
1190                 echo -e "File with name ipfire-install-1.4.i386-r`svn info | grep Revision | cut -c 11-`.iso already exists on the ftp server!"
1191         fi
1192         rm -f ipfire-install-1.4.i386-r`svn info | grep Revision | cut -c 11-`.iso{,.md5}
1193         ;;
1194 pub-paks)
1195         echo -e "Upload the packages to the beta-mirror!"
1196         if [ -f .pass ]; then
1197                 PASS="`cat .pass`"
1198         else
1199                 echo -ne "Password for mirror.ipfire.org: "; read PASS
1200         fi
1201         ncftpput -z -u web3 -p $PASS mirror.ipfire.org /html/source-packages/packages/ packages/*
1202         if [ "$?" -eq "0" ]; then
1203                 echo -e "The packages were successfully uploaded to the ftp server."
1204         else
1205                 echo -e "There was an error while uploading the packages to the ftp server."
1206         fi
1207         ;;
1208 *)
1209         echo "Usage: $0 {build|changelog|check|checkclean|clean|commit|diff|dist|gettoolchain|make|newpak|prefetch|pub-iso|pub-paks|shell|sync|toolchain|update}"
1210         cat doc/make.sh-usage
1211         exit 1
1212         ;;
1213 esac