make.sh: Cleanup prepareenv
[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 102# This is the directory where make.sh is in
aecbe123 103export BASEDIR=$(echo $FULLPATH | sed "s/\/$BASENAME//g")
69a6ec55 104
15679d9f 105LOGFILE=$BASEDIR/log/_build.preparation.log
aecbe123 106export LOGFILE
15679d9f
MT
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
aecbe123
MT
429prepareenv() {
430 # Are we running the right shell?
431 if [ ! -z "${BASH}" ]; then
432 exiterror "BASH environment variable is not set. You're probably running the wrong shell."
433 fi
434
435 if [ -z "${BASH_VERSION}" ]; then
436 exiterror "Not running BASH shell."
437 fi
438
439 # Trap on emergency exit
440 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
441
442 # Resetting our nice level
443 echo -ne "Resetting our nice level to $NICE" | tee -a $LOGFILE
444 renice $NICE $$ > /dev/null
445 if [ `nice` != "$NICE" ]; then
446 beautify message FAIL
447 exiterror "Failed to set correct nice level"
448 else
449 beautify message DONE
450 fi
451
452 # Checking if running as root user
453 echo -ne "Checking if we're running as root user" | tee -a $LOGFILE
454 if [ `id -u` != 0 ]; then
455 beautify message FAIL
456 exiterror "Not building as root"
457 else
458 beautify message DONE
459 fi
460
461 # Checking for necessary temporary space
462 echo -ne "Checking for necessary space on disk $BASE_DEV" | tee -a $LOGFILE
463 BASE_DEV=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
464 BASE_ASPACE=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
465 if (( 2048000 > $BASE_ASPACE )); then
466 BASE_USPACE=`du -skx $BASEDIR | awk '{print $1}'`
467 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
468 beautify message FAIL
469 exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
470 fi
471 else
472 beautify message DONE
473 fi
474
475 # Set umask
476 umask 022
477
478 # Set LFS Directory
479 LFS=$BASEDIR/build
480
481 # Check ${TOOLS_DIR} symlink
482 if [ -h "${TOOLS_DIR}" ]; then
483 rm -f "${TOOLS_DIR}"
484 fi
485
486 if [ ! -e "${TOOLS_DIR}" ]; then
487 ln -s "${BASEDIR}/build${TOOLS_DIR}" "${TOOLS_DIR}"
488 fi
489
490 if [ ! -h "${TOOLS_DIR}" ]; then
491 exiterror "Could not create ${TOOLS_DIR} symbolic link"
492 fi
493
494 # Setup environment
495 set +h
496 LC_ALL=POSIX
497 export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING
498 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
499
500 # Make some extra directories
501 mkdir -p "${BASEDIR}/build${TOOLS_DIR}" 2>/dev/null
502 mkdir -p $BASEDIR/build/{etc,usr/src} 2>/dev/null
503 mkdir -p $BASEDIR/build/{dev/{shm,pts},proc,sys}
504 mkdir -p $BASEDIR/{cache,ccache} 2>/dev/null
505 mkdir -p $BASEDIR/build/usr/src/{cache,config,doc,html,langs,lfs,log,src,ccache}
506
507 mknod -m 600 $BASEDIR/build/dev/console c 5 1 2>/dev/null
508 mknod -m 666 $BASEDIR/build/dev/null c 1 3 2>/dev/null
509
510 # Make all sources and proc available under lfs build
511 mount --bind /dev $BASEDIR/build/dev
512 mount --bind /dev/pts $BASEDIR/build/dev/pts
513 mount --bind /dev/shm $BASEDIR/build/dev/shm
514 mount --bind /proc $BASEDIR/build/proc
515 mount --bind /sys $BASEDIR/build/sys
516 mount --bind $BASEDIR/cache $BASEDIR/build/usr/src/cache
517 mount --bind $BASEDIR/ccache $BASEDIR/build/usr/src/ccache
518 mount --bind $BASEDIR/config $BASEDIR/build/usr/src/config
519 mount --bind $BASEDIR/doc $BASEDIR/build/usr/src/doc
520 mount --bind $BASEDIR/html $BASEDIR/build/usr/src/html
521 mount --bind $BASEDIR/langs $BASEDIR/build/usr/src/langs
522 mount --bind $BASEDIR/lfs $BASEDIR/build/usr/src/lfs
523 mount --bind $BASEDIR/log $BASEDIR/build/usr/src/log
524 mount --bind $BASEDIR/src $BASEDIR/build/usr/src/src
525
526 # Run LFS static binary creation scripts one by one
527 export CCACHE_DIR=$BASEDIR/ccache
528 export CCACHE_COMPRESS=1
529 export CCACHE_COMPILERCHECK="string:toolchain-${TOOLCHAINVER} ${BUILD_ARCH}"
530
531 # Remove pre-install list of installed files in case user erase some files before rebuild
532 rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null
533
534 # Prepare string for /etc/system-release.
535 SYSTEM_RELEASE="${NAME} ${VERSION} (${BUILD_ARCH})"
536 if [ "$(git status -s | wc -l)" == "0" ]; then
537 GIT_STATUS=""
538 else
539 GIT_STATUS="-dirty"
540 fi
541 case "$GIT_BRANCH" in
542 core*|beta?|rc?)
543 SYSTEM_RELEASE="${SYSTEM_RELEASE} - $GIT_BRANCH$GIT_STATUS"
544 ;;
545 *)
546 SYSTEM_RELEASE="${SYSTEM_RELEASE} - Development Build: $GIT_BRANCH/$GIT_LASTCOMMIT$GIT_STATUS"
547 ;;
548 esac
549}
550
69a6ec55
MT
551enterchroot() {
552 # Install QEMU helper, if needed
553 qemu_install_helper
554
555 local PATH="${TOOLS_DIR}/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/bin"
556
557 PATH="${PATH}" chroot ${LFS} env -i \
558 HOME="/root" \
559 TERM="${TERM}" \
560 PS1="${PS1}" \
561 PATH="${PATH}" \
562 SYSTEM_RELEASE="${SYSTEM_RELEASE}" \
563 PAKFIRE_CORE="${PAKFIRE_CORE}" \
564 NAME="${NAME}" \
565 SNAME="${SNAME}" \
566 VERSION="${VERSION}" \
567 CORE="${CORE}" \
568 SLOGAN="${SLOGAN}" \
569 TOOLS_DIR="${TOOLS_DIR}" \
570 CONFIG_ROOT="${CONFIG_ROOT}" \
571 CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
572 CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
573 BUILDTARGET="${BUILDTARGET}" \
574 CROSSTARGET="${CROSSTARGET}" \
575 BUILD_ARCH="${BUILD_ARCH}" \
576 BUILD_PLATFORM="${BUILD_PLATFORM}" \
577 CCACHE_DIR=/usr/src/ccache \
578 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
579 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
580 KVER="${KVER}" \
581 $(fake_environ) \
582 $(qemu_environ) \
583 "$@"
584}
585
586entershell() {
587 if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
588 exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
589 fi
590
591 echo "Entering to a shell inside LFS chroot, go out with exit"
592 local PS1="ipfire build chroot ($(uname -m)) \u:\w\$ "
593
594 if enterchroot bash -i; then
595 stdumount
596 else
597 beautify message FAIL
598 exiterror "chroot error"
599 fi
600}
601
602lfsmakecommoncheck() {
603 # Script present?
604 if [ ! -f $BASEDIR/lfs/$1 ]; then
605 exiterror "No such file or directory: $BASEDIR/$1"
606 fi
607
608 local PKG_VER=`get_pkg_ver $BASEDIR/lfs/$1`
609 beautify make_pkg "$PKG_VER $*"
610
611 # Check if this package is supported by our architecture.
612 # If no SUP_ARCH is found, we assume the package can be built for all.
613 if grep "^SUP_ARCH" ${BASEDIR}/lfs/${1} >/dev/null; then
614 # Check if package supports ${BUILD_ARCH} or all architectures.
615 if ! grep -E "^SUP_ARCH.*${BUILD_ARCH}|^SUP_ARCH.*all" ${BASEDIR}/lfs/${1} >/dev/null; then
616 beautify result SKIP
617 return 1
618 fi
619 fi
620
621 # Script slipped?
622 local i
623 for i in $SKIP_PACKAGE_LIST
624 do
625 if [ "$i" == "$1" ]; then
626 beautify result SKIP
627 return 1;
628 fi
629 done
630
631 echo -ne "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
632
633 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
634 MESSAGE="$1\t " download >> $LOGFILE 2>&1
635 if [ $? -ne 0 ]; then
636 exiterror "Download error in $1"
637 fi
638
639 cd $BASEDIR/lfs && make -s -f $* LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
640 MESSAGE="$1\t md5sum" md5 >> $LOGFILE 2>&1
641 if [ $? -ne 0 ]; then
642 exiterror "md5sum error in $1, check file in cache or signature"
643 fi
644
645 return 0 # pass all!
646}
647
648lfsmake1() {
649 lfsmakecommoncheck $*
650 [ $? == 1 ] && return 0
651
652 local PKG_TIME_START=`date +%s`
653
654 cd $BASEDIR/lfs && env -i \
655 PATH="${TOOLS_DIR}/ccache/bin:${TOOLS_DIR}/bin:$PATH" \
656 CCACHE_DIR="${CCACHE_DIR}" \
657 CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
658 CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
659 CFLAGS="${CFLAGS}" \
660 CXXFLAGS="${CXXFLAGS}" \
661 MAKETUNING="${MAKETUNING}" \
662 make -f $* \
663 TOOLCHAIN=1 \
664 TOOLS_DIR="${TOOLS_DIR}" \
665 CROSSTARGET="${CROSSTARGET}" \
666 BUILDTARGET="${BUILDTARGET}" \
667 BUILD_ARCH="${BUILD_ARCH}" \
668 BUILD_PLATFORM="${BUILD_PLATFORM}" \
669 LFS_BASEDIR="${BASEDIR}" \
670 ROOT="${LFS}" \
671 KVER="${KVER}" \
672 install >> $LOGFILE 2>&1
673
674 local COMPILE_SUCCESS=$?
675 local PKG_TIME_END=`date +%s`
676
677 if [ $COMPILE_SUCCESS -ne 0 ]; then
678 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
679 exiterror "Building $*";
680 else
681 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
682 fi
683
684 return 0
685}
686
687lfsmake2() {
688 lfsmakecommoncheck $*
689 [ $? == 1 ] && return 0
690
691 local PKG_TIME_START=`date +%s`
692 local PS1='\u:\w$ '
693
694 enterchroot \
695 bash -x -c "cd /usr/src/lfs && \
696 MAKETUNING=${MAKETUNING} \
697 make -f $* \
698 LFS_BASEDIR=/usr/src install" \
699 >> ${LOGFILE} 2>&1
700
701 local COMPILE_SUCCESS=$?
702 local PKG_TIME_END=`date +%s`
703
704 if [ $COMPILE_SUCCESS -ne 0 ]; then
705 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
706 exiterror "Building $*";
707 else
708 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
709 fi
710
711 return 0
712}
713
714ipfiredist() {
715 lfsmakecommoncheck $*
716 [ $? == 1 ] && return 0
717
718 local PKG_TIME_START=`date +%s`
719 local PS1='\u:\w$ '
720
721 enterchroot \
722 bash -x -c "cd /usr/src/lfs && make -f $* LFS_BASEDIR=/usr/src dist" \
723 >> ${LOGFILE} 2>&1
724
725 local COMPILE_SUCCESS=$?
726 local PKG_TIME_END=`date +%s`
727
728 if [ $COMPILE_SUCCESS -ne 0 ]; then
729 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ]
730 exiterror "Packaging $*";
731 else
732 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ]
733 fi
734 return 0
735}
736
737fake_environ() {
738 [ -e "${BASEDIR}/build${TOOLS_DIR}/lib/libpakfire_preload.so" ] || return
739
740 local env="LD_PRELOAD=${TOOLS_DIR}/lib/libpakfire_preload.so"
741
742 # Fake kernel version, because some of the packages do not compile
743 # with kernel 3.0 and later.
744 env="${env} UTS_RELEASE=${KVER}"
745
746 # Fake machine version.
747 env="${env} UTS_MACHINE=${BUILD_ARCH}"
748
749 echo "${env}"
750}
751
752qemu_environ() {
753 local env
754
755 # Don't add anything if qemu is not used.
756 if ! qemu_is_required; then
757 return
758 fi
759
760 # Set default qemu options
761 case "${BUILD_ARCH}" in
762 arm*)
763 QEMU_CPU="${QEMU_CPU:-cortex-a9}"
764
765 env="${env} QEMU_CPU=${QEMU_CPU}"
766 ;;
767 esac
768
769 # Enable QEMU strace
770 #env="${env} QEMU_STRACE=1"
771
772 echo "${env}"
773}
774
775qemu_is_required() {
776 local build_arch="${1}"
777
778 if [ -z "${build_arch}" ]; then
779 build_arch="${BUILD_ARCH}"
780 fi
781
782 case "${HOST_ARCH},${build_arch}" in
783 x86_64,arm*|i?86,arm*|i?86,x86_64)
784 return 0
785 ;;
786 *)
787 return 1
788 ;;
789 esac
790}
791
792qemu_install_helper() {
793 # Do nothing, if qemu is not required
794 if ! qemu_is_required; then
795 return 0
796 fi
797
798 if [ ! -e /proc/sys/fs/binfmt_misc/status ]; then
799 exiterror "binfmt_misc not mounted. QEMU_TARGET_HELPER not useable."
800 fi
801
802 if [ ! $(cat /proc/sys/fs/binfmt_misc/status) = 'enabled' ]; then
803 exiterror "binfmt_misc not enabled. QEMU_TARGET_HELPER not useable."
804 fi
805
806
807 if [ -z "${QEMU_TARGET_HELPER}" ]; then
808 exiterror "QEMU_TARGET_HELPER not set"
809 fi
810
811 # Check if the helper is already installed.
812 if [ -x "${LFS}${QEMU_TARGET_HELPER}" ]; then
813 return 0
814 fi
815
816 # Try to find a suitable binary that we can install
817 # to the build environment.
818 local file
819 for file in "${QEMU_TARGET_HELPER}" "${QEMU_TARGET_HELPER}-static"; do
820 # file must exist and be executable.
821 [ -x "${file}" ] || continue
822
823 # Must be static.
824 file_is_static "${file}" || continue
825
826 local dirname="${LFS}$(dirname "${file}")"
827 mkdir -p "${dirname}"
828
829 install -m 755 "${file}" "${LFS}${QEMU_TARGET_HELPER}"
830 return 0
831 done
832
833 exiterror "Could not find a statically-linked QEMU emulator: ${QEMU_TARGET_HELPER}"
834}
835
836qemu_find_build_helper_name() {
837 local build_arch="${1}"
838
839 local magic
840 case "${build_arch}" in
841 arm*)
842 magic="7f454c4601010100000000000000000002002800"
843 ;;
844 x86_64)
845 magic="7f454c4602010100000000000000000002003e00"
846 ;;
847 esac
848
849 [ -z "${magic}" ] && return 1
850
851 local file
852 for file in /proc/sys/fs/binfmt_misc/*; do
853 # skip write only register entry
854 [ $(basename "${file}") = "register" ] && continue
855 # Search for the file with the correct magic value.
856 grep -qE "^magic ${magic}$" "${file}" || continue
857
858 local interpreter="$(grep "^interpreter" "${file}" | awk '{ print $2 }')"
859
860 [ -n "${interpreter}" ] || continue
861 [ "${interpreter:0:1}" = "/" ] || continue
862 [ -x "${interpreter}" ] || continue
863
864 echo "${interpreter}"
865 return 0
866 done
867
868 return 1
869}
870
871file_is_static() {
872 local file="${1}"
873
874 file ${file} 2>/dev/null | grep -q "statically linked"
875}
876
877update_language_list() {
878 local path="${1}"
879
880 local lang
881 for lang in ${path}/*.po; do
882 lang="$(basename "${lang}")"
883 echo "${lang%*.po}"
884 done | sort -u > "${path}/LINGUAS"
885}
886
a98ab1d7
MT
887# Load configuration file
888if [ -f .config ]; then
889 . .config
890fi
891
813659f2
MT
892# TARGET_ARCH is BUILD_ARCH now
893if [ -n "${TARGET_ARCH}" ]; then
894 BUILD_ARCH="${TARGET_ARCH}"
895 unset TARGET_ARCH
896fi
897
5190eea2
MT
898# Get the amount of memory in this build system
899HOST_MEM=$(system_memory)
900
dc7d6b20
MT
901if [ -n "${BUILD_ARCH}" ]; then
902 configure_build "${BUILD_ARCH}"
949544f5 903else
dc7d6b20 904 configure_build "default"
949544f5
MT
905fi
906
df5e82b3 907buildtoolchain() {
69a6ec55
MT
908 local error=false
909 case "${BUILD_ARCH}:${HOST_ARCH}" in
910 # x86_64
911 x86_64:x86_64)
912 # This is working.
913 ;;
914
915 # x86
916 i586:i586|i586:i686|i586:x86_64)
917 # These are working.
918 ;;
919 i586:*)
920 error=true
921 ;;
922
923 # ARM
924 arvm7hl:armv7hl|armv7hl:armv7l)
925 # These are working.
926 ;;
927
928 armv5tel:armv5tel|armv5tel:armv5tejl|armv5tel:armv6l|armv5tel:armv7l|armv5tel:aarch64)
929 # These are working.
930 ;;
931 armv5tel:*)
932 error=true
933 ;;
934 esac
935
936 ${error} && \
937 exiterror "Cannot build ${BUILD_ARCH} toolchain on $(uname -m). Please use the download if any."
938
939 local gcc=$(type -p gcc)
940 if [ -z "${gcc}" ]; then
941 exiterror "Could not find GCC. You will need a working build enviroment in order to build the toolchain."
942 fi
943
944 LOGFILE="$BASEDIR/log/_build.toolchain.log"
945 export LOGFILE
946
947 lfsmake1 stage1
948 lfsmake1 ccache PASS=1
949 lfsmake1 binutils PASS=1
950 lfsmake1 gcc PASS=1
951 lfsmake1 linux KCFG="-headers"
952 lfsmake1 glibc
953 lfsmake1 gcc PASS=L
954 lfsmake1 binutils PASS=2
955 lfsmake1 gcc PASS=2
956 lfsmake1 ccache PASS=2
957 lfsmake1 tcl
958 lfsmake1 expect
959 lfsmake1 dejagnu
960 lfsmake1 pkg-config
961 lfsmake1 ncurses
962 lfsmake1 bash
963 lfsmake1 bzip2
964 lfsmake1 automake
965 lfsmake1 coreutils
966 lfsmake1 diffutils
967 lfsmake1 findutils
968 lfsmake1 gawk
969 lfsmake1 gettext
970 lfsmake1 grep
971 lfsmake1 gzip
972 lfsmake1 m4
973 lfsmake1 make
974 lfsmake1 patch
975 lfsmake1 perl
976 lfsmake1 sed
977 lfsmake1 tar
978 lfsmake1 texinfo
979 lfsmake1 xz
980 lfsmake1 fake-environ
981 lfsmake1 cleanup-toolchain
df5e82b3
MT
982}
983
984buildbase() {
69a6ec55
MT
985 LOGFILE="$BASEDIR/log/_build.base.log"
986 export LOGFILE
987 lfsmake2 stage2
988 lfsmake2 linux KCFG="-headers"
989 lfsmake2 man-pages
990 lfsmake2 glibc
991 lfsmake2 tzdata
992 lfsmake2 cleanup-toolchain
993 lfsmake2 zlib
994 lfsmake2 binutils
995 lfsmake2 gmp
996 lfsmake2 gmp-compat
997 lfsmake2 mpfr
998 lfsmake2 libmpc
999 lfsmake2 file
1000 lfsmake2 gcc
1001 lfsmake2 sed
1002 lfsmake2 autoconf
1003 lfsmake2 automake
1004 lfsmake2 berkeley
1005 lfsmake2 coreutils
1006 lfsmake2 iana-etc
1007 lfsmake2 m4
1008 lfsmake2 bison
1009 lfsmake2 ncurses-compat
1010 lfsmake2 ncurses
1011 lfsmake2 procps
1012 lfsmake2 libtool
1013 lfsmake2 perl
1014 lfsmake2 readline
1015 lfsmake2 readline-compat
1016 lfsmake2 bzip2
1017 lfsmake2 pcre
1018 lfsmake2 pcre-compat
1019 lfsmake2 bash
1020 lfsmake2 diffutils
1021 lfsmake2 e2fsprogs
1022 lfsmake2 ed
1023 lfsmake2 findutils
1024 lfsmake2 flex
1025 lfsmake2 gawk
1026 lfsmake2 gettext
1027 lfsmake2 grep
1028 lfsmake2 groff
1029 lfsmake2 gperf
1030 lfsmake2 gzip
1031 lfsmake2 hostname
1032 lfsmake2 iproute2
1033 lfsmake2 jwhois
1034 lfsmake2 kbd
1035 lfsmake2 less
1036 lfsmake2 make
1037 lfsmake2 man
1038 lfsmake2 kmod
1039 lfsmake2 net-tools
1040 lfsmake2 patch
1041 lfsmake2 psmisc
1042 lfsmake2 shadow
1043 lfsmake2 sysklogd
1044 lfsmake2 sysvinit
1045 lfsmake2 tar
1046 lfsmake2 texinfo
1047 lfsmake2 util-linux
1048 lfsmake2 udev
1049 lfsmake2 vim
1050 lfsmake2 xz
1051 lfsmake2 paxctl
df5e82b3
MT
1052}
1053
15679d9f 1054buildipfire() {
907cd036 1055 LOGFILE="$BASEDIR/log/_build.ipfire.log"
df5e82b3 1056 export LOGFILE
489145db
MT
1057 lfsmake2 configroot
1058 lfsmake2 initscripts
1059 lfsmake2 backup
1060 lfsmake2 pkg-config
1061 lfsmake2 libusb
1062 lfsmake2 libusb-compat
1063 lfsmake2 libpcap
1064 lfsmake2 ppp
1065 lfsmake2 pptp
1066 lfsmake2 unzip
1067 lfsmake2 which
1068 lfsmake2 linux-firmware
1069 lfsmake2 ath10k-firmware
1070 lfsmake2 dvb-firmwares
1071 lfsmake2 mt7601u-firmware
1072 lfsmake2 zd1211-firmware
1073 lfsmake2 rpi-firmware
1074 lfsmake2 bc
1075 lfsmake2 u-boot
1076 lfsmake2 cpio
1077 lfsmake2 mdadm
1078 lfsmake2 dracut
1079 lfsmake2 lvm2
1080 lfsmake2 multipath-tools
1081 lfsmake2 freetype
1082 lfsmake2 grub
1083 lfsmake2 libmnl
1084 lfsmake2 libnfnetlink
1085 lfsmake2 libnetfilter_queue
1086 lfsmake2 libnetfilter_conntrack
1087 lfsmake2 libnetfilter_cthelper
1088 lfsmake2 libnetfilter_cttimeout
1089 lfsmake2 iptables
8e6fb99d 1090
dc7d6b20 1091 case "${BUILD_ARCH}" in
fc155193 1092 x86_64)
489145db
MT
1093 lfsmake2 linux KCFG=""
1094 lfsmake2 backports KCFG=""
1095 lfsmake2 e1000e KCFG=""
1096 lfsmake2 igb KCFG=""
1097 lfsmake2 ixgbe KCFG=""
1098 lfsmake2 xtables-addons KCFG=""
1099 lfsmake2 linux-initrd KCFG=""
fc155193 1100 ;;
3d02c091
MT
1101 i586)
1102 # x86-pae (Native and new XEN) kernel build
489145db
MT
1103 lfsmake2 linux KCFG="-pae"
1104 lfsmake2 backports KCFG="-pae"
1105 lfsmake2 e1000e KCFG="-pae"
1106 lfsmake2 igb KCFG="-pae"
1107 lfsmake2 ixgbe KCFG="-pae"
1108 lfsmake2 xtables-addons KCFG="-pae"
1109 lfsmake2 linux-initrd KCFG="-pae"
3d02c091
MT
1110
1111 # x86 kernel build
489145db
MT
1112 lfsmake2 linux KCFG=""
1113 lfsmake2 backports KCFG=""
1114 lfsmake2 e1000e KCFG=""
1115 lfsmake2 igb KCFG=""
1116 lfsmake2 ixgbe KCFG=""
1117 lfsmake2 xtables-addons KCFG=""
1118 lfsmake2 linux-initrd KCFG=""
3d02c091 1119 ;;
544f40d4 1120
3d02c091
MT
1121 armv5tel)
1122 # arm-rpi (Raspberry Pi) kernel build
489145db
MT
1123 lfsmake2 linux KCFG="-rpi"
1124 lfsmake2 backports KCFG="-rpi"
1125 lfsmake2 xtables-addons KCFG="-rpi"
1126 lfsmake2 linux-initrd KCFG="-rpi"
3d02c091
MT
1127
1128 # arm multi platform (Panda, Wandboard ...) kernel build
489145db
MT
1129 lfsmake2 linux KCFG="-multi"
1130 lfsmake2 backports KCFG="-multi"
1131 lfsmake2 e1000e KCFG="-multi"
1132 lfsmake2 igb KCFG="-multi"
1133 lfsmake2 ixgbe KCFG="-multi"
1134 lfsmake2 xtables-addons KCFG="-multi"
1135 lfsmake2 linux-initrd KCFG="-multi"
3d02c091
MT
1136
1137 # arm-kirkwood (Dreamplug, ICY-Box ...) kernel build
489145db
MT
1138 lfsmake2 linux KCFG="-kirkwood"
1139 lfsmake2 backports KCFG="-kirkwood"
1140 lfsmake2 e1000e KCFG="-kirkwood"
1141 lfsmake2 igb KCFG="-kirkwood"
1142 lfsmake2 ixgbe KCFG="-kirkwood"
1143 lfsmake2 xtables-addons KCFG="-kirkwood"
1144 lfsmake2 linux-initrd KCFG="-kirkwood"
3d02c091
MT
1145 ;;
1146 esac
489145db
MT
1147 lfsmake2 xtables-addons USPACE="1"
1148 lfsmake2 openssl
1149 [ "${BUILD_ARCH}" = "i586" ] && lfsmake2 openssl KCFG='-sse2'
1150 lfsmake2 libgpg-error
1151 lfsmake2 libgcrypt
1152 lfsmake2 libassuan
1153 lfsmake2 nettle
1154 lfsmake2 libevent
1155 lfsmake2 libevent2
89ad036a 1156 lfsmake2 libevent2-compat
489145db 1157 lfsmake2 expat
c8e9a7a8
WA
1158 lfsmake2 apr
1159 lfsmake2 aprutil
489145db
MT
1160 lfsmake2 unbound
1161 lfsmake2 gnutls
1162 lfsmake2 bind
1163 lfsmake2 dhcp
1164 lfsmake2 dhcpcd
1165 lfsmake2 boost
1166 lfsmake2 linux-atm
1167 lfsmake2 gdbm
1168 lfsmake2 pam
1169 lfsmake2 curl
1170 lfsmake2 tcl
1171 lfsmake2 sqlite
1172 lfsmake2 libffi
1173 lfsmake2 python
1174 lfsmake2 python3
1175 lfsmake2 ca-certificates
1176 lfsmake2 fireinfo
1177 lfsmake2 libnet
1178 lfsmake2 libnl
1179 lfsmake2 libnl-3
1180 lfsmake2 libidn
1181 lfsmake2 nasm
1182 lfsmake2 libjpeg
1183 lfsmake2 libjpeg-compat
1184 lfsmake2 libexif
1185 lfsmake2 libpng
1186 lfsmake2 libtiff
1187 lfsmake2 libart
1188 lfsmake2 gd
1189 lfsmake2 popt
489145db
MT
1190 lfsmake2 slang
1191 lfsmake2 newt
1192 lfsmake2 libsmooth
1193 lfsmake2 attr
1194 lfsmake2 acl
1195 lfsmake2 libcap
1196 lfsmake2 pciutils
1197 lfsmake2 usbutils
1198 lfsmake2 libxml2
1199 lfsmake2 libxslt
1200 lfsmake2 BerkeleyDB
1201 lfsmake2 mysql
1202 lfsmake2 cyrus-sasl
1203 lfsmake2 openldap
1204 lfsmake2 apache2
1205 lfsmake2 php
1206 lfsmake2 web-user-interface
1207 lfsmake2 flag-icons
1208 lfsmake2 jquery
6033b271 1209 lfsmake2 bootstrap
489145db
MT
1210 lfsmake2 arping
1211 lfsmake2 beep
1212 lfsmake2 dvdrtools
1213 lfsmake2 dosfstools
1214 lfsmake2 reiserfsprogs
1215 lfsmake2 xfsprogs
1216 lfsmake2 sysfsutils
1217 lfsmake2 fuse
1218 lfsmake2 ntfs-3g
1219 lfsmake2 ethtool
1220 lfsmake2 ez-ipupdate
1221 lfsmake2 fcron
1222 lfsmake2 perl-GD
1223 lfsmake2 GD-Graph
1224 lfsmake2 GD-TextUtil
1225 lfsmake2 perl-Device-SerialPort
1226 lfsmake2 perl-Device-Modem
1227 lfsmake2 perl-Apache-Htpasswd
1228 lfsmake2 gnupg
1229 lfsmake2 hdparm
1230 lfsmake2 sdparm
1231 lfsmake2 mtools
1232 lfsmake2 whatmask
1233 lfsmake2 conntrack-tools
1234 lfsmake2 libupnp
1235 lfsmake2 ipaddr
1236 lfsmake2 iputils
1237 lfsmake2 l7-protocols
1238 lfsmake2 mISDNuser
1239 lfsmake2 capi4k-utils
1240 lfsmake2 hwdata
1241 lfsmake2 logrotate
1242 lfsmake2 logwatch
1243 lfsmake2 misc-progs
1244 lfsmake2 nano
1245 lfsmake2 URI
1246 lfsmake2 HTML-Tagset
1247 lfsmake2 HTML-Parser
1248 lfsmake2 HTML-Template
1249 lfsmake2 Compress-Zlib
1250 lfsmake2 Digest
1251 lfsmake2 Digest-SHA1
1252 lfsmake2 Digest-HMAC
1253 lfsmake2 libwww-perl
1254 lfsmake2 Net-DNS
1255 lfsmake2 Net-IPv4Addr
1256 lfsmake2 Net_SSLeay
1257 lfsmake2 IO-Stringy
1258 lfsmake2 IO-Socket-SSL
1259 lfsmake2 Unix-Syslog
1260 lfsmake2 Mail-Tools
1261 lfsmake2 MIME-Tools
1262 lfsmake2 Net-Server
1263 lfsmake2 Convert-TNEF
1264 lfsmake2 Convert-UUlib
1265 lfsmake2 Archive-Tar
1266 lfsmake2 Archive-Zip
1267 lfsmake2 Text-Tabs+Wrap
1268 lfsmake2 Locale-Country
1269 lfsmake2 XML-Parser
1270 lfsmake2 Crypt-PasswdMD5
1271 lfsmake2 Net-Telnet
1272 lfsmake2 python-setuptools
1273 lfsmake2 python-clientform
1274 lfsmake2 python-mechanize
1275 lfsmake2 python-feedparser
1276 lfsmake2 python-rssdler
1277 lfsmake2 python-inotify
1278 lfsmake2 python-docutils
1279 lfsmake2 python-daemon
1280 lfsmake2 python-ipaddress
1281 lfsmake2 glib
1282 lfsmake2 GeoIP
489145db
MT
1283 lfsmake2 noip_updater
1284 lfsmake2 ntp
1285 lfsmake2 openssh
1286 lfsmake2 fontconfig
1287 lfsmake2 dejavu-fonts-ttf
70f6cba4 1288 lfsmake2 ubuntu-font-family
489145db
MT
1289 lfsmake2 freefont
1290 lfsmake2 pixman
1291 lfsmake2 cairo
1292 lfsmake2 pango
1293 lfsmake2 rrdtool
1294 lfsmake2 setserial
1295 lfsmake2 setup
1296 lfsmake2 libdnet
1297 lfsmake2 daq
1298 lfsmake2 snort
1299 lfsmake2 oinkmaster
1300 lfsmake2 squid
1301 lfsmake2 squidguard
1302 lfsmake2 calamaris
1303 lfsmake2 tcpdump
1304 lfsmake2 traceroute
1305 lfsmake2 vlan
1306 lfsmake2 wireless
1307 lfsmake2 pakfire
1308 lfsmake2 spandsp
1309 lfsmake2 lzo
1310 lfsmake2 openvpn
1311 lfsmake2 pammysql
1312 lfsmake2 mpage
1313 lfsmake2 dbus
1314 lfsmake2 intltool
1315 lfsmake2 libdaemon
1316 lfsmake2 cups
489145db 1317 lfsmake2 lcms2
56170c2a 1318 lfsmake2 ghostscript
489145db
MT
1319 lfsmake2 qpdf
1320 lfsmake2 poppler
1321 lfsmake2 cups-filters
1322 lfsmake2 epson-inkjet-printer-escpr
1323 lfsmake2 foomatic
1324 lfsmake2 hplip
1325 lfsmake2 cifs-utils
1326 lfsmake2 krb5
1327 lfsmake2 samba
1328 lfsmake2 sudo
1329 lfsmake2 mc
1330 lfsmake2 wget
1331 lfsmake2 bridge-utils
1332 lfsmake2 screen
1333 lfsmake2 smartmontools
1334 lfsmake2 htop
1335 lfsmake2 chkconfig
1336 lfsmake2 postfix
1337 lfsmake2 fetchmail
1338 lfsmake2 cyrus-imapd
1339 lfsmake2 openmailadmin
1340 lfsmake2 clamav
1341 lfsmake2 spamassassin
1342 lfsmake2 amavisd
1343 lfsmake2 dma
1344 lfsmake2 alsa
1345 lfsmake2 mpfire
1346 lfsmake2 guardian
1347 lfsmake2 libid3tag
1348 lfsmake2 libmad
1349 lfsmake2 libogg
1350 lfsmake2 libvorbis
1351 lfsmake2 libdvbpsi
1352 lfsmake2 flac
1353 lfsmake2 lame
1354 lfsmake2 sox
1355 lfsmake2 libshout
1356 lfsmake2 xvid
1357 lfsmake2 libmpeg2
1358 lfsmake2 libarchive
1359 lfsmake2 cmake
1360 lfsmake2 gnump3d
1361 lfsmake2 rsync
1362 lfsmake2 tcpwrapper
1363 lfsmake2 libtirpc
1364 lfsmake2 rpcbind
1365 lfsmake2 nfs
1366 lfsmake2 gnu-netcat
1367 lfsmake2 ncat
1368 lfsmake2 nmap
489145db
MT
1369 lfsmake2 etherwake
1370 lfsmake2 bwm-ng
1371 lfsmake2 sysstat
1372 lfsmake2 vsftpd
1373 lfsmake2 strongswan
1374 lfsmake2 rng-tools
1375 lfsmake2 lsof
1376 lfsmake2 br2684ctl
1377 lfsmake2 pcmciautils
1378 lfsmake2 lm_sensors
1379 lfsmake2 liboping
1380 lfsmake2 collectd
1381 lfsmake2 elinks
1382 lfsmake2 igmpproxy
1383 lfsmake2 fbset
1384 lfsmake2 opus
1385 lfsmake2 python-six
1386 lfsmake2 python-pyparsing
1387 lfsmake2 spice-protocol
1388 lfsmake2 spice
1389 lfsmake2 sdl
1390 lfsmake2 libusbredir
1391 lfsmake2 qemu
1392 lfsmake2 sane
1393 lfsmake2 netpbm
1394 lfsmake2 phpSANE
1395 lfsmake2 tunctl
1396 lfsmake2 netsnmpd
1397 lfsmake2 nagios
1398 lfsmake2 nagios_nrpe
1399 lfsmake2 icinga
1400 lfsmake2 ebtables
1401 lfsmake2 directfb
489145db
MT
1402 lfsmake2 faad2
1403 lfsmake2 ffmpeg
1404 lfsmake2 vdr
1405 lfsmake2 vdr_streamdev
489145db
MT
1406 lfsmake2 vdr_epgsearch
1407 lfsmake2 vdr_dvbapi
1408 lfsmake2 vdr_eepg
1409 lfsmake2 w_scan
1410 lfsmake2 icecast
1411 lfsmake2 icegenerator
1412 lfsmake2 mpd
1413 lfsmake2 libmpdclient
1414 lfsmake2 mpc
1415 lfsmake2 perl-Net-SMTP-SSL
1416 lfsmake2 perl-MIME-Base64
1417 lfsmake2 perl-Authen-SASL
1418 lfsmake2 perl-MIME-Lite
1419 lfsmake2 perl-Email-Date-Format
1420 lfsmake2 git
1421 lfsmake2 squidclamav
1422 lfsmake2 vnstat
1423 lfsmake2 iw
1424 lfsmake2 wpa_supplicant
1425 lfsmake2 hostapd
1426 lfsmake2 pycurl
1427 lfsmake2 urlgrabber
1428 lfsmake2 syslinux
1429 lfsmake2 tftpd
1430 lfsmake2 cpufrequtils
1431 lfsmake2 bluetooth
1432 lfsmake2 gutenprint
1433 lfsmake2 apcupsd
1434 lfsmake2 iperf
1435 lfsmake2 iperf3
1436 lfsmake2 7zip
1437 lfsmake2 lynis
1438 lfsmake2 streamripper
1439 lfsmake2 sshfs
1440 lfsmake2 taglib
1441 #lfsmake2 mediatomb
1442 lfsmake2 sslh
1443 lfsmake2 perl-gettext
1444 lfsmake2 perl-Sort-Naturally
1445 lfsmake2 vdradmin
1446 lfsmake2 miau
1447 lfsmake2 perl-DBI
1448 lfsmake2 perl-DBD-mysql
1449 lfsmake2 perl-DBD-SQLite
1450 lfsmake2 perl-File-ReadBackwards
1451 lfsmake2 cacti
1452 lfsmake2 openvmtools
1453 lfsmake2 nagiosql
489145db
MT
1454 lfsmake2 motion
1455 lfsmake2 joe
1456 lfsmake2 monit
1457 lfsmake2 nut
1458 lfsmake2 watchdog
1459 lfsmake2 libpri
1460 lfsmake2 libsrtp
1461 lfsmake2 asterisk
1462 lfsmake2 lcr
1463 lfsmake2 usb_modeswitch
1464 lfsmake2 usb_modeswitch_data
1465 lfsmake2 zerofree
1466 lfsmake2 pound
1467 lfsmake2 minicom
1468 lfsmake2 ddrescue
489145db
MT
1469 lfsmake2 miniupnpd
1470 lfsmake2 client175
1471 lfsmake2 powertop
1472 lfsmake2 parted
1473 lfsmake2 swig
1474 lfsmake2 python-m2crypto
1475 lfsmake2 wireless-regdb
1476 lfsmake2 crda
1477 lfsmake2 libsolv
1478 lfsmake2 python-distutils-extra
1479 lfsmake2 python-lzma
1480 lfsmake2 python-progressbar
1481 lfsmake2 python-xattr
1482 lfsmake2 ddns
1483 lfsmake2 transmission
1484 lfsmake2 dpfhack
1485 lfsmake2 lcd4linux
1486 lfsmake2 mtr
489145db
MT
1487 lfsmake2 minidlna
1488 lfsmake2 acpid
1489 lfsmake2 fping
1490 lfsmake2 telnet
1491 lfsmake2 xinetd
1492 lfsmake2 gpgme
1493 lfsmake2 pygpgme
1494 lfsmake2 pakfire3
1495 lfsmake2 stress
1496 lfsmake2 libstatgrab
1497 lfsmake2 sarg
1498 lfsmake2 check_mk_agent
1499 lfsmake2 nginx
1500 lfsmake2 sendEmail
1501 lfsmake2 sysbench
1502 lfsmake2 strace
1503 lfsmake2 elfutils
1504 lfsmake2 ltrace
1505 lfsmake2 ipfire-netboot
1506 lfsmake2 lcdproc
1507 lfsmake2 bitstream
1508 lfsmake2 multicat
1509 lfsmake2 keepalived
1510 lfsmake2 ipvsadm
1511 lfsmake2 perl-Carp-Clan
1512 lfsmake2 perl-Date-Calc
1513 lfsmake2 perl-Date-Manip
1514 lfsmake2 perl-File-Tail
1515 lfsmake2 perl-TimeDate
1516 lfsmake2 swatch
1517 lfsmake2 tor
1518 lfsmake2 arm
1519 lfsmake2 wavemon
1520 lfsmake2 iptraf-ng
1521 lfsmake2 iotop
1522 lfsmake2 stunnel
1523 lfsmake2 sslscan
1524 lfsmake2 owncloud
1525 lfsmake2 bacula
1526 lfsmake2 batctl
b62c826f
MT
1527 lfsmake2 perl-Font-TTF
1528 lfsmake2 perl-IO-String
489145db
MT
1529 lfsmake2 perl-PDF-API2
1530 lfsmake2 squid-accounting
1531 lfsmake2 pigz
1532 lfsmake2 tmux
1533 lfsmake2 perl-Text-CSV_XS
1534 lfsmake2 swconfig
1535 lfsmake2 haproxy
1536 lfsmake2 ipset
1537 lfsmake2 lua
1538 lfsmake2 dnsdist
1539 lfsmake2 bird
1540 lfsmake2 dmidecode
1541 lfsmake2 mcelog
1542 lfsmake2 rtpproxy
1543 lfsmake2 util-macros
1544 lfsmake2 libpciaccess
1545 lfsmake2 libyajl
1546 lfsmake2 libvirt
b190cbe2 1547 lfsmake2 python3-libvirt
489145db
MT
1548 lfsmake2 freeradius
1549 lfsmake2 perl-common-sense
1550 lfsmake2 perl-inotify2
1551 lfsmake2 perl-Net-IP
0d6cc79d 1552 lfsmake2 wio
773caa66 1553 lfsmake2 iftop
d0817963 1554}
df5e82b3
MT
1555
1556buildinstaller() {
1557 # Run installer scripts one by one
1558 LOGFILE="$BASEDIR/log/_build.installer.log"
1559 export LOGFILE
489145db
MT
1560 lfsmake2 memtest
1561 lfsmake2 installer
4960c912 1562 lfsmake1 strip
df5e82b3
MT
1563}
1564
1565buildpackages() {
1566 LOGFILE="$BASEDIR/log/_build.packages.log"
1567 export LOGFILE
1568 echo "... see detailed log in _build.*.log files" >> $LOGFILE
0fbb45e9 1569
df5e82b3
MT
1570
1571 # Generating list of packages used
0fbb45e9 1572 echo -n "Generating packages list from logs" | tee -a $LOGFILE
df5e82b3
MT
1573 rm -f $BASEDIR/doc/packages-list
1574 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
1575 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
7471f6ab 1576 echo "* `basename $i`" >>$BASEDIR/doc/packages-list
df5e82b3
MT
1577 fi
1578 done
7471f6ab 1579 echo "== List of softwares used to build $NAME Version: $VERSION ==" > $BASEDIR/doc/packages-list.txt
4fe9acb2 1580 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
1581 $BASEDIR/doc/packages-list | sort >> $BASEDIR/doc/packages-list.txt
1582 rm -f $BASEDIR/doc/packages-list
c9673262 1583 # packages-list.txt is ready to be displayed for wiki page
0fbb45e9 1584 beautify message DONE
4b06f504
MT
1585
1586 # Update changelog
e49f7f0d 1587 cd $BASEDIR
c43b07fd
AF
1588 [ -z $GIT_TAG ] || LAST_TAG=$GIT_TAG
1589 [ -z $LAST_TAG ] || EXT="$LAST_TAG..HEAD"
1590 git log -n 500 --no-merges --pretty=medium --shortstat $EXT > $BASEDIR/doc/ChangeLog
df5e82b3 1591
9607771a 1592 # Create images for install
489145db 1593 lfsmake2 cdrom
bada0832 1594
4dc82852 1595 # Check if there is a loop device for building in virtual environments
841663e7
MT
1596 modprobe loop 2>/dev/null
1597 if [ $BUILD_IMAGES == 1 ] && ([ -e /dev/loop/0 ] || [ -e /dev/loop0 ] || [ -e "/dev/loop-control" ]); then
489145db
MT
1598 lfsmake2 flash-images
1599 lfsmake2 flash-images SCON=1
4dc82852 1600 fi
c9673262 1601
f0fc8807 1602 mv $LFS/install/images/{*.iso,*.tgz,*.img.gz,*.bz2} $BASEDIR >> $LOGFILE 2>&1
c9673262 1603
0d909a4a 1604 ipfirepackages
e67a57fe 1605
489145db 1606 lfsmake2 xen-image
939c2a21 1607 mv $LFS/install/images/*.bz2 $BASEDIR >> $LOGFILE 2>&1
bada0832 1608
b307417f 1609 cd $BASEDIR
744a04ea
AF
1610
1611 # remove not useable iso on armv5tel (needed to build flash images)
dc7d6b20 1612 [ "${BUILD_ARCH}" = "armv5tel" ] && rm -rf *.iso
744a04ea 1613
b307417f
AF
1614 for i in `ls *.bz2 *.img.gz *.iso`; do
1615 md5sum $i > $i.md5
1616 done
1617 cd $PWD
1618
e67a57fe
MT
1619 # Cleanup
1620 stdumount
1621 rm -rf $BASEDIR/build/tmp/*
1622
1623 # Generating total list of files
0d909a4a 1624 echo -n "Generating files list from logs" | tee -a $LOGFILE
e67a57fe
MT
1625 rm -f $BASEDIR/log/FILES
1626 for i in `ls -1tr $BASEDIR/log/[^_]*`; do
1627 if [ "$i" != "$BASEDIR/log/FILES" -a -n $i ]; then
1628 echo "##" >>$BASEDIR/log/FILES
1629 echo "## `basename $i`" >>$BASEDIR/log/FILES
1630 echo "##" >>$BASEDIR/log/FILES
1631 cat $i | sed "s%^\./%#%" | sort >> $BASEDIR/log/FILES
1632 fi
1633 done
0d909a4a 1634 beautify message DONE
e67a57fe
MT
1635
1636 cd $PWD
e67a57fe
MT
1637}
1638
1639ipfirepackages() {
489145db 1640 lfsmake2 core-updates
5596077b
MT
1641
1642 local i
dc7d6b20 1643 for i in $(find $BASEDIR/config/rootfiles/packages{/${BUILD_ARCH},} -maxdepth 1 -type f); do
5596077b 1644 i=$(basename ${i})
453b418b
MT
1645 if [ -e $BASEDIR/lfs/$i ]; then
1646 ipfiredist $i
1647 else
1648 echo -n $i
1649 beautify message SKIP
1650 fi
fe7fe395 1651 done
78331e30 1652 test -d $BASEDIR/packages || mkdir $BASEDIR/packages
5c8cfc99 1653 mv -f $LFS/install/packages/* $BASEDIR/packages >> $LOGFILE 2>&1
483f59cd 1654 rm -rf $BASEDIR/build/install/packages/*
df5e82b3
MT
1655}
1656
bcb9dc13
MT
1657while [ $# -gt 0 ]; do
1658 case "${1}" in
1659 --target=*)
c2e810de 1660 configure_build "${1#--target=}"
bcb9dc13
MT
1661 ;;
1662 -*)
1663 exiterror "Unknown configuration option: ${1}"
1664 ;;
1665 *)
1666 # Found a command, so exit options parsing.
1667 break
1668 ;;
1669 esac
1670 shift
1671done
1672
df5e82b3
MT
1673# See what we're supposed to do
1674case "$1" in
1675build)
9729e787 1676 clear
dc7d6b20 1677 PACKAGE=`ls -v -r $BASEDIR/cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz 2> /dev/null | head -n 1`
df5e82b3 1678 #only restore on a clean disk
6c4cc7ea 1679 if [ ! -e "${BASEDIR}/build${TOOLS_DIR}/.toolchain-successful" ]; then
df5e82b3 1680 if [ ! -n "$PACKAGE" ]; then
ea465705 1681 beautify build_stage "Full toolchain compilation"
df5e82b3
MT
1682 prepareenv
1683 buildtoolchain
1684 else
1685 PACKAGENAME=${PACKAGE%.tar.gz}
15679d9f 1686 beautify build_stage "Packaged toolchain compilation"
df5e82b3
MT
1687 if [ `md5sum $PACKAGE | awk '{print $1}'` == `cat $PACKAGENAME.md5 | awk '{print $1}'` ]; then
1688 tar zxf $PACKAGE
1689 prepareenv
1690 else
1691 exiterror "$PACKAGENAME md5 did not match, check downloaded package"
1692 fi
1693 fi
1694 else
9729e787
MT
1695 echo -n "Using installed toolchain" | tee -a $LOGFILE
1696 beautify message SKIP
df5e82b3
MT
1697 prepareenv
1698 fi
5cfe86e6 1699
7ab7a9b4 1700 beautify build_start
0b59f25c 1701 beautify build_stage "Building LFS"
df5e82b3 1702 buildbase
15679d9f 1703
0b59f25c 1704 beautify build_stage "Building IPFire"
15679d9f 1705 buildipfire
5cfe86e6 1706
0b59f25c 1707 beautify build_stage "Building installer"
df5e82b3 1708 buildinstaller
15679d9f 1709
0b59f25c 1710 beautify build_stage "Building packages"
df5e82b3 1711 buildpackages
7a5ed24e
CS
1712
1713 beautify build_stage "Checking Logfiles for new Files"
b307417f
AF
1714
1715 cd $BASEDIR
7a5ed24e 1716 tools/checknewlog.pl
e0c923f4 1717 tools/checkrootfiles
b307417f 1718 cd $PWD
a23731d1 1719
7ab7a9b4 1720 beautify build_end
df5e82b3
MT
1721 ;;
1722shell)
1723 # enter a shell inside LFS chroot
1724 # may be used to changed kernel settings
1725 prepareenv
1726 entershell
1727 ;;
df5e82b3 1728clean)
a50d04ab 1729 echo -en "${BOLD}Cleaning build directory...${NORMAL}"
df5e82b3
MT
1730 for i in `mount | grep $BASEDIR | sed 's/^.*loop=\(.*\))/\1/'`; do
1731 $LOSETUP -d $i 2>/dev/null
1732 done
1733 for i in `mount | grep $BASEDIR | cut -d " " -f 1`; do
1734 umount $i
1735 done
1736 stdumount
1737 for i in `seq 0 7`; do
69a6ec55 1738 if ( losetup /dev/loop${i} 2>/dev/null | grep -q "/install/images" ); then
df5e82b3
MT
1739 umount /dev/loop${i} 2>/dev/null;
1740 losetup -d /dev/loop${i} 2>/dev/null;
69a6ec55 1741 fi;
df5e82b3
MT
1742 done
1743 rm -rf $BASEDIR/build
1744 rm -rf $BASEDIR/cdrom
f9315063 1745 rm -rf $BASEDIR/packages
df5e82b3 1746 rm -rf $BASEDIR/log
6c4cc7ea
MT
1747 if [ -h "${TOOLS_DIR}" ]; then
1748 rm -f "${TOOLS_DIR}"
df5e82b3 1749 fi
b307417f 1750 rm -f $BASEDIR/ipfire-*
a50d04ab 1751 beautify message DONE
df5e82b3 1752 ;;
c3db995c 1753downloadsrc)
df5e82b3
MT
1754 if [ ! -d $BASEDIR/cache ]; then
1755 mkdir $BASEDIR/cache
1756 fi
1757 mkdir -p $BASEDIR/log
857d9bf2 1758 echo -e "${BOLD}Preload all source files${NORMAL}" | tee -a $LOGFILE
df5e82b3
MT
1759 FINISHED=0
1760 cd $BASEDIR/lfs
1761 for c in `seq $MAX_RETRIES`; do
1762 if (( FINISHED==1 )); then
1763 break
1764 fi
1765 FINISHED=1
1766 cd $BASEDIR/lfs
1767 for i in *; do
1768 if [ -f "$i" -a "$i" != "Config" ]; then
846e756e
MT
1769 lfsmakecommoncheck ${i} || continue
1770
dc7d6b20 1771 make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
51f9e7ac 1772 MESSAGE="$i\t ($c/$MAX_RETRIES)" download >> $LOGFILE 2>&1
df5e82b3 1773 if [ $? -ne 0 ]; then
e22c7973 1774 beautify message FAIL
df5e82b3
MT
1775 FINISHED=0
1776 else
1777 if [ $c -eq 1 ]; then
e22c7973 1778 beautify message DONE
df5e82b3
MT
1779 fi
1780 fi
1781 fi
1782 done
1783 done
e22c7973 1784 echo -e "${BOLD}***Verifying md5sums${NORMAL}"
df5e82b3
MT
1785 ERROR=0
1786 for i in *; do
1787 if [ -f "$i" -a "$i" != "Config" ]; then
a4130265 1788 lfsmakecommoncheck ${i} > /dev/null || continue
dc7d6b20 1789 make -s -f $i LFS_BASEDIR=$BASEDIR BUILD_ARCH="${BUILD_ARCH}" \
51f9e7ac 1790 MESSAGE="$i\t " md5 >> $LOGFILE 2>&1
df5e82b3 1791 if [ $? -ne 0 ]; then
e22c7973
MT
1792 echo -ne "MD5 difference in lfs/$i"
1793 beautify message FAIL
df5e82b3
MT
1794 ERROR=1
1795 fi
1796 fi
1797 done
1798 if [ $ERROR -eq 0 ]; then
e22c7973
MT
1799 echo -ne "${BOLD}all files md5sum match${NORMAL}"
1800 beautify message DONE
1801 else
1802 echo -ne "${BOLD}not all files were correctly download${NORMAL}"
1803 beautify message FAIL
df5e82b3 1804 fi
e22c7973 1805 cd - >/dev/null 2>&1
df5e82b3 1806 ;;
df5e82b3 1807toolchain)
9729e787 1808 clear
df5e82b3 1809 prepareenv
602cb8bd 1810 beautify build_stage "Toolchain compilation"
df5e82b3 1811 buildtoolchain
dc7d6b20 1812 echo "`date -u '+%b %e %T'`: Create toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
11104bfe 1813 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
dc7d6b20 1814 cd $BASEDIR && tar -zc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
6c4cc7ea 1815 build/${TOOLS_DIR} build/bin/sh log >> $LOGFILE
dc7d6b20
MT
1816 md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.gz \
1817 > cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.md5
df5e82b3
MT
1818 stdumount
1819 ;;
1820gettoolchain)
df5e82b3 1821 # arbitrary name to be updated in case of new toolchain package upload
dc7d6b20 1822 PACKAGE=$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}
712d859c 1823 if [ ! -f $BASEDIR/cache/toolchains/$PACKAGE.tar.gz ]; then
5bd13f01 1824 URL_TOOLCHAIN=`grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }'`
11104bfe 1825 test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
dc7d6b20 1826 echo "`date -u '+%b %e %T'`: Load toolchain tar.gz for ${BUILD_ARCH}" | tee -a $LOGFILE
712d859c 1827 cd $BASEDIR/cache/toolchains
74f3678b 1828 wget -U "IPFireSourceGrabber/2.x" $URL_TOOLCHAIN/$PACKAGE.tar.gz $URL_TOOLCHAIN/$PACKAGE.md5 >& /dev/null
712d859c 1829 if [ $? -ne 0 ]; then
dc7d6b20 1830 echo "`date -u '+%b %e %T'`: error downloading $PACKAGE toolchain for ${BUILD_ARCH} machine" | tee -a $LOGFILE
40a4ea4c 1831 else
712d859c
MT
1832 if [ "`md5sum $PACKAGE.tar.gz | awk '{print $1}'`" = "`cat $PACKAGE.md5 | awk '{print $1}'`" ]; then
1833 echo "`date -u '+%b %e %T'`: toolchain md5 ok" | tee -a $LOGFILE
1834 else
1835 exiterror "$PACKAGE.md5 did not match, check downloaded package"
1836 fi
40a4ea4c 1837 fi
712d859c
MT
1838 else
1839 echo "Toolchain is already downloaded. Exiting..."
df5e82b3
MT
1840 fi
1841 ;;
15679d9f
MT
1842uploadsrc)
1843 PWD=`pwd`
661d9388
CS
1844 if [ -z $IPFIRE_USER ]; then
1845 echo -n "You have to setup IPFIRE_USER first. See .config for details."
1846 beautify message FAIL
1847 exit 1
1848 fi
ae23a606 1849
661d9388 1850 URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
15e38431 1851 REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
661d9388 1852
15e38431
MT
1853 for file in ${BASEDIR}/cache/*; do
1854 [ -d "${file}" ] && continue
1855 grep -q "$(basename ${file})" <<<$REMOTE_FILES && continue
661d9388 1856 NEW_FILES="$NEW_FILES $file"
0eab8e84 1857 done
661d9388
CS
1858 [ -n "$NEW_FILES" ] && scp -2 $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
1859 cd $BASEDIR
15679d9f
MT
1860 cd $PWD
1861 exit 0
0eab8e84 1862 ;;
bf7c473f 1863lang)
69a6ec55
MT
1864 echo -ne "Checking the translations for missing or obsolete strings..."
1865 chmod 755 $BASEDIR/tools/{check_strings.pl,sort_strings.pl,check_langs.sh}
1866 $BASEDIR/tools/sort_strings.pl en
1867 $BASEDIR/tools/sort_strings.pl de
1868 $BASEDIR/tools/sort_strings.pl fr
1869 $BASEDIR/tools/sort_strings.pl es
1870 $BASEDIR/tools/sort_strings.pl pl
1871 $BASEDIR/tools/sort_strings.pl ru
1872 $BASEDIR/tools/sort_strings.pl nl
1873 $BASEDIR/tools/sort_strings.pl tr
1874 $BASEDIR/tools/sort_strings.pl it
1875 $BASEDIR/tools/check_strings.pl en > $BASEDIR/doc/language_issues.en
1876 $BASEDIR/tools/check_strings.pl de > $BASEDIR/doc/language_issues.de
1877 $BASEDIR/tools/check_strings.pl fr > $BASEDIR/doc/language_issues.fr
1878 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.es
1879 $BASEDIR/tools/check_strings.pl es > $BASEDIR/doc/language_issues.pl
1880 $BASEDIR/tools/check_strings.pl ru > $BASEDIR/doc/language_issues.ru
1881 $BASEDIR/tools/check_strings.pl nl > $BASEDIR/doc/language_issues.nl
1882 $BASEDIR/tools/check_strings.pl tr > $BASEDIR/doc/language_issues.tr
1883 $BASEDIR/tools/check_strings.pl it > $BASEDIR/doc/language_issues.it
1884 $BASEDIR/tools/check_langs.sh > $BASEDIR/doc/language_missings
1885 beautify message DONE
1886
1887 echo -ne "Updating language lists..."
1888 update_language_list ${BASEDIR}/src/installer/po
1889 update_language_list ${BASEDIR}/src/setup/po
1890 beautify message DONE
bf7c473f 1891 ;;
6b8cff41 1892*)
a50d04ab 1893 echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain}"
6b8cff41
MT
1894 cat doc/make.sh-usage
1895 ;;
3ea75603 1896esac