xref: /netbsd/external/bsd/ntp/dist/flock-build (revision 6550d01e)
1#! /bin/sh
2
3IAM=`hostname || uname -n`
4MYNAME=`IFS=. ; set $IAM ; echo $1`
5
6case "$1" in
7 '--one'|'-1')
8     shift
9     FB_FIRSTONLY=1
10     LIST=$MYNAME
11     ;;
12 *)
13     FB_FIRSTONLY=0
14esac
15
16BUILD_ARGS="$@"
17PARSE="--enable-parse-clocks"
18#PARSE=
19STD="--enable-simulator"
20
21case "$SIMUL" in
22 '') PARALLEL_BUILDS=1
23     ;;
24 *)  PARALLEL_BUILDS=$SIMUL
25esac
26
27case "$PARALLEL_BUILDS" in
28 1)  ;;
29 *)  echo Launching $PARALLEL_BUILDS parallel builds on each machine
30esac
31
32# Backroom:
33#   barnstable	   freebsd-6.1
34#   beauregard	   freebsd-6.0
35# X churchy	   alpha-dec-osf5.1
36#   deacon	   sparc-sun-solaris2.10
37#   grundoon	   freebsd-6.2
38#   howland	   freebsd-6.1
39# o macabre	   freebsd-6.1-STABLE
40# o mort	   freebsd-6.1
41#   whimsy	   sparc-sun-solaris2.10
42
43# Campus:
44# * baldwin	   sparc-sun-solaris2.10
45# * bridgeport	   sparc-sun-solaris2.10
46# * malarky	   sparc-sun-solaris2.10
47# * pogo	   sparc-sun-solaris2.10
48# * rackety	   freebsd-6.1
49
50# HMS: we need $PWD because solaris produces /deacon/backroom when
51# we are in /backroom and in general there is no /deacon/backroom.
52c_d=${PWD:-`pwd`}
53
54SIG=`perl -e 'print rand'`
55
56case "$LIST" in
57 '') LIST="malarky rackety" ;;
58esac
59
60for i in $LIST
61do
62    SKIPTHIS=0
63    [ -f .buildkey-$i ] && SKIPTHIS=1
64    case "$SKIPTHIS" in
65     1)
66        echo flock-build running on $i? check LIST, skipping
67        ;;
68     0)
69        echo $i
70        echo $SIG > .buildkey-$i
71        case "1" in
72         0)
73            ssh $i "cd $c_d ; ./build $SIG $PARSE $STD $BUILD_ARGS" &
74            ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --without-crypto $BUILD_ARGS" &
75            ssh $i "cd $c_d ; ./build $SIG        $STD --disable-all-clocks $BUILD_ARGS" &
76            ;;
77         1)
78            cat > .flockbuild-$i-$SIG <<-ENDQUOT
79		#!/bin/sh
80
81		# script uses job control and expects to be invoked
82		# in a ssh session started with the -tt option, 
83		# which forces a pseudo-tty to be used.
84		
85		cd $c_d
86		COUNT=0
87
88		./build $SIG $PARSE $STD $BUILD_ARGS &
89
90		COUNT=\`expr \$COUNT + 1\`
91		echo \`date -u '+%H:%M:%S'\` $i started build \$COUNT of 4
92		[ 0 -lt \`expr \$COUNT % $PARALLEL_BUILDS\` ] || wait
93
94		case $FB_FIRSTONLY in
95		 '0')
96			./build $SIG $PARSE $STD --disable-debugging $BUILD_ARGS &
97
98			COUNT=\`expr \$COUNT + 1\`
99			echo \`date -u '+%H:%M:%S'\` $i started build \$COUNT of 4
100			[ 0 -lt \`expr \$COUNT % $PARALLEL_BUILDS\` ] || wait
101
102			./build $SIG $PARSE $STD --without-crypto $BUILD_ARGS &
103
104			COUNT=\`expr \$COUNT + 1\`
105			echo \`date -u '+%H:%M:%S'\` $i started build \$COUNT of 4
106			[ 0 -lt \`expr \$COUNT % $PARALLEL_BUILDS\` ] || wait
107
108			./build $SIG        $STD --disable-all-clocks $BUILD_ARGS &
109
110			COUNT=\`expr \$COUNT + 1\`
111			echo \`date -u '+%H:%M:%S'\` $i started build \$COUNT of 4
112			wait
113		esac
114		echo \`date -u '+%H:%M:%S'\` $i flock-build $c_d done.
115		rm .buildkey-$i
116ENDQUOT
117            chmod +x .flockbuild-$i-$SIG
118            ssh -tt $i "$c_d/.flockbuild-$i-$SIG ; \
119                      rm $c_d/.flockbuild-$i-$SIG" 2>/dev/null &
120        esac
121    esac
122done
123echo `date -u '+%H:%M:%S'` flock-build launched
124