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