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 LOCALVERSION lfs/linux | awk '{ print $3 }' | tail -1`
31 MACHINE_REAL
=`uname -m`
32 GIT_TAG
=$
(git tag |
tail -1)
43 PARALLELISMFLAGS
=-j$
(( $
(grep processor
< /proc
/cpuinfo |
wc -l) * 2 + 1 ))
44 DISTCC_HOSTS
=localhost
47 BASENAME
=`basename $0`
49 # Debian specific settings
50 if [ ! -e /etc
/debian_version
]; then
53 if [ -x /usr
/bin
/realpath
]; then
54 FULLPATH
=`/usr/bin/realpath $0`
56 echo "ERROR: Need to do apt-get install realpath"
61 BASEDIR
=`echo $FULLPATH | sed "s/\/$BASENAME//g"`
64 HOSTNAME
=${HOSTNAME-$(hostname -f || hostname)}
66 .
$BASEDIR/tools
/make-beautify
# Load this very early
68 ###############################################################################
70 # Read the local configuration to override the environment variables
72 ###############################################################################
74 if ! [ -e .config
]; then
75 sed -e "s/@UUID@/$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)/" \
76 -e "s/^#UUID=/UUID=/" < $BASEDIR/.config-default
> $BASEDIR/.config
81 ###############################################################################
83 # Variables that are not modifyable by .config
85 ###############################################################################
87 if [ 'i686' = $MACHINE_REAL \
88 -o 'i586' = $MACHINE_REAL \
89 -o 'i486' = $MACHINE_REAL \
90 -o 'x86_64' = $MACHINE_REAL ]; then
91 IFS_HOST
="$(echo $MACHTYPE | sed "s
/$
(echo $MACHTYPE | cut
-d- -f2)/cross
/")"
94 echo "Can't determine your architecture - $MACHINE_REAL"
98 if [ 'i686' = $TARGET -o 'i586' = $TARGET \
99 -o 'i486' = $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} -O2 -pipe -fomit-frame-pointer"
106 UCLIBC_TARGET
=${MACHINE}-pc-linux-uclibc
107 UCLIBC_CFLAGS
="-march=${MACHINE} -Os -pipe"
108 elif [ 'via-c7' = $TARGET ]; then
110 MACHINE_REAL
=${MACHINE_REAL}
111 LINKER
=/lib
/ld-linux.so
.2
112 IFS_TARGET
="${MACHINE}-pc-linux-gnu"
113 CFLAGS
="-march=${MACHINE} -mmmx -msse -msse2 -msse3 -O2 -pipe"
115 UCLIBC_TARGET
=${MACHINE}-pc-linux-uclibc
116 UCLIBC_CFLAGS
="-march=i386 -Os -pipe"
117 elif [ 'via-c3' = $TARGET ]; then
119 MACHINE_REAL
=${MACHINE_REAL}
120 LINKER
=/lib
/ld-linux.so
.2
121 IFS_TARGET
="${MACHINE}-pc-linux-gnu"
122 CFLAGS
="-march=c3 -m3dnow -O2 -pipe -fomit-frame-pointer"
124 UCLIBC_TARGET
=${MACHINE}-pc-linux-uclibc
125 UCLIBC_CFLAGS
="-march=${MACHINE} -Os -pipe"
126 elif [ 'geodelx' = $TARGET ]; then
128 MACHINE_REAL
=${MACHINE_REAL}
129 LINKER
=/lib
/ld-linux.so
.2
130 IFS_TARGET
="${MACHINE}-pc-linux-gnu"
131 CFLAGS
="-march=geode -Os -pipe -fomit-frame-pointer"
133 UCLIBC_TARGET
=${MACHINE}-pc-linux-uclibc
134 UCLIBC_CFLAGS
="-march=geode -Os -pipe"
136 beautify message FAIL
137 echo "Not a valid target arch (i686|i586|i486|via-c7|via-c3|geodelx) - $TARGET"
141 mkdir
$BASEDIR/log_
${MACHINE}/ 2>/dev
/null
143 # Set up what used to be /tools
144 TOOLS_DIR
=/tools_
${MACHINE}
147 INSTALLER_DIR
=/installer
149 # A place to build the iso
152 # A place to keep the images
155 # include machine in TOOLCHAINNAME
156 TOOLCHAINNAME
=$SNAME-$TOOLCHAINVERSION-toolchain-t${TARGET}-m${MACHINE}
158 # The place where all uclibc files are stored in
159 UCLIBC_DIR
=/usr
/${UCLIBC_TARGET}
160 UCLIBC_CC_CORE_STATIC_DIR
=${UCLIBC_DIR}/gcc-core-static
162 #UCLIBC_SYSROOT_DIR=${UCLIBC_DIR}/${UCLIBC_TARGET}/sys-root
163 UCLIBC_SYSROOT_DIR
=${INSTALLER_DIR}
165 # Files that indicates that we are running or failed
166 RUNNING
=$BASEDIR/.running
167 FAILED
=$BASEDIR/.failed
169 ################################################################################
171 # Necessary shell functions #
173 ################################################################################
175 .
$BASEDIR/tools
/make-buildspy
176 .
$BASEDIR/tools
/make-check
177 .
$BASEDIR/tools
/make-batch
178 .
$BASEDIR/tools
/make-compilers
179 .
$BASEDIR/tools
/make-git
183 if [ "$RETVAL" -eq "0" ]; then
184 beautify message DONE
186 beautify message FAIL
192 sleep 0.3 # Wait one second for finish of processes
193 for fs
in `mount | grep $BASEDIR/build_${MACHINE} | awk '{print $3}'`; do
194 umount
$fs #2>/dev/null;
196 } # End of stdumount()
203 rm -f $RUNNING 2>/dev
/null
205 } # End of exiterror()
207 ################################################################################
208 # This is the function that sets the environment of a chroot and enters it #
209 ################################################################################
211 PATH
=${TOOLS_DIR}/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/bin:/usr/${MACHINE_REAL}-linux/bin
213 if [ ! -e $LFS/usr
/src
/lfs
/ ]; then
214 exiterror
"No such file or directory: $LFS/usr/src/lfs/"
217 echo -ne "Entering ${BOLD}$MACHINE${NORMAL} LFS chroot, type exit to return to host environment\n"
219 chroot
$LFS $TOOLS_DIR/bin
/env
-i \
222 PS1
="${BOLD}[chroot-${TARGET}(${MACHINE})]${NORMAL} \u:\w\$ " \
224 CONFIG_ROOT
=${CONFIG_ROOT} \
229 CCACHE_DIR
=/usr
/src
/ccache \
230 CCACHE_PREFIX
=${CCACHE_PREFIX} \
231 CCACHE_HASHDIR
=${CCACHE_HASHDIR} \
232 DISTCC_DIR
=/usr
/src
/distcc \
233 PARALLELISMFLAGS
=$PARALLELISMFLAGS \
235 TOOLS_DIR
=$TOOLS_DIR \
236 INSTALLER_DIR
=$INSTALLER_DIR \
238 MACHINE_REAL
="$MACHINE_REAL" \
240 CXXFLAGS
="$CXXFLAGS" \
241 IFS_HOST
="$IFS_HOST" \
242 IFS_TARGET
="$IFS_TARGET" \
245 STAGE_ORDER
=$STAGE_ORDER \
246 LOGFILE
=`echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g"` \
249 if [ $?
-ne 0 ]; then
250 exiterror
"chroot error"
254 } # End of entershell()
258 ################################################################################
259 # Common checking before entering the chroot and compilling #
260 # Return:0 caller can continue #
261 # :1 skip (nothing to do) #
262 # or fail if no script file found #
263 ################################################################################
267 if [ ! -f $BASEDIR/lfs
/$1 ]; then
268 exiterror
"No such file or directory: $BASEDIR/lfs/$1"
271 local PKG_VER
=`get_pkg_ver $BASEDIR/lfs/$1`
272 beautify make_pkg
"$PKG_VER $*"
276 for i
in $SKIP_PACKAGE_LIST
278 if [ "$i" == "$1" ]; then
284 echo -e "`date -u '+%b %e %T'`: Building $* " >> $LOGFILE
286 cd $BASEDIR/lfs
&& make -s -f $
* MACHINE
=$MACHINE LFS_BASEDIR
=$BASEDIR MESSAGE
="$1\t " download
>> $LOGFILE 2>&1
287 if [ $?
-ne 0 ]; then
288 exiterror
"Download error in $1"
291 build_spy
set package
$1 &
294 } # End of lfsmakecommoncheck()
296 ################################################################################
297 # This is the function that builds every package in stage "toolchain" #
298 ################################################################################
300 lfsmakecommoncheck $
*
301 [ $?
== 1 ] && return 0
303 local PKG_VER
=`get_pkg_ver $BASEDIR/lfs/$1`
305 local EXTRA_MAKE
=$EXTRA_MAKE
307 local PKG_TIME_START
=`date +%s`
308 cd $BASEDIR/lfs
&& $EXTRA_MAKE make -f $
* \
309 CONFIG_ROOT
=$CONFIG_ROOT \
311 TOOLS_DIR
=$TOOLS_DIR \
313 MACHINE_REAL
="$MACHINE_REAL" \
314 IFS_HOST
="$IFS_HOST" \
315 IFS_TARGET
="$IFS_TARGET" \
316 LFS_BASEDIR
=$BASEDIR \
318 INSTALLER_DIR
=$INSTALLER_DIR \
319 PARALLELISMFLAGS
=$PARALLELISMFLAGS \
322 STAGE_ORDER
=$STAGE_ORDER \
326 install >> $LOGFILE 2>&1
328 local COMPILE_SUCCESS
=$?
329 local PKG_TIME_END
=`date +%s`
331 if [ $COMPILE_SUCCESS -ne 0 ]; then
332 beautify result FAIL $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
333 exiterror
"Building $*";
335 beautify result DONE $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
339 } # End of toolchain_make()
341 ################################################################################
342 # This is the function that builds every package in stage "base" and "ipfire" #
343 ################################################################################
345 lfsmakecommoncheck $
*
346 [ $?
== 1 ] && return 0
348 local PKG_VER
=`get_pkg_ver $BASEDIR/lfs/$1`
350 local EXTRA_MAKE
=$EXTRA_MAKE
351 # When cross-compiling, make sure the kernel is compiled for the target
352 [ "$MACHINE" != "$MACHINE_REAL" -a "$1" == "linux" ] && unset EXTRA_MAKE
354 # Also, make sure external kernel modules are compiled 64bit
355 if grep -qEi 'KERNEL_MOD = yes' $1 ; then
359 local MYCFLAGS MYCXXFLAGS
360 if [ "${STAGE}" = "installer" ]; then
361 MYCFLAGS
=${UCLIBC_CFLAGS}
362 MYCXXFLAGS
=${UCLIBC_CFLAGS}
365 MYCXXFLAGS
=${CXXFLAGS}
368 local PKG_TIME_START
=`date +%s`
369 chroot
$LFS $TOOLS_DIR/bin
/env
-i \
374 CONFIG_ROOT
=${CONFIG_ROOT} \
379 CCACHE_DIR
=/usr
/src
/ccache \
380 CCACHE_PREFIX
=${CCACHE_PREFIX} \
381 CCACHE_HASHDIR
=${CCACHE_HASHDIR} \
382 DISTCC_DIR
=/usr
/src
/distcc \
383 PARALLELISMFLAGS
=$PARALLELISMFLAGS \
385 TOOLS_DIR
=$TOOLS_DIR \
386 INSTALLER_DIR
=$INSTALLER_DIR \
387 CDROM_DIR
=$CDROM_DIR \
388 IMAGES_DIR
=$IMAGES_DIR \
389 UCLIBC_DIR
=$UCLIBC_DIR \
390 UCLIBC_SYSROOT_DIR
=$UCLIBC_SYSROOT_DIR \
391 UCLIBC_TARGET
=$UCLIBC_TARGET \
392 UCLIBC_CC_CORE_STATIC_DIR
=${UCLIBC_CC_CORE_STATIC_DIR} \
394 MACHINE_REAL
="$MACHINE_REAL" \
396 CXXFLAGS
="$MYCXXFLAGS" \
397 IFS_HOST
="$IFS_HOST" \
398 IFS_TARGET
="$IFS_TARGET" \
402 STAGE_ORDER
=$STAGE_ORDER \
407 LOGFILE
=`echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g"` \
408 bash
-x -c "cd /usr/src/lfs && \
409 $EXTRA_MAKE make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
411 local COMPILE_SUCCESS
=$?
412 local PKG_TIME_END
=`date +%s`
414 if [ $COMPILE_SUCCESS -ne 0 ]; then
415 beautify result FAIL $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
416 exiterror
"Building $*";
418 beautify result DONE $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
422 } # End of ipfire_make()
424 ################################################################################
425 # This prepares the build environment #
426 ################################################################################
428 LOGFILE
=$BASEDIR/log_
${MACHINE}/_build
.00-preparation.log
430 mkdir
-p $BASEDIR/log_
${MACHINE}/01_toolchain
2>/dev
/null
431 mkdir
-p $BASEDIR/log_
${MACHINE}/02_base
2>/dev
/null
432 mkdir
-p $BASEDIR/log_
${MACHINE}/03_
${SNAME} 2>/dev
/null
433 mkdir
-p $BASEDIR/log_
${MACHINE}/04_misc
2>/dev
/null
434 mkdir
-p $BASEDIR/log_
${MACHINE}/05_installer
2>/dev
/null
435 mkdir
-p $BASEDIR/log_
${MACHINE}/06_packages
2>/dev
/null
437 #############################################################################
438 # Are we running the right shell? #
439 #############################################################################
441 if [ ! "$BASH" ]; then
442 exiterror
"BASH environment variable is not set. You're probably running the wrong shell."
445 if [ -z "${BASH_VERSION}" ]; then
446 exiterror
"Not running BASH shell."
449 #############################################################################
450 # Trap on emergency exit #
451 #############################################################################
452 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
455 #############################################################################
456 # Resetting our nice level #
457 #############################################################################
458 echo -ne "Resetting our nice level to $NICE"
459 renice
$NICE $$
> /dev
/null
460 if [ `nice` != "$NICE" ]; then
461 beautify message FAIL
462 exiterror
"Failed to set correct nice level"
464 beautify message DONE
468 if [ -x /usr
/bin
/schedtool
]; then
469 /usr
/bin
/schedtool
-B $$
470 if [ $?
-ne 0 ]; then
471 echo -ne "Setting kernel schedular to SCHED_BATCH"
472 beautify message FAIL
476 ##############################################################################
477 # Checking if running as root user #
478 ##############################################################################
479 if [ `id -u` != 0 ]; then
480 echo -ne "Checking if we're running as root user"
481 beautify message FAIL
482 exiterror
"Not building as root"
486 ##############################################################################
487 # Checking for necessary temporary space #
488 ##############################################################################
489 BASE_DEV
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
490 BASE_ASPACE
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
491 if (( 2048000 > $BASE_ASPACE )); then
492 BASE_USPACE
=`du -skx $BASEDIR | awk '{print $1}'`
493 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
494 echo -ne "Checking for necessary space on disk $BASE_DEV"
495 beautify message FAIL
496 exiterror
"Not enough temporary space available, need at least 2GB on $BASE_DEV"
500 ##############################################################################
501 # Setting security features #
502 ##############################################################################
504 echo -ne "Stack smashing protector (SSP)"
505 if [ $SSP -eq 1 ]; then
511 echo -ne "Position independent executeables (PIE)"
512 if [ $PIE -eq 1 ]; then
518 echo -ne "GRSecurity (PAX)"
519 if [ $PAX -eq 1 ]; then
527 ##############################################################################
529 ##############################################################################
531 echo -ne "Embedded build"
532 if [ $EMB -eq 1 ]; then
534 check_loop || exiterror
"Can't build flash images on this machine."
541 ##############################################################################
542 # Checking CPU features #
543 ##############################################################################
546 if [ 'via-c7' = $TARGET ]; then
547 CHECK_CPU
="sse sse2 pne"
548 elif [ 'via-c3' = $TARGET ]; then
552 for flag
in $CHECK_CPU; do
554 exiterror
"Your system doesn't support needed cpu feature \"$flag\" to build target $TARGET."
557 ##############################################################################
558 # Building Linux From Scratch system configuration #
559 ##############################################################################
565 LFS
=$BASEDIR/build_
${MACHINE}/${SNAME}
567 # Check /tools symlink
568 if [ -h $TOOLS_DIR ]; then
571 if [ ! -a $TOOLS_DIR ]; then
572 ln -s $BASEDIR/build_
${MACHINE}/$TOOLS_DIR /
574 if [ ! -h $TOOLS_DIR ]; then
575 exiterror
"Could not create $TOOLS_DIR symbolic link."
582 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
584 # Make some extra directories
585 mkdir
-p $BASEDIR/build_
${MACHINE}/{$TOOLS_DIR,cdrom
} 2>/dev
/null
586 mkdir
-p $BASEDIR/{cache
,ccache
,distcc
} 2>/dev
/null
587 mkdir
-p $BASEDIR/cache
/{toolchains
,patches
,tarballs
} 2>/dev
/null
588 mkdir
-p $LFS/{$TOOLS_DIR,usr
/src
} 2>/dev
/null
589 mkdir
-p $LFS/dev
/pts
591 mkdir
-p $LFS/usr
/src
/{cache
,config
,doc
,lfs
,log_
${MACHINE},src
,ccache
,distcc
}
592 mkdir
-p $LFS/{$INSTALLER_DIR,cdrom
,images
}
595 mknod
-m 600 $BASEDIR/build
/dev
/console c
5 1 2>/dev
/null
596 mknod
-m 666 $BASEDIR/build
/dev
/null c
1 3 2>/dev
/null
598 # Make all sources and proc available under lfs build
599 mount
--bind /dev
$LFS/dev
600 mount
--bind /proc
$LFS/proc
601 mount
--bind $BASEDIR/cache
$LFS/usr
/src
/cache
602 mount
--bind $BASEDIR/ccache
$LFS/usr
/src
/ccache
603 mount
--bind $BASEDIR/distcc
$LFS/usr
/src
/distcc
604 mount
--bind $BASEDIR/config
$LFS/usr
/src
/config
605 mount
--bind $BASEDIR/doc
$LFS/usr
/src
/doc
606 mount
--bind $BASEDIR/lfs
$LFS/usr
/src
/lfs
607 mount
--bind $BASEDIR/log_
${MACHINE} $LFS/usr
/src
/log_
${MACHINE}
608 mount
--bind $BASEDIR/src
$LFS/usr
/src
/src
609 mount
--bind $BASEDIR/build_
${MACHINE}/$TOOLS_DIR $LFS/$TOOLS_DIR
610 mount
--bind $BASEDIR/build_
${MACHINE}/$CDROM_DIR $LFS/$CDROM_DIR
612 # Run LFS static binary creation scripts one by one
613 export CCACHE_DIR
=$BASEDIR/ccache
614 export CCACHE_HASHDIR
=1
615 if [ ! -z "$DISTCC_HOSTS" ]; then
616 export CCACHE_PREFIX
="distcc"
617 export DISTCC_DIR
=$BASEDIR/distcc
620 [ -z "$DISTCC_HOSTS" ] ||
echo "$DISTCC_HOSTS" > $DISTCC_DIR/hosts
622 # Remove pre-install list of installed files in case user erase some files before rebuild
623 rm -f $LFS/usr
/src
/lsalr
2>/dev
/null
628 #a prebuilt toolchain package is only used if found in cache
629 if [ ! -d $BASEDIR/cache
]; then
630 exiterror
"Use make.sh source get first!"
632 cd $BASEDIR/cache
/toolchains
633 PACKAGE
=`ls -v -r $TOOLCHAINNAME.tar.bz2 2> /dev/null | head -n 1`
634 #only restore on a clean disk
636 local BLD_TIME_START
=`date +%s`
637 touch $RUNNING; rm -f $FAILED 2>/dev
/null
639 echo -ne "Building for ${BOLD}${TARGET} (${MACHINE}) on ${MACHINE_REAL}${NORMAL}\n"
641 build_spy_send_profile
&
642 build_spy compiling
&
644 if [ -f $BASEDIR/log_
${MACHINE}/02_base
/stage2-LFS
]; then
646 echo "Using installed toolchain" >> $LOGFILE
647 beautify message DONE
"Stage toolchain already built or extracted"
649 if [ -z "$PACKAGE" ]; then
650 echo "Full toolchain compilation"
655 beautify build_stage
"Building toolchain"
658 echo "Restore from $PACKAGE"
659 cd $BASEDIR && tar jxf
$BASEDIR/cache
/toolchains
/$PACKAGE
664 beautify build_stage
"Building base"
667 beautify build_stage
"Building $SNAME"
670 beautify build_stage
"Building miscellaneous"
673 beautify build_stage
"Building installer"
676 beautify build_stage
"Building packages"
680 echo "... and all this hard work for this:"
681 ls -sh $BASEDIR/${SNAME}-${VERSION}.${MACHINE}.iso
683 local BLD_TIME_END
=`date +%s`
684 build_spy
set duration $
[ $BLD_TIME_END - $BLD_TIME_START ]
691 if [ ! -f $BASEDIR/cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2
]; then
692 URL_TOOLCHAIN
=$
(grep URL_TOOLCHAIN lfs
/Config |
awk '{ print $3 }')
693 DIR_TOOLCHAIN
="$BASEDIR/cache/toolchains"
695 echo "Loading toolchain for $MACHINE"
696 scp
-2C ${IPFIRE_USER}@
${URL_TOOLCHAIN}/$TOOLCHAINNAME.
tar.bz2 \
699 echo -n "Toolchain \"$TOOLCHAINNAME\" is already existing"
700 beautify message SKIP
706 if [ -f $BASEDIR/cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2
]; then
707 URL_TOOLCHAIN
=$
(grep URL_TOOLCHAIN lfs
/Config |
awk '{ print $3 }')
708 DIR_TOOLCHAIN
="$BASEDIR/cache/toolchains"
710 echo "Pushing toolchain for $MACHINE"
711 scp
-2C ${DIR_TOOLCHAIN}/$TOOLCHAINNAME.
tar.bz2 \
712 ${IPFIRE_USER}@
${URL_TOOLCHAIN}
714 echo -n "Toolchain \"$TOOLCHAINNAME\" is not existing. "
715 echo -n "Run \"./make.sh build\", first"
716 beautify message SKIP
721 if [ ! -d $BASEDIR/cache
]; then
722 mkdir
-p $BASEDIR/cache
/{tarballs
,patches
}
724 mkdir
-p $BASEDIR/log_
${MACHINE}
725 echo -e "${BOLD}Preload all source files${NORMAL}"
728 if [ -f "$i" -a "$i" != "Config" ]; then
730 LFS_BASEDIR
=$BASEDIR \
734 PAX
=$PAX download
2>> $LOGFILE
735 [ $?
-ne 0 ] && beautify message FAIL
743 URL_SOURCE
=$
(grep URL_SOURCE lfs
/Config |
awk '{ print $3 }')
744 REMOTE_FILES
=$
(echo "ls -1" | sftp
-C ${IPFIRE_USER}@
${URL_SOURCE})
746 cd $BASEDIR/cache
/tarballs
/
747 for file in $
(ls -1); do
748 grep -q "$file" <<<$REMOTE_FILES && continue
749 NEW_FILES
="$NEW_FILES $file"
751 [ -n "$NEW_FILES" ] && scp
-2C $NEW_FILES ${IPFIRE_USER}@
${URL_SOURCE}
757 URL_TARGET
=$
(grep URL_TARGET lfs
/Config |
awk '{ print $3 }')
758 DIR
="${BASEDIR}/${HOSTNAME}/$(date '+%Y%m%d-%0k')/"
760 # If there is no iso, we do nothing.
761 [ -e "${BASEDIR}/${SNAME}-${VERSION}.${MACHINE}.iso" ] ||
return 0
763 rm -rf ${BASEDIR}/${HOSTNAME} 2>/dev
/null
766 [ -e "${BASEDIR}/packages" ] && cp -al ${BASEDIR}/packages ${DIR}
767 cp -l ${BASEDIR}/${SNAME}-${VERSION}.${MACHINE}.iso ${DIR}
770 scp -2C -r ${HOSTNAME} ${IPFIRE_USER}@${URL_TARGET} || :
772 rm -rf ${BASEDIR}/${HOSTNAME} 2>/dev/null