]> git.ipfire.org Git - ipfire-3.x.git/blobdiff - tools/make-compilers
Added new package: dosfstools.
[ipfire-3.x.git] / tools / make-compilers
index 848f6de725d1fe8b06ce6e58569d950ceb6aeb1c..4400b9da1839acee57c8c44ef7f27042e1a4dc90 100755 (executable)
@@ -21,7 +21,7 @@
 
 ccache_stats() {
        if [ -e $BASEDIR/ccache ]; then
-               PATH=$PATH:build_${MACHINE}/tools_${MACHINE}/usr/bin \
+               PATH=$PATH:build_${TARGET}/${TOOLS_DIR}/usr/bin \
                CCACHE_DIR=${BASEDIR}/ccache \
                ccache -s
        else
@@ -32,6 +32,15 @@ ccache_stats() {
 
 distcc_mon() {
 
+       # run gnome thing if we can...
+       if [ -n "$DISPLAY" ]; then
+               monitor=$(which distccmon-gnome 2>/dev/null)
+               if [ -n "$monitor" ]; then
+                       DISTCC_DIR=$BASEDIR/distcc $monitor &
+                       return 0
+               fi
+       fi
+
        INTERVAL=1 # in seconds
 
        if [ -e $BASEDIR/distcc ]; then
@@ -39,7 +48,7 @@ distcc_mon() {
                        clear
                        echo "$NAME - Distcc monitor - Cancel with ctrl+c"
                        echo
-                       PATH=$PATH:build_${MACHINE}/tools_${MACHINE}/usr/bin \
+                       PATH=$PATH:build_${TARGET}/${TOOLS_DIR}/usr/bin \
                        DISTCC_DIR=${BASEDIR}/distcc \
                        distccmon-text
                done
@@ -51,7 +60,15 @@ distcc_mon() {
 
 distccd_start() {
        echo -n "Running distcc daemon"
-       TOOLS_DIR=$TOOLS_DIR $BASEDIR/tools/make-compilers &
+
+       if [ "$DISTCC_PORT" == "0" ]; then
+               beautify message DISA
+               return
+       fi
+
+       TOOLS_DIR=$TOOLS_DIR DISTCC_PORT=$DISTCC_PORT DISTCC_JOBS=$DISTCC_JOBS \
+               LOGFILE=$BASEDIR/log_${TARGET}/_build.00-distccd.log \
+               $BASEDIR/tools/make-compilers &
        if [ "$?" -eq "0" ]; then
                beautify message DONE
        else
@@ -60,8 +77,8 @@ distccd_start() {
 }
 
 distccd_stop() {
-       echo "Stopping distcc daemon"
-       killall distccd
+       echo -n "Stopping distcc daemon"
+       killall distccd &>/dev/null
        if [ "$?" -eq "0" ]; then
                beautify message DONE
        else
@@ -69,19 +86,54 @@ distccd_stop() {
        fi
 }
 
+distccd_restart() {
+       distccd_stop
+       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() {
+       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
        # Exit, when distccd is already running
-       pidof distccd >/dev/null && exit 1
+       pidof distccd &>/dev/null && exit
 
        # Run distccd
-       DISTCCD_PATH=$TOOLS_DIR/bin:$(echo $TOOLS_DIR/libexec/gcc/*-pc-linux-gnu/*/) \
+       DISTCCD_PATH=$TOOLS_DIR/bin \
                $TOOLS_DIR/usr/bin/distccd --daemon --allow 0.0.0.0/0 \
-               --user nobody --nice 10 --jobs 4 &>/dev/null
+               --user nobody --nice 10 --jobs $DISTCC_JOBS --port $DISTCC_PORT \
+               --log-file $LOGFILE --stats --job-lifetime 600 \
+               --stats-port $(( $DISTCC_PORT + 1 )) &>/dev/null
 
        # When $TOOLS_DIR is not available (esp. gcc) --> exit
        while pidof distccd >/dev/null && [ -x $TOOLS_DIR/bin/gcc ]; do
                sleep 10
        done
 
-       distccd_stop
+       killall distccd &>/dev/null
 fi