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