--- /dev/null
+#!/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)
build_spy() {
local KEY
KEY=$1; shift 1
- echo -n "&${KEY}=$*" >> $BUILD_SPY_FILENAME
+ echo -n "${KEY}=$* " >> $BUILD_SPY_FILENAME
}
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
> $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
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
PARALLELISMFLAGS=-j$(( $(grep processor < /proc/cpuinfo | wc -l) * 2 + 1 ))
# Default distcc options
-DISTCC_HOSTS=localhost
DISTCC_PORT=3632
DISTCC_JOBS=4
#
###############################################################################
-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-)
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 #
################################################################################
# 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