]> git.ipfire.org Git - people/ms/ipfire-3.x.git/commitdiff
Worked on buildscripts, again.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Jun 2008 10:06:40 +0000 (12:06 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 26 Jun 2008 10:06:40 +0000 (12:06 +0200)
./make.sh ---
            |`- toolchain [get|put]
             `- source    [get|put]

lfs/Config
tools/downloader
tools/make-batch
tools/make-buildspy
tools/make-check
tools/make-git
tools/make-include
tools/make-interactive

index 2932638a2268191f10a43c9da27d6a9cdd02ac5d..19b3be72300b2910b69128cce19d3675cf6fc709 100644 (file)
@@ -34,7 +34,8 @@
 # a site you should change its URL to that of a suitable mirror site.
 #
 URL_IPFIRE  = http://source.ipfire.org/download
-URL_TOOLCHAIN = http://source.ipfire.org/toolchains
+URL_TOOLCHAIN = source.ipfire.org:/pub/source/toolchains
+URL_SOURCE = source.ipfire.org:/pub/source/source-3.x
 
 # Default compiler optimizations.
 #
index 0ac4eb518e8251c7a9f380574be3def67e6f37d0..866f7a363fd9cbb6d342d6ca26a7f688a11fd132 100644 (file)
@@ -81,9 +81,9 @@ g = URLGrabber( user_agent = "IPFireSourceGrabber/3.x",
 try:
        gobj = g.urlopen(url)
 except URLGrabError, e:
-       if e.errno == 14: # 404
-               sys.stderr.write("404 - File not found.\n")
-               sys.exit(1)
+       sys.stdout.write("%s: %s" % (filename, e))
+       sys.stderr.write("Error: %s\n" % e)
+       sys.exit(1)
 
 if not gobj:
        sys.stderr.write("Unknown happended: %s\n" % (url,))
index 29488b46859f6ba7b08d82db29b1541d260170c4..4d414440d102047ec2213f078185cb7b5c7bd078 100644 (file)
@@ -25,101 +25,57 @@ BATCHLOG=$BASEDIR/log_${MACHINE}/_build.00-batch.log
 # Starts the batch process in the background                                  #
 ###############################################################################
 batch_start() {
-
-       if [ -e "$BASEDIR/.running" ]; then
+       if [ -e "$RUNNING" ]; then
                echo -n "Build is already running..."
                beautify message FAIL
                exit 1
        fi
-       
-       screen -dmS ipfire $0 batch _run
 
+       yes "y" | git_pull --batch
+       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() {
-
-       > $BATCHLOG             ## Empty the log
-       
-       yes "y" | git_pull | tee -a $BATCHLOG
-       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
-
+batch_run() {  
+       gettoolchain
+       $0 build | tee $BATCHLOG
+       batch_mail
 }
 
 ###############################################################################                   
 # A function to send an email to the developers                               #
 ###############################################################################
 batch_mail() {
-
-       ACTION=$1
-
-       SUBJECT="IPFire.org $(hostname -f):"
+       SUBJECT="IPFire.org ${HOSTNAME-$(hostname -f || hostname)} Build"
        MAILLOG=$BASEDIR/log_${MACHINE}/_mail.body.$$
-       
-       > $MAILLOG              ## Empty the log
+
+       > $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
+       evaluate
 
+       rm -f $MAILLOG
 }
index 0fb4548bd7d9b4f99bfe65f4d0d580bb703115fc..672ee34965ec7779bc5d970b8ab7ee91a7e226aa 100644 (file)
@@ -52,7 +52,7 @@ build_spy_send_profile() {
        CPU_NAME=$(grep "^model name" --max-count=1 /proc/cpuinfo | \
                        awk -F': ' '{ print $2 }')
 
-       build_spy set hostname $(hostname -f || hostname)
+       build_spy set hostname ${HOSTNAME-$(hostname -f || hostname)}
        build_spy set cpu_mhz  $CPU_MHZ
        build_spy set cpu_cnt  $CPU_CNT
        build_spy set cpu_mips $CPU_MIPS
index 75d13acde2c59fb8eadc7a2495f4a7dc7266efce..8d9ed2195a6870785ce34e8eca52a5ca490c9e0e 100644 (file)
@@ -147,3 +147,11 @@ check_sanity() {
        check_rootfiles $*
 
 }
+
+check_user() {
+       if [ -z $IPFIRE_USER ]; then
+               echo -n "You have to setup IPFIRE_USER first. See .config for details."
+               beautify message FAIL
+               exit 1
+       fi
+}
index f77ec1b09ef35fd353cda1602701853c789817d6..a34e6b6554127e39975c0f79fe0536af8c0d70d0 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # 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        #
@@ -46,48 +46,51 @@ CURRENT_BRANCH=$(git branch | grep ^* | cut -c 3-)
 ###############################################################################
 
 git_pull() {
-       if [ "$CURRENT_BRANCH" == "master" ]; then
-               if ! (git status | grep -q "working directory clean"); then
-                       echo    "Your \"master\" branch is not clean. This may cause a merge commit."
-                       echo -n "Do you want this? [y/N]"
+       if [ "$1" = "--batch" ]; then
+               shift
+               git pull $*
+       else
+               if [ "$CURRENT_BRANCH" == "master" ]; then
+                       if ! (git status | grep -q "working directory clean"); then
+                               echo    "Your \"master\" branch is not clean. This may cause a merge commit."
+                               echo -n "Do you want this? [y/N]"
+                               read
+                               [ -z $REPLY ] && exit 0
+                               for i in y Y j J; do
+                                       if [ "$i" == "$REPLY" ]; then
+                                               git pull
+                                               exit $?
+                                       fi
+                               done
+                               exit 0
+                       else
+                               git pull
+                       fi
+               else
+                       echo -n "You are not on branch \"master\". Do you want to rebase from \"master\"? [y/N]"
                        read
                        [ -z $REPLY ] && exit 0
                        for i in y Y j J; do
                                if [ "$i" == "$REPLY" ]; then
-                                       git pull
+                                       git rebase -v refs/heads/master
                                        exit $?
                                fi
                        done
-                       exit 0
-               else
-                       git pull
+                       exiterror "\"$REPLY\" is not a valid answer."
                fi
-       else
-               echo -n "You are not on branch \"master\". Do you want to rebase from \"master\"? [y/N]"
-               read
-               [ -z $REPLY ] && exit 0
-               for i in y Y j J; do
-                       if [ "$i" == "$REPLY" ]; then
-                               git rebase -v refs/heads/master
-                               exit $?
-                       fi
-               done
-               exiterror "\"$REPLY\" is not a valid answer."
        fi
 }
 
 git_push() {
-       [ -z $GIT_USER ] && exiterror "You have to setup GIT_USER first."
-
-       GIT_URL="ssh://${GIT_USER}@git.ipfire.org/pub/git/ipfire-3.x"
+       check_user
 
        [ "$CURRENT_BRANCH" == "master" ] || \
                exiterror "You have to be in branch \"master\", if you want to push."
-       git push ${GIT_URL} master
+       git push ssh://${IPFIRE_USER}@git.ipfire.org/pub/git/ipfire-3.x master
 }
 
 git_commit() {
-       . $BASEDIR/tools/make-check && check_sanity
+       check_sanity
 
        git commit $*
        
@@ -106,24 +109,23 @@ git_commit() {
 }
 
 git_diff() {
-       . $BASEDIR/tools/make-check && check_sanity
+       check_sanity
 
        echo -ne "Make a local diff to last revision"
        git diff HEAD > ipfire-diff-$(date +'%Y-%m-%d-%H:%M').diff
-       evaluate 1
+       evaluate
        echo "Diff was successfully saved to ipfire-diff-$(date +'%Y-%m-%d-%H:%M').diff"
        git diff HEAD --stat
 }
 
 git_log() {
        echo -n "Generating changelog from repository"
-       
+
        [ -z $GIT_TAG ]  || LAST_TAG=$GIT_TAG
        [ -z $LAST_TAG ] || EXT="$LAST_TAG..HEAD"
-       
+
        git log -n 500 --no-merges --pretty=medium --shortstat $EXT > $BASEDIR/doc/ChangeLog
-       
-       beautify message DONE
+       evaluate
 }
 
 git_export() {
@@ -131,7 +133,6 @@ git_export() {
 }
 
 ssh_cert() {
-
        test $# -gt 0 || exiterror "You need to pass the hostname of the remote host."
 
        SSH_KEYGEN=`which ssh-keygen`
@@ -177,12 +178,10 @@ ssh_cert() {
 
        for IP in $*; do
                echo "You will now be asked for password for $IP"
-       #       set -x
                ssh -oStrictHostKeyChecking=no $IP "mkdir -p ~/.ssh; chmod 700 ~/.ssh; \
                        echo \"$SSH1_RSA_KEY\" >> ~/.ssh/authorized_keys; \
                        echo \"$SSH2_DSA_KEY\" >> ~/.ssh/authorized_keys2; \
                        chmod 600 ~/.ssh/authorized_keys ~/.ssh/authorized_keys2"
-       #       set +x
                if test $? -eq 0; then
                        echo "Keys were put successfully"
                else
@@ -195,11 +194,7 @@ ssh_cert() {
                        echo -n "Checking $IP connectivity by ssh$ver... "
                        ssh -q -oProtocol=${ver} -oBatchMode=yes \
                          -oStrictHostKeyChecking=no $IP /bin/true
-                       if [ $? -eq 0 ]; then
-                               echo "OK"
-                       else
-                               echo "failed" 1>&2
-                       fi
+                       evaluate
                done
        done
 }
index 5c2d9f08356394a1726948a55eda8eb30543b0e3..78253f147d7fc3e7b6aa3b5be57739227e853013 100644 (file)
@@ -126,7 +126,6 @@ mkdir $BASEDIR/log_${MACHINE}/ 2>/dev/null
 
 # Set up what used to be /tools
 TOOLS_DIR=/tools_${MACHINE}
-CTOOLS_DIR=/cross-tools_${MACHINE}
 
 # Set up /installer
 INSTALLER_DIR=/installer
@@ -147,6 +146,9 @@ UCLIBC_CC_CORE_STATIC_DIR=${UCLIBC_DIR}/gcc-core-static
 #UCLIBC_SYSROOT_DIR=${UCLIBC_DIR}/${UCLIBC_TARGET}/sys-root
 UCLIBC_SYSROOT_DIR=${INSTALLER_DIR}
 
+# A file that indicates that we are running
+RUNNING=$BASEDIR/.running
+
 ###############################################################################
 #
 # Beautifying variables & presentation & input output interface
@@ -181,14 +183,49 @@ SET_TIME_COL="\\033[${TIME_COL}G"
 SET_VER_COL="\\033[${VER_COL}G"
 SET_OPT_COL="\\033[${OPT_COL}G"
 
-# Define color for messages
-BOLD="\\033[1;39m"
-DONE="\\033[1;32m"
-SKIP="\\033[1;34m"
-WARN="\\033[1;35m"
-FAIL="\\033[1;31m"
-NORMAL="\\033[0;39m"
-
+# Normal colors
+CLR_NORM_BLK="\\033[0;30m"    # black
+CLR_NORM_RED="\\033[0;31m"    # red
+CLR_NORM_GRN="\\033[0;32m"    # green
+CLR_NORM_YEL="\\033[0;33m"    # yellow
+CLR_NORM_BLU="\\033[0;34m"    # blue
+CLR_NORM_MAG="\\033[0;35m"    # magenta
+CLR_NORM_CYN="\\033[0;36m"    # cyan
+CLR_NORM_WHT="\\033[0;37m"    # white
+CLR_NORM_GRY="\\033[0;39m"    # grey
+
+# Emphased colors
+CLR_BOLD_BLK="\\033[1;30m"    # black
+CLR_BOLD_RED="\\033[1;31m"    # red
+CLR_BOLD_GRN="\\033[1;32m"    # green
+CLR_BOLD_YEL="\\033[1;33m"    # yellow
+CLR_BOLD_BLU="\\033[1;34m"    # blue
+CLR_BOLD_MAG="\\033[1;35m"    # magenta
+CLR_BOLD_CYN="\\033[1;36m"    # cyan
+CLR_BOLD_WHT="\\033[1;37m"    # white
+CLR_BOLD_GRY="\\033[1;39m"    # grey
+
+# Background colors
+CLR_BACK_BLK="\\033[40m"      # black
+CLR_BACK_RED="\\033[41m"      # red
+CLR_BACK_GRN="\\033[42m"      # green
+CLR_BACK_YEL="\\033[43m"      # yellow
+CLR_BACK_BLU="\\033[44m"      # blue
+CLR_BACK_MAG="\\033[45m"      # magenta
+CLR_BACK_CYN="\\033[46m"      # cyan
+CLR_BACK_WHT="\\033[47m"      # white
+
+# Action colors
+BOLD=$CLR_BOLD_GRY
+DONE=$CLR_BOLD_GRN
+SKIP=$CLR_BOLD_BLU
+WARN=$CLR_BOLD_MAG
+FAIL=$CLR_BOLD_RED
+NORMAL=$CLR_NORM_GRY
+
+# Color hooks
+BRACKET_L="${CLR_BOLD_BLU}[${NORMAL}"
+BRACKET_R="${CLR_BOLD_BLU}]${NORMAL}"
 
 ################################################################################
 #                                                                              #
@@ -203,17 +240,13 @@ NORMAL="\\033[0;39m"
 . $BASEDIR/tools/make-git
 
 evaluate() {
-       if [ "$?" -eq "0" ]; then
+       RETVAL=$?
+       if [ "$RETVAL" -eq "0" ]; then
                beautify message DONE
        else
-               EXITCODE=$1
-               shift 1
                beautify message FAIL
-               $*
-               if [ $EXITCODE -ne "0" ]; then
-                       exit $EXITCODE
-               fi
        fi
+       (exit $RETVAL)
 }
 
 position_cursor()
@@ -253,26 +286,16 @@ beautify()
        case "$1" in
                message)
                        MESSAGE="$3"
+                       echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}${BRACKET_L}"
                        case "$2" in
-                               DONE)
-                                       echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
-                                       ;;
-                               WARN)
-                                       echo -ne "${WARN}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${WARN} WARN ${NORMAL}]\n"
-                                       ;;      
-                               FAIL)
-                                       echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
-                                       ;;
-                               SKIP)
-                                       echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
-                                       ;;
-                               ON)
-                                       echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${DONE}  ON  ${NORMAL}]\n"
-                                       ;;
-                               OFF)
-                                       echo -ne "${BOLD}${MESSAGE}${NORMAL}${SET_RESULT_COL}[${FAIL} OFF  ${NORMAL}]\n"
-                                       ;;
+                               DONE) echo -ne "${DONE} DONE ${NORMAL}";;
+                               WARN) echo -ne "${WARN} WARN ${NORMAL}";;
+                               FAIL) echo -ne "${FAIL} FAIL ${NORMAL}";;
+                               SKIP) echo -ne "${SKIP} SKIP ${NORMAL}";;
+                               ON|ENAB*) echo -ne "${DONE} ENAB ${NORMAL}";;
+                               OFF|DISA*) echo -ne "${FAIL} DISA ${NORMAL}";;
                        esac
+                       echo -ne "${BRACKET_R}\n"
                        ;;
                build_stage)
                        MESSAGE=$2
@@ -286,14 +309,14 @@ beautify()
 
                                echo -ne "${PROGRAM}"
                                if ! [ "$OPTIONS" == "" ]; then
-                                       echo -ne "${SET_OPT_COL}[ ${BOLD}${OPTIONS}${NORMAL} ]"
+                                       echo -ne "${SET_OPT_COL}${BRACKET_L} ${BOLD}${OPTIONS}${NORMAL} ${BRACKET_R}"
                                fi
 
                                if [ "${PKG_VER}" == "${SNAME}" ] || [ "${PKG_VER}" == "LFS" ]; then
                                        echo -ne "${SET_RESULT_COL}"
                                else
-                                       echo -ne "${SET_VER_COL}[ ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
-                                       echo -ne "${NORMAL} ]${SET_RESULT_COL}"
+                                       echo -ne "${SET_VER_COL}${BRACKET_L} ${BOLD}${SET_VER_COL_REAL}${PKG_VER}"
+                                       echo -ne "${NORMAL} ${BRACKET_R}${SET_RESULT_COL}"
                                fi
                        done
                        ;;
@@ -307,19 +330,11 @@ beautify()
                        fi
 
                        SET_TIME_COL_REAL=`position_cursor $RESULT_COL $PKG_TIME -3`
+                       echo -ne "${SET_TIME_COL}${BRACKET_L} ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ${BRACKET_R}"
                        case "$RESULT" in
-                               DONE)
-                                       echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
-                                       echo -ne "${SET_RESULT_COL}[${DONE} DONE ${NORMAL}]\n"
-                                       ;;
-                               FAIL)
-                                       echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
-                                       echo -ne "${SET_RESULT_COL}[${FAIL} FAIL ${NORMAL}]\n"
-                                       ;;
-                               SKIP)
-                                       echo -ne "${SET_TIME_COL}[ ${BOLD}${SET_TIME_COL_REAL}$PKG_TIME${NORMAL} ]"
-                                       echo -ne "${SET_RESULT_COL}[${SKIP} SKIP ${NORMAL}]\n"
-                                       ;;
+                               DONE) echo -ne "${SET_RESULT_COL}${BRACKET_L}${DONE} DONE ${NORMAL}${BRACKET_R}\n";;
+                               FAIL) echo -ne "${SET_RESULT_COL}${BRACKET_L}${FAIL} FAIL ${NORMAL}${BRACKET_R}\n";;
+                               SKIP) echo -ne "${SET_RESULT_COL}${BRACKET_L}${SKIP} SKIP ${NORMAL}${BRACKET_R}\n";;
                        esac
                        ;;
        esac
@@ -357,13 +372,14 @@ stdumount() {
 
 exiterror() {
        stdumount
-       
+
        beautify message FAIL
+
        echo -ne "${FAIL}ERROR${NORMAL}: ${BOLD}$*${NORMAL}\n"
        [ -z "$LOGFILE" ] || \
        echo "       Check $LOGFILE for errors if applicable"
        build_spy error
+       rm -f $RUNNING
        exit 1
 } # End of exiterror()
 
@@ -470,7 +486,6 @@ toolchain_make() {
                CONFIG_ROOT=$CONFIG_ROOT \
                LINKER=$LINKER \
                TOOLS_DIR=$TOOLS_DIR \
-               CTOOLS_DIR=$CTOOLS_DIR \
                MACHINE="$MACHINE" \
                MACHINE_REAL="$MACHINE_REAL" \
                IFS_HOST="$IFS_HOST" \
@@ -585,7 +600,6 @@ ipfire_make() {
 # This prepares the build environment                                          #
 ################################################################################
 prepareenv() {
-
        LOGFILE=$BASEDIR/log_${MACHINE}/_build.00-preparation.log
        export LOGFILE
        mkdir -p $BASEDIR/log_${MACHINE}/01_toolchain 2>/dev/null
@@ -772,6 +786,7 @@ build() {
        #only restore on a clean disk
 
        local BLD_TIME_START=`date +%s`
+       touch $RUNNING
 
        echo -ne "Building for ${BOLD}${TARGET} (${MACHINE}) on ${MACHINE_REAL}${NORMAL}\n"
 
@@ -820,27 +835,71 @@ build() {
        local BLD_TIME_END=`date +%s`
        build_spy set duration $[ $BLD_TIME_END - $BLD_TIME_START ]
        build_spy idle
+       rm -f $RUNNING
 }
 
 gettoolchain() {
+       check_user
        if [ ! -f $BASEDIR/cache/toolchains/$TOOLCHAINNAME.tar.bz2 ]; then
                URL_TOOLCHAIN=$(grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }')
                DIR_TOOLCHAIN="$BASEDIR/cache/toolchains"
 
                echo "Loading toolchain for $MACHINE"
-               BASEDIR=$BASEDIR DIR_TMP=/tmp DIR_DL=$DIR_TOOLCHAIN \
-                       sh $BASEDIR/tools/downloader $URL_TOOLCHAIN $TOOLCHAINNAME.tar.bz2
-
-               if [ $? -eq 0 ]; then
-                       echo -n "Toolchain was successfully downloaded"
-                       beautify message DONE
-               else
-                       echo -n "ERROR: Downloading toolchain \"$TOOLCHAINNAME\""
-                       beautify message FAIL
-                       echo "Precompiled toolchain not always available for every machine"
-               fi
+               scp -2C ${IPFIRE_USER}@${URL_TOOLCHAIN}/$TOOLCHAINNAME.tar.bz2 \
+                       ${DIR_TOOLCHAIN}
        else
                echo -n "Toolchain \"$TOOLCHAINNAME\" is already existing"
                beautify message SKIP
        fi
 }
+
+puttoolchain() {
+       check_user
+       if [ -f $BASEDIR/cache/toolchains/$TOOLCHAINNAME.tar.bz2 ]; then
+               URL_TOOLCHAIN=$(grep URL_TOOLCHAIN lfs/Config | awk '{ print $3 }')
+               DIR_TOOLCHAIN="$BASEDIR/cache/toolchains"
+
+               echo "Pushing toolchain for $MACHINE"
+               scp -2C ${DIR_TOOLCHAIN}/$TOOLCHAINNAME.tar.bz2 \
+                       ${IPFIRE_USER}@${URL_TOOLCHAIN}
+       else
+               echo -n "Toolchain \"$TOOLCHAINNAME\" is not existing. "
+               echo -n "Run \"./make.sh build\", first"
+               beautify message SKIP
+       fi
+}
+
+getsource() {
+       if [ ! -d $BASEDIR/cache ]; then
+               mkdir -p $BASEDIR/cache/{tarballs,patches}
+       fi
+       mkdir -p $BASEDIR/log_${MACHINE}
+       echo -e "${BOLD}Preload all source files${NORMAL}"
+       cd $BASEDIR/lfs
+       for i in *; do
+               if [ -f "$i" -a "$i" != "Config" ]; then
+                       make -s -f $i \
+                       LFS_BASEDIR=$BASEDIR \
+                       MESSAGE="$i\t" \
+                       SSP=$SSP \
+                       PIE=$PIE \
+                       PAX=$PAX download 2>> $LOGFILE
+                       [ $? -ne 0 ] && beautify message FAIL
+               fi
+       done
+       cd $BASEDIR
+}
+
+putsource() {
+       check_user
+       URL_SOURCE=$(grep URL_SOURCE lfs/Config | awk '{ print $3 }')
+       REMOTE_FILES=$(echo "ls -1" | sftp -C ${IPFIRE_USER}@${URL_SOURCE})
+
+       cd $BASEDIR/cache/tarballs/
+       for file in $(ls -1); do
+               grep -q "$file" <<<$REMOTE_FILES && continue
+               NEW_FILES="$NEW_FILES $file"
+       done
+       [ -n "$NEW_FILES" ] && scp -2C $NEW_FILES ${IPFIRE_USER}@${URL_SOURCE}
+       cd $BASEDIR
+}
index 7e9c1f382e764485b122ccfadbb830dbe11bbb70..fa055a534b41faf8acc5c30cc8c6c91b005061e1 100644 (file)
@@ -89,53 +89,52 @@ clean)
        beautify message DONE
        ;;
 
-downloadsrc)
+source|src)
        LOGFILE=$BASEDIR/log_${MACHINE}/_build.00-preparation.log
-       
-       if [ ! -d $BASEDIR/cache ]; then
-               mkdir -p $BASEDIR/cache/{tarballs,patches}
-       fi
-       mkdir -p $BASEDIR/log_${MACHINE}
-       echo -e "${BOLD}Preload all source files${NORMAL}"
-       cd $BASEDIR/lfs
-       for i in *; do
-               if [ -f "$i" -a "$i" != "Config" ]; then
-                       make -s -f $i LFS_BASEDIR=$BASEDIR MESSAGE="$i\t" download 2>> $LOGFILE
-                       if [ $? -ne 0 ]; then
-                               echo -ne "Couldn't download all files for ${BOLD}${i}${NORMAL}"
-                               beautify message FAIL
-                       fi
-               fi
-       done
-       cd - >/dev/null 2>&1
+       case "$2" in
+               get|pull|download)
+                       getsource
+                       ;;
+               put|push|upload)
+                       putsource
+                       ;;
+       esac
        ;;
 
 toolchain)
-       prepareenv
-       # Check if host can build the toolchain
-       check_toolchain
+       case "$2" in
+               get|pull|download)
+                       gettoolchain
+                       ;;
+               put|push|upload)
+                       puttoolchain
+                       ;;
+               "")
+                       prepareenv
+                       # Check if host can build the toolchain
+                       check_toolchain
 
-       build_spy compiling
+                       build_spy compiling
 
-       toolchain_build
-       
-       stdumount
-       echo -ne "\ntarball creation "
-       [ -d $BASEDIR/cache/toolchains ] || mkdir $BASEDIR/cache/toolchains
-       cd $BASEDIR && tar cj --exclude='log_${MACHINE}/_build.*.log' \
-               --file=cache/toolchains/$TOOLCHAINNAME.tar.bz2 \
-               build_${MACHINE} log_${MACHINE} >> $LOGFILE
-       beautify message DONE
-       echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2`
-       md5sum cache/toolchains/$TOOLCHAINNAME.tar.bz2 \
-               > cache/toolchains/$TOOLCHAINNAME.tar.bz2.md5
-       stdumount
+                       toolchain_build
 
-       build_spy idle
-       ;;
+                       stdumount
+                       echo -ne "\ntarball creation "
+                       [ -d $BASEDIR/cache/toolchains ] || mkdir $BASEDIR/cache/toolchains
+                       cd $BASEDIR && tar cj --exclude='log_${MACHINE}/_build.*.log' \
+                               --file=cache/toolchains/$TOOLCHAINNAME.tar.bz2 \
+                               build_${MACHINE} log_${MACHINE} >> $LOGFILE
+                       beautify message DONE
+                       echo `ls -sh cache/toolchains/$TOOLCHAINNAME.tar.bz2`
+
+                       stdumount
 
-gettoolchain)
-       gettoolchain
+                       build_spy idle
+                       ;;
+               *)
+                       usage
+                       ;;
+       esac
        ;;
 
 check)
@@ -173,32 +172,6 @@ g[iu]t)
        esac
        ;;
 
-uploadsrc)
-       PWD=`pwd`
-       cd $BASEDIR/cache/
-       echo -e "Uploading cache to ftp server:"
-       for i in *; do
-               echo "${i}" | fgrep -q .md5 && continue
-               [ -e ${i}.md5 ] && continue
-               md5sum ${i} | tee ${i}.md5
-       done
-       ncftpls -u $FTP_CACHE_USER -p $FTP_CACHE_PASS ftp://$FTP_CACHE_URL/$FTP_CACHE_PATH/ > /tmp/ftplist
-       for i in *; do
-               if [ "$(basename $i)" == "toolchains" ]; then continue; fi
-               grep -q $(basename $i) /tmp/ftplist
-               if [ "$?" -ne "0" ]; then
-                       echo -ne "$(basename $i)"
-                       ncftpput -u $FTP_CACHE_USER -p $FTP_CACHE_PASS $FTP_CACHE_URL $FTP_CACHE_PATH/ $(basename $i)
-                       if [ "$?" -ne "0" ]; then
-                               beautify message FAIL
-                       fi
-               fi
-       done
-       rm -f /tmp/ftplist
-       cd $PWD
-       exit 0
-       ;;
-
 *)
        usage
        ;;