]> git.ipfire.org Git - ipfire-2.x.git/blob - make.sh
make.sh: Refactor build status code
[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="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
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=20171121
41
42 ###############################################################################
43 #
44 # Beautifying variables & presentation & input output interface
45 #
46 ###############################################################################
47
48 # Remember if the shell is interactive or not
49 if [ -t 0 ] && [ -t 1 ]; then
50 INTERACTIVE=true
51 else
52 INTERACTIVE=false
53 fi
54
55 ## Screen Dimentions
56 # Find current screen size
57 if [ -z "${COLUMNS}" ]; then
58 COLUMNS=$(stty size)
59 COLUMNS=${COLUMNS##* }
60 fi
61
62 # When using remote connections, such as a serial port, stty size returns 0
63 if ! ${INTERACTIVE} || [ "${COLUMNS}" = "0" ]; then
64 COLUMNS=80
65 fi
66
67 ## Measurements for positioning result messages
68 OPTIONS_WIDTH=20
69 TIME_WIDTH=12
70 STATUS_WIDTH=8
71 NAME_WIDTH=$(( COLUMNS - OPTIONS_WIDTH - TIME_WIDTH - STATUS_WIDTH ))
72 LINE_WIDTH=$(( COLUMNS - STATUS_WIDTH ))
73
74 TIME_COL=$(( COLUMNS - TIME_WIDTH - STATUS_WIDTH ))
75 STATUS_COL=$(( COLUMNS - STATUS_WIDTH ))
76
77 # Define color for messages
78 BOLD="\\033[1;39m"
79 DONE="\\033[1;32m"
80 SKIP="\\033[1;34m"
81 WARN="\\033[1;35m"
82 FAIL="\\033[1;31m"
83 NORMAL="\\033[0;39m"
84
85 # New architecture variables
86 HOST_ARCH="$(uname -m)"
87
88 PWD=$(pwd)
89 BASENAME=$(basename $0)
90
91 # Debian specific settings
92 if [ ! -e /etc/debian_version ]; then
93 FULLPATH=`which $0`
94 else
95 if [ -x /usr/bin/realpath ]; then
96 FULLPATH=`/usr/bin/realpath $0`
97 else
98 echo "ERROR: Need to do apt-get install realpath"
99 exit 1
100 fi
101 fi
102
103 # This is the directory where make.sh is in
104 export BASEDIR=$(echo $FULLPATH | sed "s/\/$BASENAME//g")
105
106 LOGFILE=$BASEDIR/log/_build.preparation.log
107 export LOGFILE
108 DIR_CHK=$BASEDIR/cache/check
109 mkdir $BASEDIR/log/ 2>/dev/null
110
111 system_processors() {
112 getconf _NPROCESSORS_ONLN 2>/dev/null || echo "1"
113 }
114
115 system_memory() {
116 local key val unit
117
118 while read -r key val unit; do
119 case "${key}" in
120 MemTotal:*)
121 # Convert to MB
122 echo "$(( ${val} / 1024 ))"
123 break
124 ;;
125 esac
126 done < /proc/meminfo
127 }
128
129 configure_build() {
130 local build_arch="${1}"
131
132 if [ "${build_arch}" = "default" ]; then
133 build_arch="$(configure_build_guess)"
134 fi
135
136 case "${build_arch}" in
137 x86_64)
138 BUILDTARGET="${build_arch}-unknown-linux-gnu"
139 CROSSTARGET="${build_arch}-cross-linux-gnu"
140 BUILD_PLATFORM="x86"
141 CFLAGS_ARCH="-m64 -mtune=generic"
142 ;;
143
144 i586)
145 BUILDTARGET="${build_arch}-pc-linux-gnu"
146 CROSSTARGET="${build_arch}-cross-linux-gnu"
147 BUILD_PLATFORM="x86"
148 CFLAGS_ARCH="-march=i586 -mtune=generic -fomit-frame-pointer"
149 ;;
150
151 aarch64)
152 BUILDTARGET="${build_arch}-unknown-linux-gnu"
153 CROSSTARGET="${build_arch}-cross-linux-gnu"
154 BUILD_PLATFORM="arm"
155 CFLAGS_ARCH=""
156 ;;
157
158 armv7hl)
159 BUILDTARGET="${build_arch}-unknown-linux-gnueabi"
160 CROSSTARGET="${build_arch}-cross-linux-gnueabi"
161 BUILD_PLATFORM="arm"
162 CFLAGS_ARCH="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
163 ;;
164
165 armv5tel)
166 BUILDTARGET="${build_arch}-unknown-linux-gnueabi"
167 CROSSTARGET="${build_arch}-cross-linux-gnueabi"
168 BUILD_PLATFORM="arm"
169 CFLAGS_ARCH="-march=armv5te -mfloat-abi=soft -fomit-frame-pointer"
170 ;;
171
172 *)
173 exiterror "Cannot build for architure ${build_arch}"
174 ;;
175 esac
176
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}")"
180
181 if [ -n "${qemu_build_helper}" ]; then
182 QEMU_TARGET_HELPER="${qemu_build_helper}"
183 else
184 exiterror "Could not find a binfmt_misc helper entry for ${build_arch}"
185 fi
186 fi
187
188 BUILD_ARCH="${build_arch}"
189 TOOLS_DIR="/tools_${BUILD_ARCH}"
190
191 # Enables hardening
192 HARDENING_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4"
193
194 CFLAGS="-O2 -pipe -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
195 CXXFLAGS="${CFLAGS}"
196
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 ))
203
204 local processors="$(system_processors)"
205 local cpu_max=$(( ${processors} * 2 ))
206
207 local parallelism
208 if [ ${mem_max} -lt ${cpu_max} ]; then
209 parallelism=${mem_max}
210 else
211 parallelism=${cpu_max}
212 fi
213
214 MAKETUNING="-j${parallelism}"
215 fi
216 }
217
218 configure_build_guess() {
219 case "${HOST_ARCH}" in
220 x86_64|i686|i586)
221 echo "i586"
222 ;;
223
224 aarch64)
225 echo "aarch64"
226 ;;
227
228 armv7*|armv6*|armv5*)
229 echo "armv5tel"
230 ;;
231
232 *)
233 exiterror "Cannot guess build architecture"
234 ;;
235 esac
236 }
237
238 stdumount() {
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;
254 }
255
256 now() {
257 date -u "+%s"
258 }
259
260 format_runtime() {
261 local seconds=${1}
262
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
269 printf "%d:%02d\n" \
270 "$(( seconds / 60 ))" \
271 "$(( seconds % 60 ))"
272 else
273 printf "%d\n" "${seconds}"
274 fi
275 }
276
277 print_line() {
278 local line="$@"
279
280 printf "%-${LINE_WIDTH}s" "${line}"
281 }
282
283 _print_line() {
284 local status="${1}"
285 shift
286
287 if ${INTERACTIVE}; then
288 printf "${!status}"
289 fi
290
291 print_line "$@"
292
293 if ${INTERACTIVE}; then
294 printf "${NORMAL}"
295 fi
296 }
297
298 print_headline() {
299 _print_line BOLD "$@"
300 }
301
302 print_error() {
303 _print_line FAIL "$@"
304 }
305
306 print_package() {
307 local name="${1}"
308 shift
309
310 local version="$(grep -E "^VER |^VER=|^VER " $BASEDIR/lfs/${name} | awk '{ print $3 }')"
311 local options="$@"
312
313 local string="${name}"
314 if [ -n "${version}" ] && [ "${version}" != "ipfire" ]; then
315 string="${string} (${version})"
316 fi
317
318 printf "%-$(( ${NAME_WIDTH} - 1 ))s " "${string}"
319
320 if [ -n "${options}" ]; then
321 printf "[ %-$(( ${OPTIONS_WIDTH} - 4 ))s ]" "${options}"
322 else
323 printf "%${OPTIONS_WIDTH}s" ""
324 fi
325 }
326
327 print_runtime() {
328 local runtime=$(format_runtime $@)
329
330 if ${INTERACTIVE}; then
331 printf "\\033[${TIME_COL}G[ ${BOLD}%$(( ${TIME_WIDTH} - 4 ))s${NORMAL} ]" "${runtime}"
332 else
333 printf "[ %$(( ${TIME_WIDTH} - 4 ))s ]" "${runtime}"
334 fi
335 }
336
337 print_status() {
338 local status="${1}"
339
340 local color="${!status}"
341
342 if ${INTERACTIVE}; then
343 printf "\\033[${STATUS_COL}G[${color-${BOLD}} %-$(( ${STATUS_WIDTH} - 4 ))s ${NORMAL}]\n" "${status}"
344 else
345 printf "[ %-$(( ${STATUS_WIDTH} - 4 ))s ]\n" "${status}"
346 fi
347 }
348
349 print_build_stage() {
350 print_headline "$@"
351
352 # end line
353 printf "\n"
354 }
355
356 print_build_summary() {
357 local runtime=$(format_runtime $@)
358
359 print_line "*** Build finished in ${runtime}"
360 print_status DONE
361 }
362
363 exiterror() {
364 stdumount
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
368 fi;
369 done
370
371 # Dump logfile
372 if [ -n "${LOGFILE}" ]; then
373 echo # empty line
374
375 local line
376 while read -r line; do
377 echo " ${line}"
378 done <<< "$(tail -n30 ${LOGFILE})"
379 fi
380
381 echo # empty line
382
383 local line
384 for line in "ERROR: $@" " Check ${LOGFILE} for errors if applicable"; do
385 print_error "${line}"
386 print_status FAIL
387 done
388
389 exit 1
390 }
391
392 prepareenv() {
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."
396 fi
397
398 if [ -z "${BASH_VERSION}" ]; then
399 exiterror "Not running BASH shell."
400 fi
401
402 # Trap on emergency exit
403 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
404
405 # Resetting our nice level
406 if ! renice ${NICE} $$ >/dev/null; then
407 exiterror "Failed to set nice level to ${NICE}"
408 fi
409
410 # Checking if running as root user
411 if [ $(id -u) -ne 0 ]; then
412 exiterror "Not building as root"
413 fi
414
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
422 print_status FAIL
423 exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
424 fi
425 else
426 print_status DONE
427 fi
428
429 # Set umask
430 umask 022
431
432 # Set LFS Directory
433 LFS=$BASEDIR/build
434
435 # Check ${TOOLS_DIR} symlink
436 if [ -h "${TOOLS_DIR}" ]; then
437 rm -f "${TOOLS_DIR}"
438 fi
439
440 if [ ! -e "${TOOLS_DIR}" ]; then
441 ln -s "${BASEDIR}/build${TOOLS_DIR}" "${TOOLS_DIR}"
442 fi
443
444 if [ ! -h "${TOOLS_DIR}" ]; then
445 exiterror "Could not create ${TOOLS_DIR} symbolic link"
446 fi
447
448 # Setup environment
449 set +h
450 LC_ALL=POSIX
451 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
452 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
453
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}
460
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
463
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
479
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}"
484
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
487
488 # Prepare string for /etc/system-release.
489 SYSTEM_RELEASE="${NAME} ${VERSION} (${BUILD_ARCH})"
490 if [ "$(git status -s | wc -l)" == "0" ]; then
491 GIT_STATUS=""
492 else
493 GIT_STATUS="-dirty"
494 fi
495 case "$GIT_BRANCH" in
496 core*|beta?|rc?)
497 SYSTEM_RELEASE="${SYSTEM_RELEASE} - $GIT_BRANCH$GIT_STATUS"
498 ;;
499 *)
500 SYSTEM_RELEASE="${SYSTEM_RELEASE} - Development Build: $GIT_BRANCH/$GIT_LASTCOMMIT$GIT_STATUS"
501 ;;
502 esac
503 }
504
505 enterchroot() {
506 # Install QEMU helper, if needed
507 qemu_install_helper
508
509 local PATH="${TOOLS_DIR}/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/bin"
510
511 PATH="${PATH}" chroot ${LFS} env -i \
512 HOME="/root" \
513 TERM="${TERM}" \
514 PS1="${PS1}" \
515 PATH="${PATH}" \
516 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
517 PAKFIRE_CORE="${PAKFIRE_CORE}" \
518 NAME="${NAME}" \
519 SNAME="${SNAME}" \
520 VERSION="${VERSION}" \
521 CORE="${CORE}" \
522 SLOGAN="${SLOGAN}" \
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}" \
534 KVER="${KVER}" \
535 $(fake_environ) \
536 $(qemu_environ) \
537 "$@"
538 }
539
540 entershell() {
541 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
542 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
543 fi
544
545 echo "Entering to a shell inside LFS chroot, go out with exit"
546 local PS1="ipfire build chroot ($(uname -m)) \u:\w\$ "
547
548 if enterchroot bash -i; then
549 stdumount
550 else
551 print_status FAIL
552 exiterror "chroot error"
553 fi
554 }
555
556 lfsmakecommoncheck() {
557 # Script present?
558 if [ ! -f $BASEDIR/lfs/$1 ]; then
559 exiterror "No such file or directory: $BASEDIR/$1"
560 fi
561
562 # Print package name and version
563 print_package $@
564
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
570 print_status SKIP
571 return 1
572 fi
573 fi
574
575 # Script slipped?
576 local i
577 for i in $SKIP_PACKAGE_LIST
578 do
579 if [ "$i" == "$1" ]; then
580 print_status SKIP
581 return 1;
582 fi
583 done
584
585 echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
586
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"
591 fi
592
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"
597 fi
598
599 return 0 # pass all!
600 }
601
602 lfsmake1() {
603 lfsmakecommoncheck $*
604 [ $? == 1 ] && return 0
605
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}" \
611 CFLAGS="${CFLAGS}" \
612 CXXFLAGS="${CXXFLAGS}" \
613 MAKETUNING="${MAKETUNING}" \
614 make -f $* \
615 TOOLCHAIN=1 \
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}" \
622 ROOT="${LFS}" \
623 KVER="${KVER}" \
624 install >> $LOGFILE 2>&1 &
625
626 if ! wait_until_finished $!; then
627 print_status FAIL
628 exiterror "Building $*"
629 fi
630
631 print_status DONE
632 }
633
634 lfsmake2() {
635 lfsmakecommoncheck $*
636 [ $? == 1 ] && return 0
637
638 local PS1='\u:\w$ '
639
640 enterchroot \
641 bash -x -c "cd /usr/src/lfs && \
642 MAKETUNING=${MAKETUNING} \
643 make -f $* \
644 LFS_BASEDIR=/usr/src install" \
645 >> ${LOGFILE} 2>&1 &
646
647 if ! wait_until_finished $!; then
648 print_status FAIL
649 exiterror "Building $*"
650 fi
651
652 print_status DONE
653 }
654
655 ipfiredist() {
656 lfsmakecommoncheck $*
657 [ $? == 1 ] && return 0
658
659 local PS1='\u:\w$ '
660
661 enterchroot \
662 bash -x -c "cd /usr/src/lfs && make -f $* LFS_BASEDIR=/usr/src dist" \
663 >> ${LOGFILE} 2>&1 &
664
665 if ! wait_until_finished $!; then
666 print_status FAIL
667 exiterror "Packaging $*"
668 fi
669
670 print_status DONE
671 }
672
673 wait_until_finished() {
674 local pid=${1}
675
676 local start_time=$(now)
677
678 # Show progress
679 if ${INTERACTIVE}; then
680 # Wait a little just in case the process
681 # has finished very quickly.
682 sleep 0.1
683
684 local runtime
685 while kill -0 ${pid} 2>/dev/null; do
686 print_runtime $(( $(now) - ${start_time} ))
687
688 # Wait a little
689 sleep 1
690 done
691 fi
692
693 # Returns the exit code of the child process
694 wait ${pid}
695 local ret=$?
696
697 if ! ${INTERACTIVE}; then
698 print_runtime $(( $(now) - ${start_time} ))
699 fi
700
701 return ${ret}
702 }
703
704 fake_environ() {
705 [ -e "${BASEDIR}/build${TOOLS_DIR}/lib/libpakfire_preload.so" ] || return
706
707 local env="LD_PRELOAD=${TOOLS_DIR}/lib/libpakfire_preload.so"
708
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}"
712
713 # Fake machine version.
714 env="${env} UTS_MACHINE=${BUILD_ARCH}"
715
716 echo "${env}"
717 }
718
719 qemu_environ() {
720 local env
721
722 # Don't add anything if qemu is not used.
723 if ! qemu_is_required; then
724 return
725 fi
726
727 # Set default qemu options
728 case "${BUILD_ARCH}" in
729 arm*)
730 QEMU_CPU="${QEMU_CPU:-cortex-a9}"
731
732 env="${env} QEMU_CPU=${QEMU_CPU}"
733 ;;
734 esac
735
736 # Enable QEMU strace
737 #env="${env} QEMU_STRACE=1"
738
739 echo "${env}"
740 }
741
742 qemu_is_required() {
743 local build_arch="${1}"
744
745 if [ -z "${build_arch}" ]; then
746 build_arch="${BUILD_ARCH}"
747 fi
748
749 case "${HOST_ARCH},${build_arch}" in
750 x86_64,arm*|i?86,arm*|i?86,x86_64)
751 return 0
752 ;;
753 *)
754 return 1
755 ;;
756 esac
757 }
758
759 qemu_install_helper() {
760 # Do nothing, if qemu is not required
761 if ! qemu_is_required; then
762 return 0
763 fi
764
765 if [ ! -e /proc/sys/fs/binfmt_misc/status ]; then
766 exiterror "binfmt_misc not mounted. QEMU_TARGET_HELPER not useable."
767 fi
768
769 if [ ! $(cat /proc/sys/fs/binfmt_misc/status) = 'enabled' ]; then
770 exiterror "binfmt_misc not enabled. QEMU_TARGET_HELPER not useable."
771 fi
772
773
774 if [ -z "${QEMU_TARGET_HELPER}" ]; then
775 exiterror "QEMU_TARGET_HELPER not set"
776 fi
777
778 # Check if the helper is already installed.
779 if [ -x "${LFS}${QEMU_TARGET_HELPER}" ]; then
780 return 0
781 fi
782
783 # Try to find a suitable binary that we can install
784 # to the build environment.
785 local file
786 for file in "${QEMU_TARGET_HELPER}" "${QEMU_TARGET_HELPER}-static"; do
787 # file must exist and be executable.
788 [ -x "${file}" ] || continue
789
790 # Must be static.
791 file_is_static "${file}" || continue
792
793 local dirname="${LFS}$(dirname "${file}")"
794 mkdir -p "${dirname}"
795
796 install -m 755 "${file}" "${LFS}${QEMU_TARGET_HELPER}"
797 return 0
798 done
799
800 exiterror "Could not find a statically-linked QEMU emulator: ${QEMU_TARGET_HELPER}"
801 }
802
803 qemu_find_build_helper_name() {
804 local build_arch="${1}"
805
806 local magic
807 case "${build_arch}" in
808 arm*)
809 magic="7f454c4601010100000000000000000002002800"
810 ;;
811 x86_64)
812 magic="7f454c4602010100000000000000000002003e00"
813 ;;
814 esac
815
816 [ -z "${magic}" ] && return 1
817
818 local file
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
824
825 local interpreter="$(grep "^interpreter" "${file}" | awk '{ print $2 }')"
826
827 [ -n "${interpreter}" ] || continue
828 [ "${interpreter:0:1}" = "/" ] || continue
829 [ -x "${interpreter}" ] || continue
830
831 echo "${interpreter}"
832 return 0
833 done
834
835 return 1
836 }
837
838 file_is_static() {
839 local file="${1}"
840
841 file ${file} 2>/dev/null | grep -q "statically linked"
842 }
843
844 update_language_list() {
845 local path="${1}"
846
847 local lang
848 for lang in ${path}/*.po; do
849 lang="$(basename "${lang}")"
850 echo "${lang%*.po}"
851 done | sort -u > "${path}/LINGUAS"
852 }
853
854 # Load configuration file
855 if [ -f .config ]; then
856 . .config
857 fi
858
859 # TARGET_ARCH is BUILD_ARCH now
860 if [ -n "${TARGET_ARCH}" ]; then
861 BUILD_ARCH="${TARGET_ARCH}"
862 unset TARGET_ARCH
863 fi
864
865 # Get the amount of memory in this build system
866 HOST_MEM=$(system_memory)
867
868 if [ -n "${BUILD_ARCH}" ]; then
869 configure_build "${BUILD_ARCH}"
870 else
871 configure_build "default"
872 fi
873
874 buildtoolchain() {
875 local error=false
876 case "${BUILD_ARCH}:${HOST_ARCH}" in
877 # x86_64
878 x86_64:x86_64)
879 # This is working.
880 ;;
881
882 # x86
883 i586:i586|i586:i686|i586:x86_64)
884 # These are working.
885 ;;
886 i586:*)
887 error=true
888 ;;
889
890 # ARM
891 arvm7hl:armv7hl|armv7hl:armv7l)
892 # These are working.
893 ;;
894
895 armv5tel:armv5tel|armv5tel:armv5tejl|armv5tel:armv6l|armv5tel:armv7l|armv5tel:aarch64)
896 # These are working.
897 ;;
898 armv5tel:*)
899 error=true
900 ;;
901 esac
902
903 ${error} && \
904 exiterror "Cannot build ${BUILD_ARCH} toolchain on $(uname -m). Please use the download if any."
905
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."
909 fi
910
911 LOGFILE="$BASEDIR/log/_build.toolchain.log"
912 export LOGFILE
913
914 lfsmake1 stage1
915 lfsmake1 ccache PASS=1
916 lfsmake1 binutils PASS=1
917 lfsmake1 gcc PASS=1
918 lfsmake1 linux KCFG="-headers"
919 lfsmake1 glibc
920 lfsmake1 gcc PASS=L
921 lfsmake1 binutils PASS=2
922 lfsmake1 gcc PASS=2
923 lfsmake1 ccache PASS=2
924 lfsmake1 tcl
925 lfsmake1 expect
926 lfsmake1 dejagnu
927 lfsmake1 pkg-config
928 lfsmake1 ncurses
929 lfsmake1 bash
930 lfsmake1 bzip2
931 lfsmake1 automake
932 lfsmake1 coreutils
933 lfsmake1 diffutils
934 lfsmake1 findutils
935 lfsmake1 gawk
936 lfsmake1 gettext
937 lfsmake1 grep
938 lfsmake1 gzip
939 lfsmake1 m4
940 lfsmake1 make
941 lfsmake1 patch
942 lfsmake1 perl
943 lfsmake1 sed
944 lfsmake1 tar
945 lfsmake1 texinfo
946 lfsmake1 xz
947 lfsmake1 fake-environ
948 lfsmake1 cleanup-toolchain
949 }
950
951 buildbase() {
952 LOGFILE="$BASEDIR/log/_build.base.log"
953 export LOGFILE
954 lfsmake2 stage2
955 lfsmake2 linux KCFG="-headers"
956 lfsmake2 man-pages
957 lfsmake2 glibc
958 lfsmake2 tzdata
959 lfsmake2 cleanup-toolchain
960 lfsmake2 zlib
961 lfsmake2 binutils
962 lfsmake2 gmp
963 lfsmake2 gmp-compat
964 lfsmake2 mpfr
965 lfsmake2 libmpc
966 lfsmake2 file
967 lfsmake2 gcc
968 lfsmake2 sed
969 lfsmake2 autoconf
970 lfsmake2 automake
971 lfsmake2 berkeley
972 lfsmake2 coreutils
973 lfsmake2 iana-etc
974 lfsmake2 m4
975 lfsmake2 bison
976 lfsmake2 ncurses-compat
977 lfsmake2 ncurses
978 lfsmake2 procps
979 lfsmake2 libtool
980 lfsmake2 perl
981 lfsmake2 readline
982 lfsmake2 readline-compat
983 lfsmake2 bzip2
984 lfsmake2 pcre
985 lfsmake2 pcre-compat
986 lfsmake2 bash
987 lfsmake2 diffutils
988 lfsmake2 e2fsprogs
989 lfsmake2 ed
990 lfsmake2 findutils
991 lfsmake2 flex
992 lfsmake2 gawk
993 lfsmake2 gettext
994 lfsmake2 grep
995 lfsmake2 groff
996 lfsmake2 gperf
997 lfsmake2 gzip
998 lfsmake2 hostname
999 lfsmake2 iproute2
1000 lfsmake2 jwhois
1001 lfsmake2 kbd
1002 lfsmake2 less
1003 lfsmake2 make
1004 lfsmake2 man
1005 lfsmake2 kmod
1006 lfsmake2 net-tools
1007 lfsmake2 patch
1008 lfsmake2 psmisc
1009 lfsmake2 shadow
1010 lfsmake2 sysklogd
1011 lfsmake2 sysvinit
1012 lfsmake2 tar
1013 lfsmake2 texinfo
1014 lfsmake2 util-linux
1015 lfsmake2 udev
1016 lfsmake2 vim
1017 lfsmake2 xz
1018 lfsmake2 paxctl
1019 }
1020
1021 buildipfire() {
1022 LOGFILE="$BASEDIR/log/_build.ipfire.log"
1023 export LOGFILE
1024 lfsmake2 configroot
1025 lfsmake2 initscripts
1026 lfsmake2 backup
1027 lfsmake2 pkg-config
1028 lfsmake2 libusb
1029 lfsmake2 libusb-compat
1030 lfsmake2 libpcap
1031 lfsmake2 ppp
1032 lfsmake2 pptp
1033 lfsmake2 unzip
1034 lfsmake2 which
1035 lfsmake2 linux-firmware
1036 lfsmake2 ath10k-firmware
1037 lfsmake2 dvb-firmwares
1038 lfsmake2 mt7601u-firmware
1039 lfsmake2 zd1211-firmware
1040 lfsmake2 rpi-firmware
1041 lfsmake2 bc
1042 lfsmake2 u-boot
1043 lfsmake2 cpio
1044 lfsmake2 mdadm
1045 lfsmake2 dracut
1046 lfsmake2 lvm2
1047 lfsmake2 multipath-tools
1048 lfsmake2 freetype
1049 lfsmake2 grub
1050 lfsmake2 libmnl
1051 lfsmake2 libnfnetlink
1052 lfsmake2 libnetfilter_queue
1053 lfsmake2 libnetfilter_conntrack
1054 lfsmake2 libnetfilter_cthelper
1055 lfsmake2 libnetfilter_cttimeout
1056 lfsmake2 iptables
1057
1058 case "${BUILD_ARCH}" in
1059 x86_64)
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=""
1067 ;;
1068 i586)
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"
1077
1078 # x86 kernel build
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=""
1086 ;;
1087
1088 armv5tel)
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"
1094
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"
1103
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"
1112 ;;
1113 esac
1114 lfsmake2 xtables-addons USPACE="1"
1115 lfsmake2 openssl
1116 [ "${BUILD_ARCH}" = "i586" ] && lfsmake2 openssl KCFG='-sse2'
1117 lfsmake2 libgpg-error
1118 lfsmake2 libgcrypt
1119 lfsmake2 libassuan
1120 lfsmake2 nettle
1121 lfsmake2 libevent
1122 lfsmake2 libevent2
1123 lfsmake2 libevent2-compat
1124 lfsmake2 expat
1125 lfsmake2 apr
1126 lfsmake2 aprutil
1127 lfsmake2 unbound
1128 lfsmake2 gnutls
1129 lfsmake2 bind
1130 lfsmake2 dhcp
1131 lfsmake2 dhcpcd
1132 lfsmake2 boost
1133 lfsmake2 linux-atm
1134 lfsmake2 gdbm
1135 lfsmake2 pam
1136 lfsmake2 curl
1137 lfsmake2 tcl
1138 lfsmake2 sqlite
1139 lfsmake2 libffi
1140 lfsmake2 python
1141 lfsmake2 python3
1142 lfsmake2 ca-certificates
1143 lfsmake2 fireinfo
1144 lfsmake2 libnet
1145 lfsmake2 libnl
1146 lfsmake2 libnl-3
1147 lfsmake2 libidn
1148 lfsmake2 nasm
1149 lfsmake2 libjpeg
1150 lfsmake2 libjpeg-compat
1151 lfsmake2 libexif
1152 lfsmake2 libpng
1153 lfsmake2 libtiff
1154 lfsmake2 libart
1155 lfsmake2 gd
1156 lfsmake2 popt
1157 lfsmake2 slang
1158 lfsmake2 newt
1159 lfsmake2 libsmooth
1160 lfsmake2 attr
1161 lfsmake2 acl
1162 lfsmake2 libcap
1163 lfsmake2 pciutils
1164 lfsmake2 usbutils
1165 lfsmake2 libxml2
1166 lfsmake2 libxslt
1167 lfsmake2 BerkeleyDB
1168 lfsmake2 mysql
1169 lfsmake2 cyrus-sasl
1170 lfsmake2 openldap
1171 lfsmake2 apache2
1172 lfsmake2 php
1173 lfsmake2 web-user-interface
1174 lfsmake2 flag-icons
1175 lfsmake2 jquery
1176 lfsmake2 bootstrap
1177 lfsmake2 arping
1178 lfsmake2 beep
1179 lfsmake2 dvdrtools
1180 lfsmake2 dosfstools
1181 lfsmake2 reiserfsprogs
1182 lfsmake2 xfsprogs
1183 lfsmake2 sysfsutils
1184 lfsmake2 fuse
1185 lfsmake2 ntfs-3g
1186 lfsmake2 ethtool
1187 lfsmake2 ez-ipupdate
1188 lfsmake2 fcron
1189 lfsmake2 perl-GD
1190 lfsmake2 GD-Graph
1191 lfsmake2 GD-TextUtil
1192 lfsmake2 perl-Device-SerialPort
1193 lfsmake2 perl-Device-Modem
1194 lfsmake2 perl-Apache-Htpasswd
1195 lfsmake2 gnupg
1196 lfsmake2 hdparm
1197 lfsmake2 sdparm
1198 lfsmake2 mtools
1199 lfsmake2 whatmask
1200 lfsmake2 conntrack-tools
1201 lfsmake2 libupnp
1202 lfsmake2 ipaddr
1203 lfsmake2 iputils
1204 lfsmake2 l7-protocols
1205 lfsmake2 mISDNuser
1206 lfsmake2 capi4k-utils
1207 lfsmake2 hwdata
1208 lfsmake2 logrotate
1209 lfsmake2 logwatch
1210 lfsmake2 misc-progs
1211 lfsmake2 nano
1212 lfsmake2 URI
1213 lfsmake2 HTML-Tagset
1214 lfsmake2 HTML-Parser
1215 lfsmake2 HTML-Template
1216 lfsmake2 Compress-Zlib
1217 lfsmake2 Digest
1218 lfsmake2 Digest-SHA1
1219 lfsmake2 Digest-HMAC
1220 lfsmake2 libwww-perl
1221 lfsmake2 Net-DNS
1222 lfsmake2 Net-IPv4Addr
1223 lfsmake2 Net_SSLeay
1224 lfsmake2 IO-Stringy
1225 lfsmake2 IO-Socket-SSL
1226 lfsmake2 Unix-Syslog
1227 lfsmake2 Mail-Tools
1228 lfsmake2 MIME-Tools
1229 lfsmake2 Net-Server
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
1236 lfsmake2 XML-Parser
1237 lfsmake2 Crypt-PasswdMD5
1238 lfsmake2 Net-Telnet
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
1248 lfsmake2 glib
1249 lfsmake2 GeoIP
1250 lfsmake2 noip_updater
1251 lfsmake2 ntp
1252 lfsmake2 openssh
1253 lfsmake2 fontconfig
1254 lfsmake2 dejavu-fonts-ttf
1255 lfsmake2 ubuntu-font-family
1256 lfsmake2 freefont
1257 lfsmake2 pixman
1258 lfsmake2 cairo
1259 lfsmake2 pango
1260 lfsmake2 rrdtool
1261 lfsmake2 setserial
1262 lfsmake2 setup
1263 lfsmake2 libdnet
1264 lfsmake2 daq
1265 lfsmake2 snort
1266 lfsmake2 oinkmaster
1267 lfsmake2 squid
1268 lfsmake2 squidguard
1269 lfsmake2 calamaris
1270 lfsmake2 tcpdump
1271 lfsmake2 traceroute
1272 lfsmake2 vlan
1273 lfsmake2 wireless
1274 lfsmake2 pakfire
1275 lfsmake2 spandsp
1276 lfsmake2 lzo
1277 lfsmake2 openvpn
1278 lfsmake2 pammysql
1279 lfsmake2 mpage
1280 lfsmake2 dbus
1281 lfsmake2 intltool
1282 lfsmake2 libdaemon
1283 lfsmake2 cups
1284 lfsmake2 lcms2
1285 lfsmake2 ghostscript
1286 lfsmake2 qpdf
1287 lfsmake2 poppler
1288 lfsmake2 cups-filters
1289 lfsmake2 epson-inkjet-printer-escpr
1290 lfsmake2 foomatic
1291 lfsmake2 hplip
1292 lfsmake2 cifs-utils
1293 lfsmake2 krb5
1294 lfsmake2 samba
1295 lfsmake2 sudo
1296 lfsmake2 mc
1297 lfsmake2 wget
1298 lfsmake2 bridge-utils
1299 lfsmake2 screen
1300 lfsmake2 smartmontools
1301 lfsmake2 htop
1302 lfsmake2 chkconfig
1303 lfsmake2 postfix
1304 lfsmake2 fetchmail
1305 lfsmake2 cyrus-imapd
1306 lfsmake2 openmailadmin
1307 lfsmake2 clamav
1308 lfsmake2 spamassassin
1309 lfsmake2 amavisd
1310 lfsmake2 dma
1311 lfsmake2 alsa
1312 lfsmake2 mpfire
1313 lfsmake2 guardian
1314 lfsmake2 libid3tag
1315 lfsmake2 libmad
1316 lfsmake2 libogg
1317 lfsmake2 libvorbis
1318 lfsmake2 libdvbpsi
1319 lfsmake2 flac
1320 lfsmake2 lame
1321 lfsmake2 sox
1322 lfsmake2 libshout
1323 lfsmake2 xvid
1324 lfsmake2 libmpeg2
1325 lfsmake2 libarchive
1326 lfsmake2 cmake
1327 lfsmake2 gnump3d
1328 lfsmake2 rsync
1329 lfsmake2 tcpwrapper
1330 lfsmake2 libtirpc
1331 lfsmake2 rpcbind
1332 lfsmake2 nfs
1333 lfsmake2 gnu-netcat
1334 lfsmake2 ncat
1335 lfsmake2 nmap
1336 lfsmake2 etherwake
1337 lfsmake2 bwm-ng
1338 lfsmake2 sysstat
1339 lfsmake2 vsftpd
1340 lfsmake2 strongswan
1341 lfsmake2 rng-tools
1342 lfsmake2 lsof
1343 lfsmake2 br2684ctl
1344 lfsmake2 pcmciautils
1345 lfsmake2 lm_sensors
1346 lfsmake2 liboping
1347 lfsmake2 collectd
1348 lfsmake2 elinks
1349 lfsmake2 igmpproxy
1350 lfsmake2 fbset
1351 lfsmake2 opus
1352 lfsmake2 python-six
1353 lfsmake2 python-pyparsing
1354 lfsmake2 spice-protocol
1355 lfsmake2 spice
1356 lfsmake2 sdl
1357 lfsmake2 libusbredir
1358 lfsmake2 qemu
1359 lfsmake2 sane
1360 lfsmake2 netpbm
1361 lfsmake2 phpSANE
1362 lfsmake2 tunctl
1363 lfsmake2 netsnmpd
1364 lfsmake2 nagios
1365 lfsmake2 nagios_nrpe
1366 lfsmake2 icinga
1367 lfsmake2 ebtables
1368 lfsmake2 directfb
1369 lfsmake2 faad2
1370 lfsmake2 ffmpeg
1371 lfsmake2 vdr
1372 lfsmake2 vdr_streamdev
1373 lfsmake2 vdr_epgsearch
1374 lfsmake2 vdr_dvbapi
1375 lfsmake2 vdr_eepg
1376 lfsmake2 w_scan
1377 lfsmake2 icecast
1378 lfsmake2 icegenerator
1379 lfsmake2 mpd
1380 lfsmake2 libmpdclient
1381 lfsmake2 mpc
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
1387 lfsmake2 git
1388 lfsmake2 squidclamav
1389 lfsmake2 vnstat
1390 lfsmake2 iw
1391 lfsmake2 wpa_supplicant
1392 lfsmake2 hostapd
1393 lfsmake2 pycurl
1394 lfsmake2 urlgrabber
1395 lfsmake2 syslinux
1396 lfsmake2 tftpd
1397 lfsmake2 cpufrequtils
1398 lfsmake2 bluetooth
1399 lfsmake2 gutenprint
1400 lfsmake2 apcupsd
1401 lfsmake2 iperf
1402 lfsmake2 iperf3
1403 lfsmake2 7zip
1404 lfsmake2 lynis
1405 lfsmake2 streamripper
1406 lfsmake2 sshfs
1407 lfsmake2 taglib
1408 #lfsmake2 mediatomb
1409 lfsmake2 sslh
1410 lfsmake2 perl-gettext
1411 lfsmake2 perl-Sort-Naturally
1412 lfsmake2 vdradmin
1413 lfsmake2 miau
1414 lfsmake2 perl-DBI
1415 lfsmake2 perl-DBD-mysql
1416 lfsmake2 perl-DBD-SQLite
1417 lfsmake2 perl-File-ReadBackwards
1418 lfsmake2 cacti
1419 lfsmake2 openvmtools
1420 lfsmake2 nagiosql
1421 lfsmake2 motion
1422 lfsmake2 joe
1423 lfsmake2 monit
1424 lfsmake2 nut
1425 lfsmake2 watchdog
1426 lfsmake2 libpri
1427 lfsmake2 libsrtp
1428 lfsmake2 asterisk
1429 lfsmake2 lcr
1430 lfsmake2 usb_modeswitch
1431 lfsmake2 usb_modeswitch_data
1432 lfsmake2 zerofree
1433 lfsmake2 pound
1434 lfsmake2 minicom
1435 lfsmake2 ddrescue
1436 lfsmake2 miniupnpd
1437 lfsmake2 client175
1438 lfsmake2 powertop
1439 lfsmake2 parted
1440 lfsmake2 swig
1441 lfsmake2 python-m2crypto
1442 lfsmake2 wireless-regdb
1443 lfsmake2 crda
1444 lfsmake2 libsolv
1445 lfsmake2 python-distutils-extra
1446 lfsmake2 python-lzma
1447 lfsmake2 python-progressbar
1448 lfsmake2 python-xattr
1449 lfsmake2 ddns
1450 lfsmake2 transmission
1451 lfsmake2 dpfhack
1452 lfsmake2 lcd4linux
1453 lfsmake2 mtr
1454 lfsmake2 minidlna
1455 lfsmake2 acpid
1456 lfsmake2 fping
1457 lfsmake2 telnet
1458 lfsmake2 xinetd
1459 lfsmake2 gpgme
1460 lfsmake2 pygpgme
1461 lfsmake2 pakfire3
1462 lfsmake2 stress
1463 lfsmake2 libstatgrab
1464 lfsmake2 sarg
1465 lfsmake2 check_mk_agent
1466 lfsmake2 nginx
1467 lfsmake2 sendEmail
1468 lfsmake2 sysbench
1469 lfsmake2 strace
1470 lfsmake2 elfutils
1471 lfsmake2 ltrace
1472 lfsmake2 ipfire-netboot
1473 lfsmake2 lcdproc
1474 lfsmake2 bitstream
1475 lfsmake2 multicat
1476 lfsmake2 keepalived
1477 lfsmake2 ipvsadm
1478 lfsmake2 perl-Carp-Clan
1479 lfsmake2 perl-Date-Calc
1480 lfsmake2 perl-Date-Manip
1481 lfsmake2 perl-File-Tail
1482 lfsmake2 perl-TimeDate
1483 lfsmake2 swatch
1484 lfsmake2 tor
1485 lfsmake2 arm
1486 lfsmake2 wavemon
1487 lfsmake2 iptraf-ng
1488 lfsmake2 iotop
1489 lfsmake2 stunnel
1490 lfsmake2 sslscan
1491 lfsmake2 owncloud
1492 lfsmake2 bacula
1493 lfsmake2 batctl
1494 lfsmake2 perl-Font-TTF
1495 lfsmake2 perl-IO-String
1496 lfsmake2 perl-PDF-API2
1497 lfsmake2 squid-accounting
1498 lfsmake2 pigz
1499 lfsmake2 tmux
1500 lfsmake2 perl-Text-CSV_XS
1501 lfsmake2 swconfig
1502 lfsmake2 haproxy
1503 lfsmake2 ipset
1504 lfsmake2 lua
1505 lfsmake2 dnsdist
1506 lfsmake2 bird
1507 lfsmake2 dmidecode
1508 lfsmake2 mcelog
1509 lfsmake2 rtpproxy
1510 lfsmake2 util-macros
1511 lfsmake2 libpciaccess
1512 lfsmake2 libyajl
1513 lfsmake2 libvirt
1514 lfsmake2 python3-libvirt
1515 lfsmake2 freeradius
1516 lfsmake2 perl-common-sense
1517 lfsmake2 perl-inotify2
1518 lfsmake2 perl-Net-IP
1519 lfsmake2 wio
1520 lfsmake2 iftop
1521 }
1522
1523 buildinstaller() {
1524 # Run installer scripts one by one
1525 LOGFILE="$BASEDIR/log/_build.installer.log"
1526 export LOGFILE
1527 lfsmake2 memtest
1528 lfsmake2 installer
1529 lfsmake1 strip
1530 }
1531
1532 buildpackages() {
1533 LOGFILE="$BASEDIR/log/_build.packages.log"
1534 export LOGFILE
1535 echo "... see detailed log in _build.*.log files" >> $LOGFILE
1536
1537
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
1544 fi
1545 done
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
1551 print_status DONE
1552
1553 # Update changelog
1554 cd $BASEDIR
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
1558
1559 # Create images for install
1560 lfsmake2 cdrom
1561
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
1567 fi
1568
1569 mv $LFS/install/images/{*.iso,*.tgz,*.img.gz,*.bz2} $BASEDIR >> $LOGFILE 2>&1
1570
1571 ipfirepackages
1572
1573 lfsmake2 xen-image
1574 mv $LFS/install/images/*.bz2 $BASEDIR >> $LOGFILE 2>&1
1575
1576 cd $BASEDIR
1577
1578 # remove not useable iso on armv5tel (needed to build flash images)
1579 [ "${BUILD_ARCH}" = "armv5tel" ] && rm -rf *.iso
1580
1581 for i in `ls *.bz2 *.img.gz *.iso`; do
1582 md5sum $i > $i.md5
1583 done
1584 cd $PWD
1585
1586 # Cleanup
1587 stdumount
1588 rm -rf $BASEDIR/build/tmp/*
1589
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
1599 fi
1600 done
1601 print_status DONE
1602
1603 cd $PWD
1604 }
1605
1606 ipfirepackages() {
1607 lfsmake2 core-updates
1608
1609 local i
1610 for i in $(find $BASEDIR/config/rootfiles/packages{/${BUILD_ARCH},} -maxdepth 1 -type f); do
1611 i=$(basename ${i})
1612 if [ -e $BASEDIR/lfs/$i ]; then
1613 ipfiredist $i
1614 else
1615 echo -n $i
1616 print_status SKIP
1617 fi
1618 done
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/*
1622 }
1623
1624 while [ $# -gt 0 ]; do
1625 case "${1}" in
1626 --target=*)
1627 configure_build "${1#--target=}"
1628 ;;
1629 -*)
1630 exiterror "Unknown configuration option: ${1}"
1631 ;;
1632 *)
1633 # Found a command, so exit options parsing.
1634 break
1635 ;;
1636 esac
1637 shift
1638 done
1639
1640 # See what we're supposed to do
1641 case "$1" in
1642 build)
1643 START_TIME=$(now)
1644
1645 # Clear screen
1646 ${INTERACTIVE} && clear
1647
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"
1653 prepareenv
1654 buildtoolchain
1655 else
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
1659 tar axf $PACKAGE
1660 prepareenv
1661 else
1662 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
1663 fi
1664 fi
1665 else
1666 prepareenv
1667 fi
1668
1669 print_build_stage "Building LFS"
1670 buildbase
1671
1672 print_build_stage "Building IPFire"
1673 buildipfire
1674
1675 print_build_stage "Building installer"
1676 buildinstaller
1677
1678 print_build_stage "Building packages"
1679 buildpackages
1680
1681 print_build_stage "Checking Logfiles for new Files"
1682
1683 cd $BASEDIR
1684 tools/checknewlog.pl
1685 tools/checkrootfiles
1686 cd $PWD
1687
1688 print_build_summary $(( $(now) - ${START_TIME} ))
1689 ;;
1690 shell)
1691 # enter a shell inside LFS chroot
1692 # may be used to changed kernel settings
1693 prepareenv
1694 entershell
1695 ;;
1696 clean)
1697 print_line "Cleaning build directory..."
1698
1699 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
1700 $LOSETUP -d $i 2>/dev/null
1701 done
1702 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
1703 umount $i
1704 done
1705 stdumount
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;
1710 fi;
1711 done
1712 rm -rf $BASEDIR/build
1713 rm -rf $BASEDIR/cdrom
1714 rm -rf $BASEDIR/packages
1715 rm -rf $BASEDIR/log
1716 if [ -h "${TOOLS_DIR}" ]; then
1717 rm -f "${TOOLS_DIR}"
1718 fi
1719 rm -f $BASEDIR/ipfire-*
1720 print_status DONE
1721 ;;
1722 downloadsrc)
1723 if [ ! -d $BASEDIR/cache ]; then
1724 mkdir $BASEDIR/cache
1725 fi
1726 mkdir -p $BASEDIR/log
1727 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
1728 FINISHED=0
1729 cd $BASEDIR/lfs
1730 for c in `seq $MAX_RETRIES`; do
1731 if (( FINISHED==1 )); then
1732 break
1733 fi
1734 FINISHED=1
1735 cd $BASEDIR/lfs
1736 for i in *; do
1737 if [ -f "$i" -a "$i" != "Config" ]; then
1738 lfsmakecommoncheck ${i} || continue
1739
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
1743 print_status FAIL
1744 FINISHED=0
1745 else
1746 if [ $c -eq 1 ]; then
1747 print_status DONE
1748 fi
1749 fi
1750 fi
1751 done
1752 done
1753 echo -e "${BOLD}***Verifying md5sums${NORMAL}"
1754 ERROR=0
1755 for i in *; do
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"
1762 print_status FAIL
1763 ERROR=1
1764 fi
1765 fi
1766 done
1767 if [ $ERROR -eq 0 ]; then
1768 echo -ne "${BOLD}all files md5sum match${NORMAL}"
1769 print_status DONE
1770 else
1771 echo -ne "${BOLD}not all files were correctly download${NORMAL}"
1772 print_status FAIL
1773 fi
1774 cd - >/dev/null 2>&1
1775 ;;
1776 toolchain)
1777 # Clear screen
1778 ${INTERACTIVE} && clear
1779
1780 prepareenv
1781 print_build_stage "Toolchain compilation"
1782 buildtoolchain
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
1789 stdumount
1790 ;;
1791 gettoolchain)
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
1802 else
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
1805 else
1806 exiterror "$PACKAGE.md5 did not match, check downloaded package"
1807 fi
1808 fi
1809 else
1810 echo "Toolchain is already downloaded. Exiting..."
1811 fi
1812 ;;
1813 uploadsrc)
1814 PWD=`pwd`
1815 if [ -z $IPFIRE_USER ]; then
1816 echo -n "You have to setup IPFIRE_USER first. See .config for details."
1817 print_status FAIL
1818 exit 1
1819 fi
1820
1821 URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
1822 REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
1823
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"
1828 done
1829 [ -n "$NEW_FILES" ] && scp -2 $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
1830 cd $BASEDIR
1831 cd $PWD
1832 exit 0
1833 ;;
1834 lang)
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
1856 print_status DONE
1857
1858 echo -ne "Updating language lists..."
1859 update_language_list ${BASEDIR}/src/installer/po
1860 update_language_list ${BASEDIR}/src/setup/po
1861 print_status DONE
1862 ;;
1863 *)
1864 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
1865 cat doc/make.sh-usage
1866 ;;
1867 esac