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