3 # prevent "*" from being expanded in builders var
18 [ -x /usr/bin/python ] && send_mode="python" || send_mode="mail"
20 if [ -n "$HOME_ETC" ]; then
21 USER_CFG=$HOME_ETC/.requestrc
23 USER_CFG=$HOME/.requestrc
26 if [ ! -f "$USER_CFG" ]; then
27 echo "Creating config file $USER_CFG. You *must* edit it."
30 requester=deviloper@pld-linux.org
31 default_key=deviloper@pld-linux.org
32 send_mode="$send_mode"
34 mailer="/usr/sbin/sendmail -t"
37 url="http://ep09.pld-linux.org:1234/"
45 if [ -f "$USER_CFG" ]; then
50 # switch to mail mode, if no url set
51 [ -z "$url" ] && send_mode="mail"
56 echo >&2 "* Sending using mail mode"
60 echo >&2 "* Sending using http mode to $url"
65 data = sys.stdin.read()
66 req = urllib2.Request(sys.argv[1], data)
67 f = urllib2.urlopen(req, timeout = 10)
70 print >> sys.stderr, "Problem while sending request via HTTP: %s" % e
72 print >> sys.stdout, "Request queued via HTTP."
84 echo "Usage: make-request.sh [OPTION] ... [SPECFILE] ...."
86 echo "Mandatory arguments to long options are mandatory for short options too."
87 echo " -C --config-file /path/to/config/file"
88 echo " Source additional config file (after $USER_CFG), useful when"
89 echo " when sending build requests to Ac/Th from the same account"
90 echo " -b 'BUILDER BUILDER ...' --builder='BUILDER BUILDER ...'"
91 echo " Sends request to given builders (in 'version-arch' format)"
92 echo " --with VALUE --without VALUE"
93 echo " Build package with(out) a given bcond"
94 echo " --kernel VALUE"
95 echo " set alt_kernel to VALUE"
96 echo " --target VALUE"
97 echo " set --target to VALUE"
98 echo " --branch VALUE"
99 echo " specify default branch for specs in request"
100 echo " -t --test-build"
101 echo " Performs a 'test-build'. Package will be uploaded to test/ tree"
102 echo " and won't be upgraded on builders"
103 echo " -r --ready-build"
104 echo " Build and upgrade package and upload it to ready/ tree"
106 echo " Forces package upgrade (for use with -c or -q, not -t)"
107 echo " -n --no-upgrade"
108 echo " Disables package upgrade (for use with -r)"
109 echo " -ni -no-install-br"
110 echo " Do not install missing BuildRequires (--nodeps)"
111 echo " -j Number of parallel jobs for single build"
114 echo " Specify value for \$distro"
115 echo " -cf --command-flag"
116 echo " Not yet documented"
118 echo " Executes a given command on builders"
119 echo " --test-remove-pkg"
120 echo " shortcut for --command poldek -evt ARGS"
122 echo " shortcut for --command poldek -ev --noask ARGS"
123 echo " --upgrade-pkg"
124 echo " shortcut for --command poldek --up -Uv ARGS"
126 echo " Updates builders infrastructure (outside chroot)"
128 echo " shortcut for --command rpm -q ARGS"
129 echo " -g --gpg-opts \"opts\""
130 echo " Pass additional options to gpg binary"
131 echo " -p --priority VALUE"
132 echo " sets request priority (default 2)"
134 echo " Displays this help message"
139 while [ $# -gt 0 ] ; do
147 [ -f $2 ] && . $2 || die "Config file not found"
152 builders="$builders $2"
162 without="$without $2"
203 --no-install-br | -ni )
204 flags="$flags no-install-br"
217 --command-flags | -cf )
228 command="poldek -evt $2"
233 command="for a in $2; do poldek -ev --noask \$a; done"
238 command="poldek --up -Uv $2"
249 command_flags="no-chroot"
264 die "unknown knob: $1"
276 builder_email="builder-ac@pld-linux.org"
277 default_builders="ac-*"
278 default_branch="AC-branch"
280 ac-java) # fake "distro" for java available ac architectures
281 builder_email="builder-ac@pld-linux.org"
282 default_builders="ac-i586 ac-i686 ac-athlon ac-amd64"
283 default_branch="AC-branch"
285 ac-xen) # fake "distro" for xen-enabled architectures
286 builder_email="builder-ac@pld-linux.org"
287 default_builders="ac-i686 ac-athlon ac-amd64"
288 default_branch="AC-branch"
291 builder_email="builderti@ep09.pld-linux.org"
292 default_builders="ti-*"
295 builder_email="builderth@ep09.pld-linux.org"
296 default_builders="th-*"
297 url="http://ep09.pld-linux.org:1234/"
299 th-java) # fake "distro" for java available th architectures
300 builder_email="builderth@ep09.pld-linux.org"
301 default_builders="th-x86_64 th-athlon th-i686"
302 url="http://ep09.pld-linux.org:1234/"
305 builder_email="builderaidath@ep09.pld-linux.org"
306 default_builders="aidath-*"
309 die "distro \`$distro' not known"
313 branch=${branch:-$default_branch}
315 specs=`for s in $specs; do
317 *.spec:*) # spec with branch
320 *.spec) # spec without branch
321 echo $(basename $s):$branch
323 *:*) # package name with branch
324 basename $s | sed -e 's/:/.spec:/'
326 *) # just package name
327 echo $(basename $s).spec:$branch
332 if [[ "$requester" != *@* ]] ; then
333 requester="$requester@pld-linux.org"
336 if [ -z "$builders" ] ; then
337 builders="$default_builders"
340 if [ "$f_upgrade" = "yes" ] ; then
341 flags="$flags upgrade"
344 if [ "$build_mode" = "test" ] ; then
345 if [ "$f_upgrade" = "yes" ] ; then
346 die "--upgrade and --test-build are mutually exclusive"
348 flags="$flags test-build"
351 if [ -z "$build_mode" ] ; then
352 # missing build mode, builders go crazy when you proceed"
353 die "please specify build mode"
362 if [ "$ok" = "" ] ; then
363 if [ "$command" = "" ] ; then
364 die "no specs passed"
367 if [ "$command" != "" ] ; then
368 die "cannot pass specs and --command"
375 echo "<group id='$id' no='0' flags='$flags'>"
376 echo " <time>$(date +%s)</time>"
377 echo " <priority>$priority</priority>"
378 if [ -n "$jobs" ]; then
379 echo " <maxjobs>$jobs</maxjobs>"
383 if [ "$command" != "" ] ; then
385 echo >&2 "* Command: $command"
386 echo " <batch id='$bid' depends-on=''>"
387 echo " <command flags='$command_flags'>$(echo "$command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g')</command>"
388 echo " <info></info>"
389 for b in $builders; do
390 echo >&2 "* Builder: $b"
391 echo " <builder>$b</builder>"
396 echo >&2 "* Using priority $priority"
397 if [ -n "$jobs" ]; then
398 echo >&2 "* Using jobs $jobs"
400 echo >&2 "* Using email $builder_email"
401 echo >&2 "* Build mode: $build_mode"
402 if [ "$f_upgrade" = "yes" ] ; then
403 echo >&2 "* Upgrade mode: $f_upgrade"
405 echo >&2 "* Queue-ID: $id"
411 for b in $builders; do
412 echo >&2 "* Builder: $b"
416 echo " <batch id='$bid' depends-on='$fid'>"
417 [ "$fid" = "" ] && fid="$bid"
418 name=$(echo "$s" | sed -e 's|:.*||')
419 branch=$(echo "$s" | sed -e 's|.*:||')
420 echo >&2 "* Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}"
421 echo " <spec>$name</spec>"
422 echo " <branch>$branch</branch>"
423 echo " ${kernel:+<kernel>$kernel</kernel>}"
424 echo " ${target:+<target>$target</target>}"
425 echo " <info></info>"
428 echo " <with>$b</with>"
430 for b in $without; do
431 echo " <without>$b</without>"
434 for b in $builders; do
435 echo " <builder>$b</builder>"
447 # make request first, so the STDERR/STDOUT streams won't be mixed
453 Subject: build request
454 Message-Id: <$id@$(hostname)>
455 X-New-PLD-Builder: request
456 X-Requester-Version: \$Id$
458 $(echo "$req" | gpg --clearsign --default-key $default_key $gpg_opts)
462 gen_email | send_request