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