summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_build_service.sh
blob: 04ee0e33704d72f0170fe78eb53227197565cf2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/bash

# Copyright © 2017 Holger Levsen (holger@layer-acht.org)
# released under the GPLv=2

set -e

# those should be global variables
NODE1=""
NODE2=""

choose_node() {
	case $1 in
		amd64_1)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build5-amd64 ;;
		amd64_2)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build1-amd64 ;;
		amd64_3)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build15-amd64 ;;
		amd64_4)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build1-amd64 ;;
		amd64_5)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build5-amd64 ;;
		amd64_6)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build11-amd64 ;;
		amd64_7)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build15-amd64 ;;
		amd64_8)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build11-amd64 ;;
		amd64_9)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build5-amd64 ;;
		amd64_10)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build1-amd64 ;;
		amd64_11)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build15-amd64 ;;
		amd64_12)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build1-amd64 ;;
		amd64_13)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build5-amd64 ;;
		amd64_14)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build11-amd64 ;;
		amd64_15)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build15-amd64 ;;
		amd64_16)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build11-amd64 ;;
		amd64_17)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build5-amd64 ;;
		amd64_18)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build1-amd64 ;;
		amd64_19)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build15-amd64 ;;
		amd64_20)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build1-amd64 ;;
		amd64_21)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build5-amd64 ;;
		amd64_22)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build11-amd64 ;;
		amd64_23)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build15-amd64 ;;
		amd64_24)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build11-amd64 ;;
		amd64_25)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build5-amd64 ;;
		amd64_26)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build1-amd64 ;;
		amd64_27)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build15-amd64 ;;
		amd64_28)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build1-amd64 ;;
		amd64_29)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build5-amd64 ;;
		amd64_30)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build11-amd64 ;;
		amd64_31)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build15-amd64 ;;
		amd64_32)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build11-amd64 ;;
		amd64_33)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build5-amd64 ;;
		amd64_34)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build1-amd64 ;;
		amd64_35)	NODE1=profitbricks-build1-amd64		NODE2=profitbricks-build15-amd64 ;;
		amd64_36)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build1-amd64 ;;
		amd64_37)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build5-amd64 ;;
		amd64_38)	NODE1=profitbricks-build5-amd64		NODE2=profitbricks-build11-amd64 ;;
		amd64_39)	NODE1=profitbricks-build11-amd64	NODE2=profitbricks-build15-amd64 ;;
		amd64_40)	NODE1=profitbricks-build15-amd64	NODE2=profitbricks-build11-amd64 ;;
		i386_1)		NODE1=profitbricks-build2-i386	NODE2=profitbricks-build6-i386 ;;
		i386_2)		NODE1=profitbricks-build6-i386	NODE2=profitbricks-build2-i386 ;;
		i386_3)		NODE1=profitbricks-build2-i386	NODE2=profitbricks-build16-i386 ;;
		i386_4)		NODE1=profitbricks-build16-i386	NODE2=profitbricks-build2-i386 ;;
		i386_5)		NODE1=profitbricks-build12-i386	NODE2=profitbricks-build6-i386 ;;
		i386_6)		NODE1=profitbricks-build6-i386	NODE2=profitbricks-build12-i386 ;;
		i386_7)		NODE1=profitbricks-build12-i386	NODE2=profitbricks-build16-i386 ;;
		i386_8)		NODE1=profitbricks-build16-i386	NODE2=profitbricks-build12-i386 ;;
		i386_9)		NODE1=profitbricks-build2-i386	NODE2=profitbricks-build6-i386 ;;
		i386_10)	NODE1=profitbricks-build6-i386	NODE2=profitbricks-build2-i386 ;;
		i386_11)	NODE1=profitbricks-build2-i386	NODE2=profitbricks-build16-i386 ;;
		i386_12)	NODE1=profitbricks-build16-i386	NODE2=profitbricks-build2-i386 ;;
		i386_13)	NODE1=profitbricks-build12-i386	NODE2=profitbricks-build6-i386 ;;
		i386_14)	NODE1=profitbricks-build6-i386	NODE2=profitbricks-build12-i386 ;;
		i386_15)	NODE1=profitbricks-build12-i386	NODE2=profitbricks-build16-i386 ;;
		i386_16)	NODE1=profitbricks-build16-i386	NODE2=profitbricks-build12-i386 ;;
		i386_17)	NODE1=profitbricks-build2-i386	NODE2=profitbricks-build6-i386 ;;
		i386_18)	NODE1=profitbricks-build6-i386	NODE2=profitbricks-build2-i386 ;;
		i386_19)	NODE1=profitbricks-build2-i386	NODE2=profitbricks-build16-i386 ;;
		i386_20)	NODE1=profitbricks-build16-i386	NODE2=profitbricks-build2-i386 ;;
		i386_21)	NODE1=profitbricks-build12-i386	NODE2=profitbricks-build6-i386 ;;
		i386_22)	NODE1=profitbricks-build6-i386	NODE2=profitbricks-build12-i386 ;;
		i386_23)	NODE1=profitbricks-build12-i386	NODE2=profitbricks-build16-i386 ;;
		i386_24)	NODE1=profitbricks-build16-i386	NODE2=profitbricks-build12-i386 ;;
                arm64_1)	NODE1=codethink-sled9-arm64	NODE2=codethink-sled10-arm64 ;;
                arm64_2)	NODE1=codethink-sled9-arm64	NODE2=codethink-sled12-arm64 ;;
                arm64_3)	NODE1=codethink-sled9-arm64	NODE2=codethink-sled14-arm64 ;;
                arm64_4)	NODE1=codethink-sled10-arm64	NODE2=codethink-sled9-arm64 ;;
                arm64_5)	NODE1=codethink-sled12-arm64	NODE2=codethink-sled9-arm64 ;;
                arm64_6)	NODE1=codethink-sled14-arm64	NODE2=codethink-sled9-arm64 ;;
                arm64_7)	NODE1=codethink-sled10-arm64	NODE2=codethink-sled11-arm64 ;;
                arm64_8)	NODE1=codethink-sled10-arm64	NODE2=codethink-sled13-arm64 ;;
                arm64_9)	NODE1=codethink-sled13-arm64	NODE2=codethink-sled10-arm64 ;;
                arm64_10)       NODE1=codethink-sled15-arm64	NODE2=codethink-sled10-arm64 ;;
                arm64_11)       NODE1=codethink-sled12-arm64	NODE2=codethink-sled11-arm64 ;;
                arm64_12)       NODE1=codethink-sled11-arm64	NODE2=codethink-sled14-arm64 ;;
                arm64_13)       NODE1=codethink-sled11-arm64	NODE2=codethink-sled16-arm64 ;;
                arm64_14)       NODE1=codethink-sled11-arm64	NODE2=codethink-sled12-arm64 ;;
                arm64_15)       NODE1=codethink-sled12-arm64	NODE2=codethink-sled15-arm64 ;;
                arm64_16)       NODE1=codethink-sled15-arm64	NODE2=codethink-sled16-arm64 ;;
                arm64_17)       NODE1=codethink-sled13-arm64	NODE2=codethink-sled12-arm64 ;;
                arm64_18)       NODE1=codethink-sled13-arm64	NODE2=codethink-sled14-arm64 ;;
                arm64_19)       NODE1=codethink-sled14-arm64	NODE2=codethink-sled13-arm64 ;;
                arm64_20)       NODE1=codethink-sled16-arm64	NODE2=codethink-sled13-arm64 ;;
                arm64_21)       NODE1=codethink-sled14-arm64	NODE2=codethink-sled15-arm64 ;;
                arm64_22)       NODE1=codethink-sled16-arm64	NODE2=codethink-sled15-arm64 ;;
                arm64_23)       NODE1=codethink-sled16-arm64	NODE2=codethink-sled11-arm64 ;;
                arm64_24)       NODE1=codethink-sled15-arm64	NODE2=codethink-sled16-arm64 ;;
                arm64_25)       NODE1=codethink-sled9-arm64	NODE2=codethink-sled16-arm64 ;;
                arm64_26)       NODE1=codethink-sled16-arm64	NODE2=codethink-sled9-arm64 ;;
                arm64_27)       NODE1=codethink-sled10-arm64	NODE2=codethink-sled15-arm64 ;;
                arm64_28)       NODE1=codethink-sled11-arm64	NODE2=codethink-sled10-arm64 ;;
                arm64_29)       NODE1=codethink-sled12-arm64	NODE2=codethink-sled13-arm64 ;;
                arm64_30)       NODE1=codethink-sled15-arm64	NODE2=codethink-sled12-arm64 ;;
                arm64_31)       NODE1=codethink-sled14-arm64	NODE2=codethink-sled11-arm64 ;;
                arm64_32)       NODE1=codethink-sled13-arm64	NODE2=codethink-sled14-arm64 ;;
		# to choose new armhf jobs:
	        #       for i in cb3a hb0 rpi2b rpi2c wbd0 bpi0 bbx15 cbxi4pro0 ff2a ff2b jtk1a odxu4 odxu4b odxu4c odu3a opi2a opi2b opi2c p64b p64c wbq0 cbxi4a cbxi4b ff4a ; do echo "$i: " ; grep NODE1 bin/reproducible_build_service.sh|grep armhf|grep $i-armhf ; done
	        #       8 jobs for quad-cores with 4 gb ram
	        #       6 jobs for octo-cores with 2 gb ram
	        #       6 jobs for quad-cores with 2 gb ram
	        #       3 jobs for dual-cores with 1 gb ram
	        #       3 jobs for quad-cores with 1 gb ram
                armhf_1)	NODE1=bbx15-armhf-rb		NODE2=odxu4-armhf-rb ;;
                armhf_2)	NODE1=wbq0-armhf-rb		NODE2=p64c-armhf-rb ;;
                armhf_3)	NODE1=hb0-armhf-rb		NODE2=p64b-armhf-rb ;;
                armhf_4)	NODE1=ff4a-armhf-rb		NODE2=wbq0-armhf-rb ;;
                armhf_5)	NODE1=cbxi4pro0-armhf-rb	NODE2=bpi0-armhf-rb ;;
                armhf_6)	NODE1=ff4a-armhf-rb		NODE2=cbxi4pro0-armhf-rb ;;
                armhf_7)	NODE1=wbq0-armhf-rb		NODE2=odxu4-armhf-rb ;;
                armhf_8)	NODE1=hb0-armhf-rb		NODE2=wbq0-armhf-rb ;;
                armhf_9)	NODE1=ff4a-armhf-rb		NODE2=bpi0-armhf-rb ;;
                armhf_10)	NODE1=odxu4-armhf-rb		NODE2=rpi2b-armhf-rb ;;
                armhf_11)	NODE1=odxu4-armhf-rb		NODE2=wbd0-armhf-rb ;;
                armhf_12)	NODE1=wbd0-armhf-rb		NODE2=cbxi4pro0-armhf-rb ;;
                armhf_13)	NODE1=cbxi4pro0-armhf-rb	NODE2=rpi2b-armhf-rb ;;
                armhf_14)	NODE1=cbxi4a-armhf-rb		NODE2=odxu4b-armhf-rb ;;
                armhf_15)	NODE1=rpi2b-armhf-rb		NODE2=odxu4c-armhf-rb ;;
                armhf_16)	NODE1=odxu4b-armhf-rb		NODE2=wbd0-armhf-rb ;;
                armhf_17)	NODE1=odxu4c-armhf-rb		NODE2=hb0-armhf-rb ;;
                armhf_18)	NODE1=odxu4b-armhf-rb		NODE2=odu3a-armhf-rb ;;
                armhf_19)	NODE1=odxu4c-armhf-rb		NODE2=opi2c-armhf-rb ;;
                armhf_20)	NODE1=opi2b-armhf-rb		NODE2=odxu4b-armhf-rb ;;
                armhf_21)	NODE1=ff2a-armhf-rb		NODE2=odxu4c-armhf-rb ;;
                armhf_22)	NODE1=ff2a-armhf-rb		NODE2=rpi2c-armhf-rb ;;
                armhf_23)	NODE1=rpi2c-armhf-rb		NODE2=odxu4b-armhf-rb ;;
                armhf_24)	NODE1=rpi2c-armhf-rb		NODE2=odxu4c-armhf-rb ;;
                armhf_25)	NODE1=odxu4b-armhf-rb		NODE2=ff2b-armhf-rb ;;
                armhf_26)	NODE1=jtk1a-armhf-rb		NODE2=ff2a-armhf-rb ;;
                armhf_27)	NODE1=odxu4c-armhf-rb		NODE2=cbxi4a-armhf-rb ;;
                armhf_28)	NODE1=jtk1a-armhf-rb		NODE2=ff2b-armhf-rb ;;
                armhf_29)	NODE1=ff2b-armhf-rb		NODE2=jtk1a-armhf-rb ;;
                armhf_30)	NODE1=ff2b-armhf-rb		NODE2=cbxi4b-armhf-rb ;;
                armhf_31)	NODE1=ff2b-armhf-rb		NODE2=opi2b-armhf-rb ;;
                armhf_32)	NODE1=jtk1a-armhf-rb		NODE2=cbxi4b-armhf-rb ;;
                armhf_33)	NODE1=ff2a-armhf-rb		NODE2=opi2b-armhf-rb ;;
                armhf_34)	NODE1=cbxi4a-armhf-rb		NODE2=opi2b-armhf-rb ;;
                armhf_35)	NODE1=opi2a-armhf-rb		NODE2=ff2b-armhf-rb ;;
                armhf_36)	NODE1=opi2a-armhf-rb		NODE2=cbxi4a-armhf-rb ;;
                armhf_37)	NODE1=opi2a-armhf-rb		NODE2=wbq0-armhf-rb ;;
                armhf_38)	NODE1=cbxi4b-armhf-rb		NODE2=jtk1a-armhf-rb ;;
                armhf_39)	NODE1=cbxi4b-armhf-rb		NODE2=cbxi4a-armhf-rb ;;
                armhf_40)	NODE1=opi2b-armhf-rb		NODE2=cbxi4b-armhf-rb ;;
                armhf_41)	NODE1=opi2b-armhf-rb		NODE2=cbxi4b-armhf-rb ;;
                armhf_42)	NODE1=cbxi4b-armhf-rb		NODE2=cbxi4a-armhf-rb ;;
                armhf_43)	NODE1=cbxi4a-armhf-rb		NODE2=opi2c-armhf-rb ;;
                armhf_44)	NODE1=bbx15-armhf-rb		NODE2=ff4a-armhf-rb ;;
                armhf_45)	NODE1=ff4a-armhf-rb		NODE2=p64b-armhf-rb ;;
                armhf_46)	NODE1=wbq0-armhf-rb		NODE2=bbx15-armhf-rb ;;
                armhf_47)	NODE1=cbxi4pro0-armhf-rb	NODE2=bbx15-armhf-rb ;;
                armhf_48)	NODE1=bbx15-armhf-rb		NODE2=p64c-armhf-rb ;;
                armhf_49)	NODE1=bpi0-armhf-rb		NODE2=ff4a-armhf-rb ;;
                armhf_50)	NODE1=odxu4-armhf-rb		NODE2=odu3a-armhf-rb ;;
                armhf_51)	NODE1=odu3a-armhf-rb		NODE2=cb3a-armhf-rb ;;
                armhf_52)	NODE1=opi2c-armhf-rb		NODE2=cb3a-armhf-rb ;;
                armhf_53)	NODE1=cb3a-armhf-rb		NODE2=ff4a-armhf-rb ;;
                armhf_54)	NODE1=odu3a-armhf-rb		NODE2=opi2c-armhf-rb ;;
                armhf_55)	NODE1=opi2c-armhf-rb		NODE2=odu3a-armhf-rb ;;
                armhf_56)	NODE1=odu3a-armhf-rb		NODE2=ff2a-armhf-rb ;;
                armhf_57)	NODE1=opi2c-armhf-rb		NODE2=ff2a-armhf-rb ;;
                armhf_58)	NODE1=cbxi4a-armhf-rb		NODE2=p64b-armhf-rb ;;
                armhf_59)	NODE1=jtk1a-armhf-rb		NODE2=p64c-armhf-rb ;;
                armhf_60)	NODE1=cbxi4b-armhf-rb		NODE2=opi2a-armhf-rb ;;
                armhf_61)	NODE1=p64c-armhf-rb		NODE2=opi2a-armhf-rb ;;
                armhf_62)	NODE1=p64b-armhf-rb		NODE2=opi2a-armhf-rb ;;
                armhf_63)	NODE1=p64b-armhf-rb		NODE2=ff4a-armhf-rb ;;
                armhf_64)	NODE1=p64c-armhf-rb		NODE2=bbx15-armhf-rb ;;
                armhf_65)	NODE1=p64b-armhf-rb		NODE2=cbxi4pro0-armhf-rb ;;
                armhf_66)	NODE1=p64c-armhf-rb		NODE2=odxu4-armhf-rb ;;

		*)		echo "Sleeping 60min"
				sleep 60m
				exit 0
				;;
	esac
}

startup_workers() {
	for ARCH in amd64 i386 arm64 armhf ; do
		case $ARCH in
			amd64)	MAX=40 ;;
			i386)	MAX=24 ;;
			arm64)	MAX=32 ;;
			armhf)	MAX=66 ;;
			*)	;;
		esac
		for i in $(seq 1 $MAX) ; do
		        # sleep up to 2.3 seconds (additionally to the random sleep reproducible_build.sh does anyway)
		        /bin/sleep $(echo "scale=1 ; $(shuf -i 1-23 -n 1)/10" | bc )

			WORKER_NAME=${ARCH}_$i
			choose_node $WORKER_NAME
			BUILD_BASE=/var/lib/jenkins/userContent/reproducible/debian/build_service/$WORKER_NAME
			mkdir -p $BUILD_BASE
			echo "$(date --utc) - Starting $WORKER_NAME"
			/srv/jenkins/bin/reproducible_worker.sh $WORKER_NAME $NODE1 $NODE2 >$BUILD_BASE/worker.log 2>&1 &
		done
	done
}

#
# main
#
startup_workers
# keep running forever…
while true ; do sleep 1337m ; done

# FIXME: TODO left for _service.sh:
# * link to console.log in rbuild.log is broken
# * logs should auto display in browser like with jenkins… (long-polling, meta-refresh, something)
#   - there's an NPH solution pointed out by Xtaran
# * enabling the service in update_jdn
# * maintenance job might want to:
#   - check for running builds using systemctl show & ps fax
#   - check if at least one build is running on a build node
# * dashboard jobs need to count for running jobs in this script…
# * drop jobs from repro.yaml
# * use ExecStop to kill remote builds on shutdown
#   - remove cleanup_nodes.sh once this works
# * add support for disabling archs and for shutdown+respan of workers
# * document the new setup in README