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