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" \
401 STAGE_ORDER
=$STAGE_ORDER \
406 LOGFILE
=`echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g"` \
407 bash
-x -c "cd /usr/src/lfs && \
408 $EXTRA_MAKE make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
410 local COMPILE_SUCCESS
=$?
411 local PKG_TIME_END
=`date +%s`
413 if [ $COMPILE_SUCCESS -ne 0 ]; then
414 beautify result FAIL $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
415 exiterror
"Building $*";
417 beautify result DONE $
[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
421 } # End of ipfire_make()
423 ################################################################################
424 # This prepares the build environment #
425 ################################################################################
427 LOGFILE
=$BASEDIR/log_
${MACHINE}/_build
.00-preparation.log
429 mkdir
-p $BASEDIR/log_
${MACHINE}/01_toolchain
2>/dev
/null
430 mkdir
-p $BASEDIR/log_
${MACHINE}/02_base
2>/dev
/null
431 mkdir
-p $BASEDIR/log_
${MACHINE}/03_
${SNAME} 2>/dev
/null
432 mkdir
-p $BASEDIR/log_
${MACHINE}/04_misc
2>/dev
/null
433 mkdir
-p $BASEDIR/log_
${MACHINE}/05_installer
2>/dev
/null
434 mkdir
-p $BASEDIR/log_
${MACHINE}/06_packages
2>/dev
/null
436 #############################################################################
437 # Are we running the right shell? #
438 #############################################################################
440 if [ ! "$BASH" ]; then
441 exiterror
"BASH environment variable is not set. You're probably running the wrong shell."
444 if [ -z "${BASH_VERSION}" ]; then
445 exiterror
"Not running BASH shell."
448 #############################################################################
449 # Trap on emergency exit #
450 #############################################################################
451 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
454 #############################################################################
455 # Resetting our nice level #
456 #############################################################################
457 echo -ne "Resetting our nice level to $NICE"
458 renice
$NICE $$
> /dev
/null
459 if [ `nice` != "$NICE" ]; then
460 beautify message FAIL
461 exiterror
"Failed to set correct nice level"
463 beautify message DONE
467 if [ -x /usr
/bin
/schedtool
]; then
468 echo -ne "Setting kernel schedular to SCHED_BATCH"
469 /usr
/bin
/schedtool
-B $$
470 if [ $?
-eq 0 ]; then
471 beautify message DONE
473 beautify message FAIL
477 ##############################################################################
478 # Checking if running as root user #
479 ##############################################################################
480 echo -ne "Checking if we're running as root user"
481 if [ `id -u` != 0 ]; then
482 beautify message FAIL
483 exiterror
"Not building as root"
485 beautify message DONE
489 ##############################################################################
490 # Checking for necessary temporary space #
491 ##############################################################################
492 echo -ne "Checking for necessary space on disk $BASE_DEV"
493 BASE_DEV
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }'`
494 BASE_ASPACE
=`df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }'`
495 if (( 2048000 > $BASE_ASPACE )); then
496 BASE_USPACE
=`du -skx $BASEDIR | awk '{print $1}'`
497 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
498 beautify message FAIL
499 exiterror
"Not enough temporary space available, need at least 2GB on $BASE_DEV"
501 beautify message DONE
503 beautify message DONE
506 ##############################################################################
507 # Setting security features #
508 ##############################################################################
510 echo -ne "Stack smashing protector (SSP)"
511 if [ $SSP -eq 1 ]; then
517 echo -ne "Position independent executeables (PIE)"
518 if [ $PIE -eq 1 ]; then
524 echo -ne "GRSecurity (PAX)"
525 if [ $PAX -eq 1 ]; then
533 ##############################################################################
535 ##############################################################################
537 echo -ne "Embedded build"
538 if [ $EMB -eq 1 ]; then
540 check_loop || exiterror
"Can't build flash images on this machine."
547 ##############################################################################
548 # Building Linux From Scratch system configuration #
549 ##############################################################################
555 LFS
=$BASEDIR/build_
${MACHINE}/${SNAME}
557 # Check /tools symlink
558 if [ -h $TOOLS_DIR ]; then
561 if [ ! -a $TOOLS_DIR ]; then
562 ln -s $BASEDIR/build_
${MACHINE}/$TOOLS_DIR /
564 if [ ! -h $TOOLS_DIR ]; then
565 exiterror
"Could not create $TOOLS_DIR symbolic link."
572 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
574 # Make some extra directories
575 mkdir
-p $BASEDIR/build_
${MACHINE}/{$TOOLS_DIR,cdrom
} 2>/dev
/null
576 mkdir
-p $BASEDIR/{cache
,ccache
,distcc
} 2>/dev
/null
577 mkdir
-p $BASEDIR/cache
/{toolchains
,patches
,tarballs
} 2>/dev
/null
578 mkdir
-p $LFS/{$TOOLS_DIR,usr
/src
} 2>/dev
/null
579 mkdir
-p $LFS/dev
/pts
581 mkdir
-p $LFS/usr
/src
/{cache
,config
,doc
,lfs
,log_
${MACHINE},src
,ccache
,distcc
}
582 mkdir
-p $LFS/{$INSTALLER_DIR,cdrom
,images
}
585 mknod
-m 600 $BASEDIR/build
/dev
/console c
5 1 2>/dev
/null
586 mknod
-m 666 $BASEDIR/build
/dev
/null c
1 3 2>/dev
/null
588 # Make all sources and proc available under lfs build
589 mount
--bind /dev
$LFS/dev
590 mount
--bind /proc
$LFS/proc
591 mount
--bind $BASEDIR/cache
$LFS/usr
/src
/cache
592 mount
--bind $BASEDIR/ccache
$LFS/usr
/src
/ccache
593 mount
--bind $BASEDIR/distcc
$LFS/usr
/src
/distcc
594 mount
--bind $BASEDIR/config
$LFS/usr
/src
/config
595 mount
--bind $BASEDIR/doc
$LFS/usr
/src
/doc
596 mount
--bind $BASEDIR/lfs
$LFS/usr
/src
/lfs
597 mount
--bind $BASEDIR/log_
${MACHINE} $LFS/usr
/src
/log_
${MACHINE}
598 mount
--bind $BASEDIR/src
$LFS/usr
/src
/src
599 mount
--bind $BASEDIR/build_
${MACHINE}/$TOOLS_DIR $LFS/$TOOLS_DIR
600 mount
--bind $BASEDIR/build_
${MACHINE}/$CDROM_DIR $LFS/$CDROM_DIR
602 # Run LFS static binary creation scripts one by one
603 export CCACHE_DIR
=$BASEDIR/ccache
604 export CCACHE_HASHDIR
=1
605 if [ ! -z "$DISTCC_HOSTS" ]; then
606 export CCACHE_PREFIX
="distcc"
607 export DISTCC_DIR
=$BASEDIR/distcc
610 [ -z "$DISTCC_HOSTS" ] ||
echo "$DISTCC_HOSTS" > $DISTCC_DIR/hosts
612 # Remove pre-install list of installed files in case user erase some files before rebuild
613 rm -f $LFS/usr
/src
/lsalr
2>/dev
/null
618 #a prebuilt toolchain package is only used if found in cache
619 if [ ! -d $BASEDIR/cache
]; then
620 exiterror
"Use make.sh downloadsrc first!"
622 cd $BASEDIR/cache
/toolchains
623 PACKAGE
=`ls -v -r $TOOLCHAINNAME.tar.bz2 2> /dev/null | head -n 1`
624 #only restore on a clean disk
626 local BLD_TIME_START
=`date +%s`
627 touch $RUNNING; rm -f $FAILED 2>/dev
/null
629 echo -ne "Building for ${BOLD}${TARGET} (${MACHINE}) on ${MACHINE_REAL}${NORMAL}\n"
631 build_spy_send_profile
&
634 if [ -f $BASEDIR/log_
${MACHINE}/02_base
/stage2-LFS
]; then
636 echo "Using installed toolchain" >> $LOGFILE
637 beautify message DONE
"Stage toolchain already built or extracted"
639 if [ -z "$PACKAGE" ]; then
640 echo "Full toolchain compilation"
645 beautify build_stage
"Building toolchain"
648 echo "Restore from $PACKAGE"
649 cd $BASEDIR && tar jxf
$BASEDIR/cache
/toolchains
/$PACKAGE
654 beautify build_stage
"Building base"
657 beautify build_stage
"Building $SNAME"
660 beautify build_stage
"Building miscellaneous"
663 beautify build_stage
"Building installer"
666 beautify build_stage
"Building packages"
670 echo "... and all this hard work for this:"
671 ls -sh $BASEDIR/${SNAME}-${VERSION}.${MACHINE}.iso
673 local BLD_TIME_END
=`date +%s`
674 build_spy
set duration $
[ $BLD_TIME_END - $BLD_TIME_START ]
681 if [ ! -f $BASEDIR/cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2
]; then
682 URL_TOOLCHAIN
=$
(grep URL_TOOLCHAIN lfs
/Config |
awk '{ print $3 }')
683 DIR_TOOLCHAIN
="$BASEDIR/cache/toolchains"
685 echo "Loading toolchain for $MACHINE"
686 scp
-2C ${IPFIRE_USER}@
${URL_TOOLCHAIN}/$TOOLCHAINNAME.
tar.bz2 \
689 echo -n "Toolchain \"$TOOLCHAINNAME\" is already existing"
690 beautify message SKIP
696 if [ -f $BASEDIR/cache
/toolchains
/$TOOLCHAINNAME.
tar.bz2
]; then
697 URL_TOOLCHAIN
=$
(grep URL_TOOLCHAIN lfs
/Config |
awk '{ print $3 }')
698 DIR_TOOLCHAIN
="$BASEDIR/cache/toolchains"
700 echo "Pushing toolchain for $MACHINE"
701 scp
-2C ${DIR_TOOLCHAIN}/$TOOLCHAINNAME.
tar.bz2 \
702 ${IPFIRE_USER}@
${URL_TOOLCHAIN}
704 echo -n "Toolchain \"$TOOLCHAINNAME\" is not existing. "
705 echo -n "Run \"./make.sh build\", first"
706 beautify message SKIP
711 if [ ! -d $BASEDIR/cache
]; then
712 mkdir
-p $BASEDIR/cache
/{tarballs
,patches
}
714 mkdir
-p $BASEDIR/log_
${MACHINE}
715 echo -e "${BOLD}Preload all source files${NORMAL}"
718 if [ -f "$i" -a "$i" != "Config" ]; then
720 LFS_BASEDIR
=$BASEDIR \
724 PAX
=$PAX download
2>> $LOGFILE
725 [ $?
-ne 0 ] && beautify message FAIL
733 URL_SOURCE
=$
(grep URL_SOURCE lfs
/Config |
awk '{ print $3 }')
734 REMOTE_FILES
=$
(echo "ls -1" | sftp
-C ${IPFIRE_USER}@
${URL_SOURCE})
736 cd $BASEDIR/cache
/tarballs
/
737 for file in $
(ls -1); do
738 grep -q "$file" <<<$REMOTE_FILES && continue
739 NEW_FILES
="$NEW_FILES $file"
741 [ -n "$NEW_FILES" ] && scp
-2C $NEW_FILES ${IPFIRE_USER}@
${URL_SOURCE}
747 URL_TARGET
=$
(grep URL_TARGET lfs
/Config |
awk '{ print $3 }')
748 DIR
="${BASEDIR}/${HOSTNAME}/$(date '+%Y%m%d-%k')/"
750 rm -rf ${DIR} 2>/dev
/null
753 [ -e "${BASEDIR}/packages" ] && cp -al ${BASEDIR}/packages ${DIR}
754 cp -l ${BASEDIR}/${SNAME}-${VERSION}.${MACHINE}.iso ${DIR}
757 scp -2C -r ${HOSTNAME} ${IPFIRE_USER}@${URL_TARGET} || :
759 rm -rf ${DIR} 2>/dev/null