2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
21 ###############################################################################
25 ###############################################################################
27 CONFIG_ROOT
=/etc
/$SNAME # Configuration rootdir
29 TARGET
=i686
# Default target
30 KVER
=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }' | tr -d '\n'; grep --max-count=1 FULLVER lfs/linux | awk '{ print $3 }' | cut -c 7-| tail -1`
31 MACHINE_REAL
=`uname -m`
32 GIT_TAG
=$
(git tag |
tail -1)
40 PARALLELISMFLAGS
=-j$
(( $
(grep processor
< /proc
/cpuinfo |
wc -l) * 2 + 1 ))
41 DISTCC_HOSTS
=localhost
44 BASENAME
=`basename $0`
46 # Debian specific settings
47 if [ ! -e /etc
/debian_version
]; then
50 if [ -x /usr
/bin
/realpath
]; then
51 FULLPATH
=`/usr/bin/realpath $0`
53 echo "ERROR: Need to do apt-get install realpath"
58 BASEDIR
=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
61 ###############################################################################
63 # Read the local configuration to override the environment variables
65 ###############################################################################
67 if [ -e .config
]; then
72 ###############################################################################
74 # Variables that are not modifyable by .config
76 ###############################################################################
78 if [ 'i686' = $MACHINE_REAL \
79 -o 'i586' = $MACHINE_REAL \
80 -o 'i486' = $MACHINE_REAL \
81 -o 'x86_64' = $MACHINE_REAL ]; then
82 IFS_HOST
="$(echo $MACHTYPE | sed "s
/$
(echo $MACHTYPE | cut
-d- -f2)/cross
/")"
85 echo "Can't determine your architecture - $MACHINE_REAL"
89 if [ 'i686' = $TARGET -o 'i586' = $TARGET \
90 -o 'i486' = $TARGET ]; then
92 MACHINE_REAL
=${MACHINE_REAL}
93 LINKER
=/lib
/ld-linux.so
.2
94 IFS_TARGET
="${MACHINE}-pc-linux-gnu"
95 CFLAGS
="-march=${MACHINE} -O2 -pipe -fomit-frame-pointer"
97 UCLIBC_TARGET
=${MACHINE}-pc-linux-uclibc
98 UCLIBC_CFLAGS
="-march=${MACHINE} -Os -pipe"
99 elif [ 'via-c7' = $TARGET ]; then
101 MACHINE_REAL
=${MACHINE_REAL}
102 LINKER
=/lib
/ld-linux.so
.2
103 IFS_TARGET
="${MACHINE}-pc-linux-gnu"
104 CFLAGS
="-march=${MACHINE} -mmmx -msse -msse2 -msse3 -O2 -pipe"
106 UCLIBC_TARGET
=${MACHINE}-pc-linux-uclibc
107 UCLIBC_CFLAGS
="-march=i386 -Os -pipe"
108 elif [ 'via-c3' = $TARGET ]; then
110 MACHINE_REAL
=${MACHINE_REAL}
111 LINKER
=/lib
/ld-linux.so
.2
112 IFS_TARGET
="${MACHINE}-pc-linux-gnu"
113 CFLAGS
="-march=c3 -m3dnow -O2 -pipe -fomit-frame-pointer"
115 UCLIBC_TARGET
=${MACHINE}-pc-linux-uclibc
116 UCLIBC_CFLAGS
="-march=${MACHINE} -Os -pipe"
118 beautify message FAIL
119 echo "Not a valid target arch (i686|i586|i486|i386|via-c7|via-c3) - $TARGET"
123 mkdir
$BASEDIR/log_
${MACHINE}/ 2>/dev
/null
125 # Set up what used to be /tools
126 TOOLS_DIR
=/tools_
${MACHINE}
127 CTOOLS_DIR
=/cross-tools_
${MACHINE}
130 INSTALLER_DIR
=/installer
132 # A place to build the iso
135 # A place to keep the images
138 # include machine in TOOLCHAINNAME
139 TOOLCHAINNAME
=$SNAME-$TOOLCHAINVERSION-toolchain-t${TARGET}-m${MACHINE}
141 # The place where all uclibc files are stored in
142 UCLIBC_DIR
=/usr
/${UCLIBC_TARGET}
143 UCLIBC_CC_CORE_STATIC_DIR
=${UCLIBC_DIR}/gcc-core-static
145 #UCLIBC_SYSROOT_DIR=${UCLIBC_DIR}/${UCLIBC_TARGET}/sys-root
146 UCLIBC_SYSROOT_DIR
=${INSTALLER_DIR}
148 ###############################################################################
150 # Beautifying variables & presentation & input output interface
152 ###############################################################################
155 # Find current screen size
156 if [ -z "${COLUMNS}" ]; then
158 COLUMNS
=${COLUMNS##* }
161 # When using remote connections, such as a serial port, stty size returns 0
162 if [ "${COLUMNS}" = "0" ]; then
166 ## Measurements for positioning result messages
171 RESULT_COL
=$
((${COLUMNS} - $RESULT_WIDTH - 4))
172 TIME_COL
=$
((${RESULT_COL} - $TIME_WIDTH - 5))
173 VER_COL
=$
((${TIME_COL} - $VER_WIDTH - 5))
174 OPT_COL
=$
((${VER_COL} - $OPT_WIDTH - 5))
176 ## Set Cursur Position Commands, used via echo -e
177 SET_RESULT_COL
="\\033[${RESULT_COL}G"
178 SET_TIME_COL
="\\033[${TIME_COL}G"
179 SET_VER_COL
="\\033[${VER_COL}G"
180 SET_OPT_COL
="\\033[${OPT_COL}G"
182 # Define color for messages
191 ################################################################################
193 # Necessary shell functions #
195 ################################################################################
198 if [ "$?" -eq "0" ]; then
199 beautify message DONE
203 beautify message FAIL
205 if [ $EXITCODE -ne "0" ]; then
213 # ARG1=starting position on screen
214 # ARG2=string to be printed
215 # ARG3=offset, negative for left movement, positive for right movement, relative to ARG1
216 # For example if your starting position is column 50 and you want to print Hello three columns to the right
217 # of your starting position, your call will look like this:
218 # position_cursor 50 "Hello" 3 (you'll get the string Hello at position 53 (= 50 + 3)
219 # If on the other hand you want your string "Hello" to end three columns to the left of position 50,
220 # your call will look like this:
221 # position_cursor 50 "Hello" -3 (you'll get the string Hello at position 42 (= 50 - 5 -3)
222 # If you want to start printing at the exact starting location, use offset 0
228 STRING_LENGTH
=${#STRING}
230 if [ ${OFFSET} -lt 0 ]; then
231 COL
=$
((${START} + ${OFFSET} - ${STRING_LENGTH}))
233 COL
=$
((${START} + ${OFFSET}))
236 SET_COL
="\\033[${COL}G"
239 } # End of position_cursor()
244 # Commands: build_stage, make_pkg, message, result
250 echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
253 echo -ne "${WARN}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${WARN} WARN ${NORMAL}]\n"
256 echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
259 echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
262 echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${DONE} ON ${NORMAL}]\n"
265 echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${FAIL} OFF ${NORMAL}]\n"
271 echo -ne "${BOLD}*** ${MESSAGE}${SET_OPT_COL} options${SET_VER_COL} version "
272 echo -ne "${SET_TIME_COL} time (sec)${SET_RESULT_COL} status${NORMAL}\n"
275 echo "$2" |
while read PKG_VER PROGRAM OPTIONS
277 SET_VER_COL_REAL
=`position_cursor $TIME_COL $PKG_VER -3`
279 echo -ne "${PROGRAM}"
280 if ! [ "$OPTIONS" == "" ]; then
281 echo -ne "${SET_OPT_COL}[ ${BOLD}${OPTIONS}${NORMAL} ]"
284 if [ "${PKG_VER}" == "${SNAME}" ] || [ "${PKG_VER}" == "LFS" ]; then
285 echo -ne "${SET_RESULT_COL}"
287 echo -ne "${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
288 echo -ne "${NORMAL} ]${SET_RESULT_COL}"
301 SET_TIME_COL_REAL
=`position_cursor $RESULT_COL $PKG_TIME -3`
304 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
305 echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
308 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
309 echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
312 echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
313 echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
318 } # End of beautify()
323 PKG_VER
=`grep ^VER $1 | awk '{print $3}'`
325 if [ -z $PKG_VER ]; then
326 PKG_VER
=`grep "Exp " $1 | awk '{print $4}'`
329 if [ ${#PKG_VER} -gt $VER_WIDTH ]; then
330 # If a package version number is greater than $VER_WIDTH, we keep the first 4 characters
331 # and replace enough characters to fit the resulting string on the screen. We'll replace
332 # the extra character with .. (two dots). That's why the "+ 2" in the formula below.
333 # Example: if we have a 21-long version number that we want to fit into a 10-long space,
334 # we have to remove 11 characters. But if we replace 11 characters with 2 characters, we'll
335 # end up with a 12-character long string. That's why we replace 12 characters with ..
336 REMOVE
=`expr substr "$PKG_VER" 4 $[ ${#PKG_VER} - $VER_WIDTH + 2 ]`
337 PKG_VER
=`echo ${PKG_VER/$REMOVE/..}`
341 } # End of get_pkg_ver()
344 sleep 0.3 # Wait one second for finish of processes
345 for fs
in `mount | grep $BASEDIR/build_${MACHINE} | awk '{print $3}'`; do
346 umount
$fs #2>/dev/null;
348 } # End of stdumount()
353 beautify message FAIL
355 echo -ne "${FAIL}ERROR${NORMAL}: ${BOLD}$*${NORMAL}\n"
356 [ -z "$LOGFILE" ] || \
357 echo " Check $LOGFILE for errors if applicable"
359 } # End of exiterror()
361 ################################################################################
362 # This is the function that sets the environment of a chroot and enters it #
363 ################################################################################
365 PATH
=${TOOLS_DIR}/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/bin:/usr/${MACHINE_REAL}-linux/bin
367 if [ ! -e $LFS/usr
/src
/lfs
/ ]; then
368 exiterror
"No such file or directory: $LFS/usr/src/lfs/"
371 echo -ne "Entering ${BOLD}$MACHINE${NORMAL} LFS chroot, type exit to return to host environment\n"
373 chroot
$LFS $TOOLS_DIR/bin
/env
-i \
376 PS1
="${BOLD}[chroot-${TARGET}(${MACHINE})]${NORMAL} \u:\w\$ " \
378 CONFIG_ROOT
=${CONFIG_ROOT} \
383 CCACHE_DIR
=/usr
/src
/ccache \
384 CCACHE_PREFIX
=${CCACHE_PREFIX} \
385 CCACHE_HASHDIR
=${CCACHE_HASHDIR} \
386 DISTCC_DIR
=/usr
/src
/distcc \
387 PARALLELISMFLAGS
=$PARALLELISMFLAGS \
389 TOOLS_DIR
=$TOOLS_DIR \
390 INSTALLER_DIR
=$INSTALLER_DIR \
392 MACHINE_REAL
="$MACHINE_REAL" \
394 CXXFLAGS
="$CXXFLAGS" \
395 IFS_HOST
="$IFS_HOST" \
396 IFS_TARGET
="$IFS_TARGET" \
399 STAGE_ORDER
=$STAGE_ORDER \
400 LOGFILE
=`echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g"` \
403 if [ $?
-ne 0 ]; then
404 exiterror
"chroot error"
408 } # End of entershell()
412 ################################################################################
413 # Common checking before entering the chroot and compilling #
414 # Return:0 caller can continue #
415 # :1 skip (nothing to do) #
416 # or fail if no script file found #
417 ################################################################################
421 if [ ! -f $BASEDIR/lfs
/$1 ]; then
422 exiterror
"No such file or directory: $BASEDIR/lfs/$1"
425 local PKG_VER
=`get_pkg_ver $BASEDIR/lfs/$1`
426 beautify make_pkg
"$PKG_VER $*"
430 for i
in $SKIP_PACKAGE_LIST
432 if [ "$i" == "$1" ]; then
438 echo -e "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
440 cd $BASEDIR/lfs
&& make -s -f $
* MACHINE
=$MACHINE LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t " download
>> $LOGFILE 2>&1
441 if [ $?
-ne 0 ]; then
442 exiterror
"Download error in $1"
446 } # End of lfsmakecommoncheck()
448 ################################################################################
449 # This is the function that builds every package in stage "toolchain" #
450 ################################################################################
452 lfsmakecommoncheck $
*
453 [ $?
== 1 ] && return 0
455 local PKG_VER
=`get_pkg_ver $BASEDIR/lfs/$1`
457 local EXTRA_MAKE
=$EXTRA_MAKE
459 local PKG_TIME_START
=`date +%s`
460 cd $BASEDIR/lfs
&& $EXTRA_MAKE make -f $
* \
461 CONFIG_ROOT
=$CONFIG_ROOT \
463 TOOLS_DIR
=$TOOLS_DIR \
464 CTOOLS_DIR
=$CTOOLS_DIR \
466 MACHINE_REAL
="$MACHINE_REAL" \
467 IFS_HOST
="$IFS_HOST" \
468 IFS_TARGET
="$IFS_TARGET" \
469 LFS_BASEDIR
=$BASEDIR \
471 INSTALLER_DIR
=$INSTALLER_DIR \
472 PARALLELISMFLAGS
=$PARALLELISMFLAGS \
475 STAGE_ORDER
=$STAGE_ORDER \
479 install >> $LOGFILE 2>&1
481 local COMPILE_SUCCESS
=$?
482 local PKG_TIME_END
=`date +%s`
484 if [ $COMPILE_SUCCESS -ne 0 ]; then
485 beautify result FAIL $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
486 exiterror
"Building $*";
488 beautify result DONE $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
492 } # End of toolchain_make()
494 ################################################################################
495 # This is the function that builds every package in stage "base" and "ipfire" #
496 ################################################################################
498 lfsmakecommoncheck $
*
499 [ $?
== 1 ] && return 0
501 local PKG_VER
=`get_pkg_ver $BASEDIR/lfs/$1`
503 local EXTRA_MAKE
=$EXTRA_MAKE
504 # When cross-compiling, make sure the kernel is compiled for the target
505 [ "$MACHINE" != "$MACHINE_REAL" -a "$1" == "linux" ] && unset EXTRA_MAKE
507 # Also, make sure external kernel modules are compiled 64bit
508 if grep -qEi 'KERNEL_MOD = yes' $1 ; then
512 local MYCFLAGS MYCXXFLAGS
513 if [ "${STAGE}" = "installer" ]; then
514 MYCFLAGS
=${UCLIBC_CFLAGS}
515 MYCXXFLAGS
=${UCLIBC_CFLAGS}
518 MYCXXFLAGS
=${CXXFLAGS}
521 local PKG_TIME_START
=`date +%s`
522 chroot
$LFS $TOOLS_DIR/bin
/env
-i \
527 CONFIG_ROOT
=${CONFIG_ROOT} \
532 CCACHE_DIR
=/usr
/src
/ccache \
533 CCACHE_PREFIX
=${CCACHE_PREFIX} \
534 CCACHE_HASHDIR
=${CCACHE_HASHDIR} \
535 DISTCC_DIR
=/usr
/src
/distcc \
536 PARALLELISMFLAGS
=$PARALLELISMFLAGS \
538 TOOLS_DIR
=$TOOLS_DIR \
539 INSTALLER_DIR
=$INSTALLER_DIR \
540 CDROM_DIR
=$CDROM_DIR \
541 IMAGES_DIR
=$IMAGES_DIR \
542 UCLIBC_DIR
=$UCLIBC_DIR \
543 UCLIBC_SYSROOT_DIR
=$UCLIBC_SYSROOT_DIR \
544 UCLIBC_TARGET
=$UCLIBC_TARGET \
545 UCLIBC_CC_CORE_STATIC_DIR
=${UCLIBC_CC_CORE_STATIC_DIR} \
547 MACHINE_REAL
="$MACHINE_REAL" \
549 CXXFLAGS
="$MYCXXFLAGS" \
550 IFS_HOST
="$IFS_HOST" \
551 IFS_TARGET
="$IFS_TARGET" \
554 STAGE_ORDER
=$STAGE_ORDER \
558 LOGFILE
=`echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g"` \
559 bash
-x -c "cd /usr/src/lfs && \
560 $EXTRA_MAKE make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
562 local COMPILE_SUCCESS
=$?
563 local PKG_TIME_END
=`date +%s`
565 if [ $COMPILE_SUCCESS -ne 0 ]; then
566 beautify result FAIL $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
567 exiterror
"Building $*";
569 beautify result DONE $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
573 } # End of ipfire_make()
575 ################################################################################
576 # This prepares the build environment #
577 ################################################################################
580 LOGFILE
=$BASEDIR/log_
${MACHINE}/_build
.00-preparation.log
582 mkdir
-p $BASEDIR/log_
${MACHINE}/01_toolchain
2>/dev
/null
583 mkdir
-p $BASEDIR/log_
${MACHINE}/02_base
2>/dev
/null
584 mkdir
-p $BASEDIR/log_
${MACHINE}/03_
${SNAME} 2>/dev
/null
585 mkdir
-p $BASEDIR/log_
${MACHINE}/04_misc
2>/dev
/null
586 mkdir
-p $BASEDIR/log_
${MACHINE}/05_installer
2>/dev
/null
587 mkdir
-p $BASEDIR/log_
${MACHINE}/06_packages
2>/dev
/null
589 #############################################################################
590 # Are we running the right shell? #
591 #############################################################################
593 if [ ! "$BASH" ]; then
594 exiterror
"BASH environment variable is not set. You're probably running the wrong shell."
597 if [ -z "${BASH_VERSION}" ]; then
598 exiterror
"Not running BASH shell."
601 #############################################################################
602 # Trap on emergency exit #
603 #############################################################################
604 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
607 #############################################################################
608 # Resetting our nice level #
609 #############################################################################
610 echo -ne "Resetting our nice level to $NICE"
611 renice
$NICE $$
> /dev
/null
612 if [ `nice` != "$NICE" ]; then
613 beautify message FAIL
614 exiterror
"Failed to set correct nice level"
616 beautify message DONE
620 if [ -x /usr
/bin
/schedtool
]; then
621 echo -ne "Setting kernel schedular to SCHED_BATCH"
622 /usr
/bin
/schedtool
-B $$
623 if [ $?
-eq 0 ]; then
624 beautify message DONE
626 beautify message FAIL
630 ##############################################################################
631 # Checking if running as root user #
632 ##############################################################################
633 echo -ne "Checking if we're running as root user"
634 if [ `id -u` != 0 ]; then
635 beautify message FAIL
636 exiterror
"Not building as root"
638 beautify message DONE
642 ##############################################################################
643 # Checking for necessary temporary space #
644 ##############################################################################
645 echo -ne "Checking for necessary space on disk $BASE_DEV"
646 BASE_DEV
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
647 BASE_ASPACE
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
648 if (( 2048000 > $BASE_ASPACE )); then
649 BASE_USPACE
=`du -skx $BASEDIR | awk '{print $1}'`
650 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
651 beautify message FAIL
652 exiterror
"Not enough temporary space available, need at least 2GB on $BASE_DEV"
654 beautify message DONE
656 beautify message DONE
659 ##############################################################################
660 # Setting security features #
661 ##############################################################################
663 echo -ne "Stack smashing protector (SSP)"
664 if [ $SSP -eq 1 ]; then
670 echo -ne "Position independent executeables (PIE)"
671 if [ $PIE -eq 1 ]; then
677 echo -ne "GRSecurity (PAX)"
678 if [ $PAX -eq 1 ]; then
686 ##############################################################################
687 # Building Linux From Scratch system configuration #
688 ##############################################################################
694 LFS
=$BASEDIR/build_
${MACHINE}/${SNAME}
696 # Check /tools symlink
697 if [ -h $TOOLS_DIR ]; then
700 if [ ! -a $TOOLS_DIR ]; then
701 ln -s $BASEDIR/build_
${MACHINE}/$TOOLS_DIR /
703 if [ ! -h $TOOLS_DIR ]; then
704 exiterror
"Could not create $TOOLS_DIR symbolic link."
711 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
713 # Make some extra directories
714 mkdir
-p $BASEDIR/build_
${MACHINE}/{$TOOLS_DIR,cdrom
} 2>/dev
/null
715 mkdir
-p $BASEDIR/{cache
,ccache
,distcc
} 2>/dev
/null
716 mkdir
-p $BASEDIR/cache
/toolchains
2>/dev
/null
717 mkdir
-p $LFS/{$TOOLS_DIR/usr
,usr
/src
} 2>/dev
/null
718 mkdir
-p $LFS/dev
/pts
720 mkdir
-p $LFS/usr
/src
/{cache
,config
,doc
,lfs
,log_
${MACHINE},src
,ccache
,distcc
}
721 mkdir
-p $LFS/{$INSTALLER_DIR,cdrom
,images
}
724 mknod
-m 600 $BASEDIR/build
/dev
/console c
5 1 2>/dev
/null
725 mknod
-m 666 $BASEDIR/build
/dev
/null c
1 3 2>/dev
/null
727 # Make all sources and proc available under lfs build
728 mount
--bind /dev
$LFS/dev
729 mount
--bind /proc
$LFS/proc
730 mount
--bind $BASEDIR/cache
$LFS/usr
/src
/cache
731 mount
--bind $BASEDIR/ccache
$LFS/usr
/src
/ccache
732 mount
--bind $BASEDIR/distcc
$LFS/usr
/src
/distcc
733 mount
--bind $BASEDIR/config
$LFS/usr
/src
/config
734 mount
--bind $BASEDIR/doc
$LFS/usr
/src
/doc
735 mount
--bind $BASEDIR/lfs
$LFS/usr
/src
/lfs
736 mount
--bind $BASEDIR/log_
${MACHINE} $LFS/usr
/src
/log_
${MACHINE}
737 mount
--bind $BASEDIR/src
$LFS/usr
/src
/src
738 mount
--bind $BASEDIR/build_
${MACHINE}/$TOOLS_DIR $LFS/$TOOLS_DIR
739 mount
--bind $BASEDIR/build_
${MACHINE}/$CDROM_DIR $LFS/$CDROM_DIR
741 # Run LFS static binary creation scripts one by one
742 export CCACHE_DIR
=$BASEDIR/ccache
743 export CCACHE_HASHDIR
=1
744 if [ ! -z "$DISTCC_HOSTS" ]; then
745 export CCACHE_PREFIX
="distcc"
746 export DISTCC_DIR
=$BASEDIR/distcc
749 [ -z "$DISTCC_HOSTS" ] ||
echo "$DISTCC_HOSTS" > $DISTCC_DIR/hosts
751 # Remove pre-install list of installed files in case user erase some files before rebuild
752 rm -f $LFS/usr
/src
/lsalr
2>/dev
/null
757 #a prebuilt toolchain package is only used if found in cache
758 if [ ! -d $BASEDIR/cache
]; then
759 exiterror
"Use make.sh downloadsrc first!"
761 cd $BASEDIR/cache
/toolchains
762 PACKAGE
=`ls -v -r $TOOLCHAINNAME.tar.bz2 2> /dev/null | head -n 1`
763 #only restore on a clean disk
765 echo -ne "Building for ${BOLD}${TARGET} (${MACHINE}) on ${MACHINE_REAL}${NORMAL}\n"
767 if [ -f $BASEDIR/log_
${MACHINE}/02_base
/stage2-LFS
]; then
769 echo "Using installed toolchain" >> $LOGFILE
770 beautify message DONE
"Stage toolchain already built or extracted"
772 if [ -z "$PACKAGE" ]; then
773 echo "Full toolchain compilation"
776 .
$BASEDIR/tools
/make-check
779 beautify build_stage
"Building toolchain"
782 echo "Restore from $PACKAGE"
783 cd $BASEDIR && tar jxf
$BASEDIR/cache
/toolchains
/$PACKAGE
788 beautify build_stage
"Building base"
791 beautify build_stage
"Building $SNAME"
794 beautify build_stage
"Building miscellaneous"
797 beautify build_stage
"Building installer"
800 beautify build_stage
"Building packages"
804 echo "... and all this hard work for this:"
805 ls -sh $BASEDIR/${SNAME}-${VERSION}.${MACHINE}.iso