make.sh: Merge make-functions into make.sh
[ipfire-2.x.git] / make.sh
CommitLineData
df5e82b3 1#!/bin/bash
df5e82b3
MT
2############################################################################
3# #
f8e5510c 4# This file is part of the IPFire Firewall. #
df5e82b3 5# #
f8e5510c 6# IPFire is free software; you can redistribute it and/or modify #
df5e82b3
MT
7# it under the terms of the GNU General Public License as published by #
8# the Free Software Foundation; either version 2 of the License, or #
9# (at your option) any later version. #
10# #
f8e5510c 11# IPFire is distributed in the hope that it will be useful, #
df5e82b3
MT
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
f8e5510c 17# along with IPFire; if not, write to the Free Software #
df5e82b3
MT
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
19# #
f7a48dd3 20# Copyright (C) 2007-2017 IPFire Team <info@ipfire.org>. #
df5e82b3
MT
21# #
22############################################################################
df5e82b3
MT
23#
24
e8ee3199
AF
25NAME="IPFire" # Software name
26SNAME="ipfire" # Short name
33513817 27VERSION="2.19" # Version number
bb3272da 28CORE="117" # Core Level (Filename)
4f248f7a 29PAKFIRE_CORE="116" # Core Level (PAKFIRE)
595e89a8 30GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` # Git Branch
e8ee3199
AF
31SLOGAN="www.ipfire.org" # Software slogan
32CONFIG_ROOT=/var/ipfire # Configuration rootdir
33NICE=10 # Nice level
34MAX_RETRIES=1 # prefetch/check loop
305a7b38 35BUILD_IMAGES=1 # Flash and Xen Downloader
15679d9f 36KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'`
e8ee3199
AF
37GIT_TAG=$(git tag | tail -1) # Git Tag
38GIT_LASTCOMMIT=$(git log | head -n1 | cut -d" " -f2 |head -c8) # Last commit
628e8c3a 39
6c4cc7ea 40TOOLCHAINVER=20171121
03ad5f93 41
69a6ec55
MT
42###############################################################################
43#
44# Beautifying variables & presentation & input output interface
45#
46###############################################################################
47
48## Screen Dimentions
49# Find current screen size
50if [ -z "${COLUMNS}" ]; then
51 COLUMNS=$(stty size)
52 COLUMNS=${COLUMNS##* }
53fi
54
55# When using remote connections, such as a serial port, stty size returns 0
56if [ "${COLUMNS}" = "0" ]; then
57 COLUMNS=80
58fi
59
60## Measurements for positioning result messages
61RESULT_WIDTH=4
62TIME_WIDTH=8
63OPT_WIDTH=6
64VER_WIDTH=10
65RESULT_COL=$((${COLUMNS} - $RESULT_WIDTH - 4))
66TIME_COL=$((${RESULT_COL} - $TIME_WIDTH - 5))
67OPT_COL=$((${TIME_COL} - $OPT_WIDTH - 5))
68VER_COL=$((${OPT_COL} - $VER_WIDTH - 5))
69
70## Set Cursur Position Commands, used via echo -e
71SET_RESULT_COL="\\033[${RESULT_COL}G"
72SET_TIME_COL="\\033[${TIME_COL}G"
73SET_OPT_COL="\\033[${OPT_COL}G"
74SET_VER_COL="\\033[${VER_COL}G"
75
76# Define color for messages
77BOLD="\\033[1;39m"
78DONE="\\033[1;32m"
79SKIP="\\033[1;34m"
80WARN="\\033[1;35m"
81FAIL="\\033[1;31m"
82NORMAL="\\033[0;39m"
83
bcb9dc13 84# New architecture variables
dc7d6b20 85HOST_ARCH="$(uname -m)"
94571564 86
69a6ec55
MT
87PWD=$(pwd)
88BASENAME=$(basename $0)
89
15679d9f
MT
90# Debian specific settings
91if [ ! -e /etc/debian_version ]; then
df5e82b3 92 FULLPATH=`which $0`
15679d9f 93else
df5e82b3
MT
94 if [ -x /usr/bin/realpath ]; then
95 FULLPATH=`/usr/bin/realpath $0`
96 else
97 echo "ERROR: Need to do apt-get install realpath"
98 exit 1
99 fi
15679d9f 100fi
df5e82b3 101
69a6ec55
MT
102# This is the directory where make.sh is in
103BASEDIR=$(echo $FULLPATH | sed "s/\/$BASENAME//g")
104
15679d9f
MT
105LOGFILE=$BASEDIR/log/_build.preparation.log
106export BASEDIR LOGFILE
107DIR_CHK=$BASEDIR/cache/check
108mkdir $BASEDIR/log/ 2>/dev/null
df5e82b3 109
69a6ec55
MT
110system_processors() {
111 getconf _NPROCESSORS_ONLN 2>/dev/null || echo "1"
112}
113
114system_memory() {
115 local key val unit
116
117 while read -r key val unit; do
118 case "${key}" in
119 MemTotal:*)
120 # Convert to MB
121 echo "$(( ${val} / 1024 ))"
122 break
123 ;;
124 esac
125 done < /proc/meminfo
126}
127
128configure_build() {
129 local build_arch="${1}"
130
131 if [ "${build_arch}" = "default" ]; then
132 build_arch="$(configure_build_guess)"
133 fi
134
135 case "${build_arch}" in
136 x86_64)
137 BUILDTARGET="${build_arch}-unknown-linux-gnu"
138 CROSSTARGET="${build_arch}-cross-linux-gnu"
139 BUILD_PLATFORM="x86"
140 CFLAGS_ARCH="-m64 -mtune=generic"
141 ;;
142
143 i586)
144 BUILDTARGET="${build_arch}-pc-linux-gnu"
145 CROSSTARGET="${build_arch}-cross-linux-gnu"
146 BUILD_PLATFORM="x86"
147 CFLAGS_ARCH="-march=i586 -mtune=generic -fomit-frame-pointer"
148 ;;
149
150 aarch64)
151 BUILDTARGET="${build_arch}-unknown-linux-gnu"
152 CROSSTARGET="${build_arch}-cross-linux-gnu"
153 BUILD_PLATFORM="arm"
154 CFLAGS_ARCH=""
155 ;;
156
157 armv7hl)
158 BUILDTARGET="${build_arch}-unknown-linux-gnueabi"
159 CROSSTARGET="${build_arch}-cross-linux-gnueabi"
160 BUILD_PLATFORM="arm"
161 CFLAGS_ARCH="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard"
162 ;;
163
164 armv5tel)
165 BUILDTARGET="${build_arch}-unknown-linux-gnueabi"
166 CROSSTARGET="${build_arch}-cross-linux-gnueabi"
167 BUILD_PLATFORM="arm"
168 CFLAGS_ARCH="-march=armv5te -mfloat-abi=soft -fomit-frame-pointer"
169 ;;
170
171 *)
172 exiterror "Cannot build for architure ${build_arch}"
173 ;;
174 esac
175
176 # Check if the QEMU helper is available if needed.
177 if qemu_is_required "${build_arch}"; then
178 local qemu_build_helper="$(qemu_find_build_helper_name "${build_arch}")"
179
180 if [ -n "${qemu_build_helper}" ]; then
181 QEMU_TARGET_HELPER="${qemu_build_helper}"
182 else
183 exiterror "Could not find a binfmt_misc helper entry for ${build_arch}"
184 fi
185 fi
186
187 BUILD_ARCH="${build_arch}"
188 TOOLS_DIR="/tools_${BUILD_ARCH}"
189
190 # Enables hardening
191 HARDENING_CFLAGS="-Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4"
192
193 CFLAGS="-O2 -pipe -Wall -fexceptions -fPIC ${CFLAGS_ARCH}"
194 CXXFLAGS="${CFLAGS}"
195
196 # Determine parallelism
197 if [ -z "${MAKETUNING}" ]; then
198 # We assume that each process consumes about
199 # 192MB of memory. Therefore we find out how
200 # many processes fit into memory.
201 local mem_max=$(( ${HOST_MEM} / 192 ))
202
203 local processors="$(system_processors)"
204 local cpu_max=$(( ${processors} * 2 ))
205
206 local parallelism
207 if [ ${mem_max} -lt ${cpu_max} ]; then
208 parallelism=${mem_max}
209 else
210 parallelism=${cpu_max}
211 fi
212
213 MAKETUNING="-j${parallelism}"
214 fi
215}
216
217configure_build_guess() {
218 case "${HOST_ARCH}" in
219 x86_64|i686|i586)
220 echo "i586"
221 ;;
222
223 aarch64)
224 echo "aarch64"
225 ;;
226
227 armv7*|armv6*|armv5*)
228 echo "armv5tel"
229 ;;
230
231 *)
232 exiterror "Cannot guess build architecture"
233 ;;
234 esac
235}
236
237evaluate() {
238 if [ "$?" -eq "0" ]; then
239 beautify message DONE
240 else
241 EXITCODE=$1
242 shift 1
243 beautify message FAIL
244 $*
245 if [ $EXITCODE -ne "0" ]; then
246 exit $EXITCODE
247 fi
248 fi
249}
250
251position_cursor() {
252 # ARG1=starting position on screen
253 # ARG2=string to be printed
254 # ARG3=offset, negative for left movement, positive for right movement, relative to ARG1
255 # For example if your starting position is column 50 and you want to print Hello three columns to the right
256 # of your starting position, your call will look like this:
257 # position_cursor 50 "Hello" 3 (you'll get the string Hello at position 53 (= 50 + 3)
258 # If on the other hand you want your string "Hello" to end three columns to the left of position 50,
259 # your call will look like this:
260 # position_cursor 50 "Hello" -3 (you'll get the string Hello at position 42 (= 50 - 5 -3)
261 # If you want to start printing at the exact starting location, use offset 0
262
263 START=$1
264 STRING=$2
265 OFFSET=$3
266
267 STRING_LENGTH=${#STRING}
268
269 if [ ${OFFSET} -lt 0 ]; then
270 COL=$((${START} + ${OFFSET} - ${STRING_LENGTH}))
271 else
272 COL=$((${START} + ${OFFSET}))
273 fi
274
275 SET_COL="\\033[${COL}G"
276
277 echo $SET_COL
278}
279
280beautify() {
281 # Commands: build_stage, make_pkg, message, result
282 case "$1" in
283 message)
284 case "$2" in
285 DONE)
286 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
287 ;;
288 WARN)
289 echo -ne "${WARN}${3}${NORMAL}${SET_RESULT_COL}[${WARN} WARN ${NORMAL}]\n"
290 ;;
291 FAIL)
292 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
293 ;;
294 SKIP)
295 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
296 ;;
297 esac
298 ;;
299 build_stage)
300 MESSAGE=$2
301 if [ "$STAGE_TIME_START" ]; then
302 LAST_STAGE_TIME=$[ `date +%s` - $STAGE_TIME_START ]
303 fi
304 STAGE_TIME_START=`date +%s`
305 echo -ne "${BOLD}*** (${BUILD_ARCH}) ${MESSAGE}${NORMAL}"
306 if [ "$LAST_STAGE_TIME" ]; then
307 echo -ne "${DONE} (Last stage took $LAST_STAGE_TIME secs)${NORMAL}\n"
308 fi
309 echo -ne "${BOLD}${SET_VER_COL} version${SET_OPT_COL} options${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n"
310 ;;
311 build_start)
312 BUILD_TIME_START=`date +%s`
313 ;;
314 build_end)
315 BUILD_TIME_END=`date +%s`
316 seconds=$[ $BUILD_TIME_END - $BUILD_TIME_START ]
317 hours=$((seconds / 3600))
318 seconds=$((seconds % 3600))
319 minutes=$((seconds / 60))
320 seconds=$((seconds % 60))
321
322 echo -ne "${DONE}***Build is finished now and took $hours hour(s) $minutes minute(s) $seconds second(s)!${NORMAL}\n"
323 ;;
324 make_pkg)
325 echo "$2" | while read PKG_VER PROGRAM OPTIONS
326 do
327 SET_VER_COL_REAL=`position_cursor $OPT_COL $PKG_VER -3`
328
329 if [ "$OPTIONS" == "" ]; then
330 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
331 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
332 else
333 echo -ne "${PROGRAM}${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
334 echo -ne "${NORMAL} ]${SET_OPT_COL}[ ${BOLD}${OPTIONS}"
335 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
336 fi
337 done
338 ;;
339 result)
340 RESULT=$2
341
342 if [ ! $3 ]; then
343 PKG_TIME=0
344 else
345 PKG_TIME=$3
346 fi
347
348 SET_TIME_COL_REAL=`position_cursor $RESULT_COL $PKG_TIME -3`
349 case "$RESULT" in
350 DONE)
351 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
352 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
353 ;;
354 FAIL)
355 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
356 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
357 ;;
358 SKIP)
359 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
360 ;;
361 esac
362 ;;
363 esac
364}
365
366get_pkg_ver() {
367 PKG_VER=`grep -E "^VER |^VER=|^VER " $1 | awk '{print $3}'`
368
369 if [ -z $PKG_VER ]; then
370 PKG_VER=`grep "Exp " $1 | awk '{print $4}'`
371 fi
372 if [ -z $PKG_VER ]; then
373 PKG_VER="?"
374 fi
375 if [ ${#PKG_VER} -gt $VER_WIDTH ]; then
376 # If a package version number is greater than $VER_WIDTH, we keep the first 4 characters
377 # and replace enough characters to fit the resulting string on the screen. We'll replace
378 # the extra character with .. (two dots). That's why the "+ 2" in the formula below.
379 # Example: if we have a 21-long version number that we want to fit into a 10-long space,
380 # we have to remove 11 characters. But if we replace 11 characters with 2 characters, we'll
381 # end up with a 12-character long string. That's why we replace 12 characters with ..
382 REMOVE=`expr substr "$PKG_VER" 4 $[ ${#PKG_VER} - $VER_WIDTH + 2 ]`
383 PKG_VER=`echo ${PKG_VER/$REMOVE/..}`
384 fi
385
386 echo "$PKG_VER"
387}
388
389stdumount() {
390 umount $BASEDIR/build/sys 2>/dev/null;
391 umount $BASEDIR/build/dev/shm 2>/dev/null;
392 umount $BASEDIR/build/dev/pts 2>/dev/null;
393 umount $BASEDIR/build/dev 2>/dev/null;
394 umount $BASEDIR/build/proc 2>/dev/null;
395 umount $BASEDIR/build/install/mnt 2>/dev/null;
396 umount $BASEDIR/build/usr/src/cache 2>/dev/null;
397 umount $BASEDIR/build/usr/src/ccache 2>/dev/null;
398 umount $BASEDIR/build/usr/src/config 2>/dev/null;
399 umount $BASEDIR/build/usr/src/doc 2>/dev/null;
400 umount $BASEDIR/build/usr/src/html 2>/dev/null;
401 umount $BASEDIR/build/usr/src/langs 2>/dev/null;
402 umount $BASEDIR/build/usr/src/lfs 2>/dev/null;
403 umount $BASEDIR/build/usr/src/log 2>/dev/null;
404 umount $BASEDIR/build/usr/src/src 2>/dev/null;
405}
406
407exiterror() {
408 stdumount
409 for i in `seq 0 7`; do
410 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
411 losetup -d /dev/loop${i} 2>/dev/null
412 fi;
413 done
414
415 if [ -n "${LOGFILE}" ]; then
416 echo # empty line
417
418 local line
419 while read -r line; do
420 echo " ${line}"
421 done <<< "$(tail -n30 ${LOGFILE})"
422 fi
423
424 echo -e "\nERROR: $*"
425 echo " Check $LOGFILE for errors if applicable"
426 exit 1
427}
428
429enterchroot() {
430 # Install QEMU helper, if needed
431 qemu_install_helper
432
433 local PATH="${TOOLS_DIR}/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/bin"
434
435 PATH="${PATH}" chroot ${LFS} env -i \
436 HOME="/root" \
437 TERM="${TERM}" \
438 PS1="${PS1}" \
439 PATH="${PATH}" \
440 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
441 PAKFIRE_CORE="${PAKFIRE_CORE}" \
442 NAME="${NAME}" \
443 SNAME="${SNAME}" \
444 VERSION="${VERSION}" \
445 CORE="${CORE}" \
446 SLOGAN="${SLOGAN}" \
447 TOOLS_DIR="${TOOLS_DIR}" \
448 CONFIG_ROOT="${CONFIG_ROOT}" \
449 CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
450 CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
451 BUILDTARGET="${BUILDTARGET}" \
452 CROSSTARGET="${CROSSTARGET}" \
453 BUILD_ARCH="${BUILD_ARCH}" \
454 BUILD_PLATFORM="${BUILD_PLATFORM}" \
455 CCACHE_DIR=/usr/src/ccache \
456 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
457 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
458 KVER="${KVER}" \
459 $(fake_environ) \
460 $(qemu_environ) \
461 "$@"
462}
463
464entershell() {
465 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
466 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
467 fi
468
469 echo "Entering to a shell inside LFS chroot, go out with exit"
470 local PS1="ipfire build chroot ($(uname -m)) \u:\w\$ "
471
472 if enterchroot bash -i; then
473 stdumount
474 else
475 beautify message FAIL
476 exiterror "chroot error"
477 fi
478}
479
480lfsmakecommoncheck() {
481 # Script present?
482 if [ ! -f $BASEDIR/lfs/$1 ]; then
483 exiterror "No such file or directory: $BASEDIR/$1"
484 fi
485
486 local PKG_VER=`get_pkg_ver $BASEDIR/lfs/$1`
487 beautify make_pkg "$PKG_VER $*"
488
489 # Check if this package is supported by our architecture.
490 # If no SUP_ARCH is found, we assume the package can be built for all.
491 if grep "^SUP_ARCH" ${BASEDIR}/lfs/${1} >/dev/null; then
492 # Check if package supports ${BUILD_ARCH} or all architectures.
493 if ! grep -E "^SUP_ARCH.*${BUILD_ARCH}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
494 beautify result SKIP
495 return 1
496 fi
497 fi
498
499 # Script slipped?
500 local i
501 for i in $SKIP_PACKAGE_LIST
502 do
503 if [ "$i" == "$1" ]; then
504 beautify result SKIP
505 return 1;
506 fi
507 done
508
509 echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
510
511 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
512 MESSAGE="$1\t " download >> $LOGFILE 2>&1
513 if [ $? -ne 0 ]; then
514 exiterror "Download error in $1"
515 fi
516
517 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
518 MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
519 if [ $? -ne 0 ]; then
520 exiterror "md5sum error in $1, check file in cache or signature"
521 fi
522
523 return 0 # pass all!
524}
525
526lfsmake1() {
527 lfsmakecommoncheck $*
528 [ $? == 1 ] && return 0
529
530 local PKG_TIME_START=`date +%s`
531
532 cd $BASEDIR/lfs && env -i \
533 PATH="${TOOLS_DIR}/ccache/bin:${TOOLS_DIR}/bin:$PATH" \
534 CCACHE_DIR="${CCACHE_DIR}" \
535 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
536 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
537 CFLAGS="${CFLAGS}" \
538 CXXFLAGS="${CXXFLAGS}" \
539 MAKETUNING="${MAKETUNING}" \
540 make -f $* \
541 TOOLCHAIN=1 \
542 TOOLS_DIR="${TOOLS_DIR}" \
543 CROSSTARGET="${CROSSTARGET}" \
544 BUILDTARGET="${BUILDTARGET}" \
545 BUILD_ARCH="${BUILD_ARCH}" \
546 BUILD_PLATFORM="${BUILD_PLATFORM}" \
547 LFS_BASEDIR="${BASEDIR}" \
548 ROOT="${LFS}" \
549 KVER="${KVER}" \
550 install >> $LOGFILE 2>&1
551
552 local COMPILE_SUCCESS=$?
553 local PKG_TIME_END=`date +%s`
554
555 if [ $COMPILE_SUCCESS -ne 0 ]; then
556 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
557 exiterror "Building $*";
558 else
559 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
560 fi
561
562 return 0
563}
564
565lfsmake2() {
566 lfsmakecommoncheck $*
567 [ $? == 1 ] && return 0
568
569 local PKG_TIME_START=`date +%s`
570 local PS1='\u:\w$ '
571
572 enterchroot \
573 bash -x -c "cd /usr/src/lfs && \
574 MAKETUNING=${MAKETUNING} \
575 make -f $* \
576 LFS_BASEDIR=/usr/src install" \
577 >> ${LOGFILE} 2>&1
578
579 local COMPILE_SUCCESS=$?
580 local PKG_TIME_END=`date +%s`
581
582 if [ $COMPILE_SUCCESS -ne 0 ]; then
583 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
584 exiterror "Building $*";
585 else
586 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
587 fi
588
589 return 0
590}
591
592ipfiredist() {
593 lfsmakecommoncheck $*
594 [ $? == 1 ] && return 0
595
596 local PKG_TIME_START=`date +%s`
597 local PS1='\u:\w$ '
598
599 enterchroot \
600 bash -x -c "cd /usr/src/lfs && make -f $* LFS_BASEDIR=/usr/src dist" \
601 >> ${LOGFILE} 2>&1
602
603 local COMPILE_SUCCESS=$?
604 local PKG_TIME_END=`date +%s`
605
606 if [ $COMPILE_SUCCESS -ne 0 ]; then
607 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
608 exiterror "Packaging $*";
609 else
610 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
611 fi
612 return 0
613}
614
615fake_environ() {
616 [ -e "${BASEDIR}/build${TOOLS_DIR}/lib/libpakfire_preload.so" ] || return
617
618 local env="LD_PRELOAD=${TOOLS_DIR}/lib/libpakfire_preload.so"
619
620 # Fake kernel version, because some of the packages do not compile
621 # with kernel 3.0 and later.
622 env="${env} UTS_RELEASE=${KVER}"
623
624 # Fake machine version.
625 env="${env} UTS_MACHINE=${BUILD_ARCH}"
626
627 echo "${env}"
628}
629
630qemu_environ() {
631 local env
632
633 # Don't add anything if qemu is not used.
634 if ! qemu_is_required; then
635 return
636 fi
637
638 # Set default qemu options
639 case "${BUILD_ARCH}" in
640 arm*)
641 QEMU_CPU="${QEMU_CPU:-cortex-a9}"
642
643 env="${env} QEMU_CPU=${QEMU_CPU}"
644 ;;
645 esac
646
647 # Enable QEMU strace
648 #env="${env} QEMU_STRACE=1"
649
650 echo "${env}"
651}
652
653qemu_is_required() {
654 local build_arch="${1}"
655
656 if [ -z "${build_arch}" ]; then
657 build_arch="${BUILD_ARCH}"
658 fi
659
660 case "${HOST_ARCH},${build_arch}" in
661 x86_64,arm*|i?86,arm*|i?86,x86_64)
662 return 0
663 ;;
664 *)
665 return 1
666 ;;
667 esac
668}
669
670qemu_install_helper() {
671 # Do nothing, if qemu is not required
672 if ! qemu_is_required; then
673 return 0
674 fi
675
676 if [ ! -e /proc/sys/fs/binfmt_misc/status ]; then
677 exiterror "binfmt_misc not mounted. QEMU_TARGET_HELPER not useable."
678 fi
679
680 if [ ! $(cat /proc/sys/fs/binfmt_misc/status) = 'enabled' ]; then
681 exiterror "binfmt_misc not enabled. QEMU_TARGET_HELPER not useable."
682 fi
683
684
685 if [ -z "${QEMU_TARGET_HELPER}" ]; then
686 exiterror "QEMU_TARGET_HELPER not set"
687 fi
688
689 # Check if the helper is already installed.
690 if [ -x "${LFS}${QEMU_TARGET_HELPER}" ]; then
691 return 0
692 fi
693
694 # Try to find a suitable binary that we can install
695 # to the build environment.
696 local file
697 for file in "${QEMU_TARGET_HELPER}" "${QEMU_TARGET_HELPER}-static"; do
698 # file must exist and be executable.
699 [ -x "${file}" ] || continue
700
701 # Must be static.
702 file_is_static "${file}" || continue
703
704 local dirname="${LFS}$(dirname "${file}")"
705 mkdir -p "${dirname}"
706
707 install -m 755 "${file}" "${LFS}${QEMU_TARGET_HELPER}"
708 return 0
709 done
710
711 exiterror "Could not find a statically-linked QEMU emulator: ${QEMU_TARGET_HELPER}"
712}
713
714qemu_find_build_helper_name() {
715 local build_arch="${1}"
716
717 local magic
718 case "${build_arch}" in
719 arm*)
720 magic="7f454c4601010100000000000000000002002800"
721 ;;
722 x86_64)
723 magic="7f454c4602010100000000000000000002003e00"
724 ;;
725 esac
726
727 [ -z "${magic}" ] && return 1
728
729 local file
730 for file in /proc/sys/fs/binfmt_misc/*; do
731 # skip write only register entry
732 [ $(basename "${file}") = "register" ] && continue
733 # Search for the file with the correct magic value.
734 grep -qE "^magic ${magic}$" "${file}" || continue
735
736 local interpreter="$(grep "^interpreter" "${file}" | awk '{ print $2 }')"
737
738 [ -n "${interpreter}" ] || continue
739 [ "${interpreter:0:1}" = "/" ] || continue
740 [ -x "${interpreter}" ] || continue
741
742 echo "${interpreter}"
743 return 0
744 done
745
746 return 1
747}
748
749file_is_static() {
750 local file="${1}"
751
752 file ${file} 2>/dev/null | grep -q "statically linked"
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"
763}
764
a98ab1d7
MT
765# Load configuration file
766if [ -f .config ]; then
767 . .config
768fi
769
5190eea2
MT
770# Get the amount of memory in this build system
771HOST_MEM=$(system_memory)
772
dc7d6b20
MT
773if [ -n "${BUILD_ARCH}" ]; then
774 configure_build "${BUILD_ARCH}"
775elif [ -n "${TARGET_ARCH}" ]; then
776 configure_build "${TARGET_ARCH}"
777 unset TARGET_ARCH
949544f5 778else
dc7d6b20 779 configure_build "default"
949544f5
MT
780fi
781
df5e82b3 782prepareenv() {
69a6ec55
MT
783 ############################################################################
784 # #
785 # Are we running the right shell? #
786 # #
787 ############################################################################
788 if [ ! "$BASH" ]; then
1b273e8f 789 exiterror "BASH environment variable is not set. You're probably running the wrong shell."
69a6ec55 790 fi
df5e82b3 791
69a6ec55 792 if [ -z "${BASH_VERSION}" ]; then
1b273e8f 793 exiterror "Not running BASH shell."
69a6ec55 794 fi
df5e82b3
MT
795
796
69a6ec55
MT
797 ############################################################################
798 # #
799 # Trap on emergency exit #
800 # #
801 ############################################################################
802 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
df5e82b3
MT
803
804
69a6ec55
MT
805 ############################################################################
806 # #
807 # Resetting our nice level #
808 # #
809 ############################################################################
810 echo -ne "Resetting our nice level to $NICE" | tee -a $LOGFILE
811 renice $NICE $$ > /dev/null
812 if [ `nice` != "$NICE" ]; then
1b273e8f
MT
813 beautify message FAIL
814 exiterror "Failed to set correct nice level"
69a6ec55 815 else
1b273e8f 816 beautify message DONE
69a6ec55 817 fi
df5e82b3 818
15679d9f 819
69a6ec55
MT
820 ############################################################################
821 # #
822 # Checking if running as root user #
823 # #
824 ############################################################################
825 echo -ne "Checking if we're running as root user" | tee -a $LOGFILE
826 if [ `id -u` != 0 ]; then
1b273e8f
MT
827 beautify message FAIL
828 exiterror "Not building as root"
69a6ec55 829 else
1b273e8f 830 beautify message DONE
69a6ec55
MT
831 fi
832
833
834 ############################################################################
835 # #
836 # Checking for necessary temporary space #
837 # #
838 ############################################################################
839 echo -ne "Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
840 BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
841 BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
842 if (( 2048000 > $BASE_ASPACE )); then
1b273e8f
MT
843 BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
844 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
845 beautify message FAIL
846 exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
847 fi
69a6ec55 848 else
1b273e8f 849 beautify message DONE
69a6ec55
MT
850 fi
851
852 ############################################################################
853 # #
854 # Building Linux From Scratch system #
855 # #
856 ############################################################################
857 # Set umask
858 umask 022
859
860 # Set LFS Directory
861 LFS=$BASEDIR/build
862
863 # Check ${TOOLS_DIR} symlink
864 if [ -h "${TOOLS_DIR}" ]; then
865 rm -f "${TOOLS_DIR}"
866 fi
867
868 if [ ! -e "${TOOLS_DIR}" ]; then
869 ln -s "${BASEDIR}/build${TOOLS_DIR}" "${TOOLS_DIR}"
870 fi
871
872 if [ ! -h "${TOOLS_DIR}" ]; then
873 exiterror "Could not create ${TOOLS_DIR} symbolic link"
874 fi
875
876 # Setup environment
877 set +h
878 LC_ALL=POSIX
879 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
880 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
881
882 # Make some extra directories
883 mkdir -p "${BASEDIR}/build${TOOLS_DIR}" 2>/dev/null
884 mkdir -p $BASEDIR/build/{etc,usr/src} 2>/dev/null
885 mkdir -p $BASEDIR/build/{dev/{shm,pts},proc,sys}
886 mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
887 mkdir -p $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
888
889 mknod -m 600 $BASEDIR/build/dev/console c 5 1 2>/dev/null
890 mknod -m 666 $BASEDIR/build/dev/null c 1 3 2>/dev/null
891
892 # Make all sources and proc available under lfs build
893 mount --bind /dev $BASEDIR/build/dev
894 mount --bind /dev/pts $BASEDIR/build/dev/pts
895 mount --bind /dev/shm $BASEDIR/build/dev/shm
896 mount --bind /proc $BASEDIR/build/proc
897 mount --bind /sys $BASEDIR/build/sys
898 mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache
899 mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
900 mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
901 mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc
902 mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html
903 mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs
904 mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs
905 mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log
906 mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src
907
908 # Run LFS static binary creation scripts one by one
909 export CCACHE_DIR=$BASEDIR/ccache
910 export CCACHE_COMPRESS=1
911 export CCACHE_COMPILERCHECK="string:toolchain-${TOOLCHAINVER} ${BUILD_ARCH}"
912
913 # Remove pre-install list of installed files in case user erase some files before rebuild
914 rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
915
916 # Prepare string for /etc/system-release.
917 SYSTEM_RELEASE="${NAME} ${VERSION} (${BUILD_ARCH})"
918 if [ "$(git status -s | wc -l)" == "0" ]; then
7f69895c 919 GIT_STATUS=""
69a6ec55 920 else
7f69895c 921 GIT_STATUS="-dirty"
69a6ec55
MT
922 fi
923 case "$GIT_BRANCH" in
7f69895c
AF
924 core*|beta?|rc?)
925 SYSTEM_RELEASE="${SYSTEM_RELEASE} - $GIT_BRANCH$GIT_STATUS"
926 ;;
927 *)
928 SYSTEM_RELEASE="${SYSTEM_RELEASE} - Development Build: $GIT_BRANCH/$GIT_LASTCOMMIT$GIT_STATUS"
929 ;;
69a6ec55 930 esac
df5e82b3
MT
931}
932
df5e82b3 933buildtoolchain() {
69a6ec55
MT
934 local error=false
935 case "${BUILD_ARCH}:${HOST_ARCH}" in
936 # x86_64
937 x86_64:x86_64)
938 # This is working.
939 ;;
940
941 # x86
942 i586:i586|i586:i686|i586:x86_64)
943 # These are working.
944 ;;
945 i586:*)
946 error=true
947 ;;
948
949 # ARM
950 arvm7hl:armv7hl|armv7hl:armv7l)
951 # These are working.
952 ;;
953
954 armv5tel:armv5tel|armv5tel:armv5tejl|armv5tel:armv6l|armv5tel:armv7l|armv5tel:aarch64)
955 # These are working.
956 ;;
957 armv5tel:*)
958 error=true
959 ;;
960 esac
961
962 ${error} && \
963 exiterror "Cannot build ${BUILD_ARCH} toolchain on $(uname -m). Please use the download if any."
964
965 local gcc=$(type -p gcc)
966 if [ -z "${gcc}" ]; then
967 exiterror "Could not find GCC. You will need a working build enviroment in order to build the toolchain."
968 fi
969
970 LOGFILE="$BASEDIR/log/_build.toolchain.log"
971 export LOGFILE
972
973 lfsmake1 stage1
974 lfsmake1 ccache PASS=1
975 lfsmake1 binutils PASS=1
976 lfsmake1 gcc PASS=1
977 lfsmake1 linux KCFG="-headers"
978 lfsmake1 glibc
979 lfsmake1 gcc PASS=L
980 lfsmake1 binutils PASS=2
981 lfsmake1 gcc PASS=2
982 lfsmake1 ccache PASS=2
983 lfsmake1 tcl
984 lfsmake1 expect
985 lfsmake1 dejagnu
986 lfsmake1 pkg-config
987 lfsmake1 ncurses
988 lfsmake1 bash
989 lfsmake1 bzip2
990 lfsmake1 automake
991 lfsmake1 coreutils
992 lfsmake1 diffutils
993 lfsmake1 findutils
994 lfsmake1 gawk
995 lfsmake1 gettext
996 lfsmake1 grep
997 lfsmake1 gzip
998 lfsmake1 m4
999 lfsmake1 make
1000 lfsmake1 patch
1001 lfsmake1 perl
1002 lfsmake1 sed
1003 lfsmake1 tar
1004 lfsmake1 texinfo
1005 lfsmake1 xz
1006 lfsmake1 fake-environ
1007 lfsmake1 cleanup-toolchain
df5e82b3
MT
1008}
1009
1010buildbase() {
69a6ec55
MT
1011 LOGFILE="$BASEDIR/log/_build.base.log"
1012 export LOGFILE
1013 lfsmake2 stage2
1014 lfsmake2 linux KCFG="-headers"
1015 lfsmake2 man-pages
1016 lfsmake2 glibc
1017 lfsmake2 tzdata
1018 lfsmake2 cleanup-toolchain
1019 lfsmake2 zlib
1020 lfsmake2 binutils
1021 lfsmake2 gmp
1022 lfsmake2 gmp-compat
1023 lfsmake2 mpfr
1024 lfsmake2 libmpc
1025 lfsmake2 file
1026 lfsmake2 gcc
1027 lfsmake2 sed
1028 lfsmake2 autoconf
1029 lfsmake2 automake
1030 lfsmake2 berkeley
1031 lfsmake2 coreutils
1032 lfsmake2 iana-etc
1033 lfsmake2 m4
1034 lfsmake2 bison
1035 lfsmake2 ncurses-compat
1036 lfsmake2 ncurses
1037 lfsmake2 procps
1038 lfsmake2 libtool
1039 lfsmake2 perl
1040 lfsmake2 readline
1041 lfsmake2 readline-compat
1042 lfsmake2 bzip2
1043 lfsmake2 pcre
1044 lfsmake2 pcre-compat
1045 lfsmake2 bash
1046 lfsmake2 diffutils
1047 lfsmake2 e2fsprogs
1048 lfsmake2 ed
1049 lfsmake2 findutils
1050 lfsmake2 flex
1051 lfsmake2 gawk
1052 lfsmake2 gettext
1053 lfsmake2 grep
1054 lfsmake2 groff
1055 lfsmake2 gperf
1056 lfsmake2 gzip
1057 lfsmake2 hostname
1058 lfsmake2 iproute2
1059 lfsmake2 jwhois
1060 lfsmake2 kbd
1061 lfsmake2 less
1062 lfsmake2 make
1063 lfsmake2 man
1064 lfsmake2 kmod
1065 lfsmake2 net-tools
1066 lfsmake2 patch
1067 lfsmake2 psmisc
1068 lfsmake2 shadow
1069 lfsmake2 sysklogd
1070 lfsmake2 sysvinit
1071 lfsmake2 tar
1072 lfsmake2 texinfo
1073 lfsmake2 util-linux
1074 lfsmake2 udev
1075 lfsmake2 vim
1076 lfsmake2 xz
1077 lfsmake2 paxctl
df5e82b3
MT
1078}
1079
15679d9f 1080buildipfire() {
907cd036 1081 LOGFILE="$BASEDIR/log/_build.ipfire.log"
df5e82b3 1082 export LOGFILE
489145db
MT
1083 lfsmake2 configroot
1084 lfsmake2 initscripts
1085 lfsmake2 backup
1086 lfsmake2 pkg-config
1087 lfsmake2 libusb
1088 lfsmake2 libusb-compat
1089 lfsmake2 libpcap
1090 lfsmake2 ppp
1091 lfsmake2 pptp
1092 lfsmake2 unzip
1093 lfsmake2 which
1094 lfsmake2 linux-firmware
1095 lfsmake2 ath10k-firmware
1096 lfsmake2 dvb-firmwares
1097 lfsmake2 mt7601u-firmware
1098 lfsmake2 zd1211-firmware
1099 lfsmake2 rpi-firmware
1100 lfsmake2 bc
1101 lfsmake2 u-boot
1102 lfsmake2 cpio
1103 lfsmake2 mdadm
1104 lfsmake2 dracut
1105 lfsmake2 lvm2
1106 lfsmake2 multipath-tools
1107 lfsmake2 freetype
1108 lfsmake2 grub
1109 lfsmake2 libmnl
1110 lfsmake2 libnfnetlink
1111 lfsmake2 libnetfilter_queue
1112 lfsmake2 libnetfilter_conntrack
1113 lfsmake2 libnetfilter_cthelper
1114 lfsmake2 libnetfilter_cttimeout
1115 lfsmake2 iptables
8e6fb99d 1116
dc7d6b20 1117 case "${BUILD_ARCH}" in
fc155193 1118 x86_64)
489145db
MT
1119 lfsmake2 linux KCFG=""
1120 lfsmake2 backports KCFG=""
1121 lfsmake2 e1000e KCFG=""
1122 lfsmake2 igb KCFG=""
1123 lfsmake2 ixgbe KCFG=""
1124 lfsmake2 xtables-addons KCFG=""
1125 lfsmake2 linux-initrd KCFG=""
fc155193 1126 ;;
3d02c091
MT
1127 i586)
1128 # x86-pae (Native and new XEN) kernel build
489145db
MT
1129 lfsmake2 linux KCFG="-pae"
1130 lfsmake2 backports KCFG="-pae"
1131 lfsmake2 e1000e KCFG="-pae"
1132 lfsmake2 igb KCFG="-pae"
1133 lfsmake2 ixgbe KCFG="-pae"
1134 lfsmake2 xtables-addons KCFG="-pae"
1135 lfsmake2 linux-initrd KCFG="-pae"
3d02c091
MT
1136
1137 # x86 kernel build
489145db
MT
1138 lfsmake2 linux KCFG=""
1139 lfsmake2 backports KCFG=""
1140 lfsmake2 e1000e KCFG=""
1141 lfsmake2 igb KCFG=""
1142 lfsmake2 ixgbe KCFG=""
1143 lfsmake2 xtables-addons KCFG=""
1144 lfsmake2 linux-initrd KCFG=""
3d02c091 1145 ;;
544f40d4 1146
3d02c091
MT
1147 armv5tel)
1148 # arm-rpi (Raspberry Pi) kernel build
489145db
MT
1149 lfsmake2 linux KCFG="-rpi"
1150 lfsmake2 backports KCFG="-rpi"
1151 lfsmake2 xtables-addons KCFG="-rpi"
1152 lfsmake2 linux-initrd KCFG="-rpi"
3d02c091
MT
1153
1154 # arm multi platform (Panda, Wandboard ...) kernel build
489145db
MT
1155 lfsmake2 linux KCFG="-multi"
1156 lfsmake2 backports KCFG="-multi"
1157 lfsmake2 e1000e KCFG="-multi"
1158 lfsmake2 igb KCFG="-multi"
1159 lfsmake2 ixgbe KCFG="-multi"
1160 lfsmake2 xtables-addons KCFG="-multi"
1161 lfsmake2 linux-initrd KCFG="-multi"
3d02c091
MT
1162
1163 # arm-kirkwood (Dreamplug, ICY-Box ...) kernel build
489145db
MT
1164 lfsmake2 linux KCFG="-kirkwood"
1165 lfsmake2 backports KCFG="-kirkwood"
1166 lfsmake2 e1000e KCFG="-kirkwood"
1167 lfsmake2 igb KCFG="-kirkwood"
1168 lfsmake2 ixgbe KCFG="-kirkwood"
1169 lfsmake2 xtables-addons KCFG="-kirkwood"
1170 lfsmake2 linux-initrd KCFG="-kirkwood"
3d02c091
MT
1171 ;;
1172 esac
489145db
MT
1173 lfsmake2 xtables-addons USPACE="1"
1174 lfsmake2 openssl
1175 [ "${BUILD_ARCH}" = "i586" ] && lfsmake2 openssl KCFG='-sse2'
1176 lfsmake2 libgpg-error
1177 lfsmake2 libgcrypt
1178 lfsmake2 libassuan
1179 lfsmake2 nettle
1180 lfsmake2 libevent
1181 lfsmake2 libevent2
89ad036a 1182 lfsmake2 libevent2-compat
489145db 1183 lfsmake2 expat
c8e9a7a8
WA
1184 lfsmake2 apr
1185 lfsmake2 aprutil
489145db
MT
1186 lfsmake2 unbound
1187 lfsmake2 gnutls
1188 lfsmake2 bind
1189 lfsmake2 dhcp
1190 lfsmake2 dhcpcd
1191 lfsmake2 boost
1192 lfsmake2 linux-atm
1193 lfsmake2 gdbm
1194 lfsmake2 pam
1195 lfsmake2 curl
1196 lfsmake2 tcl
1197 lfsmake2 sqlite
1198 lfsmake2 libffi
1199 lfsmake2 python
1200 lfsmake2 python3
1201 lfsmake2 ca-certificates
1202 lfsmake2 fireinfo
1203 lfsmake2 libnet
1204 lfsmake2 libnl
1205 lfsmake2 libnl-3
1206 lfsmake2 libidn
1207 lfsmake2 nasm
1208 lfsmake2 libjpeg
1209 lfsmake2 libjpeg-compat
1210 lfsmake2 libexif
1211 lfsmake2 libpng
1212 lfsmake2 libtiff
1213 lfsmake2 libart
1214 lfsmake2 gd
1215 lfsmake2 popt
489145db
MT
1216 lfsmake2 slang
1217 lfsmake2 newt
1218 lfsmake2 libsmooth
1219 lfsmake2 attr
1220 lfsmake2 acl
1221 lfsmake2 libcap
1222 lfsmake2 pciutils
1223 lfsmake2 usbutils
1224 lfsmake2 libxml2
1225 lfsmake2 libxslt
1226 lfsmake2 BerkeleyDB
1227 lfsmake2 mysql
1228 lfsmake2 cyrus-sasl
1229 lfsmake2 openldap
1230 lfsmake2 apache2
1231 lfsmake2 php
1232 lfsmake2 web-user-interface
1233 lfsmake2 flag-icons
1234 lfsmake2 jquery
6033b271 1235 lfsmake2 bootstrap
489145db
MT
1236 lfsmake2 arping
1237 lfsmake2 beep
1238 lfsmake2 dvdrtools
1239 lfsmake2 dosfstools
1240 lfsmake2 reiserfsprogs
1241 lfsmake2 xfsprogs
1242 lfsmake2 sysfsutils
1243 lfsmake2 fuse
1244 lfsmake2 ntfs-3g
1245 lfsmake2 ethtool
1246 lfsmake2 ez-ipupdate
1247 lfsmake2 fcron
1248 lfsmake2 perl-GD
1249 lfsmake2 GD-Graph
1250 lfsmake2 GD-TextUtil
1251 lfsmake2 perl-Device-SerialPort
1252 lfsmake2 perl-Device-Modem
1253 lfsmake2 perl-Apache-Htpasswd
1254 lfsmake2 gnupg
1255 lfsmake2 hdparm
1256 lfsmake2 sdparm
1257 lfsmake2 mtools
1258 lfsmake2 whatmask
1259 lfsmake2 conntrack-tools
1260 lfsmake2 libupnp
1261 lfsmake2 ipaddr
1262 lfsmake2 iputils
1263 lfsmake2 l7-protocols
1264 lfsmake2 mISDNuser
1265 lfsmake2 capi4k-utils
1266 lfsmake2 hwdata
1267 lfsmake2 logrotate
1268 lfsmake2 logwatch
1269 lfsmake2 misc-progs
1270 lfsmake2 nano
1271 lfsmake2 URI
1272 lfsmake2 HTML-Tagset
1273 lfsmake2 HTML-Parser
1274 lfsmake2 HTML-Template
1275 lfsmake2 Compress-Zlib
1276 lfsmake2 Digest
1277 lfsmake2 Digest-SHA1
1278 lfsmake2 Digest-HMAC
1279 lfsmake2 libwww-perl
1280 lfsmake2 Net-DNS
1281 lfsmake2 Net-IPv4Addr
1282 lfsmake2 Net_SSLeay
1283 lfsmake2 IO-Stringy
1284 lfsmake2 IO-Socket-SSL
1285 lfsmake2 Unix-Syslog
1286 lfsmake2 Mail-Tools
1287 lfsmake2 MIME-Tools
1288 lfsmake2 Net-Server
1289 lfsmake2 Convert-TNEF
1290 lfsmake2 Convert-UUlib
1291 lfsmake2 Archive-Tar
1292 lfsmake2 Archive-Zip
1293 lfsmake2 Text-Tabs+Wrap
1294 lfsmake2 Locale-Country
1295 lfsmake2 XML-Parser
1296 lfsmake2 Crypt-PasswdMD5
1297 lfsmake2 Net-Telnet
1298 lfsmake2 python-setuptools
1299 lfsmake2 python-clientform
1300 lfsmake2 python-mechanize
1301 lfsmake2 python-feedparser
1302 lfsmake2 python-rssdler
1303 lfsmake2 python-inotify
1304 lfsmake2 python-docutils
1305 lfsmake2 python-daemon
1306 lfsmake2 python-ipaddress
1307 lfsmake2 glib
1308 lfsmake2 GeoIP
489145db
MT
1309 lfsmake2 noip_updater
1310 lfsmake2 ntp
1311 lfsmake2 openssh
1312 lfsmake2 fontconfig
1313 lfsmake2 dejavu-fonts-ttf
70f6cba4 1314 lfsmake2 ubuntu-font-family
489145db
MT
1315 lfsmake2 freefont
1316 lfsmake2 pixman
1317 lfsmake2 cairo
1318 lfsmake2 pango
1319 lfsmake2 rrdtool
1320 lfsmake2 setserial
1321 lfsmake2 setup
1322 lfsmake2 libdnet
1323 lfsmake2 daq
1324 lfsmake2 snort
1325 lfsmake2 oinkmaster
1326 lfsmake2 squid
1327 lfsmake2 squidguard
1328 lfsmake2 calamaris
1329 lfsmake2 tcpdump
1330 lfsmake2 traceroute
1331 lfsmake2 vlan
1332 lfsmake2 wireless
1333 lfsmake2 pakfire
1334 lfsmake2 spandsp
1335 lfsmake2 lzo
1336 lfsmake2 openvpn
1337 lfsmake2 pammysql
1338 lfsmake2 mpage
1339 lfsmake2 dbus
1340 lfsmake2 intltool
1341 lfsmake2 libdaemon
1342 lfsmake2 cups
489145db 1343 lfsmake2 lcms2
56170c2a 1344 lfsmake2 ghostscript
489145db
MT
1345 lfsmake2 qpdf
1346 lfsmake2 poppler
1347 lfsmake2 cups-filters
1348 lfsmake2 epson-inkjet-printer-escpr
1349 lfsmake2 foomatic
1350 lfsmake2 hplip
1351 lfsmake2 cifs-utils
1352 lfsmake2 krb5
1353 lfsmake2 samba
1354 lfsmake2 sudo
1355 lfsmake2 mc
1356 lfsmake2 wget
1357 lfsmake2 bridge-utils
1358 lfsmake2 screen
1359 lfsmake2 smartmontools
1360 lfsmake2 htop
1361 lfsmake2 chkconfig
1362 lfsmake2 postfix
1363 lfsmake2 fetchmail
1364 lfsmake2 cyrus-imapd
1365 lfsmake2 openmailadmin
1366 lfsmake2 clamav
1367 lfsmake2 spamassassin
1368 lfsmake2 amavisd
1369 lfsmake2 dma
1370 lfsmake2 alsa
1371 lfsmake2 mpfire
1372 lfsmake2 guardian
1373 lfsmake2 libid3tag
1374 lfsmake2 libmad
1375 lfsmake2 libogg
1376 lfsmake2 libvorbis
1377 lfsmake2 libdvbpsi
1378 lfsmake2 flac
1379 lfsmake2 lame
1380 lfsmake2 sox
1381 lfsmake2 libshout
1382 lfsmake2 xvid
1383 lfsmake2 libmpeg2
1384 lfsmake2 libarchive
1385 lfsmake2 cmake
1386 lfsmake2 gnump3d
1387 lfsmake2 rsync
1388 lfsmake2 tcpwrapper
1389 lfsmake2 libtirpc
1390 lfsmake2 rpcbind
1391 lfsmake2 nfs
1392 lfsmake2 gnu-netcat
1393 lfsmake2 ncat
1394 lfsmake2 nmap
489145db
MT
1395 lfsmake2 etherwake
1396 lfsmake2 bwm-ng
1397 lfsmake2 sysstat
1398 lfsmake2 vsftpd
1399 lfsmake2 strongswan
1400 lfsmake2 rng-tools
1401 lfsmake2 lsof
1402 lfsmake2 br2684ctl
1403 lfsmake2 pcmciautils
1404 lfsmake2 lm_sensors
1405 lfsmake2 liboping
1406 lfsmake2 collectd
1407 lfsmake2 elinks
1408 lfsmake2 igmpproxy
1409 lfsmake2 fbset
1410 lfsmake2 opus
1411 lfsmake2 python-six
1412 lfsmake2 python-pyparsing
1413 lfsmake2 spice-protocol
1414 lfsmake2 spice
1415 lfsmake2 sdl
1416 lfsmake2 libusbredir
1417 lfsmake2 qemu
1418 lfsmake2 sane
1419 lfsmake2 netpbm
1420 lfsmake2 phpSANE
1421 lfsmake2 tunctl
1422 lfsmake2 netsnmpd
1423 lfsmake2 nagios
1424 lfsmake2 nagios_nrpe
1425 lfsmake2 icinga
1426 lfsmake2 ebtables
1427 lfsmake2 directfb
489145db
MT
1428 lfsmake2 faad2
1429 lfsmake2 ffmpeg
1430 lfsmake2 vdr
1431 lfsmake2 vdr_streamdev
489145db
MT
1432 lfsmake2 vdr_epgsearch
1433 lfsmake2 vdr_dvbapi
1434 lfsmake2 vdr_eepg
1435 lfsmake2 w_scan
1436 lfsmake2 icecast
1437 lfsmake2 icegenerator
1438 lfsmake2 mpd
1439 lfsmake2 libmpdclient
1440 lfsmake2 mpc
1441 lfsmake2 perl-Net-SMTP-SSL
1442 lfsmake2 perl-MIME-Base64
1443 lfsmake2 perl-Authen-SASL
1444 lfsmake2 perl-MIME-Lite
1445 lfsmake2 perl-Email-Date-Format
1446 lfsmake2 git
1447 lfsmake2 squidclamav
1448 lfsmake2 vnstat
1449 lfsmake2 iw
1450 lfsmake2 wpa_supplicant
1451 lfsmake2 hostapd
1452 lfsmake2 pycurl
1453 lfsmake2 urlgrabber
1454 lfsmake2 syslinux
1455 lfsmake2 tftpd
1456 lfsmake2 cpufrequtils
1457 lfsmake2 bluetooth
1458 lfsmake2 gutenprint
1459 lfsmake2 apcupsd
1460 lfsmake2 iperf
1461 lfsmake2 iperf3
1462 lfsmake2 7zip
1463 lfsmake2 lynis
1464 lfsmake2 streamripper
1465 lfsmake2 sshfs
1466 lfsmake2 taglib
1467 #lfsmake2 mediatomb
1468 lfsmake2 sslh
1469 lfsmake2 perl-gettext
1470 lfsmake2 perl-Sort-Naturally
1471 lfsmake2 vdradmin
1472 lfsmake2 miau
1473 lfsmake2 perl-DBI
1474 lfsmake2 perl-DBD-mysql
1475 lfsmake2 perl-DBD-SQLite
1476 lfsmake2 perl-File-ReadBackwards
1477 lfsmake2 cacti
1478 lfsmake2 openvmtools
1479 lfsmake2 nagiosql
489145db
MT
1480 lfsmake2 motion
1481 lfsmake2 joe
1482 lfsmake2 monit
1483 lfsmake2 nut
1484 lfsmake2 watchdog
1485 lfsmake2 libpri
1486 lfsmake2 libsrtp
1487 lfsmake2 asterisk
1488 lfsmake2 lcr
1489 lfsmake2 usb_modeswitch
1490 lfsmake2 usb_modeswitch_data
1491 lfsmake2 zerofree
1492 lfsmake2 pound
1493 lfsmake2 minicom
1494 lfsmake2 ddrescue
489145db
MT
1495 lfsmake2 miniupnpd
1496 lfsmake2 client175
1497 lfsmake2 powertop
1498 lfsmake2 parted
1499 lfsmake2 swig
1500 lfsmake2 python-m2crypto
1501 lfsmake2 wireless-regdb
1502 lfsmake2 crda
1503 lfsmake2 libsolv
1504 lfsmake2 python-distutils-extra
1505 lfsmake2 python-lzma
1506 lfsmake2 python-progressbar
1507 lfsmake2 python-xattr
1508 lfsmake2 ddns
1509 lfsmake2 transmission
1510 lfsmake2 dpfhack
1511 lfsmake2 lcd4linux
1512 lfsmake2 mtr
489145db
MT
1513 lfsmake2 minidlna
1514 lfsmake2 acpid
1515 lfsmake2 fping
1516 lfsmake2 telnet
1517 lfsmake2 xinetd
1518 lfsmake2 gpgme
1519 lfsmake2 pygpgme
1520 lfsmake2 pakfire3
1521 lfsmake2 stress
1522 lfsmake2 libstatgrab
1523 lfsmake2 sarg
1524 lfsmake2 check_mk_agent
1525 lfsmake2 nginx
1526 lfsmake2 sendEmail
1527 lfsmake2 sysbench
1528 lfsmake2 strace
1529 lfsmake2 elfutils
1530 lfsmake2 ltrace
1531 lfsmake2 ipfire-netboot
1532 lfsmake2 lcdproc
1533 lfsmake2 bitstream
1534 lfsmake2 multicat
1535 lfsmake2 keepalived
1536 lfsmake2 ipvsadm
1537 lfsmake2 perl-Carp-Clan
1538 lfsmake2 perl-Date-Calc
1539 lfsmake2 perl-Date-Manip
1540 lfsmake2 perl-File-Tail
1541 lfsmake2 perl-TimeDate
1542 lfsmake2 swatch
1543 lfsmake2 tor
1544 lfsmake2 arm
1545 lfsmake2 wavemon
1546 lfsmake2 iptraf-ng
1547 lfsmake2 iotop
1548 lfsmake2 stunnel
1549 lfsmake2 sslscan
1550 lfsmake2 owncloud
1551 lfsmake2 bacula
1552 lfsmake2 batctl
b62c826f
MT
1553 lfsmake2 perl-Font-TTF
1554 lfsmake2 perl-IO-String
489145db
MT
1555 lfsmake2 perl-PDF-API2
1556 lfsmake2 squid-accounting
1557 lfsmake2 pigz
1558 lfsmake2 tmux
1559 lfsmake2 perl-Text-CSV_XS
1560 lfsmake2 swconfig
1561 lfsmake2 haproxy
1562 lfsmake2 ipset
1563 lfsmake2 lua
1564 lfsmake2 dnsdist
1565 lfsmake2 bird
1566 lfsmake2 dmidecode
1567 lfsmake2 mcelog
1568 lfsmake2 rtpproxy
1569 lfsmake2 util-macros
1570 lfsmake2 libpciaccess
1571 lfsmake2 libyajl
1572 lfsmake2 libvirt
b190cbe2 1573 lfsmake2 python3-libvirt
489145db
MT
1574 lfsmake2 freeradius
1575 lfsmake2 perl-common-sense
1576 lfsmake2 perl-inotify2
1577 lfsmake2 perl-Net-IP
0d6cc79d 1578 lfsmake2 wio
773caa66 1579 lfsmake2 iftop
d0817963 1580}
df5e82b3
MT
1581
1582buildinstaller() {
1583 # Run installer scripts one by one
1584 LOGFILE="$BASEDIR/log/_build.installer.log"
1585 export LOGFILE
489145db
MT
1586 lfsmake2 memtest
1587 lfsmake2 installer
4960c912 1588 lfsmake1 strip
df5e82b3
MT
1589}
1590
1591buildpackages() {
1592 LOGFILE="$BASEDIR/log/_build.packages.log"
1593 export LOGFILE
1594 echo "... see detailed log in _build.*.log files" >> $LOGFILE
0fbb45e9 1595
df5e82b3
MT
1596
1597 # Generating list of packages used
0fbb45e9 1598 echo -n "Generating packages list from logs" | tee -a $LOGFILE
df5e82b3
MT
1599 rm -f $BASEDIR/doc/packages-list
1600 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
1601 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
7471f6ab 1602 echo "* `basename $i`" >>$BASEDIR/doc/packages-list
df5e82b3
MT
1603 fi
1604 done
7471f6ab 1605 echo "== List of softwares used to build $NAME Version: $VERSION ==" > $BASEDIR/doc/packages-list.txt
4fe9acb2 1606 grep -v 'configroot$\|img$\|initrd$\|initscripts$\|installer$\|install$\|setup$\|pakfire$\|stage2$\|smp$\|tools$\|tools1$\|tools2$\|.tgz$\|-config$\|_missing_rootfile$\|install1$\|install2$\|pass1$\|pass2$\|pass3$' \
df5e82b3
MT
1607 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
1608 rm -f $BASEDIR/doc/packages-list
c9673262 1609 # packages-list.txt is ready to be displayed for wiki page
0fbb45e9 1610 beautify message DONE
4b06f504
MT
1611
1612 # Update changelog
e49f7f0d 1613 cd $BASEDIR
c43b07fd
AF
1614 [ -z $GIT_TAG ] || LAST_TAG=$GIT_TAG
1615 [ -z $LAST_TAG ] || EXT="$LAST_TAG..HEAD"
1616 git log -n 500 --no-merges --pretty=medium --shortstat $EXT > $BASEDIR/doc/ChangeLog
df5e82b3 1617
9607771a 1618 # Create images for install
489145db 1619 lfsmake2 cdrom
bada0832 1620
4dc82852 1621 # Check if there is a loop device for building in virtual environments
841663e7
MT
1622 modprobe loop 2>/dev/null
1623 if [ $BUILD_IMAGES == 1 ] && ([ -e /dev/loop/0 ] || [ -e /dev/loop0 ] || [ -e "/dev/loop-control" ]); then
489145db
MT
1624 lfsmake2 flash-images
1625 lfsmake2 flash-images SCON=1
4dc82852 1626 fi
c9673262 1627
f0fc8807 1628 mv $LFS/install/images/{*.iso,*.tgz,*.img.gz,*.bz2} $BASEDIR >> $LOGFILE 2>&1
c9673262 1629
0d909a4a 1630 ipfirepackages
e67a57fe 1631
489145db 1632 lfsmake2 xen-image
939c2a21 1633 mv $LFS/install/images/*.bz2 $BASEDIR >> $LOGFILE 2>&1
bada0832 1634
b307417f 1635 cd $BASEDIR
744a04ea
AF
1636
1637 # remove not useable iso on armv5tel (needed to build flash images)
dc7d6b20 1638 [ "${BUILD_ARCH}" = "armv5tel" ] && rm -rf *.iso
744a04ea 1639
b307417f
AF
1640 for i in `ls *.bz2 *.img.gz *.iso`; do
1641 md5sum $i > $i.md5
1642 done
1643 cd $PWD
1644
e67a57fe
MT
1645 # Cleanup
1646 stdumount
1647 rm -rf $BASEDIR/build/tmp/*
1648
1649 # Generating total list of files
0d909a4a 1650 echo -n "Generating files list from logs" | tee -a $LOGFILE
e67a57fe
MT
1651 rm -f $BASEDIR/log/FILES
1652 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
1653 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
1654 echo "##" >>$BASEDIR/log/FILES
1655 echo "## `basename $i`" >>$BASEDIR/log/FILES
1656 echo "##" >>$BASEDIR/log/FILES
1657 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
1658 fi
1659 done
0d909a4a 1660 beautify message DONE
e67a57fe
MT
1661
1662 cd $PWD
e67a57fe
MT
1663}
1664
1665ipfirepackages() {
489145db 1666 lfsmake2 core-updates
5596077b
MT
1667
1668 local i
dc7d6b20 1669 for i in $(find $BASEDIR/config/rootfiles/packages{/${BUILD_ARCH},} -maxdepth 1 -type f); do
5596077b 1670 i=$(basename ${i})
453b418b
MT
1671 if [ -e $BASEDIR/lfs/$i ]; then
1672 ipfiredist $i
1673 else
1674 echo -n $i
1675 beautify message SKIP
1676 fi
fe7fe395 1677 done
78331e30 1678 test -d $BASEDIR/packages || mkdir $BASEDIR/packages
5c8cfc99 1679 mv -f $LFS/install/packages/* $BASEDIR/packages >> $LOGFILE 2>&1
483f59cd 1680 rm -rf $BASEDIR/build/install/packages/*
df5e82b3
MT
1681}
1682
bcb9dc13
MT
1683while [ $# -gt 0 ]; do
1684 case "${1}" in
1685 --target=*)
c2e810de 1686 configure_build "${1#--target=}"
bcb9dc13
MT
1687 ;;
1688 -*)
1689 exiterror "Unknown configuration option: ${1}"
1690 ;;
1691 *)
1692 # Found a command, so exit options parsing.
1693 break
1694 ;;
1695 esac
1696 shift
1697done
1698
df5e82b3
MT
1699# See what we're supposed to do
1700case "$1" in
1701build)
9729e787 1702 clear
dc7d6b20 1703 PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz 2> /dev/null | head -n 1`
df5e82b3 1704 #only restore on a clean disk
6c4cc7ea 1705 if [ ! -e "${BASEDIR}/build${TOOLS_DIR}/.toolchain-successful" ]; then
df5e82b3 1706 if [ ! -n "$PACKAGE" ]; then
ea465705 1707 beautify build_stage "Full toolchain compilation"
df5e82b3
MT
1708 prepareenv
1709 buildtoolchain
1710 else
1711 PACKAGENAME=${PACKAGE%.tar.gz}
15679d9f 1712 beautify build_stage "Packaged toolchain compilation"
df5e82b3
MT
1713 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
1714 tar zxf $PACKAGE
1715 prepareenv
1716 else
1717 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
1718 fi
1719 fi
1720 else
9729e787
MT
1721 echo -n "Using installed toolchain" | tee -a $LOGFILE
1722 beautify message SKIP
df5e82b3
MT
1723 prepareenv
1724 fi
5cfe86e6 1725
7ab7a9b4 1726 beautify build_start
0b59f25c 1727 beautify build_stage "Building LFS"
df5e82b3 1728 buildbase
15679d9f 1729
0b59f25c 1730 beautify build_stage "Building IPFire"
15679d9f 1731 buildipfire
5cfe86e6 1732
0b59f25c 1733 beautify build_stage "Building installer"
df5e82b3 1734 buildinstaller
15679d9f 1735
0b59f25c 1736 beautify build_stage "Building packages"
df5e82b3 1737 buildpackages
7a5ed24e
CS
1738
1739 beautify build_stage "Checking Logfiles for new Files"
b307417f
AF
1740
1741 cd $BASEDIR
7a5ed24e 1742 tools/checknewlog.pl
e0c923f4 1743 tools/checkrootfiles
b307417f 1744 cd $PWD
a23731d1 1745
7ab7a9b4 1746 beautify build_end
df5e82b3
MT
1747 ;;
1748shell)
1749 # enter a shell inside LFS chroot
1750 # may be used to changed kernel settings
1751 prepareenv
1752 entershell
1753 ;;
df5e82b3 1754clean)
a50d04ab 1755 echo -en "${BOLD}Cleaning build directory...${NORMAL}"
df5e82b3
MT
1756 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
1757 $LOSETUP -d $i 2>/dev/null
1758 done
1759 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
1760 umount $i
1761 done
1762 stdumount
1763 for i in `seq 0 7`; do
69a6ec55 1764 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
df5e82b3
MT
1765 umount /dev/loop${i} 2>/dev/null;
1766 losetup -d /dev/loop${i} 2>/dev/null;
69a6ec55 1767 fi;
df5e82b3
MT
1768 done
1769 rm -rf $BASEDIR/build
1770 rm -rf $BASEDIR/cdrom
f9315063 1771 rm -rf $BASEDIR/packages
df5e82b3 1772 rm -rf $BASEDIR/log
6c4cc7ea
MT
1773 if [ -h "${TOOLS_DIR}" ]; then
1774 rm -f "${TOOLS_DIR}"
df5e82b3 1775 fi
b307417f 1776 rm -f $BASEDIR/ipfire-*
a50d04ab 1777 beautify message DONE
df5e82b3 1778 ;;
c3db995c 1779downloadsrc)
df5e82b3
MT
1780 if [ ! -d $BASEDIR/cache ]; then
1781 mkdir $BASEDIR/cache
1782 fi
1783 mkdir -p $BASEDIR/log
857d9bf2 1784 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
df5e82b3
MT
1785 FINISHED=0
1786 cd $BASEDIR/lfs
1787 for c in `seq $MAX_RETRIES`; do
1788 if (( FINISHED==1 )); then
1789 break
1790 fi
1791 FINISHED=1
1792 cd $BASEDIR/lfs
1793 for i in *; do
1794 if [ -f "$i" -a "$i" != "Config" ]; then
846e756e
MT
1795 lfsmakecommoncheck ${i} || continue
1796
dc7d6b20 1797 make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
51f9e7ac 1798 MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
df5e82b3 1799 if [ $? -ne 0 ]; then
e22c7973 1800 beautify message FAIL
df5e82b3
MT
1801 FINISHED=0
1802 else
1803 if [ $c -eq 1 ]; then
e22c7973 1804 beautify message DONE
df5e82b3
MT
1805 fi
1806 fi
1807 fi
1808 done
1809 done
e22c7973 1810 echo -e "${BOLD}***Verifying md5sums${NORMAL}"
df5e82b3
MT
1811 ERROR=0
1812 for i in *; do
1813 if [ -f "$i" -a "$i" != "Config" ]; then
a4130265 1814 lfsmakecommoncheck ${i} > /dev/null || continue
dc7d6b20 1815 make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
51f9e7ac 1816 MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
df5e82b3 1817 if [ $? -ne 0 ]; then
e22c7973
MT
1818 echo -ne "MD5 difference in lfs/$i"
1819 beautify message FAIL
df5e82b3
MT
1820 ERROR=1
1821 fi
1822 fi
1823 done
1824 if [ $ERROR -eq 0 ]; then
e22c7973
MT
1825 echo -ne "${BOLD}all files md5sum match${NORMAL}"
1826 beautify message DONE
1827 else
1828 echo -ne "${BOLD}not all files were correctly download${NORMAL}"
1829 beautify message FAIL
df5e82b3 1830 fi
e22c7973 1831 cd - >/dev/null 2>&1
df5e82b3 1832 ;;
df5e82b3 1833toolchain)
9729e787 1834 clear
df5e82b3 1835 prepareenv
602cb8bd 1836 beautify build_stage "Toolchain compilation"
df5e82b3 1837 buildtoolchain
dc7d6b20 1838 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
11104bfe 1839 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
dc7d6b20 1840 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
6c4cc7ea 1841 build/${TOOLS_DIR} build/bin/sh log >> $LOGFILE
dc7d6b20
MT
1842 md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
1843 > cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.md5
df5e82b3
MT
1844 stdumount
1845 ;;
1846gettoolchain)
df5e82b3 1847 # arbitrary name to be updated in case of new toolchain package upload
dc7d6b20 1848 PACKAGE=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}
712d859c 1849 if [ ! -f $BASEDIR/cache/toolchains/$PACKAGE.tar.gz ]; then
5bd13f01 1850 URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
11104bfe 1851 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
dc7d6b20 1852 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
712d859c 1853 cd $BASEDIR/cache/toolchains
74f3678b 1854 wget -U "IPFireSourceGrabber/2.x" $URL_TOOLCHAIN/$PACKAGE.tar.gz $URL_TOOLCHAIN/$PACKAGE.md5 >& /dev/null
712d859c 1855 if [ $? -ne 0 ]; then
dc7d6b20 1856 echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for ${BUILD_ARCH} machine" | tee -a $LOGFILE
40a4ea4c 1857 else
712d859c
MT
1858 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1859 echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1860 else
1861 exiterror "$PACKAGE.md5 did not match, check downloaded package"
1862 fi
40a4ea4c 1863 fi
712d859c
MT
1864 else
1865 echo "Toolchain is already downloaded. Exiting..."
df5e82b3
MT
1866 fi
1867 ;;
15679d9f
MT
1868uploadsrc)
1869 PWD=`pwd`
661d9388
CS
1870 if [ -z $IPFIRE_USER ]; then
1871 echo -n "You have to setup IPFIRE_USER first. See .config for details."
1872 beautify message FAIL
1873 exit 1
1874 fi
ae23a606 1875
661d9388 1876 URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
15e38431 1877 REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
661d9388 1878
15e38431
MT
1879 for file in ${BASEDIR}/cache/*; do
1880 [ -d "${file}" ] && continue
1881 grep -q "$(basename ${file})" <<<$REMOTE_FILES && continue
661d9388 1882 NEW_FILES="$NEW_FILES $file"
0eab8e84 1883 done
661d9388
CS
1884 [ -n "$NEW_FILES" ] && scp -2 $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
1885 cd $BASEDIR
15679d9f
MT
1886 cd $PWD
1887 exit 0
0eab8e84 1888 ;;
bf7c473f 1889lang)
69a6ec55
MT
1890 echo -ne "Checking the translations for missing or obsolete strings..."
1891 chmod 755 $BASEDIR/tools/{check_strings.pl,sort_strings.pl,check_langs.sh}
1892 $BASEDIR/tools/sort_strings.pl en
1893 $BASEDIR/tools/sort_strings.pl de
1894 $BASEDIR/tools/sort_strings.pl fr
1895 $BASEDIR/tools/sort_strings.pl es
1896 $BASEDIR/tools/sort_strings.pl pl
1897 $BASEDIR/tools/sort_strings.pl ru
1898 $BASEDIR/tools/sort_strings.pl nl
1899 $BASEDIR/tools/sort_strings.pl tr
1900 $BASEDIR/tools/sort_strings.pl it
1901 $BASEDIR/tools/check_strings.pl en > $BASEDIR/doc/language_issues.en
1902 $BASEDIR/tools/check_strings.pl de > $BASEDIR/doc/language_issues.de
1903 $BASEDIR/tools/check_strings.pl fr > $BASEDIR/doc/language_issues.fr
1904 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.es
1905 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.pl
1906 $BASEDIR/tools/check_strings.pl ru > $BASEDIR/doc/language_issues.ru
1907 $BASEDIR/tools/check_strings.pl nl > $BASEDIR/doc/language_issues.nl
1908 $BASEDIR/tools/check_strings.pl tr > $BASEDIR/doc/language_issues.tr
1909 $BASEDIR/tools/check_strings.pl it > $BASEDIR/doc/language_issues.it
1910 $BASEDIR/tools/check_langs.sh > $BASEDIR/doc/language_missings
1911 beautify message DONE
1912
1913 echo -ne "Updating language lists..."
1914 update_language_list ${BASEDIR}/src/installer/po
1915 update_language_list ${BASEDIR}/src/setup/po
1916 beautify message DONE
bf7c473f 1917 ;;
6b8cff41 1918*)
a50d04ab 1919 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
6b8cff41
MT
1920 cat doc/make.sh-usage
1921 ;;
3ea75603 1922esac