PAM-MySQL + BerkeleyDB + SASLauthd hinzugefuegt
[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 save 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
343 installmake() {
344         if [ -f $BASEDIR/build/usr/src/lfs/$1 ]; then
345                 echo "`date -u '+%b %e %T'`: Building $*" | tee -a $LOGFILE
346                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download  >> $LOGFILE 2>&1
347                 if [ $? -ne 0 ]; then
348                         exiterror "Download error in $1"
349                 fi
350                 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MESSAGE="$1\t md5sum" md5  >> $LOGFILE 2>&1
351                 if [ $? -ne 0 ]; then
352                         exiterror "md5sum error in $1, check file in cache or signature"
353                 fi
354                 chroot $LFS /tools/bin/env -i   HOME=/root \
355                                                 TERM=$TERM PS1='\u:\w\$ ' \
356                                                 PATH=/usr/local/bin:/opt/$MACHINE-uClibc/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin \
357                                                 VERSION=$VERSION \
358                                                 CONFIG_ROOT=$CONFIG_ROOT \
359                                                 LFS_PASS="install" \
360                                                 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
361                                                 CFLAGS="-Os" CXXFLAGS="-Os" \
362                                                 CCACHE_DIR=/usr/src/ccache CCACHE_HASHDIR=1 \
363                                                 KVER=$KVER \
364                                                 BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
365                     /bin/bash -x -c "cd /usr/src/lfs && \
366                     make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
367                 if [ $? -ne 0 ]; then
368                         exiterror "Building $*"
369                 fi
370         else
371                 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
372         fi
373         return 0
374 }
375
376 buildtoolchain() {
377     LOGFILE="$BASEDIR/log/_build.toolchain.log"
378     export LOGFILE
379     echo -ne "`date -u '+%b %e %T'`: Stage1 toolchain build \n" | tee -a $LOGFILE
380     # Build sed now, as we use some extensions
381     ORG_PATH=$PATH
382     NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}`
383     export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
384     lfsmake1 ccache
385     lfsmake1 sed        LFS_PASS=1
386     lfsmake1 m4         LFS_PASS=1
387     lfsmake1 bison      LFS_PASS=1
388     lfsmake1 flex       LFS_PASS=1
389     lfsmake1 binutils   LFS_PASS=1
390     lfsmake1 gcc        LFS_PASS=1
391     export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
392     
393     lfsmake1 linux
394     lfsmake1 tcl
395     lfsmake1 expect
396     lfsmake1 glibc
397     lfsmake1 dejagnu
398     lfsmake1 gcc        LFS_PASS=2
399     lfsmake1 binutils   LFS_PASS=2
400     lfsmake1 gawk
401     lfsmake1 coreutils
402     lfsmake1 bzip2
403     lfsmake1 gzip
404     lfsmake1 diffutils
405     lfsmake1 findutils
406     lfsmake1 make
407     lfsmake1 grep
408     lfsmake1 sed        LFS_PASS=2
409     lfsmake1 m4         LFS_PASS=2
410     lfsmake1 bison      LFS_PASS=2
411     lfsmake1 flex       LFS_PASS=2
412     lfsmake1 gettext
413     lfsmake1 ncurses
414     lfsmake1 patch
415     lfsmake1 tar
416     lfsmake1 texinfo
417     lfsmake1 bash
418     lfsmake1 util-linux
419     lfsmake1 perl
420     export PATH=$ORG_PATH
421 }
422
423 buildbase() {
424     LOGFILE="$BASEDIR/log/_build.base.log"
425     export LOGFILE
426     echo -ne "`date -u '+%b %e %T'`: Stage2 linux base build \n" | tee -a $LOGFILE
427     # Run LFS dynamic binary creation scripts one by one
428     lfsmake2 stage2
429     lfsmake2 makedev
430     lfsmake2 linux
431     lfsmake2 man-pages
432     lfsmake2 glibc
433     lfsmake2 binutils
434     lfsmake2 gcc
435     lfsmake2 coreutils
436     lfsmake2 zlib
437     lfsmake2 mktemp
438     lfsmake2 iana-etc
439     lfsmake2 findutils
440     lfsmake2 gawk
441     lfsmake2 ncurses
442     lfsmake2 vim
443     lfsmake2 m4
444     lfsmake2 bison
445     lfsmake2 less
446     lfsmake2 groff
447     lfsmake2 sed
448     lfsmake2 flex
449     lfsmake2 gettext
450     lfsmake2 net-tools
451     lfsmake2 inetutils
452     lfsmake2 perl
453     lfsmake2 texinfo
454     lfsmake2 autoconf
455     lfsmake2 automake
456     lfsmake2 bash
457     lfsmake2 file
458     lfsmake2 libtool
459     lfsmake2 bzip2
460     lfsmake2 diffutils
461     lfsmake2 ed
462     lfsmake2 kbd
463     lfsmake2 e2fsprogs
464     lfsmake2 grep
465     if [ 'i386' = $MACHINE ]; then 
466         lfsmake2 grub
467     elif [ 'alpha' = $MACHINE ]; then 
468         lfsmake2 aboot
469     fi
470     lfsmake2 gzip
471     lfsmake2 man
472     lfsmake2 make
473     lfsmake2 modutils
474     lfsmake2 patch
475     lfsmake2 procinfo
476     lfsmake2 procps
477     lfsmake2 psmisc
478     lfsmake2 shadow
479     lfsmake2 sysklogd
480     lfsmake2 sysvinit
481     lfsmake2 tar
482     lfsmake2 util-linux
483 }
484
485 buildipcop() {
486   # Run IPCop make scripts one by one
487   LOGFILE="$BASEDIR/log/_build.ipcop.log"
488   export LOGFILE
489   echo -ne "`date -u '+%b %e %T'`: Stage3 $NAME build \n" | tee -a $LOGFILE
490
491   # Build these first as some of the kernel packages below rely on 
492   # these for some of their client program functionality 
493   ipcopmake configroot
494   ipcopmake dhcp
495   ipcopmake dhcpcd
496   ipcopmake libusb
497   ipcopmake libpcap
498   ipcopmake linux-atm
499   ipcopmake ppp
500   ipcopmake rp-pppoe
501   ipcopmake unzip
502   # Do SMP now
503   if [ 'i386' = $MACHINE ]; then 
504         # abuse the SMP flag, and make an minimal installer kernel first
505         # so that the boot floppy always works.....
506         ipcopmake linux         LFS_PASS=ipcop SMP=installer
507         ipcopmake linux         LFS_PASS=ipcop SMP=1
508         ipcopmake 3cp4218       SMP=1
509         ipcopmake amedyn        SMP=1
510         ipcopmake cxacru        SMP=1
511         ipcopmake eagle         SMP=1
512
513         # These are here because they have i386 only binary libraries
514         # included in the package.
515         ipcopmake cnx_pci       SMP=1
516         ipcopmake fcdsl         SMP=1
517         ipcopmake fcdsl2        SMP=1
518         ipcopmake fcdslsl       SMP=1
519         ipcopmake fcdslusb      SMP=1
520         ipcopmake fcdslslusb    SMP=1
521         ipcopmake pulsar        SMP=1
522         ipcopmake unicorn       SMP=1
523   fi
524
525   ipcopmake linux       LFS_PASS=ipcop
526   ipcopmake 3cp4218     
527   ipcopmake amedyn      
528   ipcopmake cxacru      
529   ipcopmake eciadsl     
530   ipcopmake eagle       
531   ipcopmake speedtouch  
532   if [ 'i386' = $MACHINE ]; then 
533         # These are here because they have i386 only binary libraries
534         # included in the package.
535         ipcopmake cnx_pci       
536         ipcopmake fcdsl         
537         ipcopmake fcdsl2        
538         ipcopmake fcdslsl       
539         ipcopmake fcdslusb      
540         ipcopmake fcdslslusb    
541         ipcopmake pulsar        
542         ipcopmake unicorn       
543   fi
544
545   ipcopmake pcmcia-cs
546   ipcopmake expat
547   ipcopmake gdbm
548   ipcopmake gmp
549   ipcopmake openssl
550   ipcopmake python
551   ipcopmake libnet
552   ipcopmake libpng
553   ipcopmake gd
554   ipcopmake popt
555   ipcopmake slang
556   ipcopmake newt
557   ipcopmake libcap
558   ipcopmake pciutils
559   ipcopmake pcre
560   ipcopmake apache
561   ipcopmake arping
562   ipcopmake beep
563   ipcopmake bind
564   ipcopmake capi4k-utils
565   ipcopmake cdrtools
566   ipcopmake dnsmasq
567   ipcopmake dosfstools
568   ipcopmake ethtool
569   ipcopmake ez-ipupdate
570   ipcopmake fcron
571   ipcopmake perl-GD
572   ipcopmake gnupg
573   ipcopmake hdparm
574   ipcopmake ibod
575   ipcopmake initscripts
576   ipcopmake iptables
577   ipcopmake ipac-ng
578   ipcopmake ipaddr
579   ipcopmake iproute2
580   ipcopmake iptstate
581   ipcopmake iputils
582   ipcopmake isapnptools
583   ipcopmake isdn4k-utils
584   ipcopmake kudzu
585   ipcopmake logrotate
586   ipcopmake logwatch
587   ipcopmake mingetty
588   ipcopmake misc-progs
589   ipcopmake mtools
590   ipcopmake nano
591   ipcopmake nash
592   ipcopmake nasm
593   ipcopmake URI
594   ipcopmake HTML-Tagset
595   ipcopmake HTML-Parser
596   ipcopmake Compress-Zlib
597   ipcopmake Digest
598   ipcopmake Digest-SHA1
599   ipcopmake Digest-HMAC
600   ipcopmake libwww-perl
601   ipcopmake Net-DNS
602   ipcopmake Net-IPv4Addr
603   ipcopmake Net_SSLeay
604   ipcopmake noip_updater
605   ipcopmake ntp
606   ipcopmake oinkmaster
607   ipcopmake openssh
608   ipcopmake openswan
609   ipcopmake pptpclient
610   ipcopmake rrdtool
611   ipcopmake setserial
612   ipcopmake setup
613   ipcopmake snort
614   #ipcopmake speedycgi
615   ipcopmake squid
616   ipcopmake squid-graph
617   ipcopmake tcpdump
618   ipcopmake traceroute
619   ipcopmake vlan
620   ipcopmake wireless
621   ipcopmake libsafe
622   ipcopmake 3c5x9setup
623   echo -ne "`date -u '+%b %e %T'`: Building IPFire modules \n" | tee -a $LOGFILE
624   ipcopmake berkeley-DB
625   ipcopmake stund
626   ipcopmake lpd
627   ipcopmake xampp
628   ipcopmake pam
629   ipcopmake pammysql
630   ipcopmake pwlib
631   ipcopmake openh323
632   ipcopmake saslauthd
633 }
634
635 buildinstaller() {
636   # Run installer scripts one by one
637   LOGFILE="$BASEDIR/log/_build.installer.log"
638   export LOGFILE
639   echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" | tee -a $LOGFILE
640   if [ 'i386' = $MACHINE ]; then 
641         ipcopmake syslinux
642         ipcopmake as86
643         ipcopmake mbr
644         ipcopmake uClibc
645   fi
646   installmake busybox
647   installmake sysvinit
648   installmake e2fsprogs
649   installmake misc-progs
650   installmake slang
651   installmake util-linux
652   installmake newt
653   installmake pciutils
654   installmake pcmcia-cs
655   installmake kbd
656   installmake installer
657   installmake scsi.img
658   installmake driver.img
659   installmake initrd
660   installmake boot.img
661 }
662
663 buildpackages() {
664   LOGFILE="$BASEDIR/log/_build.packages.log"
665   export LOGFILE
666   echo "... see detailed log in _build.*.log files" >> $LOGFILE
667   echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" | tee -a $LOGFILE
668   # Strip files
669   echo "`date -u '+%b %e %T'`: Stripping files" | tee -a $LOGFILE
670   find $LFS/lib $LFS/usr/lib $LFS/usr/share/rrdtool-* $LFS/install ! -type l \( -name '*.so' -o -name '*.so[\.0-9]*' \) \
671         ! -name 'libc.so' ! -name 'libpthread.so' ! -name 'libcrypto.so.0.9.7.sha1' \
672         -exec $LFS/tools/bin/strip --strip-all {} \; >> $LOGFILE 2>&1
673   # add -ls before -exec if you want to verify what files are stripped
674
675   find $LFS/{,s}bin $LFS/usr/{,s}bin $LFS/usr/local/{,s}bin ! -type l \
676         -exec file {} \; | grep " ELF " | cut -f1 -d ':' | xargs $LFS/tools/bin/strip --strip-all >> $LOGFILE 2>&1
677   # there add -v to strip to verify
678
679   if [ 'i386' = $MACHINE ]; then
680         # Create fcdsl packages
681         echo "`date -u '+%b %e %T'`: Building fcdsl tgz" | tee -a $LOGFILE
682         cp $LFS/install/images/fcdsl/license.txt $LFS  >> $LOGFILE 2>&1
683         touch $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
684         cd $LFS && tar cvfz $LFS/install/images/$SNAME-fcdsl-$VERSION.$MACHINE.tgz \
685                 lib/modules/$KVER/misc/fcdsl*.o.gz \
686                 lib/modules/$KVER-smp/misc/fcdsl*.o.gz \
687                 usr/lib/isdn/{fds?base.bin,fd?ubase.frm} \
688                 etc/fcdsl/fcdsl*.conf \
689                 etc/drdsl/{drdsl,drdsl.ini} \
690                 license.txt \
691                 var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} >> $LOGFILE 2>&1
692         rm -f $LFS/license.txt >> $LOGFILE 2>&1
693         cd $BASEDIR
694   fi
695
696   # Create update for this version
697 #  echo "`date -u '+%b %e %T'`: Building update $VERSION tgz" | tee -a $LOGFILE
698 #  tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/$VERSION/ROOTFILES.$MACHINE-$VERSION -f $BASEDIR/updates/$VERSION/patch.tar.gz --exclude='#*'; 
699 #  chmod 755 $BASEDIR/updates/$VERSION/setup
700 #  tar -cz -C $BASEDIR/updates/$VERSION -f $LFS/install/images/$SNAME-update-$VERSION.$MACHINE.tgz patch.tar.gz setup information
701 #  rm -f $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
702   
703   # Generating list of packages used
704   echo "`date -u '+%b %e %T'`: Generating packages list from logs" | tee -a $LOGFILE
705   rm -f $BASEDIR/doc/packages-list
706   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
707         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
708                 echo "* `basename $i`" >>$BASEDIR/doc/packages-list
709         fi
710   done
711   echo "!!! List of softwares used to build $NAME Version:$VERSION" > $BASEDIR/doc/packages-list.txt
712   grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|ipcop$\|setup$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \
713         $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
714   rm -f $BASEDIR/doc/packages-list
715   # packages-list.txt is ready to be displayed for wiki page IPCopSoftwares
716
717   # Create ISO for CDRom and USB-superfloppy
718   ipcopmake cdrom
719   cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1
720
721   # Cleanup
722   stdumount
723   rm -rf $BASEDIR/build/tmp/*
724
725   # Generating total list of files
726   echo "`date -u '+%b %e %T'`: Generating files list from logs" | tee -a $LOGFILE
727   rm -f $BASEDIR/log/FILES
728   for i in `ls -1tr $BASEDIR/log/[^_]*`; do
729         if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
730                 echo "##" >>$BASEDIR/log/FILES
731                 echo "## `basename $i`" >>$BASEDIR/log/FILES
732                 echo "##" >>$BASEDIR/log/FILES
733                 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
734         fi
735   done
736
737   cd $PWD
738
739 }
740
741 # See what we're supposed to do
742 case "$1" in 
743 build)
744         BUILDMACHINE=`uname -m`
745         PACKAGE=`ls -v -r $BASEDIR/cache/$SNAME-1.4.*-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
746         #only restore on a clean disk
747         if [ ! -f log/perl-*-tools ]; then
748                 if [ ! -n "$PACKAGE" ]; then
749                         echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE
750                         prepareenv
751                         buildtoolchain
752                 else
753                         PACKAGENAME=${PACKAGE%.tar.gz}
754                         echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" | tee -a $LOGFILE
755                         if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
756                                 tar zxf $PACKAGE
757                                 prepareenv
758                         else
759                                 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
760                         fi
761                 fi
762         else
763                 echo "`date -u '+%b %e %T'`: Using installed toolchain" | tee -a $LOGFILE
764                 prepareenv
765         fi
766         buildbase
767         buildipcop
768         buildinstaller
769         buildpackages
770         ;;
771 shell)
772         # enter a shell inside LFS chroot
773         # may be used to changed kernel settings
774         prepareenv
775         entershell
776         ;;
777 changelog)
778         echo "Building doc/Changelog from CVS"
779         # cv2cl script come from http://www.red-bean.com/cvs2cl/
780         if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
781                 BRANCHOPTS=""
782         else
783                 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
784                 BRANCH=${BRANCH:1}
785                 BRANCHOPTS="--follow-only $BRANCH"
786         fi
787         
788         $BASEDIR/tools/cvs2cl.pl --gmt --show-dead $BRANCHOPTS -f $BASEDIR/doc/ChangeLog
789         rm -f $BASEDIR/doc/ChangeLog.bak
790         echo
791         echo "Commit the change now to update CVS"
792         ;;
793 check)
794         echo "Checking sources files availability on the web"
795         if [ ! -d $DIR_CHK ]; then
796                 mkdir -p $DIR_CHK
797         fi
798         FINISHED=0
799         cd $BASEDIR/lfs
800         for c in `seq $MAX_RETRIES`; do
801                 if (( FINISHED==1 )); then
802                         break
803                 fi
804                 FINISHED=1
805                 cd $BASEDIR/lfs
806                 for i in *; do
807                         if [ -f "$i" -a "$i" != "Config" ]; then
808                                 make -s -f $i MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR ROOT=$BASEDIR/build \
809                                         MESSAGE="$i\t ($c/$MAX_RETRIES)" check
810                                 if [ $? -ne 0 ]; then
811                                         echo "Check : wget error in lfs/$i"
812                                         FINISHED=0
813                                 fi
814                         fi
815                 done
816         done
817         cd -
818         ;;
819 checkclean)
820         echo "Erasing sources files availability tags"
821         rm -rf $DIR_CHK/*
822         ;;
823 clean)
824         for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
825                 $LOSETUP -d $i 2>/dev/null
826         done
827         for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
828                 umount $i
829         done
830         stdumount
831         for i in `seq 0 7`; do
832             if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
833                 umount /dev/loop${i}     2>/dev/null;
834                 losetup -d /dev/loop${i} 2>/dev/null;
835             fi;
836         done
837         rm -rf $BASEDIR/build
838         rm -rf $BASEDIR/cdrom
839         rm -rf $BASEDIR/log
840         rm -f $BASEDIR/updates/$VERSION/patch.tar.gz;
841         if [ -h /tools ]; then
842                 rm -f /tools
843         fi
844         ;;
845 dist)
846         echo "Building source package from CVS, list of changed files, MD5 of release files"
847         if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
848                 BRANCH=""
849                 BRANCHOPTS="-D `date +'%Y-%m-%d'`"
850         else
851                 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
852                 BRANCH=${BRANCH:1}
853                 BRANCHOPTS="-r $BRANCH"
854         fi
855
856         rm -rf $BASEDIR/build/tmp/$SNAME-$VERSION $BASEDIR/doc/release.txt
857         cd $BASEDIR/build/tmp
858         # build sources tgz
859         echo "Export tree $BRANCH $SNAME-$VERSION"
860         cvs -z3 -d `cat $BASEDIR/CVS/Root` export $BRANCHOPTS ipcop
861         if [ $? -eq 0 ]; then
862                 mv ipcop $SNAME-$VERSION
863                 tar cfz $BASEDIR/$SNAME-sources-$VERSION.tgz $SNAME-$VERSION
864                 cd $BASEDIR
865
866                 if [ ! -d $BASEDIR/build/tmp/$PREVIOUSTAG ]; then
867                         # export previous version to be compared with actual, this help to check wich files need to go in update
868                         cd $BASEDIR/build/tmp
869                         echo "Export tree $PREVIOUSTAG"
870                         cvs -z3 -d `cat $BASEDIR/CVS/Root` export -r $PREVIOUSTAG ipcop
871                         mv ipcop $PREVIOUSTAG
872                 fi
873                 if [ -d $BASEDIR/build/tmp/$PREVIOUSTAG -o -d $BASEDIR/build/tmp/$SNAME-$VERSION ]; then
874                         cd $BASEDIR/build/tmp
875                         echo "diff $PREVIOUSTAG <> $BRANCH $SNAME-$VERSION >doc/updated-sources.txt"
876                         diff -rq $PREVIOUSTAG $SNAME-$VERSION > $BASEDIR/doc/updated-sources.txt
877                         mv $BASEDIR/doc/updated-sources.txt $BASEDIR/doc/updated-sources.bak
878                         sed -e "s+Files $PREVIOUSTAG\/++" \
879                                 -e "s+ and .*$++" \
880                                 -e "s+src/rc.d+etc/rc.d+" \
881                                 -e "s+^langs/+var/ipcop/langs/+" \
882                                 -e "s+html/cgi-bin+home/httpd/cgi-bin+" $BASEDIR/doc/updated-sources.bak \
883                                 > $BASEDIR/doc/updated-sources.txt
884                         rm -f $BASEDIR/doc/updated-sources.bak
885                 fi
886         fi
887         ;;
888 newupdate)
889         # create structure for $VERSION update
890         if [ ! -f "updates/$VERSION" ]; then
891                 mkdir -p updates/$VERSION
892                 cd updates/$VERSION
893                 touch information
894                 echo 'etc/issue' > ROOTFILES.alpha-$VERSION
895                 echo 'etc/issue' > ROOTFILES.i386-$VERSION
896                 echo 'patch.tar.gz' > .cvsignore
897                 sed -e "s+^UPGRADEVERSION.*$+UPGRADEVERSION=$VERSION+" $BASEDIR/src/scripts/updatesetup > setup
898                 chmod 755 setup
899                 cd ..
900                 echo "Adding directory $VERSION to cvs"
901                 cvs add $VERSION
902                 echo "Adding files to cvs"
903                 cvs add $VERSION/ROOTFILES.alpha-$VERSION \
904                         $VERSION/ROOTFILES.i386-$VERSION \
905                         $VERSION/information \
906                         $VERSION/setup \
907                         $VERSION/.cvsignore
908         else
909                 echo "update/$VERSION already exist"
910         fi
911         cd -
912         exit 0
913         ;;
914 prefetch)
915         if [ ! -d $BASEDIR/cache ]; then
916                 mkdir $BASEDIR/cache
917         fi
918         mkdir -p $BASEDIR/log
919         echo "`date -u '+%b %e %T'`:Preload all source files" | tee -a $LOGFILE
920         FINISHED=0
921         cd $BASEDIR/lfs
922         for c in `seq $MAX_RETRIES`; do
923                 if (( FINISHED==1 )); then 
924                         break
925                 fi
926                 FINISHED=1
927                 cd $BASEDIR/lfs
928                 for i in *; do
929                         if [ -f "$i" -a "$i" != "Config" ]; then
930                                 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
931                                 if [ $? -ne 0 ]; then
932                                         echo "Prefetch : wget error in lfs/$i"
933                                         FINISHED=0
934                                 else
935                                         if [ $c -eq 1 ]; then
936                                                 echo "Prefetch : lfs/$i files loaded"
937                                         fi
938                                 fi
939                         fi
940                 done
941         done
942         echo "Prefetch : verifying md5sum"
943         ERROR=0
944         for i in *; do
945                 if [ -f "$i" -a "$i" != "Config" ]; then
946                         make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
947                         if [ $? -ne 0 ]; then
948                                 echo "md5 difference in lfs/$i"
949                                 ERROR=1
950                         fi
951                 fi
952         done
953         if [ $ERROR -eq 0 ]; then
954                 echo "Prefetch : all files md5sum match"
955         fi
956         cd -
957         ;;
958 rootfiles)
959         PREVIOUSVERSION=`echo $PREVIOUSTAG | sed -e 's/IPCOP_v//' -e 's/_FINAL//' -e 's/_/\./g'`
960         # make md5 list of actual build
961         # some packages include a timestamp (kernel/perl/python/vim and more), so md5 vary at each build
962         # anyway, it is sometime usable after a patch or a minor upgrade to know wich files include in update
963         if [ ! -f "$BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz" ]; then
964                 echo "need cdrom be build to read include files list, use ./make.sh build before."
965         else
966                 tar tzf $BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz > $BASEDIR/updates/$VERSION/FILES.tmp
967                 cd $BASEDIR/build
968                 rm -f $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
969                 for line in `cat $BASEDIR/updates/$VERSION/FILES.tmp`; do
970                         if [ -f "$line" -a ! -L "$line" ]; then
971                                 md5sum "$line" >> $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
972                         fi
973                 done
974                 diff $BASEDIR/updates/$PREVIOUSVERSION/FILES-$MACHINE-$PREVIOUSVERSION.md5 \
975                         $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 \
976                         > $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff
977                 awk '$1==">" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
978                         > $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE
979                 awk '$1=="<" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
980                         > $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp
981                 rm -f $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
982                 for line in `cat $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp`; do
983                         # a file is only removed when not in add file
984                         if ( ! grep -q "^$line$" $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE ); then
985                                 echo $line >> $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
986                         fi
987                 done
988                 rm -f $BASEDIR/updates/$VERSION/{FILES.tmp,FILES-*.diff,ROOTFILES.remove.*.tmp}
989         fi
990         exit 0
991         ;;
992 toolchain)
993         prepareenv
994         buildtoolchain
995         BUILDMACHINE=`uname -m`
996         echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
997         cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
998                 build/{bin,etc,usr/bin,usr/local} \
999                 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
1000                 log >> $LOGFILE
1001         md5sum cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1002                 > cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.md5
1003         stdumount
1004         ;;
1005 gettoolchain)
1006         BUILDMACHINE=`uname -m`
1007         # arbitrary name to be updated in case of new toolchain package upload
1008         PACKAGE=$SNAME-1.4.11-toolchain-$BUILDMACHINE
1009         URL_SFNET=`grep URL_SFNET lfs/Config | awk '{ print $3 }'`
1010         echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1011         cd $BASEDIR/cache
1012         wget -c $URL_SFNET/ipcop/$PACKAGE.tar.gz $URL_SFNET/ipcop/$PACKAGE.md5
1013         if [ $? -ne 0 ]; then
1014                 echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
1015         else
1016                 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1017                         echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1018                 else
1019                         exiterror "$PACKAGE.md5 did not match, check downloaded package"
1020                 fi
1021         fi
1022         ;;
1023 *)
1024         echo "Usage: $0 {build|changelog|check|checkclean|clean|dist|gettoolchain|newupdate|prefetch|rootfiles|shell|toolchain}"
1025         cat doc/make.sh-usage
1026         exit 1
1027         ;;
1028 esac