3 ############################################################################
5 # This file is part of the IPFire Firewall. #
7 # IPFire is free software; you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation; either version 2 of the License, or #
10 # (at your option) any later version. #
12 # IPFire is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with IPFire; if not, write to the Free Software #
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
21 # Copyright (C) 2006 IPFire-Team <entwickler@ipfire.org>. #
23 ############################################################################
26 NAME
="IPFire" # Software name
27 SNAME
="ipfire" # Short name
28 VERSION
="1.4" # Version number
29 # PREVIOUSTAG=IPCOP_v1_4_10_FINAL
30 SLOGAN
="We secure your network" # Software slogan
31 CONFIG_ROOT
=/var
/ipfire
# Configuration rootdir
33 MAX_RETRIES
=3 # prefetch/check loop
34 KVER
=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
37 # Debian specific settings
38 if [ ! -e /etc
/debian_version
]; then
41 if [ -x /usr
/bin
/realpath
]; then
42 FULLPATH
=`/usr/bin/realpath $0`
44 echo "ERROR: Need to do apt-get install realpath"
51 BASENAME
=`basename $0`
52 BASEDIR
=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
53 LOGFILE
=$BASEDIR/log
/_build.preparation.log
54 export BASEDIR LOGFILE
55 DIR_CHK
=$BASEDIR/cache
/check
56 mkdir
$BASEDIR/log
/ 2>/dev
/null
58 if [ 'x86_64' = $MACHINE -o 'i686' = $MACHINE -o 'i586' = $MACHINE -o 'i486' = $MACHINE -o 'i386' = $MACHINE ]; then
59 echo "`date -u '+%b %e %T'`: Machine is ix86 (or equivalent)" |
tee -a $LOGFILE
61 BUILDTARGET
=i386-pc-linux-gnu
62 CFLAGS
="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
63 CXXFLAGS
="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
64 elif [ 'alpha' = $MACHINE ]; then
65 echo "`date -u '+%b %e %T'`: Machine is Alpha AXP" |
tee -a $LOGFILE
66 BUILDTARGET
=alpha-unknown-linux-gnu
67 CFLAGS
="-O2 -mcpu=ev4 -mieee -pipe"
68 CXXFLAGS
="-O2 -mcpu=ev4 -mieee -pipe"
70 echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" |
tee -a $LOGFILE
76 umount
$BASEDIR/build
/dev
/pts
2>/dev
/null
;
77 umount
$BASEDIR/build
/proc
2>/dev
/null
;
78 umount
$BASEDIR/build
/install
/mnt
2>/dev
/null
;
79 umount
$BASEDIR/build
/usr
/src
/cache
2>/dev
/null
;
80 umount
$BASEDIR/build
/usr
/src
/ccache
2>/dev
/null
;
81 umount
$BASEDIR/build
/usr
/src
/config
2>/dev
/null
;
82 umount
$BASEDIR/build
/usr
/src
/doc
2>/dev
/null
;
83 umount
$BASEDIR/build
/usr
/src
/html
2>/dev
/null
;
84 umount
$BASEDIR/build
/usr
/src
/langs
2>/dev
/null
;
85 umount
$BASEDIR/build
/usr
/src
/lfs
2>/dev
/null
;
86 umount
$BASEDIR/build
/usr
/src
/log
2>/dev
/null
;
87 umount
$BASEDIR/build
/usr
/src
/src
2>/dev
/null
;
92 for i
in `seq 0 7`; do
93 if ( losetup
/dev
/loop
${i} 2>/dev
/null |
grep -q "/install/images" ); then
94 losetup
-d /dev
/loop
${i} 2>/dev
/null
98 echo " Check $LOGFILE for errors if applicable"
103 if [ ! -e $BASEDIR/build
/usr
/src
/lfs
/ ]; then
104 exiterror
"No such file or directory: $BASEDIR/build/usr/src/lfs/"
106 echo "Entering to a shell inside LFS chroot, go out with exit"
107 chroot
$LFS /tools
/bin
/env
-i HOME
=/root TERM
=$TERM PS1
='\u:\w\$ ' \
108 PATH
=/usr
/local
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin
:/tools
/bin \
109 VERSION
=$VERSION CONFIG_ROOT
=$CONFIG_ROOT \
110 NAME
="$NAME" SNAME
="$SNAME" SLOGAN
="$SLOGAN" \
111 CFLAGS
="$CFLAGS" CXXFLAGS
="$CXXFLAGS" \
112 CCACHE_DIR
=/usr
/src
/ccache \
115 BUILDTARGET
="$BUILDTARGET" MACHINE
="$MACHINE" \
116 KGCC
="ccache /usr/bin/gcc" \
118 if [ $?
-ne 0 ]; then
119 exiterror
"chroot error"
126 ############################################################################
128 # Are we running the right shell? #
130 ############################################################################
131 if [ ! "$BASH" ]; then
132 exiterror
"BASH environment variable is not set. You're probably running the wrong shell."
135 if [ -z "${BASH_VERSION}" ]; then
136 exiterror
"Not running BASH shell."
140 ############################################################################
142 # Trap on emergency exit #
144 ############################################################################
145 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
148 ############################################################################
150 # Resetting our nice level #
152 ############################################################################
153 echo "`date -u '+%b %e %T'`: Resetting our nice level to $NICE" |
tee -a $LOGFILE
154 renice
$NICE $$
> /dev
/null
155 if [ `nice` != "$NICE" ]; then
156 exiterror
"Failed to set correct nice level"
159 ############################################################################
161 # Checking if running as root user #
163 ############################################################################
164 echo "`date -u '+%b %e %T'`: Checking if we're running as root user" |
tee -a $LOGFILE
165 if [ `id -u` != 0 ]; then
166 exiterror
"Not building as root"
170 ############################################################################
172 # Checking for necessary temporary space #
174 ############################################################################
175 echo "`date -u '+%b %e %T'`: Checking for necessary space on disk $BASE_DEV" |
tee -a $LOGFILE
176 BASE_DEV
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
177 BASE_ASPACE
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
178 if (( 2202000 > $BASE_ASPACE )); then
179 BASE_USPACE
=`du -skx $BASEDIR | awk '{print $1}'`
180 if (( 2202000 - $BASE_USPACE > $BASE_ASPACE )); then
181 exiterror
"Not enough temporary space available, need at least 2.1GB on $BASE_DEV"
185 ############################################################################
187 # Building Linux From Scratch system #
189 ############################################################################
190 echo "`date -u '+%b %e %T'`: Building Linux From Scratch system" |
tee -a $LOGFILE
198 # Check /tools symlink
199 if [ -h /tools
]; then
202 if [ ! -a /tools
]; then
203 ln -s $BASEDIR/build
/tools
/
205 if [ ! -h /tools
]; then
206 exiterror
"Could not create /tools symbolic link."
212 export LFS LC_ALL CFLAGS CXXFLAGS
213 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
215 # Make some extra directories
216 mkdir
-p $BASEDIR/build
/{tools
,etc
,usr
/src
} 2>/dev
/null
217 mkdir
-p $BASEDIR/{cache
,ccache
} 2>/dev
/null
218 mkdir
-p $BASEDIR/build
/dev
/pts
$BASEDIR/build
/proc
$BASEDIR/build
/usr
/src
/{cache
,config
,doc
,html
,langs
,lfs
,log
,src
,ccache
}
220 # Make all sources and proc available under lfs build
221 mount
--bind /dev
/pts
$BASEDIR/build
/dev
/pts
222 mount
--bind /proc
$BASEDIR/build
/proc
223 mount
--bind $BASEDIR/cache
$BASEDIR/build
/usr
/src
/cache
224 mount
--bind $BASEDIR/ccache
$BASEDIR/build
/usr
/src
/ccache
225 mount
--bind $BASEDIR/config
$BASEDIR/build
/usr
/src
/config
226 mount
--bind $BASEDIR/doc
$BASEDIR/build
/usr
/src
/doc
227 mount
--bind $BASEDIR/html
$BASEDIR/build
/usr
/src
/html
228 mount
--bind $BASEDIR/langs
$BASEDIR/build
/usr
/src
/langs
229 mount
--bind $BASEDIR/lfs
$BASEDIR/build
/usr
/src
/lfs
230 mount
--bind $BASEDIR/log
$BASEDIR/build
/usr
/src
/log
231 mount
--bind $BASEDIR/src
$BASEDIR/build
/usr
/src
/src
233 # Run LFS static binary creation scripts one by one
234 export CCACHE_DIR
=$BASEDIR/ccache
235 export CCACHE_HASHDIR
=1
237 # Remove pre-install list of installed files in case user erase some files before rebuild
238 rm -f $BASEDIR/build
/usr
/src
/lsalr
2>/dev
/null
242 ############################################################################
244 # Necessary shell functions #
246 ############################################################################
248 if [ -f $BASEDIR/lfs
/$1 ]; then
249 echo "`date -u '+%b %e %T'`: Building $*" |
tee -a $LOGFILE
250 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t " download
>> $LOGFILE 2>&1
251 if [ $?
-ne 0 ]; then
252 exiterror
"Download error in $1"
254 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t md5sum" md5
>> $LOGFILE 2>&1
255 if [ $?
-ne 0 ]; then
256 exiterror
"md5sum error in $1, check file in cache or signature"
258 cd $BASEDIR/lfs
&& make -f $
* BUILDTARGET
=$BUILDTARGET \
260 LFS_BASEDIR
=$BASEDIR \
263 install >> $LOGFILE 2>&1
264 if [ $?
-ne 0 ]; then
265 exiterror
"Building $*";
268 exiterror
"No such file or directory: $BASEDIR/$1"
274 if [ -f $BASEDIR/build
/usr
/src
/lfs
/$1 ]; then
275 echo "`date -u '+%b %e %T'`: Building $*" |
tee -a $LOGFILE
276 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t " download
>> $LOGFILE 2>&1
277 if [ $?
-ne 0 ]; then
278 exiterror
"Download error in $1"
280 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t md5sum" md5
>> $LOGFILE 2>&1
281 if [ $?
-ne 0 ]; then
282 exiterror
"md5sum error in $1, check file in cache or signature"
284 chroot
$LFS /tools
/bin
/env
-i HOME
=/root \
285 TERM
=$TERM PS1
='\u:\w\$ ' \
286 PATH
=/usr
/local
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin
:/tools
/bin \
288 CONFIG_ROOT
=$CONFIG_ROOT \
289 NAME
="$NAME" SNAME
="$SNAME" SLOGAN
="$SLOGAN" \
290 CFLAGS
="$CFLAGS" CXXFLAGS
="$CXXFLAGS" \
291 CCACHE_DIR
=/usr
/src
/ccache CCACHE_HASHDIR
=1 \
293 BUILDTARGET
="$BUILDTARGET" MACHINE
="$MACHINE" \
294 /tools
/bin
/bash
-x -c "cd /usr/src/lfs && \
295 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
296 if [ $?
-ne 0 ]; then
297 exiterror
"Building $*"
300 exiterror
"No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
306 if [ -f $BASEDIR/build
/usr
/src
/lfs
/$1 ]; then
307 echo "`date -u '+%b %e %T'`: Building $*" |
tee -a $LOGFILE
308 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t " download
>> $LOGFILE 2>&1
309 if [ $?
-ne 0 ]; then
310 exiterror
"Download error in $1"
312 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t md5sum" md5
>> $LOGFILE 2>&1
313 if [ $?
-ne 0 ]; then
314 exiterror
"md5sum error in $1, check file in cache or signature"
316 chroot
$LFS /tools
/bin
/env
-i HOME
=/root \
317 TERM
=$TERM PS1
='\u:\w\$ ' \
318 PATH
=/usr
/local
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin \
320 CONFIG_ROOT
=$CONFIG_ROOT \
321 NAME
="$NAME" SNAME
="$SNAME" SLOGAN
="$SLOGAN" \
322 CFLAGS
="$CFLAGS" CXXFLAGS
="$CXXFLAGS" \
323 CCACHE_DIR
=/usr
/src
/ccache CCACHE_HASHDIR
=1 \
325 BUILDTARGET
="$BUILDTARGET" MACHINE
="$MACHINE" \
326 /bin
/bash
-x -c "cd /usr/src/lfs && \
327 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
328 if [ $?
-ne 0 ]; then
329 exiterror
"Building $*"
332 exiterror
"No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
338 if [ -f $BASEDIR/build
/usr
/src
/lfs
/$1 ]; then
339 echo "`date -u '+%b %e %T'`: Packaging $1" |
tee -a $LOGFILE
340 cp -f $BASEDIR/src
/scripts
/make-packages.sh
$BASEDIR/build
/usr
/local
/bin
341 chroot
$LFS /tools
/bin
/env
-i HOME
=/root \
342 TERM
=$TERM PS1
='\u:\w\$ ' \
343 PATH
=/usr
/local
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin \
345 CONFIG_ROOT
=$CONFIG_ROOT \
346 NAME
="$NAME" SNAME
="$SNAME" SLOGAN
="$SLOGAN" \
347 CFLAGS
="$CFLAGS" CXXFLAGS
="$CXXFLAGS" \
348 CCACHE_DIR
=/usr
/src
/ccache CCACHE_HASHDIR
=1 \
350 BUILDTARGET
="$BUILDTARGET" MACHINE
="$MACHINE" \
351 /bin
/bash
-x -c "cd /usr/src/lfs && \
352 make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
353 if [ $?
-ne 0 ]; then
354 exiterror
"Packaging $1"
357 exiterror
"No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
359 test -d $BASEDIR/packages || mkdir
$BASEDIR/packages
360 mv -f $BASEDIR/build
/paks
/* $BASEDIR/packages
/
366 if [ -f $BASEDIR/build
/usr
/src
/lfs
/$1 ]; then
367 echo "`date -u '+%b %e %T'`: Building $*" |
tee -a $LOGFILE
368 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t " download
>> $LOGFILE 2>&1
369 if [ $?
-ne 0 ]; then
370 exiterror
"Download error in $1"
372 cd $BASEDIR/lfs
&& make -s -f $
* LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t md5sum" md5
>> $LOGFILE 2>&1
373 if [ $?
-ne 0 ]; then
374 exiterror
"md5sum error in $1, check file in cache or signature"
376 chroot
$LFS /tools
/bin
/env
-i HOME
=/root \
377 TERM
=$TERM PS1
='\u:\w\$ ' \
378 PATH
=/usr
/local
/bin
:/opt
/$MACHINE-uClibc/usr
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin \
380 CONFIG_ROOT
=$CONFIG_ROOT \
382 NAME
="$NAME" SNAME
="$SNAME" SLOGAN
="$SLOGAN" \
383 CFLAGS
="-Os" CXXFLAGS
="-Os" \
384 CCACHE_DIR
=/usr
/src
/ccache CCACHE_HASHDIR
=1 \
386 BUILDTARGET
="$BUILDTARGET" MACHINE
="$MACHINE" \
387 /bin
/bash
-x -c "cd /usr/src/lfs && \
388 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
389 if [ $?
-ne 0 ]; then
390 exiterror
"Building $*"
393 exiterror
"No such file or directory: $BASEDIR/build/usr/src/lfs/$1"
399 LOGFILE
="$BASEDIR/log/_build.toolchain.log"
401 echo -ne "`date -u '+%b %e %T'`: Stage1 toolchain build \n" |
tee -a $LOGFILE
402 # Build sed now, as we use some extensions
404 NATIVEGCC
=`gcc --version | grep GCC | awk {'print $3'}`
405 export NATIVEGCC GCCmajor
=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
407 lfsmake1
sed LFS_PASS
=1
408 lfsmake1
m4 LFS_PASS
=1
409 lfsmake1 bison LFS_PASS
=1
410 lfsmake1 flex LFS_PASS
=1
411 lfsmake1 binutils LFS_PASS
=1
412 lfsmake1 gcc LFS_PASS
=1
413 export PATH
=$BASEDIR/build
/usr
/local
/bin
:$BASEDIR/build
/tools
/bin
:$PATH
420 lfsmake1 gcc LFS_PASS
=2
421 lfsmake1 binutils LFS_PASS
=2
430 lfsmake1
sed LFS_PASS
=2
431 lfsmake1
m4 LFS_PASS
=2
432 lfsmake1 bison LFS_PASS
=2
433 lfsmake1 flex LFS_PASS
=2
442 export PATH
=$ORG_PATH
446 LOGFILE
="$BASEDIR/log/_build.base.log"
448 echo -ne "`date -u '+%b %e %T'`: Stage2 linux base build \n" |
tee -a $LOGFILE
449 # Run LFS dynamic binary creation scripts one by one
487 if [ 'i386' = $MACHINE ]; then
489 elif [ 'alpha' = $MACHINE ]; then
508 # Run IPCop make scripts one by one
509 LOGFILE
="$BASEDIR/log/_build.ipcop.log"
511 echo -ne "`date -u '+%b %e %T'`: Stage3 $NAME build \n" |
tee -a $LOGFILE
513 # Build these first as some of the kernel packages below rely on
514 # these for some of their client program functionality
525 if [ 'i386' = $MACHINE ]; then
526 # abuse the SMP flag, and make an minimal installer kernel first
527 # so that the boot floppy always works.....
528 ipcopmake linux LFS_PASS
=ipcop SMP
=installer
529 ipcopmake linux LFS_PASS
=ipcop SMP
=1
530 ipcopmake
3cp4218 SMP
=1
531 ipcopmake amedyn SMP
=1
532 ipcopmake cxacru SMP
=1
533 ipcopmake eagle SMP
=1
535 # These are here because they have i386 only binary libraries
536 # included in the package.
537 ipcopmake cnx_pci SMP
=1
538 ipcopmake fcdsl SMP
=1
539 ipcopmake fcdsl2 SMP
=1
540 ipcopmake fcdslsl SMP
=1
541 ipcopmake fcdslusb SMP
=1
542 ipcopmake fcdslslusb SMP
=1
543 ipcopmake pulsar SMP
=1
544 ipcopmake unicorn SMP
=1
547 ipcopmake linux LFS_PASS
=ipcop
554 if [ 'i386' = $MACHINE ]; then
555 # These are here because they have i386 only binary libraries
556 # included in the package.
586 ipcopmake capi4k-utils
591 ipcopmake ez-ipupdate
597 ipcopmake initscripts
604 ipcopmake isapnptools
605 ipcopmake isdn4k-utils
616 ipcopmake HTML-Tagset
617 ipcopmake HTML-Parser
618 ipcopmake Compress-Zlib
620 ipcopmake Digest-SHA1
621 ipcopmake Digest-HMAC
622 ipcopmake libwww-perl
624 ipcopmake Net-IPv4Addr
626 ipcopmake noip_updater
638 ipcopmake squid-graph
645 echo -ne "`date -u '+%b %e %T'`: Building IPFire modules \n" |
tee -a $LOGFILE
646 ## Zuerst die Libs und dann die Programme. Ordnung muss sein!
657 ipcopmake saslauthd PASS
=1
659 ipcopmake saslauthd PASS
=2
667 ipcopmake bridge-utils
674 # wget http://www.guzu.net/linux/hddtemp.db && mv hddtemp.db $BASEDIR/build/etc/hddtemp.db
676 # ipcopmake stunnel # Ausgeschaltet, weil wir es doch nicht nutzen
680 # Run installer scripts one by one
681 LOGFILE
="$BASEDIR/log/_build.installer.log"
683 echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" |
tee -a $LOGFILE
684 if [ 'i386' = $MACHINE ]; then
692 installmake e2fsprogs
693 installmake misc-progs
695 installmake util-linux
698 installmake pcmcia-cs
700 installmake installer
702 installmake driver.img
708 LOGFILE
="$BASEDIR/log/_build.packages.log"
710 echo "... see detailed log in _build.*.log files" >> $LOGFILE
711 echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" |
tee -a $LOGFILE
713 echo "`date -u '+%b %e %T'`: Stripping files" |
tee -a $LOGFILE
714 find $LFS/lib
$LFS/usr
/lib
$LFS/usr
/share
/rrdtool-
* $LFS/install ! -type l \
( -name '*.so' -o -name '*.so[\.0-9]*' \
) \
715 ! -name 'libc.so' ! -name 'libpthread.so' ! -name 'libcrypto.so.0.9.7.sha1' \
716 -ls -exec $LFS/tools
/bin
/strip
--strip-all {} \
; >> $LOGFILE 2>&1
717 # add -ls before -exec if you want to verify what files are stripped
719 find $LFS/{,s
}bin
$LFS/usr
/{,s
}bin
$LFS/usr
/local
/{,s
}bin
! -type l \
720 -exec file {} \
; |
grep " ELF " | cut
-f1 -d ':' |
xargs $LFS/tools
/bin
/strip
--strip-all >> $LOGFILE 2>&1
721 # there add -v to strip to verify
723 if [ 'i386' = $MACHINE ]; then
724 # Create fcdsl packages
725 echo "`date -u '+%b %e %T'`: Building fcdsl tgz" |
tee -a $LOGFILE
726 cp $LFS/install
/images
/fcdsl
/license.txt
$LFS >> $LOGFILE 2>&1
727 touch $LFS/var
/run
/{need-depmod-
$KVER,need-depmod-
$KVER-smp}
728 cd $LFS && tar cvfz
$LFS/install
/images
/$SNAME-fcdsl-$VERSION.
$MACHINE.tgz \
729 lib
/modules
/$KVER/misc
/fcdsl
*.o.gz \
730 lib
/modules
/$KVER-smp/misc
/fcdsl
*.o.gz \
731 usr
/lib
/isdn
/{fds?base.bin
,fd?ubase.frm
} \
732 etc
/fcdsl
/fcdsl
*.conf \
733 etc
/drdsl
/{drdsl
,drdsl.ini
} \
735 var
/run
/{need-depmod-
$KVER,need-depmod-
$KVER-smp} >> $LOGFILE 2>&1
736 rm -f $LFS/license.txt
>> $LOGFILE 2>&1
740 # Create update for this version
741 # echo "`date -u '+%b %e %T'`: Building update $VERSION tgz" | tee -a $LOGFILE
742 # tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/$VERSION/ROOTFILES.$MACHINE-$VERSION -f $BASEDIR/updates/$VERSION/patch.tar.gz --exclude='#*';
743 # chmod 755 $BASEDIR/updates/$VERSION/setup
744 # tar -cz -C $BASEDIR/updates/$VERSION -f $LFS/install/images/$SNAME-update-$VERSION.$MACHINE.tgz patch.tar.gz setup information
745 # rm -f $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
747 # Generating list of packages used
748 echo "`date -u '+%b %e %T'`: Generating packages list from logs" |
tee -a $LOGFILE
749 rm -f $BASEDIR/doc
/packages-list
750 for i
in `ls -1tr $BASEDIR/log/[^_]*`; do
751 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
752 echo " * `basename $i`" >>$BASEDIR/doc
/packages-list
755 echo "====== List of softwares used to build $NAME Version: $VERSION ======" > $BASEDIR/doc
/packages-list.txt
756 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|ipcop$\|setup$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \
757 $BASEDIR/doc
/packages-list |
sort >> $BASEDIR/doc
/packages-list.txt
758 rm -f $BASEDIR/doc
/packages-list
759 # packages-list.txt is ready to be displayed for wiki page
761 # Create ISO for CDRom and USB-superfloppy
763 # cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1
765 # Build IPFire packages
775 test -d $BASEDIR/packages || mkdir
$BASEDIR/packages
776 cp -f $LFS/paks
/* $BASEDIR/packages
>> $LOGFILE 2>&1
780 rm -rf $BASEDIR/build
/tmp
/*
782 # Generating total list of files
783 echo "`date -u '+%b %e %T'`: Generating files list from logs" |
tee -a $LOGFILE
784 rm -f $BASEDIR/log
/FILES
785 for i
in `ls -1tr $BASEDIR/log/[^_]*`; do
786 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
787 echo "##" >>$BASEDIR/log
/FILES
788 echo "## `basename $i`" >>$BASEDIR/log
/FILES
789 echo "##" >>$BASEDIR/log
/FILES
790 cat $i |
sed "s%^\./%#%" |
sort >> $BASEDIR/log
/FILES
798 # See what we're supposed to do
801 BUILDMACHINE
=`uname -m`
802 PACKAGE
=`ls -v -r $BASEDIR/cache/$SNAME-1.4.*-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
803 #only restore on a clean disk
804 if [ ! -f log
/perl-
*-tools ]; then
805 if [ ! -n "$PACKAGE" ]; then
806 echo "`date -u '+%b %e %T'`: Full toolchain compilation" |
tee -a $LOGFILE
810 PACKAGENAME
=${PACKAGE%.tar.gz}
811 echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" |
tee -a $LOGFILE
812 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
816 exiterror
"$PACKAGENAME md5 did not match, check downloaded package"
820 echo "`date -u '+%b %e %T'`: Using installed toolchain" |
tee -a $LOGFILE
829 # enter a shell inside LFS chroot
830 # may be used to changed kernel settings
835 echo "Building doc/Changelog from CVS"
836 # cv2cl script come from http://www.red-bean.com/cvs2cl/
837 if [ ! -s $BASEDIR/doc
/CVS
/Tag
]; then
840 BRANCH
=`cat $BASEDIR/doc/CVS/Tag`
842 BRANCHOPTS
="--follow-only $BRANCH"
845 $BASEDIR/tools
/cvs2cl.pl
--gmt --show-dead $BRANCHOPTS -f $BASEDIR/doc
/ChangeLog
846 rm -f $BASEDIR/doc
/ChangeLog.bak
848 echo "Commit the change now to update CVS"
851 echo "Checking sources files availability on the web"
852 if [ ! -d $DIR_CHK ]; then
857 for c
in `seq $MAX_RETRIES`; do
858 if (( FINISHED
==1 )); then
864 if [ -f "$i" -a "$i" != "Config" ]; then
865 make -s -f $i MACHINE
=$MACHINE LFS_BASEDIR
=$BASEDIR ROOT
=$BASEDIR/build \
866 MESSAGE
="$i\t ($c/$MAX_RETRIES)" check
867 if [ $?
-ne 0 ]; then
868 echo "Check : wget error in lfs/$i"
877 echo "Erasing sources files availability tags"
881 for i
in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
882 $LOSETUP -d $i 2>/dev
/null
884 for i
in `mount | grep $BASEDIR | cut -d " " -f 1`; do
888 for i
in `seq 0 7`; do
889 if ( losetup
/dev
/loop
${i} 2>/dev
/null |
grep -q "/install/images" ); then
890 umount
/dev
/loop
${i} 2>/dev
/null
;
891 losetup
-d /dev
/loop
${i} 2>/dev
/null
;
894 rm -rf $BASEDIR/build
895 rm -rf $BASEDIR/cdrom
897 rm -f $BASEDIR/updates
/$VERSION/patch.
tar.gz
;
898 if [ -h /tools
]; then
903 echo "Building source package from CVS, list of changed files, MD5 of release files"
904 if [ ! -s $BASEDIR/doc
/CVS
/Tag
]; then
906 BRANCHOPTS
="-D `date +'%Y-%m-%d'`"
908 BRANCH
=`cat $BASEDIR/doc/CVS/Tag`
910 BRANCHOPTS
="-r $BRANCH"
913 rm -rf $BASEDIR/build
/tmp
/$SNAME-$VERSION $BASEDIR/doc
/release.txt
914 cd $BASEDIR/build
/tmp
916 echo "Export tree $BRANCH $SNAME-$VERSION"
917 cvs
-z3 -d `cat $BASEDIR/CVS/Root` export $BRANCHOPTS ipcop
918 if [ $?
-eq 0 ]; then
919 mv ipcop
$SNAME-$VERSION
920 tar cfz
$BASEDIR/$SNAME-sources-$VERSION.tgz
$SNAME-$VERSION
923 if [ ! -d $BASEDIR/build
/tmp
/$PREVIOUSTAG ]; then
924 # export previous version to be compared with actual, this help to check wich files need to go in update
925 cd $BASEDIR/build
/tmp
926 echo "Export tree $PREVIOUSTAG"
927 cvs
-z3 -d `cat $BASEDIR/CVS/Root` export -r $PREVIOUSTAG ipcop
928 mv ipcop
$PREVIOUSTAG
930 if [ -d $BASEDIR/build
/tmp
/$PREVIOUSTAG -o -d $BASEDIR/build
/tmp
/$SNAME-$VERSION ]; then
931 cd $BASEDIR/build
/tmp
932 echo "diff $PREVIOUSTAG <> $BRANCH $SNAME-$VERSION >doc/updated-sources.txt"
933 diff -rq $PREVIOUSTAG $SNAME-$VERSION > $BASEDIR/doc
/updated-sources.txt
934 mv $BASEDIR/doc
/updated-sources.txt
$BASEDIR/doc
/updated-sources.bak
935 sed -e "s+Files $PREVIOUSTAG\/++" \
937 -e "s+src/rc.d+etc/rc.d+" \
938 -e "s+^langs/+var/ipcop/langs/+" \
939 -e "s+html/cgi-bin+home/httpd/cgi-bin+" $BASEDIR/doc
/updated-sources.bak \
940 > $BASEDIR/doc
/updated-sources.txt
941 rm -f $BASEDIR/doc
/updated-sources.bak
946 # create structure for a new package
947 echo -e "Name of the new package: $2"
948 if [ ! -f "lfs/$2" ]; then
949 echo "`date -u '+%b %e %T'`: Creating directory src/paks/$2"
952 echo "`date -u '+%b %e %T'`: Creating files"
953 cp $BASEDIR/lfs
/postfix
$BASEDIR/lfs
/$2
957 touch {,un
}install.sh
959 echo '#!/bin/bash' > install.sh
960 echo '#' >> install.sh
961 echo '#################################################################' >> install.sh
962 echo '# #' >> install.sh
963 echo '# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #' >> install.sh
964 echo '# #' >> install.sh
965 echo '#################################################################' >> install.sh
966 echo '#' >> install.sh
967 echo '# Extract the files' >> install.sh
968 echo 'tar xfz files.tgz -C /' >> install.sh
969 echo 'cp -f ROOTFILES /opt/pakfire/installed/ROOTFILES.$2' >> install.sh
971 echo '#!/bin/bash' > uninstall.sh
972 echo '#################################################################' >> uninstall.sh
973 echo '# #' >> uninstall.sh
974 echo '# This file belongs to IPFire Firewall - GPLv2 - www.ipfire.org #' >> uninstall.sh
975 echo '# #' >> uninstall.sh
976 echo '#################################################################' >> uninstall.sh
977 echo '#' >> uninstall.sh
978 echo '# Delete the files' >> uninstall.sh
979 echo '## Befehl fehlt noch' >> uninstall.sh
980 echo 'rm -f /opt/pakfire/installed/ROOTFILES.$2' >> uninstall.sh
981 echo "`date -u '+%b %e %T'`: Adding files to SVN"
982 cd - && svn add lfs
/$2 && svn add src
/paks
/$2
984 echo -n "Do you want to remove the folders? [y/n]"
986 if [ "$REM" == "y" ]; then
987 echo "Removing the folders..."
988 svn del src
/paks
/$2 --force
990 echo "Folders are kept."
993 echo "$2 already exists"
998 if [ ! -d $BASEDIR/cache
]; then
1001 mkdir
-p $BASEDIR/log
1002 echo "`date -u '+%b %e %T'`:Preload all source files" |
tee -a $LOGFILE
1005 for c
in `seq $MAX_RETRIES`; do
1006 if (( FINISHED
==1 )); then
1012 if [ -f "$i" -a "$i" != "Config" ]; then
1013 make -s -f $i LFS_BASEDIR
=$BASEDIR MESSAGE
="$i\t ($c/$MAX_RETRIES)" download
>> $LOGFILE 2>&1
1014 if [ $?
-ne 0 ]; then
1015 echo "Prefetch : wget error in lfs/$i"
1018 if [ $c -eq 1 ]; then
1019 echo "Prefetch : lfs/$i files loaded"
1025 echo "Prefetch : verifying md5sum"
1028 if [ -f "$i" -a "$i" != "Config" ]; then
1029 make -s -f $i LFS_BASEDIR
=$BASEDIR MESSAGE
="$i\t " md5
>> $LOGFILE 2>&1
1030 if [ $?
-ne 0 ]; then
1031 echo "md5 difference in lfs/$i"
1036 if [ $ERROR -eq 0 ]; then
1037 echo "Prefetch : all files md5sum match"
1042 PREVIOUSVERSION
=`echo $PREVIOUSTAG | sed -e 's/IPCOP_v//' -e 's/_FINAL//' -e 's/_/\./g'`
1043 # make md5 list of actual build
1044 # some packages include a timestamp (kernel/perl/python/vim and more), so md5 vary at each build
1045 # anyway, it is sometime usable after a patch or a minor upgrade to know wich files include in update
1046 if [ ! -f "$BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz" ]; then
1047 echo "need cdrom be build to read include files list, use ./make.sh build before."
1049 tar tzf
$BASEDIR/build
/install
/cdrom
/$SNAME-$VERSION.tgz
> $BASEDIR/updates
/$VERSION/FILES.tmp
1051 rm -f $BASEDIR/updates
/$VERSION/FILES-
$MACHINE-$VERSION.md5
1052 for line
in `cat $BASEDIR/updates/$VERSION/FILES.tmp`; do
1053 if [ -f "$line" -a ! -L "$line" ]; then
1054 md5sum "$line" >> $BASEDIR/updates
/$VERSION/FILES-
$MACHINE-$VERSION.md5
1057 diff $BASEDIR/updates
/$PREVIOUSVERSION/FILES-
$MACHINE-$PREVIOUSVERSION.md5 \
1058 $BASEDIR/updates
/$VERSION/FILES-
$MACHINE-$VERSION.md5 \
1059 > $BASEDIR/updates
/$VERSION/FILES-
$MACHINE.
diff
1060 awk '$1==">" {print $3}' $BASEDIR/updates
/$VERSION/FILES-
$MACHINE.
diff \
1061 > $BASEDIR/updates
/$VERSION/ROOTFILES.add.
$MACHINE
1062 awk '$1=="<" {print $3}' $BASEDIR/updates
/$VERSION/FILES-
$MACHINE.
diff \
1063 > $BASEDIR/updates
/$VERSION/ROOTFILES.remove.
$MACHINE.tmp
1064 rm -f $BASEDIR/updates
/$VERSION/ROOTFILES.remove.
$MACHINE
1065 for line
in `cat $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp`; do
1066 # a file is only removed when not in add file
1067 if ( ! grep -q "^$line$" $BASEDIR/updates
/$VERSION/ROOTFILES.add.
$MACHINE ); then
1068 echo $line >> $BASEDIR/updates
/$VERSION/ROOTFILES.remove.
$MACHINE
1071 rm -f $BASEDIR/updates
/$VERSION/{FILES.tmp
,FILES-
*.
diff,ROOTFILES.remove.
*.tmp
}
1078 BUILDMACHINE
=`uname -m`
1079 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" |
tee -a $LOGFILE
1080 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache
/$SNAME-$VERSION-toolchain-$BUILDMACHINE.
tar.gz \
1081 build
/{bin
,etc
,usr
/bin
,usr
/local} \
1082 build
/tools
/{bin
,etc
,*-linux-gnu,include
,lib
,libexec
,sbin
,share
,var
} \
1084 md5sum cache
/$SNAME-$VERSION-toolchain-$BUILDMACHINE.
tar.gz \
1085 > cache
/$SNAME-$VERSION-toolchain-$BUILDMACHINE.md5
1089 BUILDMACHINE
=`uname -m`
1090 # arbitrary name to be updated in case of new toolchain package upload
1091 PACKAGE
=$SNAME-1.4
-toolchain-$BUILDMACHINE
1092 URL_IPFIRE
=`grep URL_IPFIRE lfs/Config | awk '{ print $3 }'`
1093 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" |
tee -a $LOGFILE
1095 wget
-c $URL_IPFIRE/toolchains
/$PACKAGE.
tar.gz
$URL_IPFIRE/toolchains
/$PACKAGE.md5
1096 if [ $?
-ne 0 ]; then
1097 echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" |
tee -a $LOGFILE
1099 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1100 echo "`date -u '+%b %e %T'`: toolchain md5 ok" |
tee -a $LOGFILE
1101 echo "`date -u '+%b %e %T'`: Uncompressing toolchain" |
tee -a $LOGFILE
1102 cd $BASEDIR && tar xvfz cache
/$PACKAGE.
tar.gz
-C .
1104 exiterror
"$PACKAGE.md5 did not match, check downloaded package"
1109 echo "Load the latest source-files:"
1113 echo "Usage: $0 {build|changelog|check|checkclean|clean|dist|gettoolchain|newpak|prefetch|rootfiles|shell|toolchain|update}"
1114 cat doc
/make.sh-usage