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