--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+BATCHLOG=$BASEDIR/log_${MACHINE}/_build.00-batch.log
+
+###############################################################################
+# Starts the batch process in the background #
+###############################################################################
+batch_start() {
+
+ if ( screen -ls | grep -q [i]pfire ); then
+ echo -n "Build is already running..."
+ beautify message FAIL
+ exit 1
+ fi
+
+ screen -dmS ipfire $0 batch _run
+}
+
+###############################################################################
+# Run this to check what is going on in the moment #
+###############################################################################
+batch_attach() {
+
+ screen -x ipfire
+ if [ "$?" -eq "0" ]; then
+ beautify message DONE
+ else
+ beautify message FAIL
+ fi
+
+}
+
+###############################################################################
+# This is the main batch function that runs one thing after an other #
+###############################################################################
+batch_run() {
+
+ . $BASEDIR/tools/make-subversion
+
+ > $BATCHLOG ## Empty the log
+
+ svn_up | tee -a $BATCHLOG
+ $0 build | tee -a $BATCHLOG
+ if [ "$?" -ne "0" ]; then
+ batch_error
+ fi
+
+ ## place uploading here
+
+ batch_success
+
+}
+
+###############################################################################
+# Do this when everything finished fine #
+###############################################################################
+batch_success() {
+
+ batch_mail success ## Send an okay message
+
+}
+
+###############################################################################
+# Do this when an error occured #
+###############################################################################
+batch_error() {
+
+ batch_mail failed ## Send an error message
+
+}
+
+###############################################################################
+# A function to send an email to the developers #
+###############################################################################
+batch_mail() {
+
+ ACTION=$1
+
+ SUBJECT="IPFire.org $(hostname -f):"
+ MAILLOG=$BASEDIR/log_${MACHINE}/_mail.body.$$
+
+ > $MAILLOG ## Empty the log
+
+ ## Form the message header
+ echo -e "From: $MAIL_FROM\nTo: $MAIL_TO" >> $MAILLOG
+ if [ "$ACTION" = "success" ]; then
+ SUBJECT="$SUBJECT success!"
+ else
+ SUBJECT="$SUBJECT failure!"
+ fi
+ echo -e "Subject: $SUBJECT\n" >> $MAILLOG
+
+ ## Remove the colors when sending an email
+ # This has to be done better by anything else
+ sed -e 's@.\[.;..m@@g' < $BATCHLOG >> $MAILLOG
+
+ ## Send the email
+ python tools/sendEmail < $MAILLOG
+
+ if [ "$?" -eq "0" ]; then
+ beautify message DONE
+ else
+ beautify message FAIL
+ fi
+ rm -f $MAILLOG
+}
###############################################################################
# #
# IPFire.org - A linux based firewall #
-# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
+# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
beautify message FAIL
fi
}
+
+distcc_mon() {
+
+ INTERVAL=1 # in seconds
+
+ if [ -e $BASEDIR/distcc ]; then
+ while sleep $INTERVAL; do
+ clear
+ PATH=$PATH:build_${MACHINE}/usr/local/distcc/bin \
+ DISTCC_DIR=${BASEDIR}/distcc \
+ distccmon-text
+ done
+ else
+ echo -n "You can't access the statistics if you didn't run ./make.sh build"
+ beautify message FAIL
+ fi
+}
rm -f $LFS/usr/src/lsalr 2>/dev/null
}
-batch_script() {
- echo -ne "${BOLD}***This is our auto buildscript! Have fun...${NORMAL}\n"
-
- if [ "$IPFIRE_REBUILD" -eq "0" ]; then
- export IPFIRE_START_TIME=`date`
- evaluate 1
-
- echo "### RUNNING SVN-UPDATE"
- $0 svn update
- evaluate 1 mail_me SVNUPDATE
-
- echo "### EXPORT SOURCES"
- $0 svn dist
- evaluate 1 mail_me SVNDIST
+build() {
+ clear
+ #a prebuilt toolchain package is only used if found in cache
+ if [ ! -d $BASEDIR/cache ]; then
+ exiterror "Use make.sh downloadsrc first!"
fi
+ cd $BASEDIR/cache/toolchains
+ PACKAGE=`ls -v -r $TOOLCHAINNAME.tar.bz2 2> /dev/null | head -n 1`
+ #only restore on a clean disk
- echo "### RUNNING BUILD"
- $0 build #--devel
- evaluate 1 mail_me ERROR
-
- echo "### UPLOADING ISO"
- $0 upload iso
- evaluate 1 mail_me ISO
+ echo -ne "Building for ${BOLD}${MACHINE}-${TARGET} on ${MACHINE_REAL}${NORMAL}\n"
- echo -ne "### UPLOADING PAKS"
- $0 upload paks
- evaluate 1 mail_me PAKS
+ if [ -f $BASEDIR/log_${MACHINE}/02_base/stage2-LFS ]; then
+ prepareenv
+ echo "Using installed toolchain" >> $LOGFILE
+ beautify message DONE "Stage toolchain already built or extracted"
+ else
+ if [ -z "$PACKAGE" ]; then
+ echo "Full toolchain compilation" | tee -a $LOGFILE
+ prepareenv
+
+ . $BASEDIR/tools/make-check
+ check_toolchain
+
+ beautify build_stage "Building toolchain"
+ toolchain_build
+ else
+ echo "Restore from $PACKAGE" | tee -a $LOGFILE
+ if [ `md5sum $BASEDIR/cache/toolchains/$PACKAGE | awk '{print $1}'` == `cat $BASEDIR/cache/toolchains/$TOOLCHAINNAME.md5 | awk '{print $1}'` ]; then
+ cd $BASEDIR && tar jxf $BASEDIR/cache/toolchains/$PACKAGE
+ prepareenv
+ else
+ exiterror "$TOOLCHAINNAME md5 did not match, check downloaded package"
+ fi
+ fi
+ fi
+
+ beautify build_stage "Building base"
+ base_build
- echo -ne "${BOLD}***SUCCESS!${NORMAL}"
- mail_me success
- exit 0
-}
+ beautify build_stage "Building $SNAME"
+ ipfire_build
-watch_screen() {
- echo -e "${BOLD}Exit with Ctrl+A, Ctrl+D.${NORMAL}"
- sleep 0.5
- screen -x ipfire
-}
+ beautify build_stage "Building miscellaneous"
+ misc_build
-mail_me() {
- echo "From: $MAIL_FROM" > /tmp/ipfire_mail_body.$$
- echo "To: $MAIL_TO" >> /tmp/ipfire_mail_body.$$
- case "$1" in
- success)
- cat <<END >> /tmp/ipfire_mail_body.$$
-Subject: SUCCESS: IPFIRE-BUILD R$SVN_REVISION on `hostname`
-Building IPFire on `hostname` in Revision $SVN_REVISION was successfull!
-You can find the ISO on your ftp server if you told the script where it is.
-
-Statistics:
------------
-Started: $IPFIRE_START_TIME
-Finished: `date`
-
-Best Regards
-Your IPFire-Build-Script
-
-END
- echo -ne "${BOLD}***Sending success message${NORMAL}"
- ;;
- *)
- cat <<END >> /tmp/ipfire_mail_body.$$
-Subject: ERROR $1: IPFIRE-BUILD R$SVN_REVISION on `hostname`
-When I was building IPFire on `hostname`, I have found an ERROR with name $1!
-Here you can see the logs and detect the reason for this error.
-
-Best Regards
-Your IPFire-Build-Script
-
-
-Here is a summary... The full logs are in the attachment.
----------------------------------------------------------
-
-`tail log/_*`
-END
- echo -ne "${BOLD}***Sending error message${NORMAL}"
- ;;
- esac
+ beautify build_stage "Building installer"
+ installer_build
-sleep 15
- python tools/sendEmail < /tmp/ipfire_mail_body.$$
- if [ "$?" -eq "0" ]; then
- beautify message DONE
- else
- beautify message FAIL
- fi
- rm -f /tmp/ipfire_mail_body.$$
+ beautify build_stage "Building packages"
+ packages_build
+
+ echo ""
+ echo "... and all this hard work for this:"
+ du -bsh $BASEDIR/${SNAME}-${VERSION}.${MACHINE}.iso
}
-
###############################################################################
# #
# IPFire.org - A linux based firewall #
-# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
+# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
case "$1" in
build)
- clear
- #a prebuilt toolchain package is only used if found in cache
- if [ ! -d $BASEDIR/cache ]; then
- exiterror "Use make.sh downloadsrc first!"
- fi
- cd $BASEDIR/cache/toolchains
- PACKAGE=`ls -v -r $TOOLCHAINNAME.tar.bz2 2> /dev/null | head -n 1`
- #only restore on a clean disk
-
- echo -ne "Building for ${BOLD}${MACHINE}-${TARGET} on ${MACHINE_REAL}${NORMAL}\n"
-
- if [ -f $BASEDIR/log_${MACHINE}/02_base/stage2-LFS ]; then
- prepareenv
- echo "Using installed toolchain" >> $LOGFILE
- beautify message DONE "Stage toolchain already built or extracted"
- else
- if [ -z "$PACKAGE" ]; then
- echo "Full toolchain compilation" | tee -a $LOGFILE
- prepareenv
-
- . $BASEDIR/tools/make-check
- check_toolchain
-
- beautify build_stage "Building toolchain"
- toolchain_build
- else
- echo "Restore from $PACKAGE" | tee -a $LOGFILE
- if [ `md5sum $BASEDIR/cache/toolchains/$PACKAGE | awk '{print $1}'` == `cat $BASEDIR/cache/toolchains/$TOOLCHAINNAME.md5 | awk '{print $1}'` ]; then
- cd $BASEDIR && tar jxf $BASEDIR/cache/toolchains/$PACKAGE
- prepareenv
- else
- exiterror "$TOOLCHAINNAME md5 did not match, check downloaded package"
- fi
- fi
- fi
-
- beautify build_stage "Building base"
- base_build
-
- beautify build_stage "Building $SNAME"
- ipfire_build
-
- beautify build_stage "Building miscellaneous"
- misc_build
-
- beautify build_stage "Building installer"
- installer_build
-
- beautify build_stage "Building packages"
- packages_build
-
- echo ""
- echo "... and all this hard work for this:"
- du -bsh $BASEDIR/${SNAME}-${VERSION}.${MACHINE}.iso
+ # compile the distro right now
+ build
;;
shell)
prepareenv
entershell
;;
+
+batch)
+ # build the distro in background
+ . $BASEDIR/tools/make-batch
+ case "$2" in
+ start)
+ batch_start
+ ;;
+ _run)
+ batch_run
+ ;;
+ attach|watch)
+ batch_attach
+ ;;
+ esac
+ ;;
+
+stats)
+ # show some stats about the compiler(s)
+ . $BASEDIR/tools/make-compilers
+
+ case "$2" in
+ ccache)
+ ccache_stats
+ ;;
+ distcc)
+ distcc_mon
+ ;;
+ esac
+ ;;
clean)
echo -ne "Cleaning ${BOLD}$MACHINE${NORMAL} buildtree"
esac
;;
-batch)
- if [ "$2" = "--background" ]; then
- batch_script
- exit $?
- fi
- if [ `screen -ls | grep -q ipfire` ]; then
- echo "Build is already running, sorry!"
- exit 1
- else
- if [ "$2" = "--rebuild" ]; then
- export IPFIRE_REBUILD=1
- echo "REBUILD!"
- else
- export IPFIRE_REBUILD=0
- fi
- echo -en "${BOLD}***IPFire-Batch-Build is starting...${NORMAL}"
- screen -dmS ipfire $0 batch --background
- evaluate 1
- exit 0
- fi
- ;;
-
-watch|attach)
- watch_screen
- ;;
-
-ccache)
- . $BASEDIR/tools/make-compilers
- ccache_stats
- ;;
-
*)
cat doc/make.sh-usage
;;