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