]> git.ipfire.org Git - ipfire-2.x.git/blame_incremental - make.sh
Webinterface gefixt.
[ipfire-2.x.git] / make.sh
... / ...
CommitLineData
1#!/bin/bash
2#
3############################################################################
4# #
5# This file is part of the IPCop Firewall. #
6# #
7# IPCop is free software; you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation; either version 2 of the License, or #
10# (at your option) any later version. #
11# #
12# IPCop is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with IPCop; if not, write to the Free Software #
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
20# #
21# Copyright (C) 2001 Mark Wormgoor <mark@wormgoor.com>. #
22# #
23# (c) 2001 Eric S. Johansson <esj@harvee.billerica.ma.us> Check for Bash #
24# (c) 2002 Thorsten Fischer <frosch@cs.tu-berlin.de> MD5Sum checking #
25# #
26############################################################################
27#
28# $Id: make.sh,v 1.129.2.145 2006/02/01 07:04:09 gespinasse Exp $
29#
30
31 NAME="IPFire" # Software name
32 SNAME="ipfire" # Short name
33 VERSION="1.4" # Version number
34# PREVIOUSTAG=IPCOP_v1_4_10_FINAL
35 SLOGAN="We secure your network" # Software slogan
36 CONFIG_ROOT=/var/ipfire # Configuration rootdir
37 NICE=10
38 MAX_RETRIES=3 # prefetch/check loop
39 KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
40 MACHINE=`uname -m`
41
42 # Debian specific settings
43 if [ ! -e /etc/debian_version ]; then
44 FULLPATH=`which $0`
45 else
46 if [ -x /usr/bin/realpath ]; then
47 FULLPATH=`/usr/bin/realpath $0`
48 else
49 echo "ERROR: Need to do apt-get install realpath"
50 exit 1
51 fi
52 fi
53
54
55 PWD=`pwd`
56 BASENAME=`basename $0`
57 BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
58 LOGFILE=$BASEDIR/log/_build.preparation.log
59 export BASEDIR LOGFILE
60 DIR_CHK=$BASEDIR/cache/check
61 mkdir $BASEDIR/log/ 2>/dev/null
62
63 if [ 'x86_64' = $MACHINE -o 'i686' = $MACHINE -o 'i586' = $MACHINE -o 'i486' = $MACHINE -o 'i386' = $MACHINE ]; then
64 echo "`date -u '+%b %e %T'`: Machine is ix86 (or equivalent)" | tee -a $LOGFILE
65 MACHINE=i386
66 BUILDTARGET=i386-pc-linux-gnu
67 CFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
68 CXXFLAGS="-O2 -mcpu=i386 -march=i386 -pipe -fomit-frame-pointer"
69 elif [ 'alpha' = $MACHINE ]; then
70 echo "`date -u '+%b %e %T'`: Machine is Alpha AXP" | tee -a $LOGFILE
71 BUILDTARGET=alpha-unknown-linux-gnu
72 CFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
73 CXXFLAGS="-O2 -mcpu=ev4 -mieee -pipe"
74 else
75 echo "`date -u '+%b %e %T'`: Can't determine your architecture - $MACHINE" | tee -a $LOGFILE
76 exit 1
77 fi
78
79# Define immediately
80stdumount() {
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
95exiterror() {
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
107entershell() {
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
130prepareenv() {
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############################################################################
252lfsmake1() {
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
278lfsmake2() {
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
310ipcopmake() {
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
343installmake() {
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
376buildtoolchain() {
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
423buildbase() {
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
485buildipcop() {
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 xampp
626 ipcopmake pam
627 ipcopmake pammysql
628 ipcopmake saslauthd
629 ipcopmake postfix
630 ipcopmake stund
631 ipcopmake lpd
632 ipcopmake pwlib
633 ipcopmake openh323
634
635}
636
637buildinstaller() {
638 # Run installer scripts one by one
639 LOGFILE="$BASEDIR/log/_build.installer.log"
640 export LOGFILE
641 echo -ne "`date -u '+%b %e %T'`: Stage4 installer build \n" | tee -a $LOGFILE
642 if [ 'i386' = $MACHINE ]; then
643 ipcopmake syslinux
644 ipcopmake as86
645 ipcopmake mbr
646 ipcopmake uClibc
647 fi
648 installmake busybox
649 installmake sysvinit
650 installmake e2fsprogs
651 installmake misc-progs
652 installmake slang
653 installmake util-linux
654 installmake newt
655 installmake pciutils
656 installmake pcmcia-cs
657 installmake kbd
658 installmake installer
659 installmake scsi.img
660 installmake driver.img
661 installmake initrd
662 installmake boot.img
663}
664
665buildpackages() {
666 LOGFILE="$BASEDIR/log/_build.packages.log"
667 export LOGFILE
668 echo "... see detailed log in _build.*.log files" >> $LOGFILE
669 echo -ne "`date -u '+%b %e %T'`: Stage5 packages build \n" | tee -a $LOGFILE
670 # Strip files
671 echo "`date -u '+%b %e %T'`: Stripping files" | tee -a $LOGFILE
672 find $LFS/lib $LFS/usr/lib $LFS/usr/share/rrdtool-* $LFS/install ! -type l \( -name '*.so' -o -name '*.so[\.0-9]*' \) \
673 ! -name 'libc.so' ! -name 'libpthread.so' ! -name 'libcrypto.so.0.9.7.sha1' \
674 -ls -exec $LFS/tools/bin/strip --strip-all {} \; >> $LOGFILE 2>&1
675 # add -ls before -exec if you want to verify what files are stripped
676
677 find $LFS/{,s}bin $LFS/usr/{,s}bin $LFS/usr/local/{,s}bin ! -type l \
678 -exec file {} \; | grep " ELF " | cut -f1 -d ':' | xargs $LFS/tools/bin/strip --strip-all >> $LOGFILE 2>&1
679 # there add -v to strip to verify
680
681 if [ 'i386' = $MACHINE ]; then
682 # Create fcdsl packages
683 echo "`date -u '+%b %e %T'`: Building fcdsl tgz" | tee -a $LOGFILE
684 cp $LFS/install/images/fcdsl/license.txt $LFS >> $LOGFILE 2>&1
685 touch $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
686 cd $LFS && tar cvfz $LFS/install/images/$SNAME-fcdsl-$VERSION.$MACHINE.tgz \
687 lib/modules/$KVER/misc/fcdsl*.o.gz \
688 lib/modules/$KVER-smp/misc/fcdsl*.o.gz \
689 usr/lib/isdn/{fds?base.bin,fd?ubase.frm} \
690 etc/fcdsl/fcdsl*.conf \
691 etc/drdsl/{drdsl,drdsl.ini} \
692 license.txt \
693 var/run/{need-depmod-$KVER,need-depmod-$KVER-smp} >> $LOGFILE 2>&1
694 rm -f $LFS/license.txt >> $LOGFILE 2>&1
695 cd $BASEDIR
696 fi
697
698# Create update for this version
699# echo "`date -u '+%b %e %T'`: Building update $VERSION tgz" | tee -a $LOGFILE
700# tar -cz -C $BASEDIR/build --files-from=$BASEDIR/updates/$VERSION/ROOTFILES.$MACHINE-$VERSION -f $BASEDIR/updates/$VERSION/patch.tar.gz --exclude='#*';
701# chmod 755 $BASEDIR/updates/$VERSION/setup
702# tar -cz -C $BASEDIR/updates/$VERSION -f $LFS/install/images/$SNAME-update-$VERSION.$MACHINE.tgz patch.tar.gz setup information
703# rm -f $LFS/var/run/{need-depmod-$KVER,need-depmod-$KVER-smp}
704
705 # Generating list of packages used
706 echo "`date -u '+%b %e %T'`: Generating packages list from logs" | tee -a $LOGFILE
707 rm -f $BASEDIR/doc/packages-list
708 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
709 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
710 echo " * `basename $i`" >>$BASEDIR/doc/packages-list
711 fi
712 done
713 echo "====== List of softwares used to build $NAME Version: $VERSION ======" > $BASEDIR/doc/packages-list.txt
714 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|ipcop$\|setup$\|stage2$\|smp$\|tools$\|tools1$\|tools2$' \
715 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
716 rm -f $BASEDIR/doc/packages-list
717 # packages-list.txt is ready to be displayed for wiki page IPCopSoftwares
718
719 # Create ISO for CDRom and USB-superfloppy
720 ipcopmake cdrom
721 cp $LFS/install/images/{*.iso,*.tgz} $BASEDIR >> $LOGFILE 2>&1
722
723 # Cleanup
724 stdumount
725 rm -rf $BASEDIR/build/tmp/*
726
727 # Generating total list of files
728 echo "`date -u '+%b %e %T'`: Generating files list from logs" | tee -a $LOGFILE
729 rm -f $BASEDIR/log/FILES
730 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
731 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
732 echo "##" >>$BASEDIR/log/FILES
733 echo "## `basename $i`" >>$BASEDIR/log/FILES
734 echo "##" >>$BASEDIR/log/FILES
735 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
736 fi
737 done
738
739 cd $PWD
740
741}
742
743# See what we're supposed to do
744case "$1" in
745build)
746 BUILDMACHINE=`uname -m`
747 PACKAGE=`ls -v -r $BASEDIR/cache/$SNAME-1.4.*-toolchain-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
748 #only restore on a clean disk
749 if [ ! -f log/perl-*-tools ]; then
750 if [ ! -n "$PACKAGE" ]; then
751 echo "`date -u '+%b %e %T'`: Full toolchain compilation" | tee -a $LOGFILE
752 prepareenv
753 buildtoolchain
754 else
755 PACKAGENAME=${PACKAGE%.tar.gz}
756 echo "`date -u '+%b %e %T'`: Restore from $PACKAGE" | tee -a $LOGFILE
757 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
758 tar zxf $PACKAGE
759 prepareenv
760 else
761 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
762 fi
763 fi
764 else
765 echo "`date -u '+%b %e %T'`: Using installed toolchain" | tee -a $LOGFILE
766 prepareenv
767 fi
768 buildbase
769 buildipcop
770 buildinstaller
771 buildpackages
772 ;;
773shell)
774 # enter a shell inside LFS chroot
775 # may be used to changed kernel settings
776 prepareenv
777 entershell
778 ;;
779changelog)
780 echo "Building doc/Changelog from CVS"
781 # cv2cl script come from http://www.red-bean.com/cvs2cl/
782 if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
783 BRANCHOPTS=""
784 else
785 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
786 BRANCH=${BRANCH:1}
787 BRANCHOPTS="--follow-only $BRANCH"
788 fi
789
790 $BASEDIR/tools/cvs2cl.pl --gmt --show-dead $BRANCHOPTS -f $BASEDIR/doc/ChangeLog
791 rm -f $BASEDIR/doc/ChangeLog.bak
792 echo
793 echo "Commit the change now to update CVS"
794 ;;
795check)
796 echo "Checking sources files availability on the web"
797 if [ ! -d $DIR_CHK ]; then
798 mkdir -p $DIR_CHK
799 fi
800 FINISHED=0
801 cd $BASEDIR/lfs
802 for c in `seq $MAX_RETRIES`; do
803 if (( FINISHED==1 )); then
804 break
805 fi
806 FINISHED=1
807 cd $BASEDIR/lfs
808 for i in *; do
809 if [ -f "$i" -a "$i" != "Config" ]; then
810 make -s -f $i MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR ROOT=$BASEDIR/build \
811 MESSAGE="$i\t ($c/$MAX_RETRIES)" check
812 if [ $? -ne 0 ]; then
813 echo "Check : wget error in lfs/$i"
814 FINISHED=0
815 fi
816 fi
817 done
818 done
819 cd -
820 ;;
821checkclean)
822 echo "Erasing sources files availability tags"
823 rm -rf $DIR_CHK/*
824 ;;
825clean)
826 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
827 $LOSETUP -d $i 2>/dev/null
828 done
829 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
830 umount $i
831 done
832 stdumount
833 for i in `seq 0 7`; do
834 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
835 umount /dev/loop${i} 2>/dev/null;
836 losetup -d /dev/loop${i} 2>/dev/null;
837 fi;
838 done
839 rm -rf $BASEDIR/build
840 rm -rf $BASEDIR/cdrom
841 rm -rf $BASEDIR/log
842 rm -f $BASEDIR/updates/$VERSION/patch.tar.gz;
843 if [ -h /tools ]; then
844 rm -f /tools
845 fi
846 ;;
847dist)
848 echo "Building source package from CVS, list of changed files, MD5 of release files"
849 if [ ! -s $BASEDIR/doc/CVS/Tag ]; then
850 BRANCH=""
851 BRANCHOPTS="-D `date +'%Y-%m-%d'`"
852 else
853 BRANCH=`cat $BASEDIR/doc/CVS/Tag`
854 BRANCH=${BRANCH:1}
855 BRANCHOPTS="-r $BRANCH"
856 fi
857
858 rm -rf $BASEDIR/build/tmp/$SNAME-$VERSION $BASEDIR/doc/release.txt
859 cd $BASEDIR/build/tmp
860 # build sources tgz
861 echo "Export tree $BRANCH $SNAME-$VERSION"
862 cvs -z3 -d `cat $BASEDIR/CVS/Root` export $BRANCHOPTS ipcop
863 if [ $? -eq 0 ]; then
864 mv ipcop $SNAME-$VERSION
865 tar cfz $BASEDIR/$SNAME-sources-$VERSION.tgz $SNAME-$VERSION
866 cd $BASEDIR
867
868 if [ ! -d $BASEDIR/build/tmp/$PREVIOUSTAG ]; then
869 # export previous version to be compared with actual, this help to check wich files need to go in update
870 cd $BASEDIR/build/tmp
871 echo "Export tree $PREVIOUSTAG"
872 cvs -z3 -d `cat $BASEDIR/CVS/Root` export -r $PREVIOUSTAG ipcop
873 mv ipcop $PREVIOUSTAG
874 fi
875 if [ -d $BASEDIR/build/tmp/$PREVIOUSTAG -o -d $BASEDIR/build/tmp/$SNAME-$VERSION ]; then
876 cd $BASEDIR/build/tmp
877 echo "diff $PREVIOUSTAG <> $BRANCH $SNAME-$VERSION >doc/updated-sources.txt"
878 diff -rq $PREVIOUSTAG $SNAME-$VERSION > $BASEDIR/doc/updated-sources.txt
879 mv $BASEDIR/doc/updated-sources.txt $BASEDIR/doc/updated-sources.bak
880 sed -e "s+Files $PREVIOUSTAG\/++" \
881 -e "s+ and .*$++" \
882 -e "s+src/rc.d+etc/rc.d+" \
883 -e "s+^langs/+var/ipcop/langs/+" \
884 -e "s+html/cgi-bin+home/httpd/cgi-bin+" $BASEDIR/doc/updated-sources.bak \
885 > $BASEDIR/doc/updated-sources.txt
886 rm -f $BASEDIR/doc/updated-sources.bak
887 fi
888 fi
889 ;;
890newupdate)
891 # create structure for $VERSION update
892 if [ ! -f "updates/$VERSION" ]; then
893 mkdir -p updates/$VERSION
894 cd updates/$VERSION
895 touch information
896 echo 'etc/issue' > ROOTFILES.alpha-$VERSION
897 echo 'etc/issue' > ROOTFILES.i386-$VERSION
898 echo 'patch.tar.gz' > .cvsignore
899 sed -e "s+^UPGRADEVERSION.*$+UPGRADEVERSION=$VERSION+" $BASEDIR/src/scripts/updatesetup > setup
900 chmod 755 setup
901 cd ..
902 echo "Adding directory $VERSION to cvs"
903 cvs add $VERSION
904 echo "Adding files to cvs"
905 cvs add $VERSION/ROOTFILES.alpha-$VERSION \
906 $VERSION/ROOTFILES.i386-$VERSION \
907 $VERSION/information \
908 $VERSION/setup \
909 $VERSION/.cvsignore
910 else
911 echo "update/$VERSION already exist"
912 fi
913 cd -
914 exit 0
915 ;;
916prefetch)
917 if [ ! -d $BASEDIR/cache ]; then
918 mkdir $BASEDIR/cache
919 fi
920 mkdir -p $BASEDIR/log
921 echo "`date -u '+%b %e %T'`:Preload all source files" | tee -a $LOGFILE
922 FINISHED=0
923 cd $BASEDIR/lfs
924 for c in `seq $MAX_RETRIES`; do
925 if (( FINISHED==1 )); then
926 break
927 fi
928 FINISHED=1
929 cd $BASEDIR/lfs
930 for i in *; do
931 if [ -f "$i" -a "$i" != "Config" ]; then
932 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
933 if [ $? -ne 0 ]; then
934 echo "Prefetch : wget error in lfs/$i"
935 FINISHED=0
936 else
937 if [ $c -eq 1 ]; then
938 echo "Prefetch : lfs/$i files loaded"
939 fi
940 fi
941 fi
942 done
943 done
944 echo "Prefetch : verifying md5sum"
945 ERROR=0
946 for i in *; do
947 if [ -f "$i" -a "$i" != "Config" ]; then
948 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
949 if [ $? -ne 0 ]; then
950 echo "md5 difference in lfs/$i"
951 ERROR=1
952 fi
953 fi
954 done
955 if [ $ERROR -eq 0 ]; then
956 echo "Prefetch : all files md5sum match"
957 fi
958 cd -
959 ;;
960rootfiles)
961 PREVIOUSVERSION=`echo $PREVIOUSTAG | sed -e 's/IPCOP_v//' -e 's/_FINAL//' -e 's/_/\./g'`
962 # make md5 list of actual build
963 # some packages include a timestamp (kernel/perl/python/vim and more), so md5 vary at each build
964 # anyway, it is sometime usable after a patch or a minor upgrade to know wich files include in update
965 if [ ! -f "$BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz" ]; then
966 echo "need cdrom be build to read include files list, use ./make.sh build before."
967 else
968 tar tzf $BASEDIR/build/install/cdrom/$SNAME-$VERSION.tgz > $BASEDIR/updates/$VERSION/FILES.tmp
969 cd $BASEDIR/build
970 rm -f $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
971 for line in `cat $BASEDIR/updates/$VERSION/FILES.tmp`; do
972 if [ -f "$line" -a ! -L "$line" ]; then
973 md5sum "$line" >> $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5
974 fi
975 done
976 diff $BASEDIR/updates/$PREVIOUSVERSION/FILES-$MACHINE-$PREVIOUSVERSION.md5 \
977 $BASEDIR/updates/$VERSION/FILES-$MACHINE-$VERSION.md5 \
978 > $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff
979 awk '$1==">" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
980 > $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE
981 awk '$1=="<" {print $3}' $BASEDIR/updates/$VERSION/FILES-$MACHINE.diff \
982 > $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp
983 rm -f $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
984 for line in `cat $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE.tmp`; do
985 # a file is only removed when not in add file
986 if ( ! grep -q "^$line$" $BASEDIR/updates/$VERSION/ROOTFILES.add.$MACHINE ); then
987 echo $line >> $BASEDIR/updates/$VERSION/ROOTFILES.remove.$MACHINE
988 fi
989 done
990 rm -f $BASEDIR/updates/$VERSION/{FILES.tmp,FILES-*.diff,ROOTFILES.remove.*.tmp}
991 fi
992 exit 0
993 ;;
994toolchain)
995 prepareenv
996 buildtoolchain
997 BUILDMACHINE=`uname -m`
998 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
999 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1000 build/{bin,etc,usr/bin,usr/local} \
1001 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
1002 log >> $LOGFILE
1003 md5sum cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.tar.gz \
1004 > cache/$SNAME-$VERSION-toolchain-$BUILDMACHINE.md5
1005 stdumount
1006 ;;
1007gettoolchain)
1008 BUILDMACHINE=`uname -m`
1009 # arbitrary name to be updated in case of new toolchain package upload
1010 PACKAGE=$SNAME-1.4.11-toolchain-$BUILDMACHINE
1011 URL_SFNET=`grep URL_SFNET lfs/Config | awk '{ print $3 }'`
1012 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
1013 cd $BASEDIR/cache
1014 wget -c $URL_SFNET/ipcop/$PACKAGE.tar.gz $URL_SFNET/ipcop/$PACKAGE.md5
1015 if [ $? -ne 0 ]; then
1016 echo "`date -u '+%b %e %T'`: error downloading toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
1017 else
1018 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1019 echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1020 else
1021 exiterror "$PACKAGE.md5 did not match, check downloaded package"
1022 fi
1023 fi
1024 ;;
1025*)
1026 echo "Usage: $0 {build|changelog|check|checkclean|clean|dist|gettoolchain|newupdate|prefetch|rootfiles|shell|toolchain}"
1027 cat doc/make.sh-usage
1028 exit 1
1029 ;;
1030esac