From: Michael Tremer Date: Sun, 25 Jan 2009 15:57:29 +0000 (+0100) Subject: Added a new buildspy tool to loose dependency to wget. X-Git-Tag: v3.0-alpha1~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=469d71b4de16cc6d1fb05172e4a184001e00c564;p=ipfire-3.x.git Added a new buildspy tool to loose dependency to wget. Additionally, we have a new cool thing that fetches regularly new distcc hosts from buildspy. --- diff --git a/tools/buildspy b/tools/buildspy new file mode 100755 index 000000000..50daef0e7 --- /dev/null +++ b/tools/buildspy @@ -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 . # +# # +############################################################################### + +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) diff --git a/tools/make-buildspy b/tools/make-buildspy index 8c3914e52..8019b2bac 100755 --- a/tools/make-buildspy +++ b/tools/make-buildspy @@ -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 diff --git a/tools/make-compilers b/tools/make-compilers index e14007fe7..55e0e84fa 100755 --- a/tools/make-compilers +++ b/tools/make-compilers @@ -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 diff --git a/tools/make-constants b/tools/make-constants index e66110e7c..4ef8a7881 100644 --- a/tools/make-constants +++ b/tools/make-constants @@ -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 diff --git a/tools/make-git b/tools/make-git index 8253b67f7..04e70470c 100755 --- a/tools/make-git +++ b/tools/make-git @@ -26,15 +26,15 @@ # ############################################################################### -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-) diff --git a/tools/make-include b/tools/make-include index 320c7323d..1eb7d7a23 100644 --- a/tools/make-include +++ b/tools/make-include @@ -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