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