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