]> git.ipfire.org Git - ipfire-2.x.git/blob - tools/make-functions
armv7hl: Build without -mthumb
[ipfire-2.x.git] / tools / make-functions
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2016 IPFire Team <info@ipfire.org> #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21 ###############################################################################
22 #
23 # Beautifying variables & presentation & input output interface
24 #
25 ###############################################################################
26
27 ## Screen Dimentions
28 # Find current screen size
29 if [ -z "${COLUMNS}" ]; then
30 COLUMNS=$(stty size)
31 COLUMNS=${COLUMNS##* }
32 fi
33
34 # When using remote connections, such as a serial port, stty size returns 0
35 if [ "${COLUMNS}" = "0" ]; then
36 COLUMNS=80
37 fi
38
39 ## Measurements for positioning result messages
40 RESULT_WIDTH=4
41 TIME_WIDTH=8
42 OPT_WIDTH=6
43 VER_WIDTH=10
44 RESULT_COL=$((${COLUMNS} - $RESULT_WIDTH - 4))
45 TIME_COL=$((${RESULT_COL} - $TIME_WIDTH - 5))
46 OPT_COL=$((${TIME_COL} - $OPT_WIDTH - 5))
47 VER_COL=$((${OPT_COL} - $VER_WIDTH - 5))
48
49 ## Set Cursur Position Commands, used via echo -e
50 SET_RESULT_COL="\\033[${RESULT_COL}G"
51 SET_TIME_COL="\\033[${TIME_COL}G"
52 SET_OPT_COL="\\033[${OPT_COL}G"
53 SET_VER_COL="\\033[${VER_COL}G"
54
55 # Define color for messages
56 BOLD="\\033[1;39m"
57 DONE="\\033[1;32m"
58 SKIP="\\033[1;34m"
59 WARN="\\033[1;35m"
60 FAIL="\\033[1;31m"
61 NORMAL="\\033[0;39m"
62
63 configure_target() {
64 local target_arch="${1}"
65
66 if [ "${target_arch}" = "default" ]; then
67 target_arch="$(configure_target_guess)"
68 fi
69
70 case "${target_arch}" in
71 x86_64)
72 BUILDTARGET="${target_arch}-unknown-linux-gnu"
73 CROSSTARGET="${target_arch}-cross-linux-gnu"
74 CFLAGS_ARCH="-m64 -mtune=generic"
75 ;;
76
77 i586)
78 BUILDTARGET="${target_arch}-pc-linux-gnu"
79 CROSSTARGET="${target_arch}-cross-linux-gnu"
80 CFLAGS_ARCH="-march=i586 -mtune=generic -fomit-frame-pointer"
81 ;;
82
83 aarch64)
84 BUILDTARGET="${target_arch}-unknown-linux-gnu"
85 CROSSTARGET="${target_arch}-cross-linux-gnu"
86 CFLAGS_ARCH=""
87 ;;
88
89 armv7hl)
90 BUILDTARGET="${target_arch}-unknown-linux-gnueabi"
91 CROSSTARGET="${target_arch}-cross-linux-gnueabi"
92 CFLAGS_ARCH="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
93 ;;
94
95 armv5tel)
96 BUILDTARGET="${target_arch}-unknown-linux-gnueabi"
97 CROSSTARGET="${target_arch}-cross-linux-gnueabi"
98 CFLAGS_ARCH="-march=armv5te -mfloat-abi=soft -fomit-frame-pointer"
99 MACHINE_TYPE="arm"
100 ;;
101
102 *)
103 exiterror "Cannot build for architure ${target_arch}"
104 ;;
105 esac
106
107 # Check if the QEMU helper is available if needed.
108 if qemu_is_required "${target_arch}"; then
109 local qemu_target_helper="$(qemu_find_target_helper_name "${target_arch}")"
110
111 if [ -n "${qemu_target_helper}" ]; then
112 QEMU_TARGET_HELPER="${qemu_target_helper}"
113 else
114 exiterror "Could not find a binfmt_misc helper entry for ${target_arch}"
115 fi
116 fi
117
118 TARGET_ARCH="${target_arch}"
119
120 # Old variable names
121 MACHINE="${TARGET_ARCH}"
122
123 # Enables hardening
124 HARDENING_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4"
125
126 CFLAGS="-O2 -pipe -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
127 CXXFLAGS="${CFLAGS}"
128 }
129
130 configure_target_guess() {
131 case "${BUILD_ARCH}" in
132 x86_64|i686|i586)
133 echo "i586"
134 ;;
135
136 aarch64)
137 echo "aarch64"
138 ;;
139
140 armv7*)
141 echo "armv7hl"
142 ;;
143
144 armv6*|armv5*)
145 echo "armv5tel"
146 ;;
147
148 *)
149 exiterror "Cannot guess target architecture"
150 ;;
151 esac
152 }
153
154 evaluate() {
155 if [ "$?" -eq "0" ]; then
156 beautify message DONE
157 else
158 EXITCODE=$1
159 shift 1
160 beautify message FAIL
161 $*
162 if [ $EXITCODE -ne "0" ]; then
163 exit $EXITCODE
164 fi
165 fi
166 }
167
168 position_cursor()
169 {
170 # ARG1=starting position on screen
171 # ARG2=string to be printed
172 # ARG3=offset, negative for left movement, positive for right movement, relative to ARG1
173 # For example if your starting position is column 50 and you want to print Hello three columns to the right
174 # of your starting position, your call will look like this:
175 # position_cursor 50 "Hello" 3 (you'll get the string Hello at position 53 (= 50 + 3)
176 # If on the other hand you want your string "Hello" to end three columns to the left of position 50,
177 # your call will look like this:
178 # position_cursor 50 "Hello" -3 (you'll get the string Hello at position 42 (= 50 - 5 -3)
179 # If you want to start printing at the exact starting location, use offset 0
180
181 START=$1
182 STRING=$2
183 OFFSET=$3
184
185 STRING_LENGTH=${#STRING}
186
187 if [ ${OFFSET} -lt 0 ]; then
188 COL=$((${START} + ${OFFSET} - ${STRING_LENGTH}))
189 else
190 COL=$((${START} + ${OFFSET}))
191 fi
192
193 SET_COL="\\033[${COL}G"
194
195 echo $SET_COL
196 } # End of position_cursor()
197
198
199 beautify()
200 {
201 # Commands: build_stage, make_pkg, message, result
202 case "$1" in
203 message)
204 case "$2" in
205 DONE)
206 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
207 ;;
208 WARN)
209 echo -ne "${WARN}${3}${NORMAL}${SET_RESULT_COL}[${WARN} WARN ${NORMAL}]\n"
210 ;;
211 FAIL)
212 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
213 ;;
214 SKIP)
215 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
216 ;;
217 esac
218 ;;
219 build_stage)
220 MESSAGE=$2
221 if [ "$STAGE_TIME_START" ]; then
222 LAST_STAGE_TIME=$[ `date +%s` - $STAGE_TIME_START ]
223 fi
224 STAGE_TIME_START=`date +%s`
225 echo -ne "${BOLD}*** ${MESSAGE}${NORMAL}"
226 if [ "$LAST_STAGE_TIME" ]; then
227 echo -ne "${DONE} (Last stage took $LAST_STAGE_TIME secs)${NORMAL}"
228 fi
229 echo -ne "${BOLD}${SET_VER_COL} version${SET_OPT_COL} options${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n"
230 ;;
231 build_start)
232 BUILD_TIME_START=`date +%s`
233 ;;
234 build_end)
235 BUILD_TIME_END=`date +%s`
236 seconds=$[ $BUILD_TIME_END - $BUILD_TIME_START ]
237 hours=$((seconds / 3600))
238 seconds=$((seconds % 3600))
239 minutes=$((seconds / 60))
240 seconds=$((seconds % 60))
241
242 echo -ne "${DONE}***Build is finished now and took $hours hour(s) $minutes minute(s) $seconds second(s)!${NORMAL}\n"
243 ;;
244 make_pkg)
245 echo "$2" | while read PKG_VER PROGRAM OPTIONS
246 do
247 SET_VER_COL_REAL=`position_cursor $OPT_COL $PKG_VER -3`
248
249 if [ "$OPTIONS" == "" ]; then
250 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
251 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
252 else
253 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
254 echo -ne "${NORMAL} ]${SET_OPT_COL}[ ${BOLD}${OPTIONS}"
255 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
256 fi
257 done
258 ;;
259 result)
260 RESULT=$2
261
262 if [ ! $3 ]; then
263 PKG_TIME=0
264 else
265 PKG_TIME=$3
266 fi
267
268 SET_TIME_COL_REAL=`position_cursor $RESULT_COL $PKG_TIME -3`
269 case "$RESULT" in
270 DONE)
271 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
272 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
273 ;;
274 FAIL)
275 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
276 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
277 ;;
278 SKIP)
279 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
280 ;;
281 esac
282 ;;
283 esac
284 } # End of beautify()
285
286
287 get_pkg_ver()
288 {
289 PKG_VER=`grep -E "^VER |^VER=|^VER " $1 | awk '{print $3}'`
290
291 if [ -z $PKG_VER ]; then
292 PKG_VER=`grep "Exp " $1 | awk '{print $4}'`
293 fi
294 if [ -z $PKG_VER ]; then
295 PKG_VER="?"
296 fi
297 if [ ${#PKG_VER} -gt $VER_WIDTH ]; then
298 # If a package version number is greater than $VER_WIDTH, we keep the first 4 characters
299 # and replace enough characters to fit the resulting string on the screen. We'll replace
300 # the extra character with .. (two dots). That's why the "+ 2" in the formula below.
301 # Example: if we have a 21-long version number that we want to fit into a 10-long space,
302 # we have to remove 11 characters. But if we replace 11 characters with 2 characters, we'll
303 # end up with a 12-character long string. That's why we replace 12 characters with ..
304 REMOVE=`expr substr "$PKG_VER" 4 $[ ${#PKG_VER} - $VER_WIDTH + 2 ]`
305 PKG_VER=`echo ${PKG_VER/$REMOVE/..}`
306 fi
307
308 echo "$PKG_VER"
309 } # End of get_pkg_ver()
310
311 # Define immediately
312 stdumount() {
313 umount $BASEDIR/build/sys 2>/dev/null;
314 umount $BASEDIR/build/dev/shm 2>/dev/null;
315 umount $BASEDIR/build/dev/pts 2>/dev/null;
316 umount $BASEDIR/build/dev 2>/dev/null;
317 umount $BASEDIR/build/proc 2>/dev/null;
318 umount $BASEDIR/build/install/mnt 2>/dev/null;
319 umount $BASEDIR/build/usr/src/cache 2>/dev/null;
320 umount $BASEDIR/build/usr/src/ccache 2>/dev/null;
321 umount $BASEDIR/build/usr/src/config 2>/dev/null;
322 umount $BASEDIR/build/usr/src/doc 2>/dev/null;
323 umount $BASEDIR/build/usr/src/html 2>/dev/null;
324 umount $BASEDIR/build/usr/src/langs 2>/dev/null;
325 umount $BASEDIR/build/usr/src/lfs 2>/dev/null;
326 umount $BASEDIR/build/usr/src/log 2>/dev/null;
327 umount $BASEDIR/build/usr/src/src 2>/dev/null;
328 }
329
330 exiterror() {
331 stdumount
332 for i in `seq 0 7`; do
333 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
334 losetup -d /dev/loop${i} 2>/dev/null
335 fi;
336 done
337
338 if [ -n "${LOGFILE}" ]; then
339 echo # empty line
340
341 local line
342 while read -r line; do
343 echo " ${line}"
344 done <<< "$(tail -n30 ${LOGFILE})"
345 fi
346
347 echo -e "\nERROR: $*"
348 echo " Check $LOGFILE for errors if applicable"
349 exit 1
350 }
351
352 fake_environ() {
353 [ -e "${BASEDIR}/build/tools/lib/libpakfire_preload.so" ] || return
354
355 local env="LD_PRELOAD=/tools/lib/libpakfire_preload.so"
356
357 # Fake kernel version, because some of the packages do not compile
358 # with kernel 3.0 and later.
359 env="${env} UTS_RELEASE=${KVER}"
360
361 # Fake machine version.
362 env="${env} UTS_MACHINE=${TARGET_ARCH}"
363
364 echo "${env}"
365 }
366
367 qemu_environ() {
368 local env
369
370 # Don't add anything if qemu is not used.
371 if ! qemu_is_required; then
372 return
373 fi
374
375 # Set default qemu options
376 case "${TARGET_ARCH}" in
377 arm*)
378 QEMU_CPU="${QEMU_CPU:-cortex-a9}"
379
380 env="${env} QEMU_CPU=${QEMU_CPU}"
381 ;;
382 esac
383
384 # Enable QEMU strace
385 #env="${env} QEMU_STRACE=1"
386
387 echo "${env}"
388 }
389
390 qemu_is_required() {
391 local target_arch="${1}"
392
393 if [ -z "${target_arch}" ]; then
394 target_arch="${TARGET_ARCH}"
395 fi
396
397 case "${BUILD_ARCH},${target_arch}" in
398 x86_64,arm*|i?86,arm*|i?86,x86_64)
399 return 0
400 ;;
401 *)
402 return 1
403 ;;
404 esac
405 }
406
407 qemu_install_helper() {
408 # Do nothing, if qemu is not required
409 if ! qemu_is_required; then
410 return 0
411 fi
412
413 if [ ! -e /proc/sys/fs/binfmt_misc/status ]; then
414 exiterror "binfmt_misc not mounted. QEMU_TARGET_HELPER not useable."
415 fi
416
417 if [ ! $(cat /proc/sys/fs/binfmt_misc/status) = 'enabled' ]; then
418 exiterror "binfmt_misc not enabled. QEMU_TARGET_HELPER not useable."
419 fi
420
421
422 if [ -z "${QEMU_TARGET_HELPER}" ]; then
423 exiterror "QEMU_TARGET_HELPER not set"
424 fi
425
426 # Check if the helper is already installed.
427 if [ -x "${LFS}${QEMU_TARGET_HELPER}" ]; then
428 return 0
429 fi
430
431 # Try to find a suitable binary that we can install
432 # to the build environment.
433 local file
434 for file in "${QEMU_TARGET_HELPER}" "${QEMU_TARGET_HELPER}-static"; do
435 # file must exist and be executable.
436 [ -x "${file}" ] || continue
437
438 # Must be static.
439 file_is_static "${file}" || continue
440
441 local dirname="${LFS}$(dirname "${file}")"
442 mkdir -p "${dirname}"
443
444 install -m 755 "${file}" "${LFS}${QEMU_TARGET_HELPER}"
445 return 0
446 done
447
448 exiterror "Could not find a statically-linked QEMU emulator: ${QEMU_TARGET_HELPER}"
449 }
450
451 qemu_find_target_helper_name() {
452 local target_arch="${1}"
453
454 local magic
455 case "${target_arch}" in
456 arm*)
457 magic="7f454c4601010100000000000000000002002800"
458 ;;
459 x86_64)
460 magic="7f454c4602010100000000000000000002003e00"
461 ;;
462 esac
463
464 [ -z "${magic}" ] && return 1
465
466 local file
467 for file in /proc/sys/fs/binfmt_misc/*; do
468 # skip write only register entry
469 [ $(basename "${file}") = "register" ] && continue
470 # Search for the file with the correct magic value.
471 grep -qE "^magic ${magic}$" "${file}" || continue
472
473 local interpreter="$(grep "^interpreter" "${file}" | awk '{ print $2 }')"
474
475 [ -n "${interpreter}" ] || continue
476 [ "${interpreter:0:1}" = "/" ] || continue
477 [ -x "${interpreter}" ] || continue
478
479 echo "${interpreter}"
480 return 0
481 done
482
483 return 1
484 }
485
486 file_is_static() {
487 local file="${1}"
488
489 file ${file} 2>/dev/null | grep -q "statically linked"
490 }
491
492 entershell() {
493 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
494 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
495 fi
496
497 # Install QEMU helper, if needed
498 qemu_install_helper
499
500 echo "Entering to a shell inside LFS chroot, go out with exit"
501 chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='ipfire build chroot ($(uname -m)) \u:\w\$ ' \
502 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
503 VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
504 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
505 CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
506 CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
507 CCACHE_DIR=/usr/src/ccache \
508 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
509 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
510 KVER=$KVER \
511 BUILDTARGET="$BUILDTARGET" \
512 CROSSTARGET="${CROSSTARGET}" \
513 MACHINE="$MACHINE" \
514 MACHINE_TYPE="$MACHINE_TYPE" \
515 $(fake_environ) \
516 $(qemu_environ) \
517 /tools/bin/bash -i
518 if [ $? -ne 0 ]; then
519 beautify message FAIL
520 exiterror "chroot error"
521 else
522 stdumount
523 fi
524 }
525
526 ############################################################################
527 # #
528 # Necessary shell functions #
529 # #
530 ############################################################################
531 #
532 # Common checking before entering the chroot and compilling
533 #
534 # Return:0 caller can continue
535 # :1 skip (nothing to do)
536 # or fail if no script file found
537 #
538 lfsmakecommoncheck()
539 {
540 # Script present?
541 if [ ! -f $BASEDIR/lfs/$1 ]; then
542 exiterror "No such file or directory: $BASEDIR/$1"
543 fi
544
545 local PKG_VER=`get_pkg_ver $BASEDIR/lfs/$1`
546 beautify make_pkg "$PKG_VER $*"
547
548 # Check if this package is supported by our architecture.
549 # If no SUP_ARCH is found, we assume the package can be built for all.
550 if grep "^SUP_ARCH" ${BASEDIR}/lfs/${1} >/dev/null; then
551 # Check if package supports ${MACHINE} or all architectures.
552 if ! grep -E "^SUP_ARCH.*${MACHINE}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
553 beautify result SKIP
554 return 1
555 fi
556 fi
557
558 # Script slipped?
559 local i
560 for i in $SKIP_PACKAGE_LIST
561 do
562 if [ "$i" == "$1" ]; then
563 beautify result SKIP
564 return 1;
565 fi
566 done
567
568 echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
569
570 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
571 MACHINE_TYPE="$MACHINE_TYPE" \
572 MESSAGE="$1\t " download >> $LOGFILE 2>&1
573 if [ $? -ne 0 ]; then
574 exiterror "Download error in $1"
575 fi
576
577 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
578 MACHINE_TYPE="$MACHINE_TYPE" \
579 MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
580 if [ $? -ne 0 ]; then
581 exiterror "md5sum error in $1, check file in cache or signature"
582 fi
583
584 return 0 # pass all!
585 } # End of lfsmakecommoncheck()
586
587 lfsmake1() {
588 lfsmakecommoncheck $*
589 [ $? == 1 ] && return 0
590
591 local PKG_TIME_START=`date +%s`
592
593 cd $BASEDIR/lfs && \
594 PATH="/tools/ccache/bin:/tools/bin:$PATH" \
595 make -f $* TOOLCHAIN=1 BUILDTARGET=$BUILDTARGET \
596 CROSSTARGET="${CROSSTARGET}" \
597 MACHINE=$MACHINE \
598 MACHINE_TYPE=$MACHINE_TYPE \
599 LFS_BASEDIR=$BASEDIR \
600 ROOT=$LFS \
601 KVER=$KVER \
602 MAKETUNING=$MAKETUNING \
603 install >> $LOGFILE 2>&1
604 local COMPILE_SUCCESS=$?
605 local PKG_TIME_END=`date +%s`
606
607 if [ $COMPILE_SUCCESS -ne 0 ]; then
608 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
609 exiterror "Building $*";
610 else
611 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
612 fi
613
614 return 0
615 }
616
617 lfsmake2() {
618 lfsmakecommoncheck $*
619 [ $? == 1 ] && return 0
620
621 # Install QEMU helper, if needed
622 qemu_install_helper
623
624 local PKG_TIME_START=`date +%s`
625 chroot $LFS /tools/bin/env -i HOME=/root \
626 TERM=$TERM PS1='\u:\w\$ ' \
627 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
628 VERSION=$VERSION PAKFIRE_CORE="${PAKFIRE_CORE}" \
629 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
630 CONFIG_ROOT=$CONFIG_ROOT \
631 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
632 CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
633 CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
634 CCACHE_DIR=/usr/src/ccache \
635 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
636 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
637 KVER=$KVER MAKETUNING=$MAKETUNING \
638 BUILDTARGET="$BUILDTARGET" \
639 CROSSTARGET="${CROSSTARGET}" \
640 MACHINE="$MACHINE" \
641 MACHINE_TYPE="$MACHINE_TYPE" \
642 $(qemu_environ) \
643 $(fake_environ) \
644 /tools/bin/bash -x -c "cd /usr/src/lfs && \
645 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
646 local COMPILE_SUCCESS=$?
647 local PKG_TIME_END=`date +%s`
648
649 if [ $COMPILE_SUCCESS -ne 0 ]; then
650 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
651 exiterror "Building $*";
652 else
653 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
654 fi
655
656 return 0
657 }
658
659 ipfiremake() {
660 lfsmakecommoncheck $*
661 [ $? == 1 ] && return 0
662
663 # Install QEMU helper, if needed
664 qemu_install_helper
665
666 local PKG_TIME_START=`date +%s`
667 chroot $LFS /tools/bin/env -i HOME=/root \
668 TERM=$TERM PS1='\u:\w\$ ' \
669 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
670 VERSION=$VERSION \
671 CORE=$CORE \
672 CONFIG_ROOT=$CONFIG_ROOT \
673 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
674 SYSTEM_RELEASE="$SYSTEM_RELEASE" \
675 CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
676 CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
677 CCACHE_DIR=/usr/src/ccache \
678 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
679 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
680 KVER=$KVER MAKETUNING=$MAKETUNING \
681 BUILDTARGET="$BUILDTARGET" \
682 CROSSTARGET="${CROSSTARGET}" \
683 MACHINE="$MACHINE" \
684 MACHINE_TYPE="$MACHINE_TYPE" \
685 $(qemu_environ) \
686 $(fake_environ) \
687 /bin/bash -x -c "cd /usr/src/lfs && \
688 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
689
690 local COMPILE_SUCCESS=$?
691 local PKG_TIME_END=`date +%s`
692
693 if [ $COMPILE_SUCCESS -ne 0 ]; then
694 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
695 exiterror "Building $*";
696 else
697 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
698 fi
699 return 0
700 }
701
702 ipfiredist() {
703 lfsmakecommoncheck $*
704 [ $? == 1 ] && return 0
705
706 # Install QEMU helper, if needed
707 qemu_install_helper
708
709 local PKG_TIME_START=`date +%s`
710 chroot $LFS /tools/bin/env -i HOME=/root \
711 TERM=$TERM PS1='\u:\w\$ ' \
712 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
713 VERSION=$VERSION \
714 CONFIG_ROOT=$CONFIG_ROOT \
715 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
716 CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
717 CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
718 CCACHE_DIR=/usr/src/ccache \
719 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
720 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
721 KVER=$KVER \
722 BUILDTARGET="$BUILDTARGET" \
723 CROSSTARGET="${CROSSTARGET}" \
724 MACHINE="$MACHINE" \
725 MACHINE_TYPE="$MACHINE_TYPE" \
726 $(qemu_environ) \
727 $(fake_environ) \
728 /bin/bash -x -c "cd /usr/src/lfs && \
729 make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1
730
731 local COMPILE_SUCCESS=$?
732 local PKG_TIME_END=`date +%s`
733
734 if [ $COMPILE_SUCCESS -ne 0 ]; then
735 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
736 exiterror "Packaging $*";
737 else
738 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
739 fi
740 return 0
741 }
742
743 installmake() {
744 lfsmakecommoncheck $*
745 [ $? == 1 ] && return 0
746
747 # Install QEMU helper, if needed
748 qemu_install_helper
749
750 local PKG_TIME_START=`date +%s`
751 chroot $LFS /tools/bin/env -i HOME=/root \
752 TERM=$TERM PS1='\u:\w\$ ' \
753 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
754 VERSION=$VERSION \
755 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
756 CONFIG_ROOT=$CONFIG_ROOT \
757 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
758 CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
759 CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
760 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 CCACHE_HASHDIR=1 \
761 KVER=$KVER \
762 BUILDTARGET="$BUILDTARGET" \
763 CROSSTARGET="${CROSSTARGET}" \
764 MACHINE="$MACHINE" \
765 MACHINE_TYPE="$MACHINE_TYPE" \
766 LD_LIBRARY_PATH=/tools/lib \
767 /tools/bin/bash -x -c "cd /usr/src/lfs && \
768 /tools/bin/make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
769
770 local COMPILE_SUCCESS=$?
771 local PKG_TIME_END=`date +%s`
772
773 if [ $COMPILE_SUCCESS -ne 0 ]; then
774 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
775 exiterror "Building $*";
776 else
777 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
778 fi
779 return 0
780 }
781
782 update_langs() {
783 echo -ne "Checking the translations for missing or obsolete strings..."
784 chmod 755 $BASEDIR/tools/{check_strings.pl,sort_strings.pl,check_langs.sh}
785 $BASEDIR/tools/sort_strings.pl en
786 $BASEDIR/tools/sort_strings.pl de
787 $BASEDIR/tools/sort_strings.pl fr
788 $BASEDIR/tools/sort_strings.pl es
789 $BASEDIR/tools/sort_strings.pl pl
790 $BASEDIR/tools/sort_strings.pl ru
791 $BASEDIR/tools/sort_strings.pl nl
792 $BASEDIR/tools/sort_strings.pl tr
793 $BASEDIR/tools/sort_strings.pl it
794 $BASEDIR/tools/check_strings.pl en > $BASEDIR/doc/language_issues.en
795 $BASEDIR/tools/check_strings.pl de > $BASEDIR/doc/language_issues.de
796 $BASEDIR/tools/check_strings.pl fr > $BASEDIR/doc/language_issues.fr
797 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.es
798 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.pl
799 $BASEDIR/tools/check_strings.pl ru > $BASEDIR/doc/language_issues.ru
800 $BASEDIR/tools/check_strings.pl nl > $BASEDIR/doc/language_issues.nl
801 $BASEDIR/tools/check_strings.pl tr > $BASEDIR/doc/language_issues.tr
802 $BASEDIR/tools/check_strings.pl it > $BASEDIR/doc/language_issues.it
803 $BASEDIR/tools/check_langs.sh > $BASEDIR/doc/language_missings
804 beautify message DONE
805
806 echo -ne "Updating language lists..."
807 update_language_list ${BASEDIR}/src/installer/po
808 update_language_list ${BASEDIR}/src/setup/po
809 beautify message DONE
810 }
811
812 update_language_list() {
813 local path="${1}"
814
815 local lang
816 for lang in ${path}/*.po; do
817 lang="$(basename "${lang}")"
818 echo "${lang%*.po}"
819 done | sort -u > "${path}/LINGUAS"
820 }