2 ############################################################################
4 # This file is part of the IPFire Firewall. #
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. #
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. #
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 #
20 # Copyright (C) 2007-2017 IPFire Team <info@ipfire.org>. #
22 ############################################################################
25 NAME
="IPFire" # Software name
26 SNAME
="ipfire" # Short name
27 VERSION
="2.19" # Version number
28 CORE
="117" # 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
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
42 ###############################################################################
44 # Beautifying variables & presentation & input output interface
46 ###############################################################################
48 # Remember if the shell is interactive or not
49 if [ -t 0 ] && [ -t 1 ]; then
56 # Find current screen size
57 if [ -z "${COLUMNS}" ]; then
59 COLUMNS
=${COLUMNS##* }
62 # When using remote connections, such as a serial port, stty size returns 0
63 if ! ${INTERACTIVE} ||
[ "${COLUMNS}" = "0" ]; then
67 ## Measurements for positioning result messages
71 NAME_WIDTH
=$
(( COLUMNS
- OPTIONS_WIDTH
- TIME_WIDTH
- STATUS_WIDTH
))
72 LINE_WIDTH
=$
(( COLUMNS
- STATUS_WIDTH
))
74 TIME_COL
=$
(( COLUMNS
- TIME_WIDTH
- STATUS_WIDTH
))
75 STATUS_COL
=$
(( COLUMNS
- STATUS_WIDTH
))
77 # Define color for messages
85 # New architecture variables
86 HOST_ARCH
="$(uname -m)"
89 BASENAME
=$
(basename $0)
91 # Debian specific settings
92 if [ ! -e /etc
/debian_version
]; then
95 if [ -x /usr
/bin
/realpath
]; then
96 FULLPATH
=`/usr/bin/realpath $0`
98 echo "ERROR: Need to do apt-get install realpath"
103 # This is the directory where make.sh is in
104 export BASEDIR
=$
(echo $FULLPATH |
sed "s/\/$BASENAME//g")
106 LOGFILE
=$BASEDIR/log
/_build.preparation.log
108 DIR_CHK
=$BASEDIR/cache
/check
109 mkdir
$BASEDIR/log
/ 2>/dev
/null
111 system_processors
() {
112 getconf _NPROCESSORS_ONLN
2>/dev
/null ||
echo "1"
118 while read -r key val unit
; do
122 echo "$(( ${val} / 1024 ))"
130 local build_arch
="${1}"
132 if [ "${build_arch}" = "default" ]; then
133 build_arch
="$(configure_build_guess)"
136 case "${build_arch}" in
138 BUILDTARGET
="${build_arch}-unknown-linux-gnu"
139 CROSSTARGET
="${build_arch}-cross-linux-gnu"
141 CFLAGS_ARCH
="-m64 -mtune=generic"
145 BUILDTARGET
="${build_arch}-pc-linux-gnu"
146 CROSSTARGET
="${build_arch}-cross-linux-gnu"
148 CFLAGS_ARCH
="-march=i586 -mtune=generic -fomit-frame-pointer"
152 BUILDTARGET
="${build_arch}-unknown-linux-gnu"
153 CROSSTARGET
="${build_arch}-cross-linux-gnu"
159 BUILDTARGET
="${build_arch}-unknown-linux-gnueabi"
160 CROSSTARGET
="${build_arch}-cross-linux-gnueabi"
162 CFLAGS_ARCH
="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
166 BUILDTARGET
="${build_arch}-unknown-linux-gnueabi"
167 CROSSTARGET
="${build_arch}-cross-linux-gnueabi"
169 CFLAGS_ARCH
="-march=armv5te -mfloat-abi=soft -fomit-frame-pointer"
173 exiterror
"Cannot build for architure ${build_arch}"
177 # Check if the QEMU helper is available if needed.
178 if qemu_is_required
"${build_arch}"; then
179 local qemu_build_helper
="$(qemu_find_build_helper_name "${build_arch}")"
181 if [ -n "${qemu_build_helper}" ]; then
182 QEMU_TARGET_HELPER
="${qemu_build_helper}"
184 exiterror
"Could not find a binfmt_misc helper entry for ${build_arch}"
188 BUILD_ARCH
="${build_arch}"
189 TOOLS_DIR
="/tools_${BUILD_ARCH}"
192 HARDENING_CFLAGS
="-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4"
194 CFLAGS
="-O2 -pipe -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
197 # Determine parallelism
198 if [ -z "${MAKETUNING}" ]; then
199 # We assume that each process consumes about
200 # 192MB of memory. Therefore we find out how
201 # many processes fit into memory.
202 local mem_max
=$
(( ${HOST_MEM} / 192 ))
204 local processors
="$(system_processors)"
205 local cpu_max
=$
(( ${processors} * 2 ))
208 if [ ${mem_max} -lt ${cpu_max} ]; then
209 parallelism
=${mem_max}
211 parallelism
=${cpu_max}
214 MAKETUNING
="-j${parallelism}"
218 configure_build_guess
() {
219 case "${HOST_ARCH}" in
228 armv7
*|armv6
*|armv5
*)
233 exiterror
"Cannot guess build architecture"
239 umount
$BASEDIR/build
/sys
2>/dev
/null
;
240 umount
$BASEDIR/build
/dev
/shm
2>/dev
/null
;
241 umount
$BASEDIR/build
/dev
/pts
2>/dev
/null
;
242 umount
$BASEDIR/build
/dev
2>/dev
/null
;
243 umount
$BASEDIR/build
/proc
2>/dev
/null
;
244 umount
$BASEDIR/build
/install
/mnt
2>/dev
/null
;
245 umount
$BASEDIR/build
/usr
/src
/cache
2>/dev
/null
;
246 umount
$BASEDIR/build
/usr
/src
/ccache
2>/dev
/null
;
247 umount
$BASEDIR/build
/usr
/src
/config
2>/dev
/null
;
248 umount
$BASEDIR/build
/usr
/src
/doc
2>/dev
/null
;
249 umount
$BASEDIR/build
/usr
/src
/html
2>/dev
/null
;
250 umount
$BASEDIR/build
/usr
/src
/langs
2>/dev
/null
;
251 umount
$BASEDIR/build
/usr
/src
/lfs
2>/dev
/null
;
252 umount
$BASEDIR/build
/usr
/src
/log
2>/dev
/null
;
253 umount
$BASEDIR/build
/usr
/src
/src
2>/dev
/null
;
263 if [ ${seconds} -ge 3600 ]; then
264 printf "%d:%02d:%02d\n" \
265 "$(( seconds / 3600 ))" \
266 "$(( seconds % 3600 / 60 ))" \
267 "$(( seconds % 3600 % 60 ))"
268 elif [ ${seconds} -ge 60 ]; then
270 "$(( seconds / 60 ))" \
271 "$(( seconds % 60 ))"
273 printf "%d\n" "${seconds}"
280 printf "%-${LINE_WIDTH}s" "${line}"
287 if ${INTERACTIVE}; then
293 if ${INTERACTIVE}; then
299 _print_line BOLD
"$@"
303 _print_line FAIL
"$@"
310 local version
="$(grep -E "^VER |^VER
=|^VER
" $BASEDIR/lfs/${name} | awk '{ print $3 }')"
313 local string
="${name}"
314 if [ -n "${version}" ] && [ "${version}" != "ipfire" ]; then
315 string
="${string} (${version})"
318 printf "%-$(( ${NAME_WIDTH} - 1 ))s " "${string}"
320 if [ -n "${options}" ]; then
321 printf "[ %-$(( ${OPTIONS_WIDTH} - 4 ))s ]" "${options}"
323 printf "%${OPTIONS_WIDTH}s" ""
328 local runtime
=$
(format_runtime $@
)
330 if ${INTERACTIVE}; then
331 printf "\\033[${TIME_COL}G[ ${BOLD}%$(( ${TIME_WIDTH} - 4 ))s${NORMAL} ]" "${runtime}"
333 printf "[ %$(( ${TIME_WIDTH} - 4 ))s ]" "${runtime}"
340 local color
="${!status}"
342 if ${INTERACTIVE}; then
343 printf "\\033[${STATUS_COL}G[${color-${BOLD}} %-$(( ${STATUS_WIDTH} - 4 ))s ${NORMAL}]\n" "${status}"
345 printf "[ %-$(( ${STATUS_WIDTH} - 4 ))s ]\n" "${status}"
349 print_build_stage
() {
356 print_build_summary
() {
357 local runtime
=$
(format_runtime $@
)
359 print_line
"*** Build finished in ${runtime}"
365 for i
in `seq 0 7`; do
366 if ( losetup
/dev
/loop
${i} 2>/dev
/null |
grep -q "/install/images" ); then
367 losetup
-d /dev
/loop
${i} 2>/dev
/null
372 if [ -n "${LOGFILE}" ]; then
376 while read -r line
; do
378 done <<< "$(tail -n30 ${LOGFILE})"
384 for line
in "ERROR: $@" " Check ${LOGFILE} for errors if applicable"; do
385 print_error
"${line}"
393 # Are we running the right shell?
394 if [ -z "${BASH}" ]; then
395 exiterror
"BASH environment variable is not set. You're probably running the wrong shell."
398 if [ -z "${BASH_VERSION}" ]; then
399 exiterror
"Not running BASH shell."
402 # Trap on emergency exit
403 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
405 # Resetting our nice level
406 if ! renice
${NICE} $$
>/dev
/null
; then
407 exiterror
"Failed to set nice level to ${NICE}"
410 # Checking if running as root user
411 if [ $
(id
-u) -ne 0 ]; then
412 exiterror
"Not building as root"
415 # Checking for necessary temporary space
416 print_line
"Checking for necessary space on disk $BASE_DEV"
417 BASE_DEV
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
418 BASE_ASPACE
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
419 if (( 2048000 > $BASE_ASPACE )); then
420 BASE_USPACE
=`du -skx $BASEDIR | awk '{print $1}'`
421 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
423 exiterror
"Not enough temporary space available, need at least 2GB on $BASE_DEV"
435 # Check ${TOOLS_DIR} symlink
436 if [ -h "${TOOLS_DIR}" ]; then
440 if [ ! -e "${TOOLS_DIR}" ]; then
441 ln -s "${BASEDIR}/build${TOOLS_DIR}" "${TOOLS_DIR}"
444 if [ ! -h "${TOOLS_DIR}" ]; then
445 exiterror
"Could not create ${TOOLS_DIR} symbolic link"
451 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
452 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
454 # Make some extra directories
455 mkdir
-p "${BASEDIR}/build${TOOLS_DIR}" 2>/dev
/null
456 mkdir
-p $BASEDIR/build
/{etc
,usr
/src
} 2>/dev
/null
457 mkdir
-p $BASEDIR/build
/{dev
/{shm
,pts
},proc
,sys
}
458 mkdir
-p $BASEDIR/{cache
,ccache
} 2>/dev
/null
459 mkdir
-p $BASEDIR/build
/usr
/src
/{cache
,config
,doc
,html
,langs
,lfs
,log
,src
,ccache
}
461 mknod
-m 600 $BASEDIR/build
/dev
/console c
5 1 2>/dev
/null
462 mknod
-m 666 $BASEDIR/build
/dev
/null c
1 3 2>/dev
/null
464 # Make all sources and proc available under lfs build
465 mount
--bind /dev
$BASEDIR/build
/dev
466 mount
--bind /dev
/pts
$BASEDIR/build
/dev
/pts
467 mount
--bind /dev
/shm
$BASEDIR/build
/dev
/shm
468 mount
--bind /proc
$BASEDIR/build
/proc
469 mount
--bind /sys
$BASEDIR/build
/sys
470 mount
--bind $BASEDIR/cache
$BASEDIR/build
/usr
/src
/cache
471 mount
--bind $BASEDIR/ccache
$BASEDIR/build
/usr
/src
/ccache
472 mount
--bind $BASEDIR/config
$BASEDIR/build
/usr
/src
/config
473 mount
--bind $BASEDIR/doc
$BASEDIR/build
/usr
/src
/doc
474 mount
--bind $BASEDIR/html
$BASEDIR/build
/usr
/src
/html
475 mount
--bind $BASEDIR/langs
$BASEDIR/build
/usr
/src
/langs
476 mount
--bind $BASEDIR/lfs
$BASEDIR/build
/usr
/src
/lfs
477 mount
--bind $BASEDIR/log
$BASEDIR/build
/usr
/src
/log
478 mount
--bind $BASEDIR/src
$BASEDIR/build
/usr
/src
/src
480 # Run LFS static binary creation scripts one by one
481 export CCACHE_DIR
=$BASEDIR/ccache
482 export CCACHE_COMPRESS
=1
483 export CCACHE_COMPILERCHECK
="string:toolchain-${TOOLCHAINVER} ${BUILD_ARCH}"
485 # Remove pre-install list of installed files in case user erase some files before rebuild
486 rm -f $BASEDIR/build
/usr
/src
/lsalr
2>/dev
/null
488 # Prepare string for /etc/system-release.
489 SYSTEM_RELEASE
="${NAME} ${VERSION} (${BUILD_ARCH})"
490 if [ "$(git status -s | wc -l)" == "0" ]; then
495 case "$GIT_BRANCH" in
497 SYSTEM_RELEASE
="${SYSTEM_RELEASE} - $GIT_BRANCH$GIT_STATUS"
500 SYSTEM_RELEASE
="${SYSTEM_RELEASE} - Development Build: $GIT_BRANCH/$GIT_LASTCOMMIT$GIT_STATUS"
506 # Install QEMU helper, if needed
509 local PATH
="${TOOLS_DIR}/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/bin"
511 PATH
="${PATH}" chroot
${LFS} env
-i \
516 SYSTEM_RELEASE
="${SYSTEM_RELEASE}" \
517 PAKFIRE_CORE
="${PAKFIRE_CORE}" \
520 VERSION
="${VERSION}" \
523 TOOLS_DIR
="${TOOLS_DIR}" \
524 CONFIG_ROOT
="${CONFIG_ROOT}" \
525 CFLAGS
="${CFLAGS} ${HARDENING_CFLAGS}" \
526 CXXFLAGS
="${CXXFLAGS} ${HARDENING_CFLAGS}" \
527 BUILDTARGET
="${BUILDTARGET}" \
528 CROSSTARGET
="${CROSSTARGET}" \
529 BUILD_ARCH
="${BUILD_ARCH}" \
530 BUILD_PLATFORM
="${BUILD_PLATFORM}" \
531 CCACHE_DIR
=/usr
/src
/ccache \
532 CCACHE_COMPRESS
="${CCACHE_COMPRESS}" \
533 CCACHE_COMPILERCHECK
="${CCACHE_COMPILERCHECK}" \
541 if [ ! -e $BASEDIR/build
/usr
/src
/lfs
/ ]; then
542 exiterror
"No such file or directory: $BASEDIR/build/usr/src/lfs/"
545 echo "Entering to a shell inside LFS chroot, go out with exit"
546 local PS1
="ipfire build chroot ($(uname -m)) \u:\w\$ "
548 if enterchroot bash
-i; then
552 exiterror
"chroot error"
556 lfsmakecommoncheck
() {
558 if [ ! -f $BASEDIR/lfs
/$1 ]; then
559 exiterror
"No such file or directory: $BASEDIR/$1"
562 # Print package name and version
565 # Check if this package is supported by our architecture.
566 # If no SUP_ARCH is found, we assume the package can be built for all.
567 if grep "^SUP_ARCH" ${BASEDIR}/lfs
/${1} >/dev
/null
; then
568 # Check if package supports ${BUILD_ARCH} or all architectures.
569 if ! grep -E "^SUP_ARCH.*${BUILD_ARCH}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
577 for i in $SKIP_PACKAGE_LIST
579 if [ "$i" == "$1" ]; then
585 echo -ne "`date -u '+%b %e %T'`: Building $
* " >> $LOGFILE
587 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
588 MESSAGE="$1\t " download >> $LOGFILE 2>&1
589 if [ $? -ne 0 ]; then
590 exiterror "Download error
in $1"
593 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
594 MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
595 if [ $? -ne 0 ]; then
596 exiterror "md5sum error
in $1, check
file in cache or signature
"
603 lfsmakecommoncheck $*
604 [ $? == 1 ] && return 0
606 cd $BASEDIR/lfs && env -i \
607 PATH="${TOOLS_DIR}/ccache
/bin
:${TOOLS_DIR}/bin
:$PATH" \
608 CCACHE_DIR="${CCACHE_DIR}" \
609 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
610 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
612 CXXFLAGS="${CXXFLAGS}" \
613 MAKETUNING="${MAKETUNING}" \
616 TOOLS_DIR="${TOOLS_DIR}" \
617 CROSSTARGET="${CROSSTARGET}" \
618 BUILDTARGET="${BUILDTARGET}" \
619 BUILD_ARCH="${BUILD_ARCH}" \
620 BUILD_PLATFORM="${BUILD_PLATFORM}" \
621 LFS_BASEDIR="${BASEDIR}" \
624 install >> $LOGFILE 2>&1 &
626 if ! wait_until_finished $!; then
628 exiterror "Building $
*"
635 lfsmakecommoncheck $*
636 [ $? == 1 ] && return 0
641 bash -x -c "cd /usr
/src
/lfs
&& \
642 MAKETUNING
=${MAKETUNING} \
644 LFS_BASEDIR
=/usr
/src
install" \
647 if ! wait_until_finished $!; then
649 exiterror "Building $
*"
656 lfsmakecommoncheck $*
657 [ $? == 1 ] && return 0
662 bash -x -c "cd /usr
/src
/lfs
&& make -f $
* LFS_BASEDIR
=/usr
/src dist
" \
665 if ! wait_until_finished $!; then
667 exiterror "Packaging $
*"
673 wait_until_finished() {
676 local start_time=$(now)
679 if ${INTERACTIVE}; then
680 # Wait a little just in case the process
681 # has finished very quickly.
685 while kill -0 ${pid} 2>/dev/null; do
686 print_runtime $(( $(now) - ${start_time} ))
693 # Returns the exit code of the child process
697 if ! ${INTERACTIVE}; then
698 print_runtime $(( $(now) - ${start_time} ))
705 [ -e "${BASEDIR}/build
${TOOLS_DIR}/lib
/libpakfire_preload.so
" ] || return
707 local env="LD_PRELOAD
=${TOOLS_DIR}/lib
/libpakfire_preload.so
"
709 # Fake kernel version, because some of the packages do not compile
710 # with kernel 3.0 and later.
711 env="${env} UTS_RELEASE
=${KVER}"
713 # Fake machine version.
714 env="${env} UTS_MACHINE
=${BUILD_ARCH}"
722 # Don't add anything if qemu is not used.
723 if ! qemu_is_required; then
727 # Set default qemu options
728 case "${BUILD_ARCH}" in
730 QEMU_CPU="${QEMU_CPU:-cortex-a9}"
732 env="${env} QEMU_CPU
=${QEMU_CPU}"
737 #env="${env} QEMU_STRACE
=1"
743 local build_arch="${1}"
745 if [ -z "${build_arch}" ]; then
746 build_arch="${BUILD_ARCH}"
749 case "${HOST_ARCH},${build_arch}" in
750 x86_64,arm*|i?86,arm*|i?86,x86_64)
759 qemu_install_helper() {
760 # Do nothing, if qemu is not required
761 if ! qemu_is_required; then
765 if [ ! -e /proc/sys/fs/binfmt_misc/status ]; then
766 exiterror "binfmt_misc not mounted. QEMU_TARGET_HELPER not useable.
"
769 if [ ! $(cat /proc/sys/fs/binfmt_misc/status) = 'enabled' ]; then
770 exiterror "binfmt_misc not enabled. QEMU_TARGET_HELPER not useable.
"
774 if [ -z "${QEMU_TARGET_HELPER}" ]; then
775 exiterror "QEMU_TARGET_HELPER not
set"
778 # Check if the helper is already installed.
779 if [ -x "${LFS}${QEMU_TARGET_HELPER}" ]; then
783 # Try to find a suitable binary that we can install
784 # to the build environment.
786 for file in "${QEMU_TARGET_HELPER}" "${QEMU_TARGET_HELPER}-static"; do
787 # file must exist and be executable.
788 [ -x "${file}" ] || continue
791 file_is_static "${file}" || continue
793 local dirname="${LFS}$
(dirname "${file}")"
794 mkdir -p "${dirname}"
796 install -m 755 "${file}" "${LFS}${QEMU_TARGET_HELPER}"
800 exiterror "Could not
find a statically-linked QEMU emulator
: ${QEMU_TARGET_HELPER}"
803 qemu_find_build_helper_name() {
804 local build_arch="${1}"
807 case "${build_arch}" in
809 magic="7f454c4601010100000000000000000002002800
"
812 magic="7f454c4602010100000000000000000002003e00
"
816 [ -z "${magic}" ] && return 1
819 for file in /proc/sys/fs/binfmt_misc/*; do
820 # skip write only register entry
821 [ $(basename "${file}") = "register
" ] && continue
822 # Search for the file with the correct magic value.
823 grep -qE "^magic
${magic}$
" "${file}" || continue
825 local interpreter="$
(grep "^interpreter" "${file}" |
awk '{ print $2 }')"
827 [ -n "${interpreter}" ] || continue
828 [ "${interpreter:0:1}" = "/" ] || continue
829 [ -x "${interpreter}" ] || continue
831 echo "${interpreter}"
841 file ${file} 2>/dev/null | grep -q "statically linked
"
844 update_language_list() {
848 for lang in ${path}/*.po; do
849 lang="$
(basename "${lang}")"
851 done | sort -u > "${path}/LINGUAS
"
854 # Load configuration file
855 if [ -f .config ]; then
859 # TARGET_ARCH is BUILD_ARCH now
860 if [ -n "${TARGET_ARCH}" ]; then
861 BUILD_ARCH="${TARGET_ARCH}"
865 # Get the amount of memory in this build system
866 HOST_MEM=$(system_memory)
868 if [ -n "${BUILD_ARCH}" ]; then
869 configure_build "${BUILD_ARCH}"
871 configure_build "default
"
876 case "${BUILD_ARCH}:${HOST_ARCH}" in
883 i586:i586|i586:i686|i586:x86_64)
891 arvm7hl:armv7hl|armv7hl:armv7l)
895 armv5tel:armv5tel|armv5tel:armv5tejl|armv5tel:armv6l|armv5tel:armv7l|armv5tel:aarch64)
904 exiterror "Cannot build
${BUILD_ARCH} toolchain on $
(uname
-m). Please use the download
if any.
"
906 local gcc=$(type -p gcc)
907 if [ -z "${gcc}" ]; then
908 exiterror "Could not
find GCC. You will need a working build enviroment
in order to build the toolchain.
"
911 LOGFILE="$BASEDIR/log
/_build.toolchain.log
"
915 lfsmake1 ccache PASS=1
916 lfsmake1 binutils PASS=1
918 lfsmake1 linux KCFG="-headers"
921 lfsmake1 binutils PASS=2
923 lfsmake1 ccache PASS=2
947 lfsmake1 fake-environ
948 lfsmake1 cleanup-toolchain
952 LOGFILE="$BASEDIR/log
/_build.base.log
"
955 lfsmake2 linux KCFG="-headers"
959 lfsmake2 cleanup-toolchain
976 lfsmake2 ncurses-compat
982 lfsmake2 readline-compat
1022 LOGFILE="$BASEDIR/log
/_build.ipfire.log
"
1025 lfsmake2 initscripts
1029 lfsmake2 libusb-compat
1035 lfsmake2 linux-firmware
1036 lfsmake2 ath10k-firmware
1037 lfsmake2 dvb-firmwares
1038 lfsmake2 mt7601u-firmware
1039 lfsmake2 zd1211-firmware
1040 lfsmake2 rpi-firmware
1047 lfsmake2 multipath-tools
1051 lfsmake2 libnfnetlink
1052 lfsmake2 libnetfilter_queue
1053 lfsmake2 libnetfilter_conntrack
1054 lfsmake2 libnetfilter_cthelper
1055 lfsmake2 libnetfilter_cttimeout
1058 case "${BUILD_ARCH}" in
1060 lfsmake2 linux KCFG=""
1061 lfsmake2 backports KCFG=""
1062 lfsmake2 e1000e KCFG=""
1063 lfsmake2 igb KCFG=""
1064 lfsmake2 ixgbe KCFG=""
1065 lfsmake2 xtables-addons KCFG=""
1066 lfsmake2 linux-initrd KCFG=""
1069 # x86-pae (Native and new XEN) kernel build
1070 lfsmake2 linux KCFG="-pae"
1071 lfsmake2 backports KCFG="-pae"
1072 lfsmake2 e1000e KCFG="-pae"
1073 lfsmake2 igb KCFG="-pae"
1074 lfsmake2 ixgbe KCFG="-pae"
1075 lfsmake2 xtables-addons KCFG="-pae"
1076 lfsmake2 linux-initrd KCFG="-pae"
1079 lfsmake2 linux KCFG=""
1080 lfsmake2 backports KCFG=""
1081 lfsmake2 e1000e KCFG=""
1082 lfsmake2 igb KCFG=""
1083 lfsmake2 ixgbe KCFG=""
1084 lfsmake2 xtables-addons KCFG=""
1085 lfsmake2 linux-initrd KCFG=""
1089 # arm-rpi (Raspberry Pi) kernel build
1090 lfsmake2 linux KCFG="-rpi"
1091 lfsmake2 backports KCFG="-rpi"
1092 lfsmake2 xtables-addons KCFG="-rpi"
1093 lfsmake2 linux-initrd KCFG="-rpi"
1095 # arm multi platform (Panda, Wandboard ...) kernel build
1096 lfsmake2 linux KCFG="-multi"
1097 lfsmake2 backports KCFG="-multi"
1098 lfsmake2 e1000e KCFG="-multi"
1099 lfsmake2 igb KCFG="-multi"
1100 lfsmake2 ixgbe KCFG="-multi"
1101 lfsmake2 xtables-addons KCFG="-multi"
1102 lfsmake2 linux-initrd KCFG="-multi"
1104 # arm-kirkwood (Dreamplug, ICY-Box ...) kernel build
1105 lfsmake2 linux KCFG="-kirkwood"
1106 lfsmake2 backports KCFG="-kirkwood"
1107 lfsmake2 e1000e KCFG="-kirkwood"
1108 lfsmake2 igb KCFG="-kirkwood"
1109 lfsmake2 ixgbe KCFG="-kirkwood"
1110 lfsmake2 xtables-addons KCFG="-kirkwood"
1111 lfsmake2 linux-initrd KCFG="-kirkwood"
1114 lfsmake2 xtables-addons USPACE="1"
1116 [ "${BUILD_ARCH}" = "i586
" ] && lfsmake2 openssl KCFG='-sse2'
1117 lfsmake2 libgpg-error
1123 lfsmake2 libevent2-compat
1142 lfsmake2 ca-certificates
1150 lfsmake2 libjpeg-compat
1173 lfsmake2 web-user-interface
1181 lfsmake2 reiserfsprogs
1187 lfsmake2 ez-ipupdate
1191 lfsmake2 GD-TextUtil
1192 lfsmake2 perl-Device-SerialPort
1193 lfsmake2 perl-Device-Modem
1194 lfsmake2 perl-Apache-Htpasswd
1200 lfsmake2 conntrack-tools
1204 lfsmake2 l7-protocols
1206 lfsmake2 capi4k-utils
1213 lfsmake2 HTML-Tagset
1214 lfsmake2 HTML-Parser
1215 lfsmake2 HTML-Template
1216 lfsmake2 Compress-Zlib
1218 lfsmake2 Digest-SHA1
1219 lfsmake2 Digest-HMAC
1220 lfsmake2 libwww-perl
1222 lfsmake2 Net-IPv4Addr
1225 lfsmake2 IO-Socket-SSL
1226 lfsmake2 Unix-Syslog
1230 lfsmake2 Convert-TNEF
1231 lfsmake2 Convert-UUlib
1232 lfsmake2 Archive-Tar
1233 lfsmake2 Archive-Zip
1234 lfsmake2 Text-Tabs+Wrap
1235 lfsmake2 Locale-Country
1237 lfsmake2 Crypt-PasswdMD5
1239 lfsmake2 python-setuptools
1240 lfsmake2 python-clientform
1241 lfsmake2 python-mechanize
1242 lfsmake2 python-feedparser
1243 lfsmake2 python-rssdler
1244 lfsmake2 python-inotify
1245 lfsmake2 python-docutils
1246 lfsmake2 python-daemon
1247 lfsmake2 python-ipaddress
1250 lfsmake2 noip_updater
1254 lfsmake2 dejavu-fonts-ttf
1255 lfsmake2 ubuntu-font-family
1285 lfsmake2 ghostscript
1288 lfsmake2 cups-filters
1289 lfsmake2 epson-inkjet-printer-escpr
1298 lfsmake2 bridge-utils
1300 lfsmake2 smartmontools
1305 lfsmake2 cyrus-imapd
1306 lfsmake2 openmailadmin
1308 lfsmake2 spamassassin
1344 lfsmake2 pcmciautils
1353 lfsmake2 python-pyparsing
1354 lfsmake2 spice-protocol
1357 lfsmake2 libusbredir
1365 lfsmake2 nagios_nrpe
1372 lfsmake2 vdr_streamdev
1373 lfsmake2 vdr_epgsearch
1378 lfsmake2 icegenerator
1380 lfsmake2 libmpdclient
1382 lfsmake2 perl-Net-SMTP-SSL
1383 lfsmake2 perl-MIME-Base64
1384 lfsmake2 perl-Authen-SASL
1385 lfsmake2 perl-MIME-Lite
1386 lfsmake2 perl-Email-Date-Format
1388 lfsmake2 squidclamav
1391 lfsmake2 wpa_supplicant
1397 lfsmake2 cpufrequtils
1405 lfsmake2 streamripper
1410 lfsmake2 perl-gettext
1411 lfsmake2 perl-Sort-Naturally
1415 lfsmake2 perl-DBD-mysql
1416 lfsmake2 perl-DBD-SQLite
1417 lfsmake2 perl-File-ReadBackwards
1419 lfsmake2 openvmtools
1430 lfsmake2 usb_modeswitch
1431 lfsmake2 usb_modeswitch_data
1441 lfsmake2 python-m2crypto
1442 lfsmake2 wireless-regdb
1445 lfsmake2 python-distutils-extra
1446 lfsmake2 python-lzma
1447 lfsmake2 python-progressbar
1448 lfsmake2 python-xattr
1450 lfsmake2 transmission
1463 lfsmake2 libstatgrab
1465 lfsmake2 check_mk_agent
1472 lfsmake2 ipfire-netboot
1478 lfsmake2 perl-Carp-Clan
1479 lfsmake2 perl-Date-Calc
1480 lfsmake2 perl-Date-Manip
1481 lfsmake2 perl-File-Tail
1482 lfsmake2 perl-TimeDate
1494 lfsmake2 perl-Font-TTF
1495 lfsmake2 perl-IO-String
1496 lfsmake2 perl-PDF-API2
1497 lfsmake2 squid-accounting
1500 lfsmake2 perl-Text-CSV_XS
1510 lfsmake2 util-macros
1511 lfsmake2 libpciaccess
1514 lfsmake2 python3-libvirt
1516 lfsmake2 perl-common-sense
1517 lfsmake2 perl-inotify2
1518 lfsmake2 perl-Net-IP
1524 # Run installer scripts one by one
1525 LOGFILE="$BASEDIR/log
/_build.installer.log
"
1533 LOGFILE="$BASEDIR/log
/_build.packages.log
"
1535 echo "... see detailed log
in _build.
*.log files
" >> $LOGFILE
1538 # Generating list of packages used
1539 echo -n "Generating packages list from logs
" | tee -a $LOGFILE
1540 rm -f $BASEDIR/doc/packages-list
1541 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
1542 if [ "$i" != "$BASEDIR/log
/FILES
" -a -n $i ]; then
1543 echo "* `basename $i`" >>$BASEDIR/doc/packages-list
1546 echo "== List of softwares used to build
$NAME Version
: $VERSION ==" > $BASEDIR/doc/packages-list.txt
1547 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|setup$\|pakfire$\|stage2$\|smp$\|tools$\|tools1$\|tools2$\|.tgz$\|-config$\|_missing_rootfile$\|install1$\|install2$\|pass1$\|pass2$\|pass3$' \
1548 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
1549 rm -f $BASEDIR/doc/packages-list
1550 # packages-list.txt is ready to be displayed for wiki page
1555 [ -z $GIT_TAG ] || LAST_TAG=$GIT_TAG
1556 [ -z $LAST_TAG ] || EXT="$LAST_TAG..HEAD
"
1557 git log -n 500 --no-merges --pretty=medium --shortstat $EXT > $BASEDIR/doc/ChangeLog
1559 # Create images for install
1562 # Check if there is a loop device for building in virtual environments
1563 modprobe loop 2>/dev/null
1564 if [ $BUILD_IMAGES == 1 ] && ([ -e /dev/loop/0 ] || [ -e /dev/loop0 ] || [ -e "/dev
/loop-control
" ]); then
1565 lfsmake2 flash-images
1566 lfsmake2 flash-images SCON=1
1569 mv $LFS/install/images/{*.iso,*.tgz,*.img.gz,*.bz2} $BASEDIR >> $LOGFILE 2>&1
1574 mv $LFS/install/images/*.bz2 $BASEDIR >> $LOGFILE 2>&1
1578 # remove not useable iso on armv5tel (needed to build flash images)
1579 [ "${BUILD_ARCH}" = "armv5tel
" ] && rm -rf *.iso
1581 for i in `ls *.bz2 *.img.gz *.iso`; do
1588 rm -rf $BASEDIR/build/tmp/*
1590 # Generating total list of files
1591 echo -n "Generating files list from logs
" | tee -a $LOGFILE
1592 rm -f $BASEDIR/log/FILES
1593 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
1594 if [ "$i" != "$BASEDIR/log
/FILES
" -a -n $i ]; then
1595 echo "##" >>$BASEDIR/log/FILES
1596 echo "## `basename $i`" >>$BASEDIR/log
/FILES
1597 echo "##" >>$BASEDIR/log
/FILES
1598 cat $i |
sed "s%^\./%#%" |
sort >> $BASEDIR/log
/FILES
1607 lfsmake2 core-updates
1610 for i
in $
(find $BASEDIR/config
/rootfiles
/packages
{/${BUILD_ARCH},} -maxdepth 1 -type f
); do
1612 if [ -e $BASEDIR/lfs
/$i ]; then
1619 test -d $BASEDIR/packages || mkdir
$BASEDIR/packages
1620 mv -f $LFS/install
/packages
/* $BASEDIR/packages
>> $LOGFILE 2>&1
1621 rm -rf $BASEDIR/build
/install
/packages
/*
1624 while [ $# -gt 0 ]; do
1627 configure_build
"${1#--target=}"
1630 exiterror
"Unknown configuration option: ${1}"
1633 # Found a command, so exit options parsing.
1640 # See what we're supposed to do
1646 ${INTERACTIVE} && clear
1648 PACKAGE
=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.xz 2> /dev/null | head -n 1`
1649 #only restore on a clean disk
1650 if [ ! -e "${BASEDIR}/build${TOOLS_DIR}/.toolchain-successful" ]; then
1651 if [ ! -n "$PACKAGE" ]; then
1652 print_build_stage
"Full toolchain compilation"
1656 PACKAGENAME
=${PACKAGE%.tar.xz}
1657 print_build_stage
"Packaged toolchain compilation"
1658 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
1662 exiterror
"$PACKAGENAME md5 did not match, check downloaded package"
1669 print_build_stage
"Building LFS"
1672 print_build_stage
"Building IPFire"
1675 print_build_stage
"Building installer"
1678 print_build_stage
"Building packages"
1681 print_build_stage
"Checking Logfiles for new Files"
1684 tools
/checknewlog.pl
1685 tools
/checkrootfiles
1688 print_build_summary $
(( $
(now
) - ${START_TIME} ))
1691 # enter a shell inside LFS chroot
1692 # may be used to changed kernel settings
1697 print_line
"Cleaning build directory..."
1699 for i
in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
1700 $LOSETUP -d $i 2>/dev
/null
1702 for i
in `mount | grep $BASEDIR | cut -d " " -f 1`; do
1706 for i
in `seq 0 7`; do
1707 if ( losetup
/dev
/loop
${i} 2>/dev
/null |
grep -q "/install/images" ); then
1708 umount
/dev
/loop
${i} 2>/dev
/null
;
1709 losetup
-d /dev
/loop
${i} 2>/dev
/null
;
1712 rm -rf $BASEDIR/build
1713 rm -rf $BASEDIR/cdrom
1714 rm -rf $BASEDIR/packages
1716 if [ -h "${TOOLS_DIR}" ]; then
1717 rm -f "${TOOLS_DIR}"
1719 rm -f $BASEDIR/ipfire-
*
1723 if [ ! -d $BASEDIR/cache
]; then
1724 mkdir
$BASEDIR/cache
1726 mkdir
-p $BASEDIR/log
1727 echo -e "${BOLD}Preload all source files${NORMAL}" |
tee -a $LOGFILE
1730 for c
in `seq $MAX_RETRIES`; do
1731 if (( FINISHED
==1 )); then
1737 if [ -f "$i" -a "$i" != "Config" ]; then
1738 lfsmakecommoncheck
${i} ||
continue
1740 make -s -f $i LFS_BASEDIR
=$BASEDIR BUILD_ARCH
="${BUILD_ARCH}" \
1741 MESSAGE
="$i\t ($c/$MAX_RETRIES)" download
>> $LOGFILE 2>&1
1742 if [ $?
-ne 0 ]; then
1746 if [ $c -eq 1 ]; then
1753 echo -e "${BOLD}***Verifying md5sums${NORMAL}"
1756 if [ -f "$i" -a "$i" != "Config" ]; then
1757 lfsmakecommoncheck
${i} > /dev
/null ||
continue
1758 make -s -f $i LFS_BASEDIR
=$BASEDIR BUILD_ARCH
="${BUILD_ARCH}" \
1759 MESSAGE
="$i\t " md5
>> $LOGFILE 2>&1
1760 if [ $?
-ne 0 ]; then
1761 echo -ne "MD5 difference in lfs/$i"
1767 if [ $ERROR -eq 0 ]; then
1768 echo -ne "${BOLD}all files md5sum match${NORMAL}"
1771 echo -ne "${BOLD}not all files were correctly download${NORMAL}"
1774 cd - >/dev
/null
2>&1
1778 ${INTERACTIVE} && clear
1781 print_build_stage
"Toolchain compilation"
1783 echo "`date -u '+%b %e %T'`: Create toolchain image for ${BUILD_ARCH}" |
tee -a $LOGFILE
1784 test -d $BASEDIR/cache
/toolchains || mkdir
-p $BASEDIR/cache
/toolchains
1785 cd $BASEDIR && XZ_OPT
="-T0 -8" tar -Jc --exclude='log/_build.*.log' -f cache
/toolchains
/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.
tar.xz \
1786 build
/${TOOLS_DIR} build
/bin
/sh log
>> $LOGFILE
1787 md5sum cache
/toolchains
/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.
tar.xz \
1788 > cache
/toolchains
/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.md5
1792 # arbitrary name to be updated in case of new toolchain package upload
1793 PACKAGE
=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}
1794 if [ ! -f $BASEDIR/cache
/toolchains
/$PACKAGE.
tar.xz
]; then
1795 URL_TOOLCHAIN
=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
1796 test -d $BASEDIR/cache
/toolchains || mkdir
-p $BASEDIR/cache
/toolchains
1797 echo "`date -u '+%b %e %T'`: Load toolchain image for ${BUILD_ARCH}" |
tee -a $LOGFILE
1798 cd $BASEDIR/cache
/toolchains
1799 wget
-U "IPFireSourceGrabber/2.x" $URL_TOOLCHAIN/$PACKAGE.
tar.xz
$URL_TOOLCHAIN/$PACKAGE.md5
>& /dev
/null
1800 if [ $?
-ne 0 ]; then
1801 echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for ${BUILD_ARCH} machine" |
tee -a $LOGFILE
1803 if [ "`md5sum $PACKAGE.tar.xz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1804 echo "`date -u '+%b %e %T'`: toolchain md5 ok" |
tee -a $LOGFILE
1806 exiterror
"$PACKAGE.md5 did not match, check downloaded package"
1810 echo "Toolchain is already downloaded. Exiting..."
1815 if [ -z $IPFIRE_USER ]; then
1816 echo -n "You have to setup IPFIRE_USER first. See .config for details."
1821 URL_SOURCE
=$
(grep URL_SOURCE lfs
/Config |
awk '{ print $3 }')
1822 REMOTE_FILES
=$
(echo "ls -1" | sftp
-C ${IPFIRE_USER}@
${URL_SOURCE})
1824 for file in ${BASEDIR}/cache
/*; do
1825 [ -d "${file}" ] && continue
1826 grep -q "$(basename ${file})" <<<$REMOTE_FILES && continue
1827 NEW_FILES
="$NEW_FILES $file"
1829 [ -n "$NEW_FILES" ] && scp
-2 $NEW_FILES ${IPFIRE_USER}@
${URL_SOURCE}
1835 echo -ne "Checking the translations for missing or obsolete strings..."
1836 chmod 755 $BASEDIR/tools
/{check_strings.pl
,sort_strings.pl
,check_langs.sh
}
1837 $BASEDIR/tools
/sort_strings.pl en
1838 $BASEDIR/tools
/sort_strings.pl de
1839 $BASEDIR/tools
/sort_strings.pl fr
1840 $BASEDIR/tools
/sort_strings.pl es
1841 $BASEDIR/tools
/sort_strings.pl pl
1842 $BASEDIR/tools
/sort_strings.pl ru
1843 $BASEDIR/tools
/sort_strings.pl
nl
1844 $BASEDIR/tools
/sort_strings.pl
tr
1845 $BASEDIR/tools
/sort_strings.pl it
1846 $BASEDIR/tools
/check_strings.pl en
> $BASEDIR/doc
/language_issues.en
1847 $BASEDIR/tools
/check_strings.pl de
> $BASEDIR/doc
/language_issues.de
1848 $BASEDIR/tools
/check_strings.pl fr
> $BASEDIR/doc
/language_issues.fr
1849 $BASEDIR/tools
/check_strings.pl es
> $BASEDIR/doc
/language_issues.es
1850 $BASEDIR/tools
/check_strings.pl es
> $BASEDIR/doc
/language_issues.pl
1851 $BASEDIR/tools
/check_strings.pl ru
> $BASEDIR/doc
/language_issues.ru
1852 $BASEDIR/tools
/check_strings.pl
nl > $BASEDIR/doc
/language_issues.
nl
1853 $BASEDIR/tools
/check_strings.pl
tr > $BASEDIR/doc
/language_issues.
tr
1854 $BASEDIR/tools
/check_strings.pl it
> $BASEDIR/doc
/language_issues.it
1855 $BASEDIR/tools
/check_langs.sh
> $BASEDIR/doc
/language_missings
1858 echo -ne "Updating language lists..."
1859 update_language_list
${BASEDIR}/src
/installer
/po
1860 update_language_list
${BASEDIR}/src
/setup
/po
1864 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
1865 cat doc
/make.sh-usage