]> git.ipfire.org Git - ipfire-2.x.git/blob - tools/make-functions
make.sh: Fix cross-architecture builds when using the --target= parameter
[ipfire-2.x.git] / tools / make-functions
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2011 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="${BUILD_ARCH}-cross-linux-gnu"
74 CFLAGS_ARCH="-m64 -mtune=generic"
75 ;;
76
77 i586)
78 BUILDTARGET="${target_arch}-pc-linux-gnu"
79 CROSSTARGET="${BUILD_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="${BUILD_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 CFLAGS="-O2 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fPIC"
112 CFLAGS="${CFLAGS} -fstack-protector-all --param=ssp-buffer-size=4 ${CFLAGS_ARCH}"
113 CXXFLAGS="${CFLAGS}"
114 }
115
116 configure_target_guess() {
117 case "${BUILD_ARCH}" in
118 x86_64|i686|i586)
119 echo "i586"
120 ;;
121 armv7*|armv6*|armv5*)
122 echo "armv5tel"
123 ;;
124 *)
125 exiterror "Cannot guess target architecture"
126 ;;
127 esac
128 }
129
130 evaluate() {
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
144 position_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
175 beautify()
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 ;;
195 build_stage)
196 MESSAGE=$2
197 if [ "$STAGE_TIME_START" ]; then
198 LAST_STAGE_TIME=$[ `date +%s` - $STAGE_TIME_START ]
199 fi
200 STAGE_TIME_START=`date +%s`
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"
206 ;;
207 build_start)
208 BUILD_TIME_START=`date +%s`
209 ;;
210 build_end)
211 BUILD_TIME_END=`date +%s`
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"
219 ;;
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)
255 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
256 ;;
257 esac
258 ;;
259 esac
260 } # End of beautify()
261
262
263 get_pkg_ver()
264 {
265 PKG_VER=`grep -E "^VER |^VER=|^VER " $1 | awk '{print $3}'`
266
267 if [ -z $PKG_VER ]; then
268 PKG_VER=`grep "Exp " $1 | awk '{print $4}'`
269 fi
270 if [ -z $PKG_VER ]; then
271 PKG_VER="?"
272 fi
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
287 # Define immediately
288 stdumount() {
289 umount $BASEDIR/build/sys 2>/dev/null;
290 umount $BASEDIR/build/dev/shm 2>/dev/null;
291 umount $BASEDIR/build/dev/pts 2>/dev/null;
292 umount $BASEDIR/build/dev 2>/dev/null;
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
306 exiterror() {
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
318 fake_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.
328 env="${env} UTS_MACHINE=${TARGET_ARCH}"
329
330 echo "${env}"
331 }
332
333 qemu_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"
352
353 echo "${env}"
354 }
355
356 qemu_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
364 x86_64,arm*|i?86,arm*)
365 return 0
366 ;;
367 *)
368 return 1
369 ;;
370 esac
371 }
372
373 qemu_install_helper() {
374 # Do nothing, if qemu is not required
375 if ! qemu_is_required; then
376 return 0
377 fi
378
379 if [ -z "${QEMU_TARGET_HELPER}" ]; then
380 exiterror "QEMU_TARGET_HELPER not set"
381 fi
382
383 # Check if the helper is already installed.
384 if [ -x "${LFS}${QEMU_TARGET_HELPER}" ]; then
385 return 0
386 fi
387
388 # Try to find a suitable binary that we can install
389 # to the build environment.
390 local file
391 for file in "${QEMU_TARGET_HELPER}" "${QEMU_TARGET_HELPER}-static"; do
392 # file must exist and be executable.
393 [ -x "${file}" ] || continue
394
395 # Must be static.
396 file_is_static "${file}" || continue
397
398 local dirname="${LFS}$(dirname "${file}")"
399 mkdir -p "${dirname}"
400
401 install -m 755 "${file}" "${LFS}${QEMU_TARGET_HELPER}"
402 return 0
403 done
404
405 exiterror "Could not find a statically-linked QEMU emulator: ${QEMU_TARGET_HELPER}"
406 }
407
408 qemu_find_target_helper_name() {
409 local target_arch="${1}"
410
411 local magic
412 case "${target_arch}" in
413 arm*)
414 magic="7f454c4601010100000000000000000002002800"
415 ;;
416 esac
417
418 [ -z "${magic}" ] && return 1
419
420 local file
421 for file in /proc/sys/fs/binfmt_misc/*; do
422 # Search for the file with the correct magic value.
423 grep -qE "^magic ${magic}$" "${file}" || continue
424
425 local interpreter="$(grep "^interpreter" "${file}" | awk '{ print $2 }')"
426
427 [ -n "${interpreter}" ] || continue
428 [ "${interpreter:0:1}" = "/" ] || continue
429 [ -x "${interpreter}" ] || continue
430
431 echo "${interpreter}"
432 return 0
433 done
434
435 return 1
436 }
437
438 file_is_static() {
439 local file="${1}"
440
441 file ${file} 2>/dev/null | grep -q "statically linked"
442 }
443
444 entershell() {
445 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
446 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
447 fi
448
449 # Install QEMU helper, if needed
450 qemu_install_helper
451
452 echo "Entering to a shell inside LFS chroot, go out with exit"
453 chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='ipfire build chroot ($(uname -m)) \u:\w\$ ' \
454 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
455 VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
456 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
457 CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" \
458 CCACHE_DIR=/usr/src/ccache \
459 CCACHE_COMPRESS=1 \
460 CCACHE_COMPILERCHECK="none" \
461 KVER=$KVER \
462 BUILDTARGET="$BUILDTARGET" \
463 CROSSTARGET="${CROSSTARGET}" \
464 MACHINE="$MACHINE" \
465 MACHINE_TYPE="$MACHINE_TYPE" \
466 $(fake_environ) \
467 $(qemu_environ) \
468 /tools/bin/bash -i
469 if [ $? -ne 0 ]; then
470 beautify message FAIL
471 exiterror "chroot error"
472 else
473 stdumount
474 fi
475 }
476
477 ############################################################################
478 # #
479 # Necessary shell functions #
480 # #
481 ############################################################################
482 #
483 # Common checking before entering the chroot and compilling
484 #
485 # Return:0 caller can continue
486 # :1 skip (nothing to do)
487 # or fail if no script file found
488 #
489 lfsmakecommoncheck()
490 {
491 # Script present?
492 if [ ! -f $BASEDIR/lfs/$1 ]; then
493 exiterror "No such file or directory: $BASEDIR/$1"
494 fi
495
496 local PKG_VER=`get_pkg_ver $BASEDIR/lfs/$1`
497 beautify make_pkg "$PKG_VER $*"
498
499 # Check if this package is supported by our architecture.
500 # If no SUP_ARCH is found, we assume the package can be built for all.
501 if grep "^SUP_ARCH" ${BASEDIR}/lfs/${1} >/dev/null; then
502 # Check if package supports ${MACHINE} or all architectures.
503 if ! grep -E "^SUP_ARCH.*${MACHINE}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
504 beautify result SKIP
505 return 1
506 fi
507 fi
508
509 # Script slipped?
510 local i
511 for i in $SKIP_PACKAGE_LIST
512 do
513 if [ "$i" == "$1" ]; then
514 beautify result SKIP
515 return 1;
516 fi
517 done
518
519 echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
520
521 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
522 MACHINE_TYPE="$MACHINE_TYPE" \
523 MESSAGE="$1\t " download >> $LOGFILE 2>&1
524 if [ $? -ne 0 ]; then
525 exiterror "Download error in $1"
526 fi
527
528 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR MACHINE=$MACHINE \
529 MACHINE_TYPE="$MACHINE_TYPE" \
530 MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
531 if [ $? -ne 0 ]; then
532 exiterror "md5sum error in $1, check file in cache or signature"
533 fi
534
535 return 0 # pass all!
536 } # End of lfsmakecommoncheck()
537
538 lfsmake1() {
539 lfsmakecommoncheck $*
540 [ $? == 1 ] && return 0
541
542 local PKG_TIME_START=`date +%s`
543
544 cd $BASEDIR/lfs && make -f $* BUILDTARGET=$BUILDTARGET \
545 CROSSTARGET="${CROSSTARGET}" \
546 MACHINE=$MACHINE \
547 MACHINE_TYPE=$MACHINE_TYPE \
548 LFS_BASEDIR=$BASEDIR \
549 ROOT=$LFS \
550 KVER=$KVER \
551 MAKETUNING=$MAKETUNING \
552 install >> $LOGFILE 2>&1
553 local COMPILE_SUCCESS=$?
554 local PKG_TIME_END=`date +%s`
555
556 if [ $COMPILE_SUCCESS -ne 0 ]; then
557 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
558 exiterror "Building $*";
559 else
560 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
561 fi
562
563 return 0
564 }
565
566 lfsmake2() {
567 lfsmakecommoncheck $*
568 [ $? == 1 ] && return 0
569
570 # Install QEMU helper, if needed
571 qemu_install_helper
572
573 local PKG_TIME_START=`date +%s`
574 chroot $LFS /tools/bin/env -i HOME=/root \
575 TERM=$TERM PS1='\u:\w\$ ' \
576 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
577 VERSION=$VERSION PAKFIRE_CORE="${PAKFIRE_CORE}" \
578 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
579 CONFIG_ROOT=$CONFIG_ROOT \
580 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
581 CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" \
582 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 \
583 CCACHE_COMPILERCHECK="none" \
584 KVER=$KVER MAKETUNING=$MAKETUNING \
585 BUILDTARGET="$BUILDTARGET" \
586 CROSSTARGET="${CROSSTARGET}" \
587 MACHINE="$MACHINE" \
588 MACHINE_TYPE="$MACHINE_TYPE" \
589 $(qemu_environ) \
590 $(fake_environ) \
591 /tools/bin/bash -x -c "cd /usr/src/lfs && \
592 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
593 local COMPILE_SUCCESS=$?
594 local PKG_TIME_END=`date +%s`
595
596 if [ $COMPILE_SUCCESS -ne 0 ]; then
597 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
598 exiterror "Building $*";
599 else
600 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
601 fi
602
603 return 0
604 }
605
606 ipfiremake() {
607 lfsmakecommoncheck $*
608 [ $? == 1 ] && return 0
609
610 # Install QEMU helper, if needed
611 qemu_install_helper
612
613 local PKG_TIME_START=`date +%s`
614 chroot $LFS /tools/bin/env -i HOME=/root \
615 TERM=$TERM PS1='\u:\w\$ ' \
616 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
617 VERSION=$VERSION \
618 CORE=$CORE \
619 CONFIG_ROOT=$CONFIG_ROOT \
620 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
621 SYSTEM_RELEASE="$SYSTEM_RELEASE" \
622 CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" \
623 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 \
624 CCACHE_COMPILERCHECK="none" \
625 KVER=$KVER MAKETUNING=$MAKETUNING \
626 BUILDTARGET="$BUILDTARGET" \
627 CROSSTARGET="${CROSSTARGET}" \
628 MACHINE="$MACHINE" \
629 MACHINE_TYPE="$MACHINE_TYPE" \
630 $(qemu_environ) \
631 $(fake_environ) \
632 /bin/bash -x -c "cd /usr/src/lfs && \
633 make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
634
635 local COMPILE_SUCCESS=$?
636 local PKG_TIME_END=`date +%s`
637
638 if [ $COMPILE_SUCCESS -ne 0 ]; then
639 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
640 exiterror "Building $*";
641 else
642 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
643 fi
644 return 0
645 }
646
647 ipfiredist() {
648 lfsmakecommoncheck $*
649 [ $? == 1 ] && return 0
650
651 # Install QEMU helper, if needed
652 qemu_install_helper
653
654 local PKG_TIME_START=`date +%s`
655 chroot $LFS /tools/bin/env -i HOME=/root \
656 TERM=$TERM PS1='\u:\w\$ ' \
657 PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin \
658 VERSION=$VERSION \
659 CONFIG_ROOT=$CONFIG_ROOT \
660 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
661 CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" \
662 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 \
663 CCACHE_COMPILERCHECK="none" \
664 KVER=$KVER \
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 $1 LFS_BASEDIR=/usr/src dist" >>$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 "Packaging $*";
680 else
681 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
682 fi
683 return 0
684 }
685
686 installmake() {
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 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
699 CONFIG_ROOT=$CONFIG_ROOT \
700 NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
701 CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" \
702 CCACHE_DIR=/usr/src/ccache CCACHE_COMPRESS=1 CCACHE_HASHDIR=1 \
703 KVER=$KVER \
704 BUILDTARGET="$BUILDTARGET" \
705 CROSSTARGET="${CROSSTARGET}" \
706 MACHINE="$MACHINE" \
707 MACHINE_TYPE="$MACHINE_TYPE" \
708 LD_LIBRARY_PATH=/tools/lib \
709 /tools/bin/bash -x -c "cd /usr/src/lfs && \
710 /tools/bin/make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
711
712 local COMPILE_SUCCESS=$?
713 local PKG_TIME_END=`date +%s`
714
715 if [ $COMPILE_SUCCESS -ne 0 ]; then
716 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
717 exiterror "Building $*";
718 else
719 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
720 fi
721 return 0
722 }
723
724 update_langs() {
725 echo -ne "Checking the translations for missing or obsolete strings..."
726 chmod 755 $BASEDIR/tools/{check_strings.pl,sort_strings.pl,check_langs.sh}
727 $BASEDIR/tools/sort_strings.pl en
728 $BASEDIR/tools/sort_strings.pl de
729 $BASEDIR/tools/sort_strings.pl fr
730 $BASEDIR/tools/sort_strings.pl es
731 $BASEDIR/tools/sort_strings.pl pl
732 $BASEDIR/tools/sort_strings.pl ru
733 $BASEDIR/tools/sort_strings.pl nl
734 $BASEDIR/tools/sort_strings.pl tr
735 $BASEDIR/tools/sort_strings.pl it
736 $BASEDIR/tools/check_strings.pl en > $BASEDIR/doc/language_issues.en
737 $BASEDIR/tools/check_strings.pl de > $BASEDIR/doc/language_issues.de
738 $BASEDIR/tools/check_strings.pl fr > $BASEDIR/doc/language_issues.fr
739 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.es
740 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.pl
741 $BASEDIR/tools/check_strings.pl ru > $BASEDIR/doc/language_issues.ru
742 $BASEDIR/tools/check_strings.pl nl > $BASEDIR/doc/language_issues.nl
743 $BASEDIR/tools/check_strings.pl tr > $BASEDIR/doc/language_issues.tr
744 $BASEDIR/tools/check_strings.pl it > $BASEDIR/doc/language_issues.it
745 $BASEDIR/tools/check_langs.sh > $BASEDIR/doc/language_missings
746 beautify message DONE
747
748 echo -ne "Updating language lists..."
749 update_language_list ${BASEDIR}/src/installer/po
750 update_language_list ${BASEDIR}/src/setup/po
751 beautify message DONE
752 }
753
754 update_language_list() {
755 local path="${1}"
756
757 local lang
758 for lang in ${path}/*.po; do
759 lang="$(basename "${lang}")"
760 echo "${lang%*.po}"
761 done | sort -u > "${path}/LINGUAS"
762 }