]> git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-include
Merge branch 'master' of ssh://ms@git.ipfire.org/pub/git/ipfire-3.x
[ipfire-3.x.git] / tools / make-include
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008 Michael Tremer & Christian Schmidt #
6 # #
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. #
11 # #
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. #
16 # #
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/>. #
19 # #
20 ###############################################################################
21 ###############################################################################
22 #
23 # System variables
24 #
25 ###############################################################################
26
27 PWD=$(pwd)
28 BASENAME=$(basename $0)
29
30 # Debian specific settings
31 if [ ! -e /etc/debian_version ]; then
32 FULLPATH=$(which $0)
33 else
34 if [ -x /usr/bin/realpath ]; then
35 FULLPATH=$(/usr/bin/realpath $0)
36 else
37 echo "ERROR: Need to do apt-get install realpath"
38 exit 1
39 fi
40 fi
41
42 BASEDIR=$(echo $FULLPATH | sed "s/\/$BASENAME//g")
43 export BASEDIR
44
45 . $BASEDIR/tools/make-constants # Load this very early
46 . $BASEDIR/tools/make-beautify
47
48 mkdir $BASEDIR/log_${TARGET}/ 2>/dev/null
49
50 ################################################################################
51 # #
52 # Necessary shell functions #
53 # #
54 ################################################################################
55
56 . $BASEDIR/tools/make-buildspy
57 . $BASEDIR/tools/make-check
58 . $BASEDIR/tools/make-batch
59 . $BASEDIR/tools/make-compilers
60 . $BASEDIR/tools/make-git
61 . $BASEDIR/tools/make-packages
62 . $BASEDIR/tools/make-rootfiles
63 . $BASEDIR/tools/make-vm
64 . $BASEDIR/tools/make-cron
65
66 evaluate() {
67 RETVAL=$?
68 if [ "$RETVAL" -eq "0" ]; then
69 beautify message DONE
70 else
71 beautify message FAIL
72 fi
73 (exit $RETVAL)
74 }
75
76 stdumount() {
77 sleep 0.3 # Wait one second for finish of processes
78 for fs in $(mount | grep $BASEDIR/build_${TARGET} | awk '{print $3}'); do
79 umount $fs 2>/dev/null;
80 done
81 } # End of stdumount()
82
83 exiterror() {
84 stdumount
85 dialogerror $*
86 build_spy state error
87 if [ -n "$LOGFILE" ]; then
88 echo "$(date -u '+%b %e %T') ERROR: $*" >> $LOGFILE
89 build_spy log $(tail -n16 $LOGFILE | $BASEDIR/tools/base64)
90 fi
91 build_spy exit
92 touch $FAILED
93 rm -f $RUNNING 2>/dev/null
94 exit 1
95 } # End of exiterror()
96
97 logger() {
98 local logfile=$LOGFILE
99 case "$1" in
100 --distcc)
101 logfile=$BASEDIR/log_$TARGET/_build.00-distcc.log
102 shift
103 ;;
104 esac
105 echo "$(date -u '+%b %e %T') $*" >> $logfile
106 }
107
108 ################################################################################
109 # This is the function that sets the environment of a chroot and enters it #
110 ################################################################################
111 entershell() {
112 PATH=${TOOLS_DIR}/usr/bin:/bin:/usr/bin:/sbin:/usr/sbin:${TOOLS_DIR}/bin:/usr/${MACHINE_REAL}-linux/bin
113
114 if [ ! -e $LFS/usr/src/lfs/ ]; then
115 exiterror "No such file or directory: $LFS/usr/src/lfs/"
116 fi
117
118 COMMAND=${@-bash} # Run command, given as parameters.
119
120 echo -ne "Entering ${BOLD}$MACHINE${NORMAL} LFS chroot, type exit to return to host environment\n"
121
122 chroot $LFS $TOOLS_DIR/bin/env -i \
123 HOME=/root \
124 TERM=$TERM \
125 PS1="${BOLD}[chroot-${TARGET}(${MACHINE})]${NORMAL} \u:\w\$ " \
126 PATH=$PATH \
127 CONFIG_ROOT=${CONFIG_ROOT} \
128 VERSION=${VERSION} \
129 NAME=${NAME} \
130 SNAME=${SNAME} \
131 SLOGAN="$SLOGAN" \
132 CCACHE_DIR=/usr/src/ccache \
133 CCACHE_PREFIX=${CCACHE_PREFIX} \
134 CCACHE_HASHDIR=${CCACHE_HASHDIR} \
135 DISTCC_DIR=/usr/src/distcc \
136 PARALLELISMFLAGS=$PARALLELISMFLAGS \
137 LINKER=$LINKER \
138 TOOLS_DIR=$TOOLS_DIR \
139 INSTALLER_DIR=$INSTALLER_DIR \
140 MACHINE="$MACHINE" \
141 MACHINE_REAL="$MACHINE_REAL" \
142 CFLAGS="$CFLAGS" \
143 CXXFLAGS="$CXXFLAGS" \
144 IFS_HOST="$IFS_HOST" \
145 IFS_TARGET="$IFS_TARGET" \
146 KVER=$KVER \
147 STAGE=$STAGE \
148 STAGE_ORDER=$STAGE_ORDER \
149 LOGFILE=$(echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g") \
150 $COMMAND
151
152 if [ $? -ne 0 ]; then
153 exiterror "chroot error"
154 else
155 stdumount
156 fi
157 } # End of entershell()
158
159
160
161 ################################################################################
162 # Common checking before entering the chroot and compilling #
163 # Return:0 caller can continue #
164 # :1 skip (nothing to do) #
165 # or fail if no script file found #
166 ################################################################################
167 lfsmakecommoncheck()
168 {
169 logger "Building $*"
170 build_spy package $1
171
172 # Script present?
173 if [ ! -f $BASEDIR/lfs/$1 ]; then
174 exiterror "No such file or directory: $BASEDIR/lfs/$1"
175 fi
176
177 local PKG_VER=$(get_pkg_ver $BASEDIR/lfs/$1)
178 beautify make_pkg "$PKG_VER $*"
179
180 # Script slipped?
181 local i
182 for i in $SKIP_PACKAGE_LIST; do
183 if [ "$i" == "$1" ]; then
184 beautify result SKIP
185 return 1
186 fi
187 done
188
189 # On debug build, we don't strip
190 if [ "$STAGE" != "toolchain" -a \
191 "$1" == "strip" -a "$BUILD_DEBUG" == "1" ]; then
192 beautify result SKIP
193 return 1
194 fi
195
196 # Don't create addons?
197 local EXTRA=$(grep ^EXTRA $BASEDIR/lfs/$1 | awk '{print $3}')
198 if [ "$EXTRA" == "yes" ] && [ "$BUILD_EXTRAS" == "0" ]; then
199 beautify result SKIP
200 return 1
201 fi
202
203 # Don't create debugging tools?
204 local DEBUG=$(grep ^DEBUG $BASEDIR/lfs/$1 | awk '{print $3}')
205 if [ "$DEBUG" == "yes" ] && [ "$BUILD_DEBUG" == "0" ]; then
206 beautify result SKIP
207 return 1
208 fi
209
210 # Searching for dependencies
211 local found message
212 for dep in $(pkg_deps $1); do
213 found=0
214 for package in $PACKAGES_DONE; do
215 if [ "$dep" = "$package" ]; then
216 found=1
217 break
218 fi
219 done
220 [ "$found" = "0" ] && message="$message $dep"
221 done
222 if [ "$message" != "" ]; then
223 message="Deps are missing: $message"
224 if [ "$EXTRA" = "yes" ]; then
225 echo -ne "${WARN}${message}${NORMAL}"
226 beautify message SKIP
227 return 1
228 else
229 exiterror "$message"
230 fi
231 fi
232
233 cd $BASEDIR/lfs && make -s -f $* MACHINE=$MACHINE LFS_BASEDIR=$BASEDIR MESSAGE="$1\t " download >> $LOGFILE 2>&1
234 if [ $? -ne 0 ]; then
235 exiterror "Download error in $1"
236 fi
237
238 distcc_reload &
239
240 return 0 # pass all!
241 } # End of lfsmakecommoncheck()
242
243 ################################################################################
244 # This is the function that builds every package in stage "toolchain" #
245 ################################################################################
246 toolchain_make() {
247 lfsmakecommoncheck $*
248 [ $? == 1 ] && return 0
249
250 local PKG_VER=$(get_pkg_ver $BASEDIR/lfs/$1)
251
252 local EXTRA_MAKE=$EXTRA_MAKE
253
254 local PKG_TIME_START=$(date +%s)
255 cd $BASEDIR/lfs && $EXTRA_MAKE make -f $* \
256 CONFIG_ROOT=$CONFIG_ROOT \
257 LINKER=$LINKER \
258 TOOLS_DIR=$TOOLS_DIR \
259 MACHINE="$MACHINE" \
260 MACHINE_REAL="$MACHINE_REAL" \
261 IFS_HOST="$IFS_HOST" \
262 IFS_TARGET="$IFS_TARGET" \
263 TARGET="$TARGET" \
264 LFS_BASEDIR=$BASEDIR \
265 LFS=$LFS \
266 INSTALLER_DIR=$INSTALLER_DIR \
267 PARALLELISMFLAGS=$PARALLELISMFLAGS \
268 KVER=$KVER \
269 STAGE=$STAGE \
270 STAGE_ORDER=$STAGE_ORDER \
271 install >> $LOGFILE 2>&1
272
273 local COMPILE_SUCCESS=$?
274 local PKG_TIME_END=$(date +%s)
275
276 if [ $COMPILE_SUCCESS -ne 0 ]; then
277 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
278 exiterror "Building $*"
279 else
280 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
281 PACKAGES_DONE="$PACKAGES_DONE $1"
282 fi
283
284 return 0
285 } # End of toolchain_make()
286
287 ################################################################################
288 # This is the function that builds every package in stage "base" and "ipfire" #
289 ################################################################################
290 ipfire_make() {
291 lfsmakecommoncheck $*
292 [ $? == 1 ] && return 0
293
294 local PKG_VER=$(get_pkg_ver $BASEDIR/lfs/$1)
295
296 local EXTRA_MAKE=$EXTRA_MAKE
297 # When cross-compiling, make sure the kernel is compiled for the target
298 [ "$MACHINE" != "$MACHINE_REAL" -a "$1" == "linux" ] && unset EXTRA_MAKE
299
300 # Also, make sure external kernel modules are compiled 64bit
301 if grep -qEi 'KERNEL_MOD = yes' $1 ; then
302 unset EXTRA_MAKE
303 fi
304
305 local PKG_TIME_START=$(date +%s)
306 chroot $LFS $TOOLS_DIR/bin/env -i \
307 HOME=/root \
308 TERM=$TERM \
309 PS1='\u:\w\$ ' \
310 PATH=$PATH \
311 CONFIG_ROOT=${CONFIG_ROOT} \
312 VERSION=${VERSION} \
313 NAME=${NAME} \
314 SNAME=${SNAME} \
315 SLOGAN="$SLOGAN" \
316 CCACHE_DIR=/usr/src/ccache \
317 CCACHE_PREFIX=${CCACHE_PREFIX} \
318 CCACHE_HASHDIR=${CCACHE_HASHDIR} \
319 DISTCC_DIR=/usr/src/distcc \
320 PARALLELISMFLAGS=$PARALLELISMFLAGS \
321 LINKER=$LINKER \
322 TOOLS_DIR=$TOOLS_DIR \
323 INSTALLER_DIR=$INSTALLER_DIR \
324 CDROM_DIR=$CDROM_DIR \
325 IMAGES_DIR=$IMAGES_DIR \
326 MACHINE="$MACHINE" \
327 MACHINE_REAL="$MACHINE_REAL" \
328 CFLAGS="$CFLAGS" \
329 CXXFLAGS="$CXXFLAGS" \
330 IFS_HOST="$IFS_HOST" \
331 IFS_TARGET="$IFS_TARGET" \
332 TARGET="$TARGET" \
333 BUILD_DEBUG=$BUILD_DEBUG \
334 BUILD_EXTRAS=$BUILD_EXTRAS \
335 KVER=$KVER \
336 STAGE=$STAGE \
337 STAGE_ORDER=$STAGE_ORDER \
338 EMB=$EMB \
339 IMAGENAME=$IMAGENAME \
340 LOGFILE=$(echo $LOGFILE | sed "s,$BASEDIR,/usr/src,g") \
341 bash -x -c "cd /usr/src/lfs && \
342 $EXTRA_MAKE make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
343
344 local COMPILE_SUCCESS=$?
345 local PKG_TIME_END=$(date +%s)
346
347 if [ $COMPILE_SUCCESS -ne 0 ]; then
348 beautify result FAIL $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
349 exiterror "Building $*"
350 else
351 beautify result DONE $[ $PKG_TIME_END - $PKG_TIME_START ] $1 $PKG_VER $STAGE_ORDER $STAGE
352 PACKAGES_DONE="$PACKAGES_DONE $1"
353 fi
354
355 return 0
356 } # End of ipfire_make()
357
358 ################################################################################
359 # This prepares the build environment #
360 ################################################################################
361 prepareenv() {
362 LOGFILE=$BASEDIR/log_${TARGET}/_build.00-preparation.log
363 export LOGFILE
364 mkdir -p $BASEDIR/log_${TARGET}/01_toolchain 2>/dev/null
365 mkdir -p $BASEDIR/log_${TARGET}/02_base 2>/dev/null
366 mkdir -p $BASEDIR/log_${TARGET}/03_${SNAME} 2>/dev/null
367 mkdir -p $BASEDIR/log_${TARGET}/04_misc 2>/dev/null
368 mkdir -p $BASEDIR/log_${TARGET}/05_installer 2>/dev/null
369 mkdir -p $BASEDIR/log_${TARGET}/06_packages 2>/dev/null
370
371 #############################################################################
372 # Are we running the right shell? #
373 #############################################################################
374
375 if [ ! "$BASH" ]; then
376 exiterror "BASH environment variable is not set. You're probably running the wrong shell."
377 fi
378
379 if [ -z "${BASH_VERSION}" ]; then
380 exiterror "Not running BASH shell."
381 fi
382
383 #############################################################################
384 # Trap on emergency exit #
385 #############################################################################
386 trap "exiterror 'Build process interrupted'" SIGINT SIGTERM SIGKILL SIGSTOP SIGQUIT
387
388
389 #############################################################################
390 # Resetting our nice level #
391 #############################################################################
392 echo -ne "Resetting our nice level to $NICE"
393 renice $NICE $$ > /dev/null
394 if [ $(nice) != "$NICE" ]; then
395 beautify message FAIL
396 exiterror "Failed to set correct nice level"
397 else
398 beautify message DONE
399 fi
400
401 # Set SCHED_BATCH
402 if [ -x /usr/bin/schedtool ]; then
403 /usr/bin/schedtool -B $$
404 if [ $? -ne 0 ]; then
405 echo -ne "Setting kernel schedular to SCHED_BATCH"
406 beautify message FAIL
407 fi
408 fi
409
410 ##############################################################################
411 # Checking if running as root user #
412 ##############################################################################
413 if [ $(id -u) != 0 ]; then
414 echo -ne "Checking if we're running as root user"
415 beautify message FAIL
416 exiterror "Not building as root"
417 fi
418
419
420 ##############################################################################
421 # Checking for necessary temporary space #
422 ##############################################################################
423 BASE_DEV=$(df -P -k $BASEDIR | tail -n 1 | awk '{ print $1 }')
424 BASE_ASPACE=$(df -P -k $BASEDIR | tail -n 1 | awk '{ print $4 }')
425 if (( 2048000 > $BASE_ASPACE )); then
426 BASE_USPACE=$(du -skx $BASEDIR | awk '{print $1}')
427 if (( 2048000 - $BASE_USPACE > $BASE_ASPACE )); then
428 echo -ne "Checking for necessary space on disk $BASE_DEV"
429 beautify message FAIL
430 exiterror "Not enough temporary space available, need at least 2GB on $BASE_DEV"
431 fi
432 fi
433
434 ##############################################################################
435 # Embedded build #
436 ##############################################################################
437
438 echo -ne "Embedded build"
439 if [ $EMB -eq 1 ]; then
440 beautify message ON
441 check_loop || exiterror "Can't build flash images on this machine."
442 else
443 beautify message OFF
444 fi
445
446 export EMB
447
448 ##############################################################################
449 # Checking CPU features #
450 ##############################################################################
451
452 check_supported_target $TARGET || \
453 exiterror "Your host doesn't have all needed cpu features for building \"$TARGET\""
454
455 ##############################################################################
456 # Building Linux From Scratch system configuration #
457 ##############################################################################
458
459 # Set umask
460 umask 022
461
462 # Set LFS Directory
463 LFS=$BASEDIR/build_${TARGET}/${SNAME}
464
465 # Check /tools symlink
466 if [ -h $TOOLS_DIR ]; then
467 rm -f $TOOLS_DIR
468 fi
469 if [ ! -a $TOOLS_DIR ]; then
470 ln -s $BASEDIR/build_${TARGET}/$TOOLS_DIR /
471 fi
472 if [ ! -h $TOOLS_DIR ]; then
473 exiterror "Could not create $TOOLS_DIR symbolic link."
474 fi
475
476 # Setup environment
477 set +h
478 LC_ALL=POSIX
479 export LFS LC_ALL
480 unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD
481
482 # Make some extra directories
483 mkdir -p $BASEDIR/build_${TARGET}/{$TOOLS_DIR,cdrom,$INSTALLER_DIR,$IMAGES_DIR} 2>/dev/null
484 mkdir -p $BASEDIR/{cache,ccache,distcc} 2>/dev/null
485 mkdir -p $BASEDIR/cache/{toolchains,patches,tarballs} 2>/dev/null
486 mkdir -p $LFS/{$TOOLS_DIR,usr/src} 2>/dev/null
487 mkdir -p $LFS/{dev,etc,proc,sys} 2>/dev/null
488 mkdir -p $LFS/dev/pts 2>/dev/null
489 mkdir -p $LFS/usr/src/{cache,config,doc,lfs,log_${TARGET},src,ccache,distcc} 2>/dev/null
490 mkdir -p $LFS/{$INSTALLER_DIR,cdrom,images} 2>/dev/null
491
492 mknod -m 600 $BASEDIR/build/dev/console c 5 1 2>/dev/null
493 mknod -m 666 $BASEDIR/build/dev/null c 1 3 2>/dev/null
494
495 # Make all sources and proc available under lfs build
496 mount --bind /dev $LFS/dev
497 mount --bind /proc $LFS/proc
498 mount --bind /sys $LFS/sys
499 mount --bind $BASEDIR/cache $LFS/usr/src/cache
500 mount --bind $BASEDIR/ccache $LFS/usr/src/ccache
501 mount --bind $BASEDIR/distcc $LFS/usr/src/distcc
502 mount --bind $BASEDIR/config $LFS/usr/src/config
503 mount --bind $BASEDIR/doc $LFS/usr/src/doc
504 mount --bind $BASEDIR/lfs $LFS/usr/src/lfs
505 mount --bind $BASEDIR/log_${TARGET} $LFS/usr/src/log_${TARGET}
506 mount --bind $BASEDIR/src $LFS/usr/src/src
507 mount --bind $BASEDIR/build_${TARGET}/$TOOLS_DIR $LFS/$TOOLS_DIR
508 mount --bind $BASEDIR/build_${TARGET}/$CDROM_DIR $LFS/$CDROM_DIR
509 mount --bind $BASEDIR/build_${TARGET}/$INSTALLER_DIR $LFS/$INSTALLER_DIR
510 mount --bind $BASEDIR/build_${TARGET}/$IMAGES_DIR $LFS/$IMAGES_DIR
511
512 # Run LFS static binary creation scripts one by one
513 export CCACHE_DIR=$BASEDIR/ccache
514 export CCACHE_HASHDIR=1
515 export CCACHE_PREFIX="distcc"
516 export DISTCC_DIR=$BASEDIR/distcc
517
518 # Remove pre-install list of installed files in case user erase some files before rebuild
519 rm -f $LFS/usr/src/lsalr 2>/dev/null
520 }
521
522 build() {
523 #a prebuilt toolchain package is only used if found in cache
524 if [ ! -d $BASEDIR/cache ]; then
525 exiterror "Use make.sh source get first!"
526 fi
527 cd $BASEDIR/cache/toolchains
528 PACKAGE=$(ls -v -r $TOOLCHAINNAME.tar.bz2 2>/dev/null | head -n 1)
529 #only restore on a clean disk
530
531 local BLD_TIME_START=$(date +%s)
532 touch $RUNNING; rm -f $FAILED $BUILD_SPY_FILENAME 2>/dev/null
533
534 echo -ne "Building for ${BOLD}${TARGET} (${MACHINE}) on ${MACHINE_REAL}${NORMAL}\n"
535
536 build_spy_send_profile
537 build_spy state compiling
538 build_spy start
539 distcc_get_hosts
540
541 if [ -f $BASEDIR/log_${TARGET}/02_base/stage2-LFS ]; then
542 prepareenv
543 echo "Using installed toolchain" >> $LOGFILE
544 beautify message DONE "Stage toolchain already built or extracted"
545 else
546 if [ -z "$PACKAGE" ]; then
547 echo "Full toolchain compilation"
548 prepareenv
549
550 check_toolchain
551
552 beautify build_stage "Building toolchain"
553 toolchain_build
554 else
555 echo "Restore from $PACKAGE"
556 cd $BASEDIR && tar jxf $BASEDIR/cache/toolchains/$PACKAGE
557 prepareenv
558 fi
559 fi
560
561 # Run distcc daemon
562 distccd_start
563
564 beautify build_stage "Building base"
565 base_build
566
567 beautify build_stage "Building $SNAME"
568 ipfire_build
569
570 beautify build_stage "Building miscellaneous"
571 misc_build
572
573 if [ "${EMB}" -eq "0" ]; then
574 beautify build_stage "Building installer"
575 installer_build
576 fi
577
578 beautify build_stage "Building packages"
579 packages_build
580
581 echo ""
582 echo "... and all this hard work for this:"
583 ls -sh $BASEDIR/${IMAGENAME}.iso
584
585 local BLD_TIME_END=$(date +%s)
586 build_spy duration $[ $BLD_TIME_END - $BLD_TIME_START ]
587 build_spy state idle
588 build_spy exit
589 rm -f $RUNNING
590 }
591
592 gettoolchain() {
593 check_user
594 DIR_TOOLCHAIN="$BASEDIR/cache/toolchains"
595 [ -d "${DIR_TOOLCHAIN}" ] || mkdir -p ${DIR_TOOLCHAIN}
596 if [ ! -f $BASEDIR/cache/toolchains/$TOOLCHAINNAME.tar.bz2 ]; then
597 URL_TOOLCHAIN=$(grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }')
598 DIR_TOOLCHAIN="$BASEDIR/cache/toolchains"
599
600 echo "Loading toolchain for $TARGET"
601 scp -2 ${IPFIRE_USER}@${URL_TOOLCHAIN}/$TOOLCHAINNAME.tar.bz2 \
602 ${DIR_TOOLCHAIN}
603 else
604 echo -n "Toolchain \"$TOOLCHAINNAME\" is already existing"
605 beautify message SKIP
606 fi
607 }
608
609 puttoolchain() {
610 check_user
611 if [ -f $BASEDIR/cache/toolchains/$TOOLCHAINNAME.tar.bz2 ]; then
612 URL_TOOLCHAIN=$(grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }')
613 DIR_TOOLCHAIN="$BASEDIR/cache/toolchains"
614
615 echo "Pushing toolchain for $TARGET"
616 scp -2 ${DIR_TOOLCHAIN}/$TOOLCHAINNAME.tar.bz2 \
617 ${IPFIRE_USER}@${URL_TOOLCHAIN}
618 else
619 echo -n "Toolchain \"$TOOLCHAINNAME\" is not existing. "
620 echo -n "Run \"./make.sh build\", first"
621 beautify message SKIP
622 fi
623 }
624
625 getsource() {
626 if [ ! -d $BASEDIR/cache ]; then
627 mkdir -p $BASEDIR/cache/{tarballs,patches}
628 fi
629 mkdir -p $BASEDIR/log_${TARGET}
630 echo -e "${BOLD}Preload all source files${NORMAL}"
631 cd $BASEDIR/lfs
632 for i in *; do
633 if [ -f "$i" -a "$i" != "Config" ]; then
634 make -s -f $i \
635 LFS_BASEDIR=$BASEDIR \
636 MESSAGE="$i\t" \
637 download 2>> $LOGFILE
638 [ $? -ne 0 ] && beautify message FAIL
639 fi
640 done
641 cd $BASEDIR
642 }
643
644 putsource() {
645 check_user
646 URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
647 REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
648
649 cd $BASEDIR/cache/tarballs/
650 for file in $(ls -1); do
651 grep -q "$file" <<<$REMOTE_FILES && continue
652 NEW_FILES="$NEW_FILES $file"
653 done
654 [ -n "$NEW_FILES" ] && scp -2 $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
655 cd $BASEDIR
656 }
657
658 puttarget() {
659 check_user
660 URL_TARGET=$(grep URL_TARGET lfs/Config | awk '{ print $3 }')
661 DIR="${BASEDIR}/${HOSTNAME}/$(date '+%Y%m%d-%0k')-${TARGET}/"
662
663 # If there is no iso, we do nothing.
664 ls ${BASEDIR}/${IMAGENAME}.* &>/dev/null || return 0
665
666 rm -rf ${BASEDIR}/${HOSTNAME} 2>/dev/null
667 mkdir -p ${DIR}
668
669 [ -e "${BASEDIR}/packages" ] && cp -al ${BASEDIR}/packages ${DIR}
670 [ -e "${BATCHLOG}" ] && \
671 python ${BASEDIR}/tools/alog2html < ${BATCHLOG} > ${DIR}/build_log.html
672 pkg_list_packages > ${DIR}/packages-list.txt
673 git_log >/dev/null; cp -l ${BASEDIR}/doc/ChangeLog ${DIR}
674 git_export; cp -l ${BASEDIR}/${SNAME}-${VERSION}.source.tar.gz ${DIR}
675 git_diff >/dev/null && cp -l ${DIFF_NAME} ${DIR}
676 cp -l ${BASEDIR}/${IMAGENAME}.* ${DIR}
677
678 cd $BASEDIR && \
679 scp -2 -r ${HOSTNAME} ${IPFIRE_USER}@${URL_TARGET} || :
680
681 rm -rf ${BASEDIR}/${HOSTNAME} 2>/dev/null
682 }