]> git.ipfire.org Git - ipfire-3.x.git/blame - tools/make-compilers
Added new package: dosfstools.
[ipfire-3.x.git] / tools / make-compilers
CommitLineData
ce85f613
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
cfccf561 5# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
ce85f613
MT
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22ccache_stats() {
23 if [ -e $BASEDIR/ccache ]; then
11f0ec61 24 PATH=$PATH:build_${TARGET}/${TOOLS_DIR}/usr/bin \
d55ff892
MT
25 CCACHE_DIR=${BASEDIR}/ccache \
26 ccache -s
27 else
28 echo -n "You can't access the statistics if you didn't run ./make.sh build"
29 beautify message FAIL
30 fi
ce85f613 31}
cfccf561
MT
32
33distcc_mon() {
d55ff892 34
ce6e6024
MT
35 # run gnome thing if we can...
36 if [ -n "$DISPLAY" ]; then
37 monitor=$(which distccmon-gnome 2>/dev/null)
38 if [ -n "$monitor" ]; then
39 DISTCC_DIR=$BASEDIR/distcc $monitor &
40 return 0
41 fi
42 fi
43
cfccf561 44 INTERVAL=1 # in seconds
d55ff892 45
cfccf561
MT
46 if [ -e $BASEDIR/distcc ]; then
47 while sleep $INTERVAL; do
48 clear
c477e0bb
MT
49 echo "$NAME - Distcc monitor - Cancel with ctrl+c"
50 echo
11f0ec61 51 PATH=$PATH:build_${TARGET}/${TOOLS_DIR}/usr/bin \
d55ff892
MT
52 DISTCC_DIR=${BASEDIR}/distcc \
53 distccmon-text
54 done
55 else
56 echo -n "You can't access the statistics if you didn't run ./make.sh build"
57 beautify message FAIL
58 fi
cfccf561 59}
689314ee
MT
60
61distccd_start() {
1f93f092 62 echo -n "Running distcc daemon"
722450e5
MT
63
64 if [ "$DISTCC_PORT" == "0" ]; then
65 beautify message DISA
66 return
67 fi
68
e3e4d196 69 TOOLS_DIR=$TOOLS_DIR DISTCC_PORT=$DISTCC_PORT DISTCC_JOBS=$DISTCC_JOBS \
11f0ec61 70 LOGFILE=$BASEDIR/log_${TARGET}/_build.00-distccd.log \
722450e5 71 $BASEDIR/tools/make-compilers &
689314ee
MT
72 if [ "$?" -eq "0" ]; then
73 beautify message DONE
74 else
75 beautify message FAIL
76 fi
77}
78
79distccd_stop() {
4ca87d59 80 echo -n "Stopping distcc daemon"
3ebb0041 81 killall distccd &>/dev/null
689314ee
MT
82 if [ "$?" -eq "0" ]; then
83 beautify message DONE
84 else
85 beautify message FAIL
86 fi
87}
88
4ca87d59
MT
89distccd_restart() {
90 distccd_stop
91 distccd_start
92}
93
469d71b4
MT
94distcc_get_hosts() {
95 if [ -n "$DISTCC_HOSTS" ]; then
96 logger --distcc "[INFO] Using local hosts: $DISTCC_HOSTS"
a614ac30 97 echo "$DISTCC_HOSTS" > $BASEDIR/distcc/hosts
469d71b4
MT
98 return 0
99 fi
100 logger --distcc "[INFO] Getting hosts..."
101 for i in $($BASEDIR/tools/buildspy uuid=$UUID action=get distcc=raw); do
102 logger --distcc "[INFO] Got host: $i"
103 echo "$i" >> $BASEDIR/distcc/hosts_new
104 done
105 [ -s "$BASEDIR/distcc/hosts_new" ] && mv -f $BASEDIR/distcc/hosts{_new,}
106}
107
74a35a02 108distcc_reload() {
469d71b4
MT
109 local NOW=$(date "+%s")
110 [ -z "$DISTCC_RELOAD_TIMESTAMP" ] && DISTCC_RELOAD_TIMESTAMP=$NOW
111
112 # Exit if last reload is less than 5 minutes ago
113 if [ $(( $DISTCC_RELOAD_TIMESTAMP + 300 )) -ge $NOW ]; then
114 return 0
115 fi
116
117 logger --distcc "[INFO] Reloading distcc..."
118 distcc_get_hosts
119 DISTCC_RELOAD_TIMESTAMP=$NOW
74a35a02
MT
120}
121
689314ee
MT
122if [ "$(basename $0)" == "make-compilers" ]; then
123 # Exit, when distccd is already running
722450e5 124 pidof distccd &>/dev/null && exit
689314ee
MT
125
126 # Run distccd
c7d8c20e 127 DISTCCD_PATH=$TOOLS_DIR/bin \
689314ee 128 $TOOLS_DIR/usr/bin/distccd --daemon --allow 0.0.0.0/0 \
e3e4d196 129 --user nobody --nice 10 --jobs $DISTCC_JOBS --port $DISTCC_PORT \
3ebb0041
MT
130 --log-file $LOGFILE --stats --job-lifetime 600 \
131 --stats-port $(( $DISTCC_PORT + 1 )) &>/dev/null
689314ee
MT
132
133 # When $TOOLS_DIR is not available (esp. gcc) --> exit
134 while pidof distccd >/dev/null && [ -x $TOOLS_DIR/bin/gcc ]; do
135 sleep 10
136 done
137
3ebb0041 138 killall distccd &>/dev/null
689314ee 139fi