]>
Commit | Line | Data |
---|---|---|
1344b6f1 MM |
1 | #!/bin/sh |
2 | ||
b4818b81 AM |
3 | # prevent "*" from being expanded in builders var |
4 | cd /usr/share/empty | |
5 | ||
864cdeb5 | 6 | builders= |
864cdeb5 MM |
7 | with= |
8 | without= | |
9 | flags= | |
10 | command= | |
11 | command_flags= | |
16b5ec37 | 12 | gpg_opts= |
e728b34c ER |
13 | default_branch='HEAD' |
14 | distro= | |
bcb3a8b8 | 15 | url= |
218a4c96 | 16 | no_depend=no |
12151609 | 17 | verbose=no |
bfa10c0d AM |
18 | |
19 | [ -x /usr/bin/python ] && send_mode="python" || send_mode="mail" | |
544ca060 | 20 | |
e29fbd39 AG |
21 | if [ -n "$HOME_ETC" ]; then |
22 | USER_CFG=$HOME_ETC/.requestrc | |
544ca060 | 23 | else |
e29fbd39 | 24 | USER_CFG=$HOME/.requestrc |
e728b34c | 25 | fi |
e29fbd39 | 26 | |
e728b34c | 27 | if [ ! -f "$USER_CFG" ]; then |
e29fbd39 | 28 | echo "Creating config file $USER_CFG. You *must* edit it." |
bcb3a8b8 | 29 | cat > $USER_CFG <<EOF |
1344b6f1 | 30 | priority=2 |
e728b34c | 31 | requester=deviloper@pld-linux.org |
544ca060 | 32 | default_key=deviloper@pld-linux.org |
bfa10c0d AM |
33 | send_mode="$send_mode" |
34 | url="$url" | |
1344b6f1 | 35 | mailer="/usr/sbin/sendmail -t" |
16b5ec37 | 36 | gpg_opts="" |
e728b34c | 37 | distro=th |
1cd123e3 | 38 | url="http://src.th.pld-linux.org:1234/" |
1344b6f1 | 39 | |
a757e911 | 40 | # defaults: |
771f742d | 41 | f_upgrade=yes |
544ca060 MM |
42 | EOF |
43 | exit | |
44 | fi | |
45 | ||
e728b34c | 46 | if [ -f "$USER_CFG" ]; then |
9cc9841b | 47 | . $USER_CFG |
e728b34c ER |
48 | fi |
49 | ||
45d8ed70 ER |
50 | # internal options, not to be overriden |
51 | specs= | |
52 | df_fetch=no | |
a166aeda | 53 | upgrade_macros=no |
45d8ed70 | 54 | |
c9f4704f ER |
55 | # Set colors |
56 | c_star=$(tput setaf 2) | |
55bfbaf6 | 57 | c_red=$(tput setaf 1) |
c9f4704f ER |
58 | c_norm=$(tput op) |
59 | msg() { | |
60 | echo >&2 "${c_star}*${c_norm} $*" | |
61 | } | |
55bfbaf6 ER |
62 | red() { |
63 | echo "${c_red}$*${c_norm}" | |
64 | } | |
c9f4704f | 65 | |
45d8ed70 ER |
66 | die() { |
67 | echo >&2 "$0: $*" | |
68 | exit 1 | |
69 | } | |
70 | ||
bfa10c0d | 71 | send_request() { |
bcb3a8b8 ER |
72 | # switch to mail mode, if no url set |
73 | [ -z "$url" ] && send_mode="mail" | |
74 | ||
bcb3a8b8 ER |
75 | case "$send_mode" in |
76 | "mail") | |
c9f4704f | 77 | msg "Sending using mail mode" |
bcb3a8b8 ER |
78 | cat - | $mailer |
79 | ;; | |
80 | *) | |
c9f4704f | 81 | msg "Sending using http mode to $url" |
bcb3a8b8 | 82 | cat - | python -c ' |
e3a591a1 | 83 | import sys, socket, urllib2 |
bfa10c0d AM |
84 | |
85 | try: | |
86 | data = sys.stdin.read() | |
e6aa37ec | 87 | url = sys.argv[1] |
e3a591a1 | 88 | socket.setdefaulttimeout(10) |
e6aa37ec | 89 | req = urllib2.Request(url, data) |
e3a591a1 | 90 | f = urllib2.urlopen(req) |
bfa10c0d AM |
91 | f.close() |
92 | except Exception, e: | |
e6aa37ec | 93 | print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e) |
bfa10c0d | 94 | sys.exit(1) |
f04b3329 | 95 | print >> sys.stdout, "Request queued via HTTP." |
bfa10c0d | 96 | ' "$url" |
bcb3a8b8 ER |
97 | ;; |
98 | esac | |
bfa10c0d AM |
99 | } |
100 | ||
45d8ed70 ER |
101 | # simple df_fetcher, based on packages/fetchsrc_request |
102 | # TODO: tcp (smtp) mode | |
103 | # TODO: adjust for ~/.requestrc config | |
104 | df_fetch() { | |
105 | local specs="$@" | |
106 | ||
107 | # Sending by | |
108 | local MAILER='/usr/sbin/sendmail' | |
109 | # MAILER='/usr/bin/msmtp' | |
110 | # Sending via | |
111 | local VIA="SENDMAIL" | |
112 | #VIA="localhost" | |
113 | local VIA_ARGS="" | |
114 | #VIA_ARGS="some additional flags" | |
115 | # e.g. for msmtp: | |
116 | # VIA_ARGS='-a gmail' | |
117 | # | |
118 | # DISTFILES EMAIL | |
119 | local DMAIL="distfiles@pld-linux.org" | |
120 | ||
121 | local HOST=$(hostname -f) | |
122 | local LOGIN=${requester%@*} | |
123 | ||
124 | for spec in $specs; do | |
125 | local SPEC=$(echo "$spec" | sed -e 's|:.*||') | |
126 | local BRANCH=$(echo "$spec" | sed -e 's|.*:||') | |
127 | echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}" | |
128 | cat <<-EOF | "$MAILER" -t -i $VIA_ARGS | |
129 | To: $DMAIL | |
130 | From: $LOGIN <$LOGIN@$HOST> | |
131 | Subject: fetchsrc_request notify | |
132 | X-CVS-Module: SPECS | |
133 | X-distfiles-request: yes | |
134 | X-Login: $LOGIN | |
135 | X-Spec: $SPEC | |
136 | X-Branch: $BRANCH | |
137 | X-Flags: force-reply | |
138 | ||
139 | . | |
140 | EOF | |
141 | done | |
a757e911 | 142 | } |
1344b6f1 | 143 | |
586a5f1f | 144 | usage() { |
23e1dcfb ER |
145 | cat <<EOF |
146 | Usage: make-request.sh [OPTION] ... [SPECFILE] .... | |
147 | ||
148 | Mandatory arguments to long options are mandatory for short options too. | |
149 | ||
bb30a063 ER |
150 | -C, --config-file /path/to/config/file |
151 | Source additional config file (after $USER_CFG), useful when | |
152 | when sending build requests to Ac/Th from the same account | |
153 | -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...' | |
23e1dcfb | 154 | Sends request to given builders (in 'version-arch' format) |
bb30a063 ER |
155 | --with VALUE, --without VALUE |
156 | Build package with(out) a given bcond | |
23e1dcfb | 157 | --kernel VALUE |
bb30a063 | 158 | set alt_kernel to VALUE |
23e1dcfb | 159 | --target VALUE |
bb30a063 | 160 | set --target to VALUE |
23e1dcfb | 161 | -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID] |
bb30a063 | 162 | mark build ids on src builder to be skipped |
23e1dcfb | 163 | --branch VALUE |
bb30a063 ER |
164 | specify default branch for specs in request |
165 | -t, --test-build | |
0e59dd68 AM |
166 | Performs a 'test-build'. Package will be uploaded to hidden .test-builds/ |
167 | ftp tree and won't be upgraded on builders. | |
bb30a063 | 168 | -r, --ready-build |
0e59dd68 AM |
169 | Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree |
170 | (and later moved by release manager staff to ready/ and main ftp tree) | |
bb30a063 ER |
171 | -u, --upgrade |
172 | Forces package upgrade (for use with -c or -q, not -t) | |
173 | -n, --no-upgrade | |
174 | Disables package upgrade (for use with -r) | |
218a4c96 | 175 | -ni, --no-install-br |
bb30a063 | 176 | Do not install missing BuildRequires (--nodeps) |
218a4c96 ER |
177 | -nd, --no-depend |
178 | Do not add dependency of build jobs, each job in batch runs itself | |
bb30a063 ER |
179 | -j, --jobs |
180 | Number of parallel jobs for single build | |
181 | -f, --flag | |
182 | -d, --distro DISTRO | |
183 | Specify value for \$distro | |
184 | -df, --distfiles-fetch[-request] PACKAGE | |
185 | Send distfiles request to fetch sources for PACKAGE | |
186 | -cf, --command-flag | |
187 | Not yet documented | |
188 | -c, --command | |
189 | Executes a given command on builders | |
190 | --test-remove-pkg | |
191 | shortcut for --command poldek -evt ARGS | |
192 | --remove-pkg | |
193 | shortcut for --command poldek -ev --noask ARGS | |
194 | --upgrade-pkg | |
195 | shortcut for --command poldek --up -Uv ARGS | |
196 | --cvsup | |
197 | Updates builders infrastructure (outside chroot) | |
a166aeda ER |
198 | --update-macros |
199 | Updates rpm-build-macros on src builder | |
23e1dcfb | 200 | -q |
bb30a063 ER |
201 | shortcut for --command rpm -q ARGS |
202 | -g, --gpg-opts "opts" | |
203 | Pass additional options to gpg binary | |
204 | -p, --priority VALUE | |
205 | sets request priority (default 2) | |
206 | -h, --help | |
207 | Displays this help message | |
23e1dcfb ER |
208 | EOF |
209 | exit 0 | |
586a5f1f AG |
210 | } |
211 | ||
212 | ||
1344b6f1 | 213 | while [ $# -gt 0 ] ; do |
9cc9841b | 214 | case "$1" in |
bb30a063 | 215 | --distro | -d) |
9cc9841b ER |
216 | distro=$2 |
217 | shift | |
218 | ;; | |
219 | ||
bb30a063 | 220 | --config-file | -C) |
9cc9841b ER |
221 | [ -f $2 ] && . $2 || die "Config file not found" |
222 | shift | |
223 | ;; | |
224 | ||
bb30a063 | 225 | --builder | -b) |
9cc9841b ER |
226 | builders="$builders $2" |
227 | shift | |
228 | ;; | |
229 | ||
bb30a063 | 230 | --with) |
9cc9841b ER |
231 | with="$with $2" |
232 | shift | |
233 | ;; | |
234 | ||
bb30a063 | 235 | --without) |
9cc9841b ER |
236 | without="$without $2" |
237 | shift | |
238 | ;; | |
239 | ||
bb30a063 | 240 | --test-build | -t) |
9cc9841b ER |
241 | build_mode=test |
242 | f_upgrade=no | |
243 | ;; | |
244 | ||
bb30a063 | 245 | --kernel) |
9cc9841b ER |
246 | kernel=$2 |
247 | shift | |
248 | ;; | |
249 | ||
be264f26 ER |
250 | --target) |
251 | target=$2 | |
252 | shift | |
253 | ;; | |
254 | ||
db286098 | 255 | -s|--skip) |
897f56ee | 256 | skip="$2" |
db286098 ER |
257 | shift |
258 | ;; | |
259 | ||
11270534 ER |
260 | --branch) |
261 | branch=$2 | |
262 | shift | |
263 | ;; | |
264 | ||
bb30a063 | 265 | --priority | -p) |
9cc9841b ER |
266 | priority=$2 |
267 | shift | |
268 | ;; | |
269 | ||
bb30a063 | 270 | --ready-build | -r) |
9cc9841b ER |
271 | build_mode=ready |
272 | ;; | |
273 | ||
bb30a063 | 274 | --upgrade | -u) |
9cc9841b ER |
275 | f_upgrade=yes |
276 | ;; | |
277 | ||
bb30a063 | 278 | --no-upgrade | -n) |
9cc9841b ER |
279 | f_upgrade=no |
280 | ;; | |
281 | ||
218a4c96 ER |
282 | --no-depend | -nd) |
283 | no_depend=yes | |
284 | ;; | |
285 | ||
bb30a063 | 286 | --no-install-br | -ni) |
9cc9841b ER |
287 | flags="$flags no-install-br" |
288 | ;; | |
289 | ||
bb30a063 | 290 | -j | --jobs) |
d8f1c9c0 AM |
291 | jobs="$2" |
292 | shift | |
293 | ;; | |
294 | ||
12151609 ER |
295 | -v) |
296 | verbose=yes | |
297 | ;; | |
298 | ||
bb30a063 | 299 | --flag | -f) |
9cc9841b ER |
300 | flags="$flags $2" |
301 | shift | |
302 | ;; | |
303 | ||
bb30a063 | 304 | --command-flags | -cf) |
9cc9841b ER |
305 | command_flags="$2" |
306 | shift | |
307 | ;; | |
308 | ||
bb30a063 | 309 | --command | -c) |
9cc9841b | 310 | command="$2" |
30ddd991 | 311 | if [ "$command" = - ]; then |
3f77765b ER |
312 | echo >&2 "Reading command from STDIN" |
313 | echo >&2 "---" | |
314 | command=$(cat) | |
315 | echo >&2 "---" | |
316 | fi | |
9cc9841b ER |
317 | f_upgrade=no |
318 | shift | |
319 | ;; | |
320 | --test-remove-pkg) | |
321 | command="poldek -evt $2" | |
322 | f_upgrade=no | |
323 | shift | |
324 | ;; | |
325 | --remove-pkg) | |
c4c115cc | 326 | command="for a in $2; do poldek -ev --noask \$a; done" |
9cc9841b ER |
327 | f_upgrade=no |
328 | shift | |
329 | ;; | |
b098536f | 330 | --upgrade-pkg|-Uhv) |
218a4c96 | 331 | command="poldek --up; poldek -uv $2" |
9cc9841b ER |
332 | f_upgrade=no |
333 | shift | |
334 | ;; | |
335 | -q) | |
336 | command="rpm -q $2" | |
337 | f_upgrade=no | |
338 | shift | |
339 | ;; | |
340 | ||
bb30a063 | 341 | --cvsup) |
9cc9841b ER |
342 | command_flags="no-chroot" |
343 | command="cvs up" | |
49a8a604 | 344 | f_upgrade=no |
9cc9841b ER |
345 | ;; |
346 | ||
a166aeda ER |
347 | --update-macros) |
348 | upgrade_macros="yes" | |
349 | ;; | |
350 | ||
45d8ed70 ER |
351 | -df | --distfiles-fetch | --distfiles-fetch-request) |
352 | df_fetch=yes | |
353 | ;; | |
354 | ||
bb30a063 | 355 | --gpg-opts | -g) |
1bf4c407 TP |
356 | gpg_opts="$2" |
357 | shift | |
358 | ;; | |
9cc9841b | 359 | |
bb30a063 | 360 | --help | -h) |
9cc9841b ER |
361 | usage |
362 | ;; | |
363 | ||
bb30a063 | 364 | -*) |
9cc9841b ER |
365 | die "unknown knob: $1" |
366 | ;; | |
367 | ||
bb30a063 | 368 | *:* | *) |
9cc9841b ER |
369 | specs="$specs $1" |
370 | ;; | |
371 | esac | |
372 | shift | |
1344b6f1 MM |
373 | done |
374 | ||
e728b34c ER |
375 | case "$distro" in |
376 | ac) | |
9cc9841b ER |
377 | builder_email="builder-ac@pld-linux.org" |
378 | default_builders="ac-*" | |
379 | default_branch="AC-branch" | |
8503c5d2 | 380 | url="http://ep09.pld-linux.org:1289/" |
a3387055 | 381 | control_url="http://ep09.pld-linux.org/~buildsrc" |
9cc9841b | 382 | ;; |
3e991c55 | 383 | ac-java) # fake "distro" for java available ac architectures |
e4047e17 | 384 | builder_email="builder-ac@pld-linux.org" |
9cc9841b ER |
385 | default_builders="ac-i586 ac-i686 ac-athlon ac-amd64" |
386 | default_branch="AC-branch" | |
8503c5d2 | 387 | url="http://ep09.pld-linux.org:1289/" |
9cc9841b | 388 | ;; |
70d46bca | 389 | ac-xen) # fake "distro" for xen-enabled architectures |
e4047e17 ER |
390 | builder_email="builder-ac@pld-linux.org" |
391 | default_builders="ac-i686 ac-athlon ac-amd64" | |
392 | default_branch="AC-branch" | |
70d46bca | 393 | ;; |
e728b34c | 394 | ti) |
9cc9841b ER |
395 | builder_email="builderti@ep09.pld-linux.org" |
396 | default_builders="ti-*" | |
5ed6b10a AM |
397 | url="http://ep09.pld-linux.org:1231/" |
398 | control_url="http://ep09.pld-linux.org/~builderti" | |
9cc9841b | 399 | ;; |
3274da14 | 400 | ti-dev) |
401 | builder_email="buildertidev@ep09.pld-linux.org" | |
402 | default_builders="ti-dev-*" | |
403 | url="http://ep09.pld-linux.org:1232/" | |
404 | control_url="http://ep09.pld-linux.org/~buildertidev" | |
405 | ;; | |
e728b34c | 406 | th) |
f0cfd110 | 407 | builder_email="builderth@pld-linux.org" |
9cc9841b | 408 | default_builders="th-*" |
1cd123e3 | 409 | url="http://src.th.pld-linux.org:1234/" |
f0cfd110 | 410 | control_url="http://src.th.pld-linux.org" |
9cc9841b | 411 | ;; |
3e991c55 | 412 | th-java) # fake "distro" for java available th architectures |
f0cfd110 | 413 | builder_email="builderth@pld-linux.org" |
976435cb | 414 | default_builders="th-x86_64 th-athlon th-i686" |
1cd123e3 | 415 | url="http://src.th.pld-linux.org:1234/" |
e219518b | 416 | ;; |
32384897 | 417 | aidath) |
418 | builder_email="builderaidath@ep09.pld-linux.org" | |
419 | default_builders="aidath-*" | |
420 | ;; | |
14b580de ER |
421 | *) |
422 | die "distro \`$distro' not known" | |
423 | ;; | |
e728b34c ER |
424 | esac |
425 | ||
897f56ee ER |
426 | # need to do this after distro selection |
427 | if [ "$skip" ]; then | |
9b86ba23 ER |
428 | skip=$(skip="$skip" control_url="$control_url" python -c ' |
429 | import urllib2 | |
430 | import sys | |
431 | import StringIO | |
432 | import gzip | |
433 | import re | |
434 | import os | |
435 | import string | |
436 | from xml.dom import minidom | |
437 | ||
438 | skip = os.environ.get("skip").split(","); | |
439 | control_url = os.environ.get("control_url") | |
440 | ||
441 | print >> sys.stderr, "* Check queue_id-s against %s" % control_url | |
442 | ||
443 | try: | |
444 | headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" } | |
445 | req = urllib2.Request(url=control_url + "/queue.gz", headers=headers) | |
446 | f = urllib2.urlopen(req) | |
447 | except Exception, e: | |
448 | print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e) | |
449 | sys.exit(1) | |
450 | ||
451 | sio = StringIO.StringIO() | |
452 | sio.write(f.read()) | |
453 | f.close() | |
454 | sio.seek(0) | |
455 | f = gzip.GzipFile(fileobj = sio) | |
456 | ||
457 | xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1) | |
458 | d = minidom.parseString(xml) | |
459 | ||
460 | q = [] | |
461 | for c in d.documentElement.childNodes: | |
462 | if c.nodeName != "group": | |
463 | continue | |
464 | q.append(c.attributes["id"].value) | |
465 | ||
466 | err = 0 | |
467 | for s in skip: | |
468 | if s not in q: | |
469 | print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s | |
470 | err = 1 | |
471 | else: | |
472 | print >> sys.stderr, "- Check %s: OK" % s | |
473 | if err == 1: | |
474 | sys.exit(1) | |
475 | print string.join(skip, ",") | |
476 | ') || exit $? | |
897f56ee ER |
477 | f_upgrade=no |
478 | build_mode=test | |
479 | priority=-1 | |
480 | command="skip:$skip" | |
481 | command_flags="no-chroot" | |
482 | builders="$distro-src" | |
483 | fi | |
484 | ||
11270534 ER |
485 | branch=${branch:-$default_branch} |
486 | ||
e728b34c | 487 | specs=`for s in $specs; do |
9cc9841b | 488 | case "$s" in |
218a4c96 ER |
489 | ^) |
490 | # skip marker | |
491 | echo $s | |
492 | ;; | |
9cc9841b | 493 | *.spec:*) # spec with branch |
b3d9fd17 | 494 | basename $s |
9cc9841b ER |
495 | ;; |
496 | *.spec) # spec without branch | |
b3d9fd17 | 497 | echo $(basename $s):$branch |
9cc9841b ER |
498 | ;; |
499 | *:*) # package name with branch | |
b3d9fd17 | 500 | basename $s | sed -e 's/:/.spec:/' |
9cc9841b ER |
501 | ;; |
502 | *) # just package name | |
b3d9fd17 | 503 | echo $(basename $s).spec:$branch |
9cc9841b ER |
504 | ;; |
505 | esac | |
878677a8 | 506 | done` |
1344b6f1 | 507 | |
45d8ed70 ER |
508 | if [ "$df_fetch" = "yes" ]; then |
509 | df_fetch $specs | |
510 | exit 0 | |
511 | fi | |
512 | ||
a166aeda | 513 | if [ "$upgrade_macros" = "yes" ]; then |
218a4c96 | 514 | command="poldek --up; poldek -uv rpm-build-macros" |
a166aeda ER |
515 | builders="$distro-src" |
516 | f_upgrade=no | |
517 | build_mode=test | |
518 | fi | |
519 | ||
2f470d17 | 520 | if [[ "$requester" != *@* ]] ; then |
b3d9fd17 | 521 | requester="$requester@pld-linux.org" |
2f470d17 MK |
522 | fi |
523 | ||
14b580de | 524 | if [ -z "$builders" ] ; then |
9cc9841b | 525 | builders="$default_builders" |
a757e911 MM |
526 | fi |
527 | ||
544ca060 | 528 | if [ "$f_upgrade" = "yes" ] ; then |
9cc9841b | 529 | flags="$flags upgrade" |
a757e911 MM |
530 | fi |
531 | ||
e936beda | 532 | if [ "$build_mode" = "test" ] ; then |
9cc9841b ER |
533 | if [ "$f_upgrade" = "yes" ] ; then |
534 | die "--upgrade and --test-build are mutually exclusive" | |
535 | fi | |
536 | flags="$flags test-build" | |
e936beda MM |
537 | fi |
538 | ||
e728b34c ER |
539 | if [ -z "$build_mode" ] ; then |
540 | # missing build mode, builders go crazy when you proceed" | |
541 | die "please specify build mode" | |
542 | fi | |
543 | ||
544 | ||
280b1afd | 545 | ok= |
e728b34c ER |
546 | for s in $specs; do |
547 | ok=1 | |
280b1afd MM |
548 | done |
549 | ||
d80e53cf ER |
550 | if [ -z "$specs" -a -z "$command" ]; then |
551 | die "no packages to build or command to invoke specified" | |
280b1afd MM |
552 | fi |
553 | ||
1344b6f1 MM |
554 | id=$(uuidgen) |
555 | ||
556 | gen_req() { | |
9cc9841b ER |
557 | echo "<group id='$id' no='0' flags='$flags'>" |
558 | echo " <time>$(date +%s)</time>" | |
c9f4704f | 559 | msg "Using priority $priority" |
9cc9841b | 560 | echo " <priority>$priority</priority>" |
d8f1c9c0 | 561 | if [ -n "$jobs" ]; then |
c9f4704f | 562 | msg "Using jobs $jobs" |
d8f1c9c0 AM |
563 | echo " <maxjobs>$jobs</maxjobs>" |
564 | fi | |
c9f4704f | 565 | msg "Build mode: $build_mode" |
fe7aaa44 | 566 | if [ -z "$url" ]; then |
c9f4704f | 567 | msg "Using email $builder_email" |
fe7aaa44 | 568 | else |
c9f4704f | 569 | msg "Using URL $url" |
fe7aaa44 | 570 | fi |
c9f4704f | 571 | msg "Queue-ID: $id" |
9cc9841b ER |
572 | echo |
573 | ||
d80e53cf ER |
574 | # job to depend on |
575 | local depend= | |
576 | local b i=1 | |
577 | local name branch builders_xml | |
578 | ||
579 | for b in $builders; do | |
55bfbaf6 | 580 | msg "Builder: $(red $b)" |
d80e53cf ER |
581 | builders_xml="$builders_xml <builder>$b</builder>" |
582 | done | |
583 | ||
584 | if [ "$command" ]; then | |
9cc9841b | 585 | bid=$(uuidgen) |
e6aa37ec | 586 | echo -E >&2 "* Command: $command" |
9cc9841b | 587 | echo " <batch id='$bid' depends-on=''>" |
30ddd991 ER |
588 | echo " <command flags='$command_flags'>" |
589 | echo -E "$command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g' | |
590 | echo "</command>" | |
9cc9841b | 591 | echo " <info></info>" |
d80e53cf | 592 | echo "$builders_xml" |
9cc9841b | 593 | echo " </batch>" |
d80e53cf ER |
594 | depend=$bid |
595 | fi | |
9cc9841b | 596 | |
f147040c | 597 | if [ "$f_upgrade" = "yes" ] ; then |
c9f4704f | 598 | msg "Upgrade mode: $f_upgrade" |
f147040c | 599 | fi |
e728b34c | 600 | |
f147040c | 601 | for s in $specs; do |
218a4c96 | 602 | # skip marker |
d80e53cf | 603 | if [ "$s" = "^" ]; then |
218a4c96 ER |
604 | depend= |
605 | continue | |
606 | fi | |
d80e53cf ER |
607 | if [ "$no_depend" = yes ]; then |
608 | depend= | |
609 | fi | |
f147040c | 610 | bid=$(uuidgen) |
218a4c96 ER |
611 | echo " <batch id='$bid' depends-on='$depend'>" |
612 | ||
f147040c AM |
613 | name=$(echo "$s" | sed -e 's|:.*||') |
614 | branch=$(echo "$s" | sed -e 's|.*:||') | |
c9f4704f | 615 | msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}" |
f147040c AM |
616 | echo " <spec>$name</spec>" |
617 | echo " <branch>$branch</branch>" | |
618 | echo " ${kernel:+<kernel>$kernel</kernel>}" | |
619 | echo " ${target:+<target>$target</target>}" | |
620 | echo " <info></info>" | |
621 | echo | |
622 | for b in $with; do | |
623 | echo " <with>$b</with>" | |
624 | done | |
625 | for b in $without; do | |
626 | echo " <without>$b</without>" | |
627 | done | |
628 | echo | |
d80e53cf | 629 | echo "$builders_xml" |
f147040c AM |
630 | echo " </batch>" |
631 | i=$((i+1)) | |
c4aa0539 | 632 | |
218a4c96 ER |
633 | # let next job depend on previous |
634 | depend=$bid | |
635 | done | |
e728b34c | 636 | |
9cc9841b | 637 | echo "</group>" |
1344b6f1 MM |
638 | } |
639 | ||
640 | gen_email () { | |
e728b34c ER |
641 | # make request first, so the STDERR/STDOUT streams won't be mixed |
642 | local req=$(gen_req) | |
643 | ||
12151609 ER |
644 | if [ "$verbose" = "yes" ]; then |
645 | echo >&2 -E "$req" | |
646 | fi | |
1344b6f1 | 647 | cat <<EOF |
2f470d17 | 648 | From: $requester |
1344b6f1 MM |
649 | To: $builder_email |
650 | Subject: build request | |
651 | Message-Id: <$id@$(hostname)> | |
652 | X-New-PLD-Builder: request | |
2d28916b | 653 | X-Requester-Version: \$Id$ |
1344b6f1 | 654 | |
30ddd991 | 655 | $(echo -E "$req" | gpg --clearsign --default-key $default_key $gpg_opts) |
1344b6f1 MM |
656 | EOF |
657 | } | |
658 | ||
bfa10c0d | 659 | gen_email | send_request |