]> git.ipfire.org Git - people/stevee/ipfire-3.x.git/commitdiff
Added a new buildspy tool to loose dependency to wget.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 25 Jan 2009 15:57:29 +0000 (16:57 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 25 Jan 2009 15:57:29 +0000 (16:57 +0100)
Additionally, we have a new cool thing that fetches regularly new
distcc hosts from buildspy.

tools/buildspy [new file with mode: 0755]
tools/make-buildspy
tools/make-compilers
tools/make-constants
tools/make-git
tools/make-include

diff --git a/tools/buildspy b/tools/buildspy
new file mode 100755 (executable)
index 0000000..50daef0
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2008, 2009 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/>.       #
+#                                                                             #
+###############################################################################
+
+import os
+import sys
+
+from urlgrabber.grabber import URLGrabber
+
+URL="http://build.ipfire.org/rpc.py"
+
+data="&".join(sys.argv)
+
+g = URLGrabber(data=data)
+print g.urlread(URL)
index 8c3914e52c287fa106cc305b2d77fe092b23707c..8019b2baca906a32a5cb7d4234457a3dc1a85817 100755 (executable)
@@ -24,7 +24,7 @@ BUILD_SPY_FILENAME=$BASEDIR/.build_spy
 build_spy() {
        local KEY
        KEY=$1; shift 1
-       echo -n "&${KEY}=$*" >> $BUILD_SPY_FILENAME
+       echo -n "${KEY}=$* " >> $BUILD_SPY_FILENAME
 }
 
 build_spy_send_profile() {
@@ -35,6 +35,7 @@ build_spy_send_profile() {
        build_spy cpu      $(grep ^model\ name /proc/cpuinfo | head -n1 | \
                awk -F: '{ print $2 }' | $BASEDIR/tools/base64)
        build_spy machine  $(uname -m)
+       build_spy toolchain "${NAME}-${TOOLCHAINVERSION}"
 }
 
 if [ "$(basename $0)" == "make-buildspy" ]; then
@@ -43,9 +44,8 @@ if [ "$(basename $0)" == "make-buildspy" ]; then
                > $BUILD_SPY_FILENAME
 
                if [ -n "$DATA" ] && \
-                       wget -q -O - --user-agent="${NAME}BuildSpy/${VERSION}" \
-                               --post-data="action=set&uuid=${UUID}${DATA}" \
-                               http://build.ipfire.org/rpc.py >> $LOGFILE 2>&1; then
+                       $BASEDIR/tools/buildspy \
+                               action=set uuid=$UUID $DATA >> $LOGFILE 2>&1; then
                        DATA=""
                fi
 
index e14007fe71bd3e1e1926b17039119c40cd579c3e..55e0e84fa6371dc0bcb8a002003fc3bc3bec672e 100755 (executable)
@@ -82,8 +82,32 @@ distccd_restart() {
        distccd_start
 }
 
+distcc_get_hosts() {
+       if [ -n "$DISTCC_HOSTS" ]; then
+               logger --distcc "[INFO] Using local hosts: $DISTCC_HOSTS"
+               echo "$DISTCC_HOSTS" >> $BASEDIR/distcc/hosts
+               return 0
+       fi
+       logger --distcc "[INFO] Getting hosts..."
+       for i in $($BASEDIR/tools/buildspy uuid=$UUID action=get distcc=raw); do
+               logger --distcc "[INFO]  Got host: $i"
+               echo "$i" >> $BASEDIR/distcc/hosts_new
+       done
+       [ -s "$BASEDIR/distcc/hosts_new" ] && mv -f $BASEDIR/distcc/hosts{_new,}
+}
+
 distcc_reload() {
-       : # This will be used later...
+       local NOW=$(date "+%s")
+       [ -z "$DISTCC_RELOAD_TIMESTAMP" ] && DISTCC_RELOAD_TIMESTAMP=$NOW
+
+       # Exit if last reload is less than 5 minutes ago
+       if [ $(( $DISTCC_RELOAD_TIMESTAMP + 300 )) -ge $NOW ]; then
+               return 0
+       fi
+
+       logger --distcc "[INFO] Reloading distcc..."
+       distcc_get_hosts
+       DISTCC_RELOAD_TIMESTAMP=$NOW
 }
 
 if [ "$(basename $0)" == "make-compilers" ]; then
index e66110e7cffae7fe970b13cc2fa6488897914198..4ef8a7881f3affd6ee8b4d22ae1aae4685e62861 100644 (file)
@@ -54,7 +54,6 @@ BUILD_DEBUG=0
 PARALLELISMFLAGS=-j$(( $(grep processor < /proc/cpuinfo | wc -l) * 2 + 1 ))
 
 # Default distcc options
-DISTCC_HOSTS=localhost
 DISTCC_PORT=3632
 DISTCC_JOBS=4
 
index 8253b67f743a1ea87e971d21181444e834d5fa3d..04e70470c124af92884963b0aa93b2ae3424d585 100755 (executable)
 #
 ###############################################################################
 
-if [ -z $EDITOR ]; then
+if [ -z "$EDITOR" ]; then
        for i in nano emacs vi; do
                EDITOR=$(which $i 2>/dev/null)
-               if ! [ -z $EDITOR ]; then
+               if ! [ -z "$EDITOR" ]; then
                        export EDITOR=$EDITOR
                        break
                fi
        done
-       [ -z $EDITOR ] && exiterror "You should have installed an editor."
+       [ -z "$EDITOR" ] && exiterror "You should have installed an editor."
 fi
 
 CURRENT_BRANCH=$(git branch | grep ^* | cut -c 3-)
index 320c7323d2a9500317e53434134b1d36bb3600a4..1eb7d7a23213a1ca3690be2baa2e7d4987f8d167 100644 (file)
@@ -93,6 +93,17 @@ exiterror() {
        exit 1
 } # End of exiterror()
 
+logger() {
+       local logfile=$LOGFILE
+       case "$1" in
+               --distcc)
+                       logfile=$BASEDIR/log_$TARGET/_build.00-distcc.log
+                       shift
+                       ;;
+       esac
+       echo "$(date -u '+%b %e %T') $*" >> $logfile
+}
+
 ################################################################################
 # This is the function that sets the environment of a chroot and enters it     #
 ################################################################################
@@ -497,12 +508,10 @@ prepareenv() {
        # Run LFS static binary creation scripts one by one
        export CCACHE_DIR=$BASEDIR/ccache
        export CCACHE_HASHDIR=1
-       if [ ! -z "$DISTCC_HOSTS" ]; then
-               export CCACHE_PREFIX="distcc"
-               export DISTCC_DIR=$BASEDIR/distcc
-       fi
-       
-       [ -z "$DISTCC_HOSTS" ] || echo "$DISTCC_HOSTS" > $DISTCC_DIR/hosts
+       export CCACHE_PREFIX="distcc"
+       export DISTCC_DIR=$BASEDIR/distcc
+
+       distcc_get_hosts
 
        # Remove pre-install list of installed files in case user erase some files before rebuild
        rm -f $LFS/usr/src/lsalr 2>/dev/null