]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame_incremental - make.sh
Fix mISDN build
[people/teissler/ipfire-2.x.git] / make.sh
... / ...
CommitLineData
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) 2007 IPFire-Team <info@ipfire.org>. #
21# #
22############################################################################
23#
24
25NAME="IPFire" # Software name
26SNAME="ipfire" # Short name
27VERSION="2.3"
28CORE="28"
29GIT_BRANCH=master:master # Version number
30SLOGAN="www.ipfire.org" # Software slogan
31CONFIG_ROOT=/var/ipfire # Configuration rootdir
32NICE=10 # Nice level
33MAX_RETRIES=1 # prefetch/check loop
34KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
35MACHINE=`uname -m`
36GIT_TAG=$(git tag | tail -1)
37TOOLCHAINVER=1
38IPFVER="full" # Which versions should be compiled? (full|devel)
39
40# Debian specific settings
41if [ ! -e /etc/debian_version ]; then
42 FULLPATH=`which $0`
43else
44 if [ -x /usr/bin/realpath ]; then
45 FULLPATH=`/usr/bin/realpath $0`
46 else
47 echo "ERROR: Need to do apt-get install realpath"
48 exit 1
49 fi
50fi
51
52PWD=`pwd`
53BASENAME=`basename $0`
54BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
55LOGFILE=$BASEDIR/log/_build.preparation.log
56export BASEDIR LOGFILE
57DIR_CHK=$BASEDIR/cache/check
58mkdir $BASEDIR/log/ 2>/dev/null
59
60# Include funtions
61. tools/make-functions
62
63if [ -f .config ]; then
64 . .config
65else
66 echo -e "${BOLD}No configuration found!${NORMAL}"
67 echo -ne "Do you want to create one (y/N)?"
68 read CREATE_CONFIG
69 echo ""
70 if [ "$CREATE_CONFIG" == "y" ]; then
71 make_config
72 fi
73fi
74
75if [ -z $EDITOR ]; then
76 for i in nano emacs vi; do
77 EDITOR=$(which $i 2>/dev/null)
78 if ! [ -z $EDITOR ]; then
79 export EDITOR=$EDITOR
80 break
81 fi
82 done
83 [ -z $EDITOR ] && exiterror "You should have installed an editor."
84fi
85
86prepareenv() {
87 ############################################################################
88 # #
89 # Are we running the right shell? #
90 # #
91 ############################################################################
92 if [ ! "$BASH" ]; then
93 exiterror "BASH environment variable is not set. You're probably running the wrong shell."
94 fi
95
96 if [ -z "${BASH_VERSION}" ]; then
97 exiterror "Not running BASH shell."
98 fi
99
100
101 ############################################################################
102 # #
103 # Trap on emergency exit #
104 # #
105 ############################################################################
106 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
107
108
109 ############################################################################
110 # #
111 # Resetting our nice level #
112 # #
113 ############################################################################
114 echo -ne "Resetting our nice level to $NICE" | tee -a $LOGFILE
115 renice $NICE $$ > /dev/null
116 if [ `nice` != "$NICE" ]; then
117 beautify message FAIL
118 exiterror "Failed to set correct nice level"
119 else
120 beautify message DONE
121 fi
122
123
124 ############################################################################
125 # #
126 # Checking if running as root user #
127 # #
128 ############################################################################
129 echo -ne "Checking if we're running as root user" | tee -a $LOGFILE
130 if [ `id -u` != 0 ]; then
131 beautify message FAIL
132 exiterror "Not building as root"
133 else
134 beautify message DONE
135 fi
136
137
138 ############################################################################
139 # #
140 # Checking for necessary temporary space #
141 # #
142 ############################################################################
143 echo -ne "Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
144 BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
145 BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
146 if (( 2048000 > $BASE_ASPACE )); then
147 BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
148 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
149 beautify message FAIL
150 exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
151 fi
152 else
153 beautify message DONE
154 fi
155
156 ############################################################################
157 # #
158 # Building Linux From Scratch system #
159 # #
160 ############################################################################
161 # Set umask
162 umask 022
163
164 # Set LFS Directory
165 LFS=$BASEDIR/build
166
167 # Check /tools symlink
168 if [ -h /tools ]; then
169 rm -f /tools
170 fi
171 if [ ! -a /tools ]; then
172 ln -s $BASEDIR/build/tools /
173 fi
174 if [ ! -h /tools ]; then
175 exiterror "Could not create /tools symbolic link."
176 fi
177
178 # Setup environment
179 set +h
180 LC_ALL=POSIX
181 if [ -z $MAKETUNING ]; then
182 MAKETUNING="-j6"
183 fi
184 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
185 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
186
187 # Make some extra directories
188 mkdir -p $BASEDIR/build/{tools,etc,usr/src} 2>/dev/null
189 mkdir -p $BASEDIR/build/{dev/{shm,pts},proc,sys}
190 mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
191 mkdir -p $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
192
193 mknod -m 600 $BASEDIR/build/dev/console c 5 1 2>/dev/null
194 mknod -m 666 $BASEDIR/build/dev/null c 1 3 2>/dev/null
195
196 # Make all sources and proc available under lfs build
197 mount --bind /dev $BASEDIR/build/dev
198 mount --bind /dev/pts $BASEDIR/build/dev/pts
199 mount --bind /dev/shm $BASEDIR/build/dev/shm
200 mount --bind /proc $BASEDIR/build/proc
201 mount --bind /sys $BASEDIR/build/sys
202 mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache
203 mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
204 mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
205 mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc
206 mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html
207 mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs
208 mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs
209 mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log
210 mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src
211
212 # This is a temporary hack!!!
213 if [ ! -f /tools/bin/hostname ]; then
214 cp -f /bin/hostname /tools/bin/hostname 2>/dev/null
215 fi
216
217 # Run LFS static binary creation scripts one by one
218 export CCACHE_DIR=$BASEDIR/ccache
219 export CCACHE_HASHDIR=1
220
221 # Remove pre-install list of installed files in case user erase some files before rebuild
222 rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
223}
224
225buildtoolchain() {
226 LOGFILE="$BASEDIR/log/_build.toolchain.log"
227 export LOGFILE
228 ORG_PATH=$PATH
229 NATIVEGCC=`gcc --version | grep GCC | awk {'print $3'}`
230 export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
231 lfsmake1 ccache
232 lfsmake1 binutils PASS=1
233 lfsmake1 gcc PASS=1
234 export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
235 lfsmake1 linux-libc-header
236 lfsmake1 glibc
237 lfsmake1 cleanup-toolchain PASS=1
238 lfsmake1 tcl
239 lfsmake1 expect
240 lfsmake1 dejagnu
241 lfsmake1 gcc PASS=2
242 lfsmake1 binutils PASS=2
243 lfsmake1 ncurses
244 lfsmake1 bash
245 lfsmake1 bzip2
246 lfsmake1 coreutils
247 lfsmake1 diffutils
248 lfsmake1 findutils
249 lfsmake1 gawk
250 lfsmake1 gettext
251 lfsmake1 grep
252 lfsmake1 gzip
253 lfsmake1 m4
254 lfsmake1 make
255 lfsmake1 patch
256 lfsmake1 perl
257 lfsmake1 sed
258 lfsmake1 tar
259 lfsmake1 texinfo
260 lfsmake1 util-linux
261 lfsmake1 cleanup-toolchain PASS=2
262 export PATH=$ORG_PATH
263}
264
265buildbase() {
266 LOGFILE="$BASEDIR/log/_build.base.log"
267 export LOGFILE
268 lfsmake2 stage2
269 lfsmake2 linux-libc-header
270 lfsmake2 man-pages
271 lfsmake2 glibc
272 lfsmake2 cleanup-toolchain PASS=3
273 lfsmake2 binutils
274 lfsmake2 gcc
275 lfsmake2 berkeley
276 lfsmake2 coreutils
277 lfsmake2 iana-etc
278 lfsmake2 m4
279 lfsmake2 bison
280 lfsmake2 ncurses
281 lfsmake2 procps
282 lfsmake2 sed
283 lfsmake2 libtool
284 lfsmake2 perl
285 lfsmake2 readline
286 lfsmake2 zlib
287 lfsmake2 autoconf
288 lfsmake2 automake
289 lfsmake2 bash
290 lfsmake2 bzip2
291 lfsmake2 diffutils
292 lfsmake2 e2fsprogs
293 lfsmake2 ed
294 lfsmake2 file
295 lfsmake2 findutils
296 lfsmake2 flex
297 lfsmake2 gawk
298 lfsmake2 gettext
299 lfsmake2 grep
300 lfsmake2 groff
301 lfsmake2 gzip
302 lfsmake2 inetutils
303 lfsmake2 iproute2
304 lfsmake2 kbd
305 lfsmake2 less
306 lfsmake2 libaal
307 lfsmake2 make
308 lfsmake2 man
309 lfsmake2 mktemp
310 lfsmake2 module-init-tools
311 lfsmake2 mtd
312 lfsmake2 net-tools
313 lfsmake2 patch
314 lfsmake2 psmisc
315 lfsmake2 reiser4progs
316 lfsmake2 shadow
317 lfsmake2 sysklogd
318 lfsmake2 sysvinit
319 lfsmake2 tar
320 lfsmake2 texinfo
321 lfsmake2 udev
322 lfsmake2 util-linux
323 lfsmake2 vim
324 lfsmake2 grub
325}
326
327buildipfire() {
328 LOGFILE="$BASEDIR/log/_build.ipfire.log"
329 export LOGFILE
330 ipfiremake configroot
331 ipfiremake backup
332 ipfiremake dhcp
333 ipfiremake dhcpcd
334 ipfiremake libusb
335 ipfiremake libpcap
336 ipfiremake ppp
337 ipfiremake rp-pppoe
338 ipfiremake pptp
339 ipfiremake unzip
340 ipfiremake linux
341 ipfiremake atl2
342 ipfiremake kqemu
343 ipfiremake v4l-dvb
344 ipfiremake madwifi
345 ipfiremake alsa KMOD=1
346 ipfiremake openswan KMOD=1
347 ipfiremake mISDN
348 ipfiremake which
349 ipfiremake compat-wireless
350 ipfiremake linux XEN=1
351 ipfiremake pkg-config
352 ipfiremake linux-atm
353 ipfiremake cpio
354 ipfiremake klibc
355 ipfiremake mkinitcpio
356 ipfiremake udev KLIBC=1
357 ipfiremake expat
358 ipfiremake gdbm
359 ipfiremake gmp
360 ipfiremake pam
361 ipfiremake openssl
362 ipfiremake curl
363 ipfiremake python
364 ipfiremake libnet
365 ipfiremake libnl
366 ipfiremake libidn
367 ipfiremake libjpeg
368 ipfiremake libpng
369 ipfiremake libtiff
370 ipfiremake libart
371 ipfiremake freetype
372 ipfiremake gd
373 ipfiremake popt
374 ipfiremake pcre
375 ipfiremake slang
376 ipfiremake newt
377 ipfiremake libcap
378 ipfiremake pciutils
379 ipfiremake usbutils
380 ipfiremake libxml2
381 ipfiremake libxslt
382 ipfiremake BerkeleyDB
383 ipfiremake mysql
384 ipfiremake cyrus-sasl
385 ipfiremake openldap
386 ipfiremake apache2
387 ipfiremake php
388 ipfiremake apache2 PASS=C
389 ipfiremake arping
390 ipfiremake beep
391 ipfiremake bind
392 ipfiremake cdrtools
393 ipfiremake dnsmasq
394 ipfiremake dosfstools
395 ipfiremake squashfstools
396 ipfiremake reiserfsprogs
397 ipfiremake xfsprogs
398 ipfiremake sysfsutils
399 ipfiremake fuse
400 ipfiremake ntfs-3g
401 ipfiremake ethtool
402 ipfiremake ez-ipupdate
403 ipfiremake fcron
404 ipfiremake perl-GD
405 ipfiremake GD-Graph
406 ipfiremake GD-TextUtil
407 ipfiremake gnupg
408 ipfiremake hdparm
409 ipfiremake sdparm
410 ipfiremake mtools
411 ipfiremake initscripts
412 ipfiremake whatmask
413 ipfiremake iptables
414 ipfiremake libupnp
415 ipfiremake ipaddr
416 ipfiremake iptstate
417 ipfiremake iputils
418 ipfiremake l7-protocols
419 ipfiremake mISDNuser
420 ipfiremake capi4k-utils
421 ipfiremake hwdata
422 ipfiremake kudzu
423 ipfiremake logrotate
424 ipfiremake logwatch
425 ipfiremake misc-progs
426 ipfiremake nano
427 ipfiremake nasm
428 ipfiremake URI
429 ipfiremake HTML-Tagset
430 ipfiremake HTML-Parser
431 ipfiremake Compress-Zlib
432 ipfiremake Digest
433 ipfiremake Digest-SHA1
434 ipfiremake Digest-HMAC
435 ipfiremake libwww-perl
436 ipfiremake Net-DNS
437 ipfiremake Net-IPv4Addr
438 ipfiremake Net_SSLeay
439 ipfiremake IO-Stringy
440 ipfiremake Unix-Syslog
441 ipfiremake Mail-Tools
442 ipfiremake MIME-Tools
443 ipfiremake Net-Server
444 ipfiremake Convert-TNEF
445 ipfiremake Convert-UUlib
446 ipfiremake Archive-Tar
447 ipfiremake Archive-Zip
448 ipfiremake Text-Tabs+Wrap
449 ipfiremake Locale-Country
450 ipfiremake XML-Parser
451 ipfiremake python-setuptools
452 ipfiremake python-clientform
453 ipfiremake python-mechanize
454 ipfiremake python-feedparser
455 ipfiremake python-rssdler
456 ipfiremake glib
457 ipfiremake GeoIP
458 ipfiremake fwhits
459 ipfiremake noip_updater
460 ipfiremake ntp
461 ipfiremake openssh
462 ipfiremake rrdtool
463 ipfiremake setserial
464 ipfiremake setup
465 ipfiremake snort
466 ipfiremake oinkmaster
467 ipfiremake squid
468 ipfiremake squidguard
469 ipfiremake calamaris
470 ipfiremake tcpdump
471 ipfiremake traceroute
472 ipfiremake vlan
473 ipfiremake wireless
474 ipfiremake libsafe
475 ipfiremake pakfire
476 ipfiremake java
477 ipfiremake spandsp
478 ipfiremake lzo
479 ipfiremake openvpn
480 ipfiremake pammysql
481 ipfiremake cups
482 ipfiremake ghostscript
483 ipfiremake foomatic
484 ipfiremake hplip
485 ipfiremake samba
486 ipfiremake sudo
487 ipfiremake mc
488 ipfiremake wget
489 ipfiremake bridge-utils
490 ipfiremake screen
491 ipfiremake hddtemp
492 ipfiremake smartmontools
493 ipfiremake htop
494 ipfiremake postfix
495 ipfiremake fetchmail
496 ipfiremake cyrus-imapd
497 ipfiremake openmailadmin
498 ipfiremake clamav
499 ipfiremake spamassassin
500 ipfiremake amavisd
501 ipfiremake alsa
502 ipfiremake mpfire
503 ipfiremake guardian
504 ipfiremake libid3tag
505 ipfiremake libmad
506 ipfiremake libogg
507 ipfiremake libvorbis
508 ipfiremake libdvbpsi
509 ipfiremake lame
510 ipfiremake sox
511 ipfiremake libshout
512 ipfiremake xvid
513 ipfiremake libmpeg2
514 ipfiremake cmake
515 ipfiremake libpri
516 ipfiremake asterisk
517 ipfiremake gnump3d
518 ipfiremake libsigc++
519 ipfiremake applejuice
520 ipfiremake ocaml
521 ipfiremake mldonkey
522 ipfiremake libtorrent
523 ipfiremake rtorrent
524 ipfiremake ipfireseeder
525 ipfiremake rsync
526 ipfiremake tcpwrapper
527 ipfiremake portmap
528 ipfiremake nfs
529 ipfiremake nmap
530 ipfiremake ncftp
531 ipfiremake etherwake
532 ipfiremake bwm-ng
533 ipfiremake tripwire
534 ipfiremake sysstat
535 ipfiremake vsftpd
536 ipfiremake openswan
537 ipfiremake lsof
538 ipfiremake centerim
539 ipfiremake br2684ctl
540 ipfiremake pcmciautils
541 ipfiremake lm_sensors
542 ipfiremake collectd
543 ipfiremake lcd4linux
544 ipfiremake tcptrack
545 ipfiremake teamspeak
546 ipfiremake elinks
547 ipfiremake igmpproxy
548 ipfiremake fbset
549 ipfiremake sdl
550 ipfiremake qemu
551 ipfiremake sane
552 ipfiremake netpbm
553 ipfiremake phpSANE
554 ipfiremake tunctl
555 ipfiremake nagios
556 ipfiremake ebtables
557 ipfiremake fontconfig
558 ipfiremake freefont
559 ipfiremake directfb
560 ipfiremake dfb++
561 ipfiremake ffmpeg
562 ipfiremake videolan
563 ipfiremake vdr
564 ipfiremake w_scan
565 ipfiremake icecast
566 ipfiremake icegenerator
567 ipfiremake mpd
568 ipfiremake mpc
569 ipfiremake git
570 ipfiremake squidclamav
571 ipfiremake bc
572 ipfiremake esniper
573 ipfiremake vnstat
574 ipfiremake vnstati
575 ipfiremake iw
576 ipfiremake wpa_supplicant
577 ipfiremake hostapd
578 ipfiremake urlgrabber
579 ipfiremake syslinux
580 ipfiremake tftpd
581 ipfiremake cpufrequtils
582 ipfiremake dbus
583 ipfiremake bluetooth
584 ipfiremake gutenprint
585 ipfiremake apcupsd
586 ipfiremake iperf
587 ipfiremake netcat
588 ipfiremake 7zip
589 ipfiremake lynis
590 ipfiremake cryptsetup
591 ipfiremake splix
592 ipfiremake streamripper
593 ipfiremake sshfs
594 ipfiremake sqlite
595 ipfiremake taglib
596# ipfiremake mediatomb
597 ipfiremake sslh
598 ipfiremake perl-gettext
599 ipfiremake vdradmin
600 ipfiremake x11libs
601 ipfiremake xen
602 ipfiremake miau
603 ipfiremake net-snmp
604 ipfiremake perl-DBI
605 ipfiremake perl-DBD-mysql
606 ipfiremake lcr
607 echo Build on $HOSTNAME > $BASEDIR/build/var/ipfire/firebuild
608 cat /proc/version >> $BASEDIR/build/var/ipfire/firebuild
609 echo >> $BASEDIR/build/var/ipfire/firebuild
610 git log -1 >> $BASEDIR/build/var/ipfire/firebuild
611 echo >> $BASEDIR/build/var/ipfire/firebuild
612 git status >> $BASEDIR/build/var/ipfire/firebuild
613 echo >> $BASEDIR/build/var/ipfire/firebuild
614 cat /proc/cpuinfo >> $BASEDIR/build/var/ipfire/firebuild
615 echo $CORE > $BASEDIR/build/opt/pakfire/db/core/mine
616}
617
618buildinstaller() {
619 # Run installer scripts one by one
620 LOGFILE="$BASEDIR/log/_build.installer.log"
621 export LOGFILE
622 ipfiremake as86
623 ipfiremake mbr
624 ipfiremake memtest
625 installmake linux-libc-header
626 installmake binutils
627 ipfiremake uClibc PASS=1
628 ipfiremake gcc INST=1
629 installmake uClibc PASS=2
630 installmake gcc INST=2
631 installmake uClibc PASS=3
632 installmake busybox
633 installmake udev
634 installmake slang
635 installmake newt
636 installmake gettext
637 installmake kbd
638 installmake popt
639 installmake sysvinit
640 installmake misc-progs
641 installmake libaal
642 installmake reiser4progs
643 installmake reiserfsprogs
644 installmake sysfsutils
645 installmake util-linux
646 installmake pciutils
647 installmake zlib
648 installmake mtd
649 installmake wget
650 installmake hwdata
651 installmake kudzu
652 installmake pcmciautils
653 installmake installer
654 installmake initrd
655}
656
657buildpackages() {
658 LOGFILE="$BASEDIR/log/_build.packages.log"
659 export LOGFILE
660 echo "... see detailed log in _build.*.log files" >> $LOGFILE
661
662 installmake strip
663
664 # Generating list of packages used
665 echo -n "Generating packages list from logs" | tee -a $LOGFILE
666 rm -f $BASEDIR/doc/packages-list
667 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
668 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
669 echo "* `basename $i`" >>$BASEDIR/doc/packages-list
670 fi
671 done
672 echo "== List of softwares used to build $NAME Version: $VERSION ==" > $BASEDIR/doc/packages-list.txt
673 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|setup$\|pakfire$\|stage2$\|smp$\|tools$\|tools1$\|tools2$\|.tgz$\|-config$\|_missing_rootfile$\|install1$\|install2$\|pass1$\|pass2$\|pass3$' \
674 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
675 rm -f $BASEDIR/doc/packages-list
676 # packages-list.txt is ready to be displayed for wiki page
677 beautify message DONE
678
679 # Update changelog
680 cd $BASEDIR
681 $0 git log
682
683 # Create images for install
684 ipfiremake cdrom ED=$IPFVER
685
686 # Check if there is a loop device for building in virtual environments
687 if [ -e /dev/loop/0 ] || [ -e /dev/loop0 ]; then
688 ipfiremake usb-stick ED=$IPFVER
689 fi
690
691 # Create updater package
692 #ipfiremake updater
693 mv $LFS/install/images/{*.iso,*.tgz,*.img.gz,*.bz2} $BASEDIR >> $LOGFILE 2>&1
694
695 ipfirepackages
696
697 # Cleanup
698 stdumount
699 rm -rf $BASEDIR/build/tmp/*
700
701 # Generating total list of files
702 echo -n "Generating files list from logs" | tee -a $LOGFILE
703 rm -f $BASEDIR/log/FILES
704 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
705 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
706 echo "##" >>$BASEDIR/log/FILES
707 echo "## `basename $i`" >>$BASEDIR/log/FILES
708 echo "##" >>$BASEDIR/log/FILES
709 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
710 fi
711 done
712 beautify message DONE
713
714 cd $PWD
715}
716
717ipfirepackages() {
718 ipfiremake core-updates
719 for i in $(ls -1 $BASEDIR/config/rootfiles/packages); do
720 if [ -e $BASEDIR/lfs/$i ]; then
721 ipfiredist $i
722 else
723 echo -n $i
724 beautify message SKIP
725 fi
726 done
727 test -d $BASEDIR/packages || mkdir $BASEDIR/packages
728 mv -f $LFS/install/packages/* $BASEDIR/packages >> $LOGFILE 2>&1
729 rm -rf $BASEDIR/build/install/packages/*
730}
731
732# See what we're supposed to do
733case "$1" in
734build)
735 clear
736 BUILDMACHINE=`uname -m`
737 PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.tar.gz 2> /dev/null | head -n 1`
738 #only restore on a clean disk
739 if [ ! -f log/cleanup-toolchain-2-tools ]; then
740 if [ ! -n "$PACKAGE" ]; then
741 beautify build_stage "Full toolchain compilation - Native GCC: `gcc --version | grep GCC | awk {'print $3'}`"
742 prepareenv
743 buildtoolchain
744 else
745 PACKAGENAME=${PACKAGE%.tar.gz}
746 beautify build_stage "Packaged toolchain compilation"
747 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
748 tar zxf $PACKAGE
749 prepareenv
750 else
751 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
752 fi
753 fi
754 else
755 echo -n "Using installed toolchain" | tee -a $LOGFILE
756 beautify message SKIP
757 prepareenv
758 fi
759
760 beautify build_start
761 beautify build_stage "Building LFS"
762 buildbase
763
764 beautify build_stage "Building IPFire"
765 buildipfire
766
767 beautify build_stage "Building installer"
768 buildinstaller
769
770 beautify build_stage "Building packages"
771 buildpackages
772
773 beautify build_stage "Checking Logfiles for new Files"
774 cd ..
775 tools/checknewlog.pl
776
777 beautify build_end
778 ;;
779shell)
780 # enter a shell inside LFS chroot
781 # may be used to changed kernel settings
782 prepareenv
783 entershell
784 ;;
785clean)
786 echo -en "${BOLD}Cleaning build directory...${NORMAL}"
787 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
788 $LOSETUP -d $i 2>/dev/null
789 done
790 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
791 umount $i
792 done
793 stdumount
794 for i in `seq 0 7`; do
795 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
796 umount /dev/loop${i} 2>/dev/null;
797 losetup -d /dev/loop${i} 2>/dev/null;
798 fi;
799 done
800 rm -rf $BASEDIR/build
801 rm -rf $BASEDIR/cdrom
802 rm -rf $BASEDIR/packages
803 rm -rf $BASEDIR/log
804 if [ -h /tools ]; then
805 rm -f /tools
806 fi
807 beautify message DONE
808 ;;
809downloadsrc)
810 if [ ! -d $BASEDIR/cache ]; then
811 mkdir $BASEDIR/cache
812 fi
813 mkdir -p $BASEDIR/log
814 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
815 FINISHED=0
816 cd $BASEDIR/lfs
817 for c in `seq $MAX_RETRIES`; do
818 if (( FINISHED==1 )); then
819 break
820 fi
821 FINISHED=1
822 cd $BASEDIR/lfs
823 for i in *; do
824 if [ -f "$i" -a "$i" != "Config" ]; then
825 echo -ne "Loading $i"
826 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
827 if [ $? -ne 0 ]; then
828 beautify message FAIL
829 FINISHED=0
830 else
831 if [ $c -eq 1 ]; then
832 beautify message DONE
833 fi
834 fi
835 fi
836 done
837 done
838 echo -e "${BOLD}***Verifying md5sums${NORMAL}"
839 ERROR=0
840 for i in *; do
841 if [ -f "$i" -a "$i" != "Config" ]; then
842 make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
843 if [ $? -ne 0 ]; then
844 echo -ne "MD5 difference in lfs/$i"
845 beautify message FAIL
846 ERROR=1
847 fi
848 fi
849 done
850 if [ $ERROR -eq 0 ]; then
851 echo -ne "${BOLD}all files md5sum match${NORMAL}"
852 beautify message DONE
853 else
854 echo -ne "${BOLD}not all files were correctly download${NORMAL}"
855 beautify message FAIL
856 fi
857 cd - >/dev/null 2>&1
858 ;;
859toolchain)
860 clear
861 prepareenv
862 beautify build_stage "Toolchain compilation - Native GCC: `gcc --version | grep GCC | awk {'print $3'}`"
863 buildtoolchain
864 BUILDMACHINE=`uname -m`
865 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
866 test -d $BASEDIR/cache/toolchains || mkdir $BASEDIR/cache/toolchains
867 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.tar.gz \
868 build/{bin,etc,usr/bin,usr/local} \
869 build/tools/{bin,etc,*-linux-gnu,include,lib,libexec,sbin,share,var} \
870 log >> $LOGFILE
871 md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.tar.gz \
872 > cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE.md5
873 stdumount
874 ;;
875gettoolchain)
876 BUILDMACHINE=`uname -m`
877 # arbitrary name to be updated in case of new toolchain package upload
878 PACKAGE=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-$BUILDMACHINE
879 if [ ! -f $BASEDIR/cache/toolchains/$PACKAGE.tar.gz ]; then
880 URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
881 test -d $BASEDIR/cache/toolchains || mkdir $BASEDIR/cache/toolchains
882 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for $BUILDMACHINE" | tee -a $LOGFILE
883 cd $BASEDIR/cache/toolchains
884 wget -U "IPFireSourceGrabber/2.x" $URL_TOOLCHAIN/$PACKAGE.tar.gz $URL_TOOLCHAIN/$PACKAGE.md5 >& /dev/null
885 if [ $? -ne 0 ]; then
886 echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for $BUILDMACHINE machine" | tee -a $LOGFILE
887 else
888 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
889 echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
890 else
891 exiterror "$PACKAGE.md5 did not match, check downloaded package"
892 fi
893 fi
894 else
895 echo "Toolchain is already downloaded. Exiting..."
896 fi
897 ;;
898othersrc)
899 prepareenv
900 echo -ne "`date -u '+%b %e %T'`: Build sources iso for $MACHINE" | tee -a $LOGFILE
901 chroot $LFS /tools/bin/env -i HOME=/root \
902 TERM=$TERM PS1='\u:\w\$ ' \
903 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
904 VERSION=$VERSION NAME="$NAME" SNAME="$SNAME" MACHINE=$MACHINE \
905 /bin/bash -x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
906 mv $LFS/install/images/ipfire-* $BASEDIR >> $LOGFILE 2>&1
907 if [ $? -eq "0" ]; then
908 beautify message DONE
909 else
910 beautify message FAIL
911 fi
912 stdumount
913 ;;
914git)
915 case "$2" in
916 update|up)
917 ## REMOVES ALL UNCOMMITTED CHANGES!
918 [ "$3" == "--force" ] && git checkout -f
919 git pull
920 ;;
921 commit|ci)
922 shift 2
923 git commit $*
924
925 [ "$?" -eq "0" ] || exiterror "git commit $* failed."
926
927 echo -e "${BOLD}Do you want to push, too? [y/N]${NORMAL}"
928 read
929 [ -z $REPLY ] && exit 0
930 for i in y Y j J; do
931 if [ "$i" == "$REPLY" ]; then
932 $0 git push
933 exit $?
934 fi
935 done
936 exiterror "\"$REPLY\" is not a valid answer."
937 ;;
938 dist)
939 git archive HEAD | gzip -9 > ${SNAME}-${VERSION}.tar.gz
940 ;;
941 diff|di)
942 echo -ne "Make a local diff to last revision"
943 git diff HEAD > ipfire-diff-$(date +'%Y-%m-%d-%H:%M').diff
944 evaluate 1
945 echo "Diff was successfully saved to ipfire-diff-$(date +'%Y-%m-%d-%H:%M').diff"
946 git diff --stat
947 ;;
948 push)
949 [ -z $GIT_USER ] && exiterror "You have to setup GIT_USER first."
950 GIT_URL="ssh://${GIT_USER}@git.ipfire.org/pub/git/ipfire-2.x"
951
952 git push ${GIT_URL} ${GIT_BRANCH} $3
953 ;;
954 log)
955 [ -z $GIT_TAG ] || LAST_TAG=$GIT_TAG
956 [ -z $LAST_TAG ] || EXT="$LAST_TAG..HEAD"
957
958 git log -n 500 --no-merges --pretty=medium --shortstat $EXT > $BASEDIR/doc/ChangeLog
959 ;;
960 esac
961 ;;
962uploadsrc)
963 PWD=`pwd`
964 if [ -z $IPFIRE_USER ]; then
965 echo -n "You have to setup IPFIRE_USER first. See .config for details."
966 beautify message FAIL
967 exit 1
968 fi
969 URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
970 REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
971
972 cd $BASEDIR/cache/
973 for file in $(ls -1); do
974 grep -q "$file" <<<$REMOTE_FILES && continue
975 NEW_FILES="$NEW_FILES $file"
976 done
977 [ -n "$NEW_FILES" ] && scp -2 $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
978 cd $BASEDIR
979 cd $PWD
980 exit 0
981 ;;
982upload)
983 FTP_ISO_PORT=`echo "$FTP_ISO_URL" | awk -F: '{ print $2 }'`
984 FTP_ISO_URL=`echo "$FTP_ISO_URL" | awk -F: '{ print $1 }'`
985 if [ -z $FTP_ISO_PORT ]; then
986 FTP_ISO_PORT=21
987 fi
988 cat <<EOF > .ftp-commands
989mkdir -p $FTP_ISO_PATH$SVN_REVISION
990mkdir -p $FTP_ISO_PATH$SVN_REVISION/paks
991quit
992EOF
993 ncftp -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL < .ftp-commands
994 rm -f .ftp-commands
995
996 case "$2" in
997 iso)
998 echo -e "Uploading the iso to $FTP_ISO_PATH/$SVN_REVISION."
999
1000 md5sum ipfire-$VERSION.$MACHINE-full.iso > ipfire-$VERSION.$MACHINE-full.iso.md5
1001 for i in svn_status ipfire-source-r$SVN_REVISION.tar.gz ipfire-$VERSION.$MACHINE-full.iso ipfire-$VERSION.$MACHINE-full.iso.md5 ipfire-$VERSION.$MACHINE-devel.iso ipfire-$VERSION.$MACHINE-devel.iso.md5; do
1002 if [ -e "$i" ]; then
1003 ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/ $i
1004 if [ "$?" -eq "0" ]; then
1005 echo "The file with name $i was successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
1006 else
1007 echo "There was an error while uploading the file $i to the ftp server."
1008 exit 1
1009 fi
1010 fi
1011 done
1012 rm -f ipfire-$VERSION.$MACHINE-full.iso.md5
1013 if [ "$3" = "--with-sources-cd" ]; then
1014 ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH/$SVN_REVISION/ ipfire-sources-cd-$VERSION.$MACHINE.iso
1015 fi
1016 ;;
1017 paks)
1018 ncftpput -u $FTP_ISO_USER -p $FTP_ISO_PASS -P $FTP_ISO_PORT $FTP_ISO_URL $FTP_ISO_PATH$SVN_REVISION/paks packages/*
1019 if [ "$?" -eq "0" ]; then
1020 echo -e "The packages were successfully uploaded to $FTP_ISO_URL$FTP_ISO_PATH$SVN_REVISION/."
1021 else
1022 echo -e "There was an error while uploading the packages to the ftp server."
1023 exit 1
1024 fi
1025 ;;
1026 esac
1027 ;;
1028batch)
1029 if [ "$2" = "--background" ]; then
1030 batch_script
1031 exit $?
1032 fi
1033 if [ `screen -ls | grep -q ipfire` ]; then
1034 echo "Build is already running, sorry!"
1035 exit 1
1036 else
1037 if [ "$2" = "--rebuild" ]; then
1038 export IPFIRE_REBUILD=1
1039 echo "REBUILD!"
1040 else
1041 export IPFIRE_REBUILD=0
1042 fi
1043 echo -en "${BOLD}***IPFire-Batch-Build is starting...${NORMAL}"
1044 screen -dmS ipfire $0 batch --background
1045 evaluate 1
1046 exit 0
1047 fi
1048 ;;
1049watch)
1050 watch_screen
1051 ;;
1052pxe)
1053 case "$2" in
1054 start)
1055 start_tftpd
1056 ;;
1057 stop)
1058 stop_tftpd
1059 ;;
1060 reload|restart)
1061 reload_tftpd
1062 ;;
1063 esac
1064 exit 0
1065 ;;
1066lang)
1067 update_langs
1068 ;;
1069"")
1070 clear
1071 select name in "Exit" "IPFIRE: Downloadsrc" "IPFIRE: Build (silent)" "IPFIRE: Watch Build" "IPFIRE: Batch" "IPFIRE: Clean" "LOG: Tail" "Help"
1072 do
1073 case $name in
1074 "IPFIRE: Downloadsrc")
1075 $0 downloadsrc
1076 ;;
1077 "IPFIRE: Build (silent)")
1078 $0 build-silent
1079 ;;
1080 "IPFIRE: Watch Build")
1081 $0 watch
1082 ;;
1083 "IPFIRE: Batch")
1084 $0 batch
1085 ;;
1086 "IPFIRE: Clean")
1087 $0 clean
1088 ;;
1089 "Help")
1090 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
1091 cat doc/make.sh-usage
1092 ;;
1093 "LOG: Tail")
1094 tail -f log/_*
1095 ;;
1096 "Exit")
1097 break
1098 ;;
1099 esac
1100 done
1101 ;;
1102config)
1103 make_config
1104 ;;
1105*)
1106 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
1107 cat doc/make.sh-usage
1108 ;;
1109esac