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