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