make.sh: Calculate MAKETUNING depending on available memory
[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-2017 IPFire Team <info@ipfire.org>. #
21 # #
22 ############################################################################
23 #
24
25 NAME="IPFire" # Software name
26 SNAME="ipfire" # Short name
27 VERSION="2.19" # Version number
28 CORE="116" # Core Level (Filename)
29 PAKFIRE_CORE="116" # Core Level (PAKFIRE)
30 GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` # 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 # Flash and Xen Downloader
36 KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
37 GIT_TAG=$(git tag | tail -1) # Git Tag
38 GIT_LASTCOMMIT=$(git log | head -n1 | cut -d" " -f2 |head -c8) # Last commit
39
40 TOOLCHAINVER=20170705
41
42 # New architecture variables
43 HOST_ARCH="$(uname -m)"
44
45 # Debian specific settings
46 if [ ! -e /etc/debian_version ]; then
47 FULLPATH=`which $0`
48 else
49 if [ -x /usr/bin/realpath ]; then
50 FULLPATH=`/usr/bin/realpath $0`
51 else
52 echo "ERROR: Need to do apt-get install realpath"
53 exit 1
54 fi
55 fi
56
57 PWD=`pwd`
58 BASENAME=`basename $0`
59 BASEDIR=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
60 LOGFILE=$BASEDIR/log/_build.preparation.log
61 export BASEDIR LOGFILE
62 DIR_CHK=$BASEDIR/cache/check
63 mkdir $BASEDIR/log/ 2>/dev/null
64
65 # Load configuration file
66 if [ -f .config ]; then
67 . .config
68 fi
69
70 # Include funtions
71 . tools/make-functions
72
73 # Get the amount of memory in this build system
74 HOST_MEM=$(system_memory)
75
76 if [ -n "${BUILD_ARCH}" ]; then
77 configure_build "${BUILD_ARCH}"
78 elif [ -n "${TARGET_ARCH}" ]; then
79 configure_build "${TARGET_ARCH}"
80 unset TARGET_ARCH
81 else
82 configure_build "default"
83 fi
84
85 prepareenv() {
86 ############################################################################
87 # #
88 # Are we running the right shell? #
89 # #
90 ############################################################################
91 if [ ! "$BASH" ]; then
92 exiterror "BASH environment variable is not set. You're probably running the wrong shell."
93 fi
94
95 if [ -z "${BASH_VERSION}" ]; then
96 exiterror "Not running BASH shell."
97 fi
98
99
100 ############################################################################
101 # #
102 # Trap on emergency exit #
103 # #
104 ############################################################################
105 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
106
107
108 ############################################################################
109 # #
110 # Resetting our nice level #
111 # #
112 ############################################################################
113 echo -ne "Resetting our nice level to $NICE" | tee -a $LOGFILE
114 renice $NICE $$ > /dev/null
115 if [ `nice` != "$NICE" ]; then
116 beautify message FAIL
117 exiterror "Failed to set correct nice level"
118 else
119 beautify message DONE
120 fi
121
122
123 ############################################################################
124 # #
125 # Checking if running as root user #
126 # #
127 ############################################################################
128 echo -ne "Checking if we're running as root user" | tee -a $LOGFILE
129 if [ `id -u` != 0 ]; then
130 beautify message FAIL
131 exiterror "Not building as root"
132 else
133 beautify message DONE
134 fi
135
136
137 ############################################################################
138 # #
139 # Checking for necessary temporary space #
140 # #
141 ############################################################################
142 echo -ne "Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
143 BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
144 BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
145 if (( 2048000 > $BASE_ASPACE )); then
146 BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
147 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
148 beautify message FAIL
149 exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
150 fi
151 else
152 beautify message DONE
153 fi
154
155 ############################################################################
156 # #
157 # Building Linux From Scratch system #
158 # #
159 ############################################################################
160 # Set umask
161 umask 022
162
163 # Set LFS Directory
164 LFS=$BASEDIR/build
165
166 # Check /tools symlink
167 if [ -h /tools ]; then
168 rm -f /tools
169 fi
170 if [ ! -a /tools ]; then
171 ln -s $BASEDIR/build/tools /
172 fi
173 if [ ! -h /tools ]; then
174 exiterror "Could not create /tools symbolic link."
175 fi
176
177 # Setup environment
178 set +h
179 LC_ALL=POSIX
180 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
181 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
182
183 # Make some extra directories
184 mkdir -p $BASEDIR/build/{tools,etc,usr/src} 2>/dev/null
185 mkdir -p $BASEDIR/build/{dev/{shm,pts},proc,sys}
186 mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
187 mkdir -p $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
188
189 mknod -m 600 $BASEDIR/build/dev/console c 5 1 2>/dev/null
190 mknod -m 666 $BASEDIR/build/dev/null c 1 3 2>/dev/null
191
192 # Make all sources and proc available under lfs build
193 mount --bind /dev $BASEDIR/build/dev
194 mount --bind /dev/pts $BASEDIR/build/dev/pts
195 mount --bind /dev/shm $BASEDIR/build/dev/shm
196 mount --bind /proc $BASEDIR/build/proc
197 mount --bind /sys $BASEDIR/build/sys
198 mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache
199 mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
200 mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
201 mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc
202 mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html
203 mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs
204 mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs
205 mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log
206 mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src
207
208 # Run LFS static binary creation scripts one by one
209 export CCACHE_DIR=$BASEDIR/ccache
210 export CCACHE_COMPRESS=1
211 export CCACHE_COMPILERCHECK="string:toolchain-${TOOLCHAINVER} ${BUILD_ARCH}"
212
213 # Remove pre-install list of installed files in case user erase some files before rebuild
214 rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
215
216 # Prepare string for /etc/system-release.
217 SYSTEM_RELEASE="${NAME} ${VERSION} (${BUILD_ARCH})"
218 if [ "$(git status -s | wc -l)" == "0" ]; then
219 GIT_STATUS=""
220 else
221 GIT_STATUS="-dirty"
222 fi
223 case "$GIT_BRANCH" in
224 core*|beta?|rc?)
225 SYSTEM_RELEASE="${SYSTEM_RELEASE} - $GIT_BRANCH$GIT_STATUS"
226 ;;
227 *)
228 SYSTEM_RELEASE="${SYSTEM_RELEASE} - Development Build: $GIT_BRANCH/$GIT_LASTCOMMIT$GIT_STATUS"
229 ;;
230 esac
231 }
232
233 buildtoolchain() {
234 local error=false
235 case "${BUILD_ARCH}:${HOST_ARCH}" in
236 # x86_64
237 x86_64:x86_64)
238 # This is working.
239 ;;
240
241 # x86
242 i586:i586|i586:i686|i586:x86_64)
243 # These are working.
244 ;;
245 i586:*)
246 error=true
247 ;;
248
249 # ARM
250 arvm7hl:armv7hl|armv7hl:armv7l)
251 # These are working.
252 ;;
253
254 armv5tel:armv5tel|armv5tel:armv5tejl|armv5tel:armv6l|armv5tel:armv7l|armv5tel:aarch64)
255 # These are working.
256 ;;
257 armv5tel:*)
258 error=true
259 ;;
260 esac
261
262 ${error} && \
263 exiterror "Cannot build ${BUILD_ARCH} toolchain on $(uname -m). Please use the download if any."
264
265 local gcc=$(type -p gcc)
266 if [ -z "${gcc}" ]; then
267 exiterror "Could not find GCC. You will need a working build enviroment in order to build the toolchain."
268 fi
269
270 LOGFILE="$BASEDIR/log/_build.toolchain.log"
271 export LOGFILE
272
273 lfsmake1 stage1
274 lfsmake1 ccache PASS=1
275 lfsmake1 binutils PASS=1
276 lfsmake1 gcc PASS=1
277 lfsmake1 linux KCFG="-headers"
278 lfsmake1 glibc
279 lfsmake1 gcc PASS=L
280 lfsmake1 binutils PASS=2
281 lfsmake1 gcc PASS=2
282 lfsmake1 ccache PASS=2
283 lfsmake1 tcl
284 lfsmake1 expect
285 lfsmake1 dejagnu
286 lfsmake1 pkg-config
287 lfsmake1 ncurses
288 lfsmake1 bash
289 lfsmake1 bzip2
290 lfsmake1 automake
291 lfsmake1 coreutils
292 lfsmake1 diffutils
293 lfsmake1 findutils
294 lfsmake1 gawk
295 lfsmake1 gettext
296 lfsmake1 grep
297 lfsmake1 gzip
298 lfsmake1 m4
299 lfsmake1 make
300 lfsmake1 patch
301 lfsmake1 perl
302 lfsmake1 sed
303 lfsmake1 tar
304 lfsmake1 texinfo
305 lfsmake1 xz
306 lfsmake1 fake-environ
307 lfsmake1 cleanup-toolchain
308 }
309
310 buildbase() {
311 LOGFILE="$BASEDIR/log/_build.base.log"
312 export LOGFILE
313 lfsmake2 stage2
314 lfsmake2 linux KCFG="-headers"
315 lfsmake2 man-pages
316 lfsmake2 glibc
317 lfsmake2 tzdata
318 lfsmake2 cleanup-toolchain
319 lfsmake2 zlib
320 lfsmake2 binutils
321 lfsmake2 gmp
322 lfsmake2 gmp-compat
323 lfsmake2 mpfr
324 lfsmake2 libmpc
325 lfsmake2 file
326 lfsmake2 gcc
327 lfsmake2 sed
328 lfsmake2 autoconf
329 lfsmake2 automake
330 lfsmake2 berkeley
331 lfsmake2 coreutils
332 lfsmake2 iana-etc
333 lfsmake2 m4
334 lfsmake2 bison
335 lfsmake2 ncurses-compat
336 lfsmake2 ncurses
337 lfsmake2 procps
338 lfsmake2 libtool
339 lfsmake2 perl
340 lfsmake2 readline
341 lfsmake2 readline-compat
342 lfsmake2 bzip2
343 lfsmake2 pcre
344 lfsmake2 pcre-compat
345 lfsmake2 bash
346 lfsmake2 diffutils
347 lfsmake2 e2fsprogs
348 lfsmake2 ed
349 lfsmake2 findutils
350 lfsmake2 flex
351 lfsmake2 gawk
352 lfsmake2 gettext
353 lfsmake2 grep
354 lfsmake2 groff
355 lfsmake2 gperf
356 lfsmake2 gzip
357 lfsmake2 hostname
358 lfsmake2 iproute2
359 lfsmake2 jwhois
360 lfsmake2 kbd
361 lfsmake2 less
362 lfsmake2 make
363 lfsmake2 man
364 lfsmake2 kmod
365 lfsmake2 net-tools
366 lfsmake2 patch
367 lfsmake2 psmisc
368 lfsmake2 shadow
369 lfsmake2 sysklogd
370 lfsmake2 sysvinit
371 lfsmake2 tar
372 lfsmake2 texinfo
373 lfsmake2 util-linux
374 lfsmake2 udev
375 lfsmake2 vim
376 lfsmake2 xz
377 lfsmake2 paxctl
378 }
379
380 buildipfire() {
381 LOGFILE="$BASEDIR/log/_build.ipfire.log"
382 export LOGFILE
383 lfsmake2 configroot
384 lfsmake2 initscripts
385 lfsmake2 backup
386 lfsmake2 pkg-config
387 lfsmake2 libusb
388 lfsmake2 libusb-compat
389 lfsmake2 libpcap
390 lfsmake2 ppp
391 lfsmake2 pptp
392 lfsmake2 unzip
393 lfsmake2 which
394 lfsmake2 linux-firmware
395 lfsmake2 ath10k-firmware
396 lfsmake2 dvb-firmwares
397 lfsmake2 mt7601u-firmware
398 lfsmake2 zd1211-firmware
399 lfsmake2 rpi-firmware
400 lfsmake2 bc
401 lfsmake2 u-boot
402 lfsmake2 cpio
403 lfsmake2 mdadm
404 lfsmake2 dracut
405 lfsmake2 lvm2
406 lfsmake2 multipath-tools
407 lfsmake2 freetype
408 lfsmake2 grub
409 lfsmake2 libmnl
410 lfsmake2 libnfnetlink
411 lfsmake2 libnetfilter_queue
412 lfsmake2 libnetfilter_conntrack
413 lfsmake2 libnetfilter_cthelper
414 lfsmake2 libnetfilter_cttimeout
415 lfsmake2 iptables
416
417 case "${BUILD_ARCH}" in
418 x86_64)
419 lfsmake2 linux KCFG=""
420 lfsmake2 backports KCFG=""
421 lfsmake2 e1000e KCFG=""
422 lfsmake2 igb KCFG=""
423 lfsmake2 ixgbe KCFG=""
424 lfsmake2 xtables-addons KCFG=""
425 lfsmake2 linux-initrd KCFG=""
426 ;;
427 i586)
428 # x86-pae (Native and new XEN) kernel build
429 lfsmake2 linux KCFG="-pae"
430 lfsmake2 backports KCFG="-pae"
431 lfsmake2 e1000e KCFG="-pae"
432 lfsmake2 igb KCFG="-pae"
433 lfsmake2 ixgbe KCFG="-pae"
434 lfsmake2 xtables-addons KCFG="-pae"
435 lfsmake2 linux-initrd KCFG="-pae"
436
437 # x86 kernel build
438 lfsmake2 linux KCFG=""
439 lfsmake2 backports KCFG=""
440 lfsmake2 e1000e KCFG=""
441 lfsmake2 igb KCFG=""
442 lfsmake2 ixgbe KCFG=""
443 lfsmake2 xtables-addons KCFG=""
444 lfsmake2 linux-initrd KCFG=""
445 ;;
446
447 armv5tel)
448 # arm-rpi (Raspberry Pi) kernel build
449 lfsmake2 linux KCFG="-rpi"
450 lfsmake2 backports KCFG="-rpi"
451 lfsmake2 xtables-addons KCFG="-rpi"
452 lfsmake2 linux-initrd KCFG="-rpi"
453
454 # arm multi platform (Panda, Wandboard ...) kernel build
455 lfsmake2 linux KCFG="-multi"
456 lfsmake2 backports KCFG="-multi"
457 lfsmake2 e1000e KCFG="-multi"
458 lfsmake2 igb KCFG="-multi"
459 lfsmake2 ixgbe KCFG="-multi"
460 lfsmake2 xtables-addons KCFG="-multi"
461 lfsmake2 linux-initrd KCFG="-multi"
462
463 # arm-kirkwood (Dreamplug, ICY-Box ...) kernel build
464 lfsmake2 linux KCFG="-kirkwood"
465 lfsmake2 backports KCFG="-kirkwood"
466 lfsmake2 e1000e KCFG="-kirkwood"
467 lfsmake2 igb KCFG="-kirkwood"
468 lfsmake2 ixgbe KCFG="-kirkwood"
469 lfsmake2 xtables-addons KCFG="-kirkwood"
470 lfsmake2 linux-initrd KCFG="-kirkwood"
471 ;;
472 esac
473 lfsmake2 xtables-addons USPACE="1"
474 lfsmake2 openssl
475 [ "${BUILD_ARCH}" = "i586" ] && lfsmake2 openssl KCFG='-sse2'
476 lfsmake2 libgpg-error
477 lfsmake2 libgcrypt
478 lfsmake2 libassuan
479 lfsmake2 nettle
480 lfsmake2 libevent
481 lfsmake2 libevent2
482 lfsmake2 libevent2-compat
483 lfsmake2 expat
484 lfsmake2 apr
485 lfsmake2 aprutil
486 lfsmake2 unbound
487 lfsmake2 gnutls
488 lfsmake2 bind
489 lfsmake2 dhcp
490 lfsmake2 dhcpcd
491 lfsmake2 boost
492 lfsmake2 linux-atm
493 lfsmake2 gdbm
494 lfsmake2 pam
495 lfsmake2 curl
496 lfsmake2 tcl
497 lfsmake2 sqlite
498 lfsmake2 libffi
499 lfsmake2 python
500 lfsmake2 python3
501 lfsmake2 ca-certificates
502 lfsmake2 fireinfo
503 lfsmake2 libnet
504 lfsmake2 libnl
505 lfsmake2 libnl-3
506 lfsmake2 libidn
507 lfsmake2 nasm
508 lfsmake2 libjpeg
509 lfsmake2 libjpeg-compat
510 lfsmake2 libexif
511 lfsmake2 libpng
512 lfsmake2 libtiff
513 lfsmake2 libart
514 lfsmake2 gd
515 lfsmake2 popt
516 lfsmake2 slang
517 lfsmake2 newt
518 lfsmake2 libsmooth
519 lfsmake2 attr
520 lfsmake2 acl
521 lfsmake2 libcap
522 lfsmake2 pciutils
523 lfsmake2 usbutils
524 lfsmake2 libxml2
525 lfsmake2 libxslt
526 lfsmake2 BerkeleyDB
527 lfsmake2 mysql
528 lfsmake2 cyrus-sasl
529 lfsmake2 openldap
530 lfsmake2 apache2
531 lfsmake2 php
532 lfsmake2 web-user-interface
533 lfsmake2 flag-icons
534 lfsmake2 jquery
535 lfsmake2 bootstrap
536 lfsmake2 arping
537 lfsmake2 beep
538 lfsmake2 dvdrtools
539 lfsmake2 dosfstools
540 lfsmake2 reiserfsprogs
541 lfsmake2 xfsprogs
542 lfsmake2 sysfsutils
543 lfsmake2 fuse
544 lfsmake2 ntfs-3g
545 lfsmake2 ethtool
546 lfsmake2 ez-ipupdate
547 lfsmake2 fcron
548 lfsmake2 perl-GD
549 lfsmake2 GD-Graph
550 lfsmake2 GD-TextUtil
551 lfsmake2 perl-Device-SerialPort
552 lfsmake2 perl-Device-Modem
553 lfsmake2 perl-Apache-Htpasswd
554 lfsmake2 gnupg
555 lfsmake2 hdparm
556 lfsmake2 sdparm
557 lfsmake2 mtools
558 lfsmake2 whatmask
559 lfsmake2 conntrack-tools
560 lfsmake2 libupnp
561 lfsmake2 ipaddr
562 lfsmake2 iputils
563 lfsmake2 l7-protocols
564 lfsmake2 mISDNuser
565 lfsmake2 capi4k-utils
566 lfsmake2 hwdata
567 lfsmake2 logrotate
568 lfsmake2 logwatch
569 lfsmake2 misc-progs
570 lfsmake2 nano
571 lfsmake2 URI
572 lfsmake2 HTML-Tagset
573 lfsmake2 HTML-Parser
574 lfsmake2 HTML-Template
575 lfsmake2 Compress-Zlib
576 lfsmake2 Digest
577 lfsmake2 Digest-SHA1
578 lfsmake2 Digest-HMAC
579 lfsmake2 libwww-perl
580 lfsmake2 Net-DNS
581 lfsmake2 Net-IPv4Addr
582 lfsmake2 Net_SSLeay
583 lfsmake2 IO-Stringy
584 lfsmake2 IO-Socket-SSL
585 lfsmake2 Unix-Syslog
586 lfsmake2 Mail-Tools
587 lfsmake2 MIME-Tools
588 lfsmake2 Net-Server
589 lfsmake2 Convert-TNEF
590 lfsmake2 Convert-UUlib
591 lfsmake2 Archive-Tar
592 lfsmake2 Archive-Zip
593 lfsmake2 Text-Tabs+Wrap
594 lfsmake2 Locale-Country
595 lfsmake2 XML-Parser
596 lfsmake2 Crypt-PasswdMD5
597 lfsmake2 Net-Telnet
598 lfsmake2 python-setuptools
599 lfsmake2 python-clientform
600 lfsmake2 python-mechanize
601 lfsmake2 python-feedparser
602 lfsmake2 python-rssdler
603 lfsmake2 python-inotify
604 lfsmake2 python-docutils
605 lfsmake2 python-daemon
606 lfsmake2 python-ipaddress
607 lfsmake2 glib
608 lfsmake2 GeoIP
609 lfsmake2 noip_updater
610 lfsmake2 ntp
611 lfsmake2 openssh
612 lfsmake2 fontconfig
613 lfsmake2 dejavu-fonts-ttf
614 lfsmake2 ubuntu-font-family
615 lfsmake2 freefont
616 lfsmake2 pixman
617 lfsmake2 cairo
618 lfsmake2 pango
619 lfsmake2 rrdtool
620 lfsmake2 setserial
621 lfsmake2 setup
622 lfsmake2 libdnet
623 lfsmake2 daq
624 lfsmake2 snort
625 lfsmake2 oinkmaster
626 lfsmake2 squid
627 lfsmake2 squidguard
628 lfsmake2 calamaris
629 lfsmake2 tcpdump
630 lfsmake2 traceroute
631 lfsmake2 vlan
632 lfsmake2 wireless
633 lfsmake2 pakfire
634 lfsmake2 spandsp
635 lfsmake2 lzo
636 lfsmake2 openvpn
637 lfsmake2 pammysql
638 lfsmake2 mpage
639 lfsmake2 dbus
640 lfsmake2 intltool
641 lfsmake2 libdaemon
642 lfsmake2 cups
643 lfsmake2 lcms2
644 lfsmake2 ghostscript
645 lfsmake2 qpdf
646 lfsmake2 poppler
647 lfsmake2 cups-filters
648 lfsmake2 epson-inkjet-printer-escpr
649 lfsmake2 foomatic
650 lfsmake2 hplip
651 lfsmake2 cifs-utils
652 lfsmake2 krb5
653 lfsmake2 samba
654 lfsmake2 sudo
655 lfsmake2 mc
656 lfsmake2 wget
657 lfsmake2 bridge-utils
658 lfsmake2 screen
659 lfsmake2 smartmontools
660 lfsmake2 htop
661 lfsmake2 chkconfig
662 lfsmake2 postfix
663 lfsmake2 fetchmail
664 lfsmake2 cyrus-imapd
665 lfsmake2 openmailadmin
666 lfsmake2 clamav
667 lfsmake2 spamassassin
668 lfsmake2 amavisd
669 lfsmake2 dma
670 lfsmake2 alsa
671 lfsmake2 mpfire
672 lfsmake2 guardian
673 lfsmake2 libid3tag
674 lfsmake2 libmad
675 lfsmake2 libogg
676 lfsmake2 libvorbis
677 lfsmake2 libdvbpsi
678 lfsmake2 flac
679 lfsmake2 lame
680 lfsmake2 sox
681 lfsmake2 libshout
682 lfsmake2 xvid
683 lfsmake2 libmpeg2
684 lfsmake2 libarchive
685 lfsmake2 cmake
686 lfsmake2 gnump3d
687 lfsmake2 rsync
688 lfsmake2 tcpwrapper
689 lfsmake2 libtirpc
690 lfsmake2 rpcbind
691 lfsmake2 nfs
692 lfsmake2 gnu-netcat
693 lfsmake2 ncat
694 lfsmake2 nmap
695 lfsmake2 etherwake
696 lfsmake2 bwm-ng
697 lfsmake2 sysstat
698 lfsmake2 vsftpd
699 lfsmake2 strongswan
700 lfsmake2 rng-tools
701 lfsmake2 lsof
702 lfsmake2 br2684ctl
703 lfsmake2 pcmciautils
704 lfsmake2 lm_sensors
705 lfsmake2 liboping
706 lfsmake2 collectd
707 lfsmake2 elinks
708 lfsmake2 igmpproxy
709 lfsmake2 fbset
710 lfsmake2 opus
711 lfsmake2 python-six
712 lfsmake2 python-pyparsing
713 lfsmake2 spice-protocol
714 lfsmake2 spice
715 lfsmake2 sdl
716 lfsmake2 libusbredir
717 lfsmake2 qemu
718 lfsmake2 sane
719 lfsmake2 netpbm
720 lfsmake2 phpSANE
721 lfsmake2 tunctl
722 lfsmake2 netsnmpd
723 lfsmake2 nagios
724 lfsmake2 nagios_nrpe
725 lfsmake2 icinga
726 lfsmake2 ebtables
727 lfsmake2 directfb
728 lfsmake2 faad2
729 lfsmake2 ffmpeg
730 lfsmake2 vdr
731 lfsmake2 vdr_streamdev
732 lfsmake2 vdr_epgsearch
733 lfsmake2 vdr_dvbapi
734 lfsmake2 vdr_eepg
735 lfsmake2 w_scan
736 lfsmake2 icecast
737 lfsmake2 icegenerator
738 lfsmake2 mpd
739 lfsmake2 libmpdclient
740 lfsmake2 mpc
741 lfsmake2 perl-Net-SMTP-SSL
742 lfsmake2 perl-MIME-Base64
743 lfsmake2 perl-Authen-SASL
744 lfsmake2 perl-MIME-Lite
745 lfsmake2 perl-Email-Date-Format
746 lfsmake2 git
747 lfsmake2 squidclamav
748 lfsmake2 vnstat
749 lfsmake2 iw
750 lfsmake2 wpa_supplicant
751 lfsmake2 hostapd
752 lfsmake2 pycurl
753 lfsmake2 urlgrabber
754 lfsmake2 syslinux
755 lfsmake2 tftpd
756 lfsmake2 cpufrequtils
757 lfsmake2 bluetooth
758 lfsmake2 gutenprint
759 lfsmake2 apcupsd
760 lfsmake2 iperf
761 lfsmake2 iperf3
762 lfsmake2 7zip
763 lfsmake2 lynis
764 lfsmake2 streamripper
765 lfsmake2 sshfs
766 lfsmake2 taglib
767 #lfsmake2 mediatomb
768 lfsmake2 sslh
769 lfsmake2 perl-gettext
770 lfsmake2 perl-Sort-Naturally
771 lfsmake2 vdradmin
772 lfsmake2 miau
773 lfsmake2 perl-DBI
774 lfsmake2 perl-DBD-mysql
775 lfsmake2 perl-DBD-SQLite
776 lfsmake2 perl-File-ReadBackwards
777 lfsmake2 cacti
778 lfsmake2 openvmtools
779 lfsmake2 nagiosql
780 lfsmake2 motion
781 lfsmake2 joe
782 lfsmake2 monit
783 lfsmake2 nut
784 lfsmake2 watchdog
785 lfsmake2 libpri
786 lfsmake2 libsrtp
787 lfsmake2 asterisk
788 lfsmake2 lcr
789 lfsmake2 usb_modeswitch
790 lfsmake2 usb_modeswitch_data
791 lfsmake2 zerofree
792 lfsmake2 pound
793 lfsmake2 minicom
794 lfsmake2 ddrescue
795 lfsmake2 miniupnpd
796 lfsmake2 client175
797 lfsmake2 powertop
798 lfsmake2 parted
799 lfsmake2 swig
800 lfsmake2 python-m2crypto
801 lfsmake2 wireless-regdb
802 lfsmake2 crda
803 lfsmake2 libsolv
804 lfsmake2 python-distutils-extra
805 lfsmake2 python-lzma
806 lfsmake2 python-progressbar
807 lfsmake2 python-xattr
808 lfsmake2 ddns
809 lfsmake2 transmission
810 lfsmake2 dpfhack
811 lfsmake2 lcd4linux
812 lfsmake2 mtr
813 lfsmake2 minidlna
814 lfsmake2 acpid
815 lfsmake2 fping
816 lfsmake2 telnet
817 lfsmake2 xinetd
818 lfsmake2 gpgme
819 lfsmake2 pygpgme
820 lfsmake2 pakfire3
821 lfsmake2 stress
822 lfsmake2 libstatgrab
823 lfsmake2 sarg
824 lfsmake2 check_mk_agent
825 lfsmake2 nginx
826 lfsmake2 sendEmail
827 lfsmake2 sysbench
828 lfsmake2 strace
829 lfsmake2 elfutils
830 lfsmake2 ltrace
831 lfsmake2 ipfire-netboot
832 lfsmake2 lcdproc
833 lfsmake2 bitstream
834 lfsmake2 multicat
835 lfsmake2 keepalived
836 lfsmake2 ipvsadm
837 lfsmake2 perl-Carp-Clan
838 lfsmake2 perl-Date-Calc
839 lfsmake2 perl-Date-Manip
840 lfsmake2 perl-File-Tail
841 lfsmake2 perl-TimeDate
842 lfsmake2 swatch
843 lfsmake2 tor
844 lfsmake2 arm
845 lfsmake2 wavemon
846 lfsmake2 iptraf-ng
847 lfsmake2 iotop
848 lfsmake2 stunnel
849 lfsmake2 sslscan
850 lfsmake2 owncloud
851 lfsmake2 bacula
852 lfsmake2 batctl
853 lfsmake2 perl-Font-TTF
854 lfsmake2 perl-IO-String
855 lfsmake2 perl-PDF-API2
856 lfsmake2 squid-accounting
857 lfsmake2 pigz
858 lfsmake2 tmux
859 lfsmake2 perl-Text-CSV_XS
860 lfsmake2 swconfig
861 lfsmake2 haproxy
862 lfsmake2 ipset
863 lfsmake2 lua
864 lfsmake2 dnsdist
865 lfsmake2 bird
866 lfsmake2 dmidecode
867 lfsmake2 mcelog
868 lfsmake2 rtpproxy
869 lfsmake2 util-macros
870 lfsmake2 libpciaccess
871 lfsmake2 libyajl
872 lfsmake2 libvirt
873 lfsmake2 python3-libvirt
874 lfsmake2 freeradius
875 lfsmake2 perl-common-sense
876 lfsmake2 perl-inotify2
877 lfsmake2 perl-Net-IP
878 lfsmake2 wio
879 lfsmake2 iftop
880 }
881
882 buildinstaller() {
883 # Run installer scripts one by one
884 LOGFILE="$BASEDIR/log/_build.installer.log"
885 export LOGFILE
886 lfsmake2 memtest
887 lfsmake2 installer
888 lfsmake1 strip
889 }
890
891 buildpackages() {
892 LOGFILE="$BASEDIR/log/_build.packages.log"
893 export LOGFILE
894 echo "... see detailed log in _build.*.log files" >> $LOGFILE
895
896
897 # Generating list of packages used
898 echo -n "Generating packages list from logs" | tee -a $LOGFILE
899 rm -f $BASEDIR/doc/packages-list
900 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
901 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
902 echo "* `basename $i`" >>$BASEDIR/doc/packages-list
903 fi
904 done
905 echo "== List of softwares used to build $NAME Version: $VERSION ==" > $BASEDIR/doc/packages-list.txt
906 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|setup$\|pakfire$\|stage2$\|smp$\|tools$\|tools1$\|tools2$\|.tgz$\|-config$\|_missing_rootfile$\|install1$\|install2$\|pass1$\|pass2$\|pass3$' \
907 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
908 rm -f $BASEDIR/doc/packages-list
909 # packages-list.txt is ready to be displayed for wiki page
910 beautify message DONE
911
912 # Update changelog
913 cd $BASEDIR
914 [ -z $GIT_TAG ] || LAST_TAG=$GIT_TAG
915 [ -z $LAST_TAG ] || EXT="$LAST_TAG..HEAD"
916 git log -n 500 --no-merges --pretty=medium --shortstat $EXT > $BASEDIR/doc/ChangeLog
917
918 # Create images for install
919 lfsmake2 cdrom
920
921 # Check if there is a loop device for building in virtual environments
922 modprobe loop 2>/dev/null
923 if [ $BUILD_IMAGES == 1 ] && ([ -e /dev/loop/0 ] || [ -e /dev/loop0 ] || [ -e "/dev/loop-control" ]); then
924 lfsmake2 flash-images
925 lfsmake2 flash-images SCON=1
926 fi
927
928 mv $LFS/install/images/{*.iso,*.tgz,*.img.gz,*.bz2} $BASEDIR >> $LOGFILE 2>&1
929
930 ipfirepackages
931
932 lfsmake2 xen-image
933 mv $LFS/install/images/*.bz2 $BASEDIR >> $LOGFILE 2>&1
934
935 cd $BASEDIR
936
937 # remove not useable iso on armv5tel (needed to build flash images)
938 [ "${BUILD_ARCH}" = "armv5tel" ] && rm -rf *.iso
939
940 for i in `ls *.bz2 *.img.gz *.iso`; do
941 md5sum $i > $i.md5
942 done
943 cd $PWD
944
945 # Cleanup
946 stdumount
947 rm -rf $BASEDIR/build/tmp/*
948
949 # Generating total list of files
950 echo -n "Generating files list from logs" | tee -a $LOGFILE
951 rm -f $BASEDIR/log/FILES
952 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
953 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
954 echo "##" >>$BASEDIR/log/FILES
955 echo "## `basename $i`" >>$BASEDIR/log/FILES
956 echo "##" >>$BASEDIR/log/FILES
957 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
958 fi
959 done
960 beautify message DONE
961
962 cd $PWD
963 }
964
965 ipfirepackages() {
966 lfsmake2 core-updates
967
968 local i
969 for i in $(find $BASEDIR/config/rootfiles/packages{/${BUILD_ARCH},} -maxdepth 1 -type f); do
970 i=$(basename ${i})
971 if [ -e $BASEDIR/lfs/$i ]; then
972 ipfiredist $i
973 else
974 echo -n $i
975 beautify message SKIP
976 fi
977 done
978 test -d $BASEDIR/packages || mkdir $BASEDIR/packages
979 mv -f $LFS/install/packages/* $BASEDIR/packages >> $LOGFILE 2>&1
980 rm -rf $BASEDIR/build/install/packages/*
981 }
982
983 while [ $# -gt 0 ]; do
984 case "${1}" in
985 --target=*)
986 configure_build "${1#--target=}"
987 ;;
988 -*)
989 exiterror "Unknown configuration option: ${1}"
990 ;;
991 *)
992 # Found a command, so exit options parsing.
993 break
994 ;;
995 esac
996 shift
997 done
998
999 # See what we're supposed to do
1000 case "$1" in
1001 build)
1002 clear
1003 PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz 2> /dev/null | head -n 1`
1004 #only restore on a clean disk
1005 if [ ! -e "${BASEDIR}/build/tools/.toolchain-successful" ]; then
1006 if [ ! -n "$PACKAGE" ]; then
1007 beautify build_stage "Full toolchain compilation"
1008 prepareenv
1009 buildtoolchain
1010 else
1011 PACKAGENAME=${PACKAGE%.tar.gz}
1012 beautify build_stage "Packaged toolchain compilation"
1013 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
1014 tar zxf $PACKAGE
1015 prepareenv
1016 else
1017 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
1018 fi
1019 fi
1020 else
1021 echo -n "Using installed toolchain" | tee -a $LOGFILE
1022 beautify message SKIP
1023 prepareenv
1024 fi
1025
1026 beautify build_start
1027 beautify build_stage "Building LFS"
1028 buildbase
1029
1030 beautify build_stage "Building IPFire"
1031 buildipfire
1032
1033 beautify build_stage "Building installer"
1034 buildinstaller
1035
1036 beautify build_stage "Building packages"
1037 buildpackages
1038
1039 beautify build_stage "Checking Logfiles for new Files"
1040
1041 cd $BASEDIR
1042 tools/checknewlog.pl
1043 tools/checkrootfiles
1044 cd $PWD
1045
1046 beautify build_end
1047 ;;
1048 shell)
1049 # enter a shell inside LFS chroot
1050 # may be used to changed kernel settings
1051 prepareenv
1052 entershell
1053 ;;
1054 clean)
1055 echo -en "${BOLD}Cleaning build directory...${NORMAL}"
1056 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
1057 $LOSETUP -d $i 2>/dev/null
1058 done
1059 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
1060 umount $i
1061 done
1062 stdumount
1063 for i in `seq 0 7`; do
1064 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
1065 umount /dev/loop${i} 2>/dev/null;
1066 losetup -d /dev/loop${i} 2>/dev/null;
1067 fi;
1068 done
1069 rm -rf $BASEDIR/build
1070 rm -rf $BASEDIR/cdrom
1071 rm -rf $BASEDIR/packages
1072 rm -rf $BASEDIR/log
1073 if [ -h /tools ]; then
1074 rm -f /tools
1075 fi
1076 rm -f $BASEDIR/ipfire-*
1077 beautify message DONE
1078 ;;
1079 downloadsrc)
1080 if [ ! -d $BASEDIR/cache ]; then
1081 mkdir $BASEDIR/cache
1082 fi
1083 mkdir -p $BASEDIR/log
1084 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
1085 FINISHED=0
1086 cd $BASEDIR/lfs
1087 for c in `seq $MAX_RETRIES`; do
1088 if (( FINISHED==1 )); then
1089 break
1090 fi
1091 FINISHED=1
1092 cd $BASEDIR/lfs
1093 for i in *; do
1094 if [ -f "$i" -a "$i" != "Config" ]; then
1095 lfsmakecommoncheck ${i} || continue
1096
1097 make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
1098 MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
1099 if [ $? -ne 0 ]; then
1100 beautify message FAIL
1101 FINISHED=0
1102 else
1103 if [ $c -eq 1 ]; then
1104 beautify message DONE
1105 fi
1106 fi
1107 fi
1108 done
1109 done
1110 echo -e "${BOLD}***Verifying md5sums${NORMAL}"
1111 ERROR=0
1112 for i in *; do
1113 if [ -f "$i" -a "$i" != "Config" ]; then
1114 lfsmakecommoncheck ${i} > /dev/null || continue
1115 make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
1116 MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
1117 if [ $? -ne 0 ]; then
1118 echo -ne "MD5 difference in lfs/$i"
1119 beautify message FAIL
1120 ERROR=1
1121 fi
1122 fi
1123 done
1124 if [ $ERROR -eq 0 ]; then
1125 echo -ne "${BOLD}all files md5sum match${NORMAL}"
1126 beautify message DONE
1127 else
1128 echo -ne "${BOLD}not all files were correctly download${NORMAL}"
1129 beautify message FAIL
1130 fi
1131 cd - >/dev/null 2>&1
1132 ;;
1133 toolchain)
1134 clear
1135 prepareenv
1136 beautify build_stage "Toolchain compilation"
1137 buildtoolchain
1138 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
1139 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
1140 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
1141 build/tools build/bin/sh log >> $LOGFILE
1142 md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
1143 > cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.md5
1144 stdumount
1145 ;;
1146 gettoolchain)
1147 # arbitrary name to be updated in case of new toolchain package upload
1148 PACKAGE=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}
1149 if [ ! -f $BASEDIR/cache/toolchains/$PACKAGE.tar.gz ]; then
1150 URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
1151 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
1152 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
1153 cd $BASEDIR/cache/toolchains
1154 wget -U "IPFireSourceGrabber/2.x" $URL_TOOLCHAIN/$PACKAGE.tar.gz $URL_TOOLCHAIN/$PACKAGE.md5 >& /dev/null
1155 if [ $? -ne 0 ]; then
1156 echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for ${BUILD_ARCH} machine" | tee -a $LOGFILE
1157 else
1158 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1159 echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1160 else
1161 exiterror "$PACKAGE.md5 did not match, check downloaded package"
1162 fi
1163 fi
1164 else
1165 echo "Toolchain is already downloaded. Exiting..."
1166 fi
1167 ;;
1168 othersrc)
1169 prepareenv
1170 echo -ne "`date -u '+%b %e %T'`: Build sources iso for ${BUILD_ARCH}" | tee -a $LOGFILE
1171 chroot $LFS /tools/bin/env -i HOME=/root \
1172 TERM=$TERM PS1='\u:\w\$ ' \
1173 PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
1174 VERSION=$VERSION NAME="$NAME" SNAME="$SNAME" BUILD_ARCH="${BUILD_ARCH}" \
1175 /bin/bash -x -c "cd /usr/src/lfs && make -f sources-iso LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
1176 mv $LFS/install/images/ipfire-* $BASEDIR >> $LOGFILE 2>&1
1177 if [ $? -eq "0" ]; then
1178 beautify message DONE
1179 else
1180 beautify message FAIL
1181 fi
1182 stdumount
1183 ;;
1184 uploadsrc)
1185 PWD=`pwd`
1186 if [ -z $IPFIRE_USER ]; then
1187 echo -n "You have to setup IPFIRE_USER first. See .config for details."
1188 beautify message FAIL
1189 exit 1
1190 fi
1191
1192 URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
1193 REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
1194
1195 for file in ${BASEDIR}/cache/*; do
1196 [ -d "${file}" ] && continue
1197 grep -q "$(basename ${file})" <<<$REMOTE_FILES && continue
1198 NEW_FILES="$NEW_FILES $file"
1199 done
1200 [ -n "$NEW_FILES" ] && scp -2 $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
1201 cd $BASEDIR
1202 cd $PWD
1203 exit 0
1204 ;;
1205 lang)
1206 update_langs
1207 ;;
1208 *)
1209 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
1210 cat doc/make.sh-usage
1211 ;;
1212 esac