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