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