3 # prevent "*" from being expanded in builders var
19 if [ -x /usr/bin/python ]; then
22 echo "No python present, using mail mode"
26 if [ -n "$HOME_ETC" ]; then
27 USER_CFG=$HOME_ETC/.requestrc
29 USER_CFG=$HOME/.requestrc
32 if [ ! -f "$USER_CFG" ]; then
33 echo "Creating config file $USER_CFG. You *must* edit it."
36 requester=deviloper@pld-linux.org
37 default_key=deviloper@pld-linux.org
38 send_mode="$send_mode"
40 mailer="/usr/sbin/sendmail -t"
43 url="http://src.th.pld-linux.org:1234/"
51 if [ -f "$USER_CFG" ]; then
55 # internal options, not to be overriden
61 c_star=$(tput setaf 2)
65 echo >&2 "${c_star}*${c_norm} $*"
68 echo "${c_red}$*${c_norm}"
77 # switch to mail mode, if no url set
78 [ -z "$url" ] && send_mode="mail"
82 msg "Sending using mail mode"
86 msg "Sending using http mode to $url"
88 import sys, socket, urllib2
91 data = sys.stdin.read()
93 socket.setdefaulttimeout(10)
94 req = urllib2.Request(url, data)
95 f = urllib2.urlopen(req)
98 print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
100 print >> sys.stdout, "Request queued via HTTP."
106 # simple df_fetcher, based on packages/fetchsrc_request
107 # TODO: tcp (smtp) mode
108 # TODO: adjust for ~/.requestrc config
113 local MAILER='/usr/sbin/sendmail'
114 # MAILER='/usr/bin/msmtp'
119 #VIA_ARGS="some additional flags"
121 # VIA_ARGS='-a gmail'
124 local DMAIL="distfiles@pld-linux.org"
126 local HOST=$(hostname -f)
127 local LOGIN=${requester%@*}
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
135 From: $LOGIN <$LOGIN@$HOST>
136 Subject: fetchsrc_request notify
138 X-distfiles-request: yes
151 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
153 Mandatory arguments to long options are mandatory for short options too.
155 --config-file /path/to/config/file
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 ...'
159 Sends request to given builders (in 'version-arch' format)
160 --with VALUE, --without VALUE
161 Build package with(out) a given bcond
163 set alt_kernel to VALUE
165 set --target to VALUE
166 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
167 mark build ids on src builder to be skipped
169 specify default branch for specs in request
171 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
172 ftp tree and won't be upgraded on builders.
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)
177 Forces package upgrade (for use with -c or -q, not -t)
179 Disables package upgrade (for use with -r)
181 Do not install missing BuildRequires (--nodeps)
183 Do not add dependency of build jobs, each job in batch runs itself
185 Number of parallel jobs for single build
188 Specify value for \$distro
189 -df, --distfiles-fetch[-request] PACKAGE
190 Send distfiles request to fetch sources for PACKAGE
194 Executes a given command on builders (prepended to build jobs if build jobs included)
196 Executes a given command on builders (appended to build jobs if build jobs included)
198 shortcut for --command poldek -evt ARGS
200 shortcut for --command poldek -ev --noask ARGS
202 shortcut for --command poldek --up -Uv ARGS
204 Updates builders infrastructure (outside chroot)
206 Updates rpm-build-macros on src builder
208 shortcut for --command rpm -q ARGS
209 -g, --gpg-opts "opts"
210 Pass additional options to gpg binary
212 sets request priority (default 2)
214 Displays this help message
219 # validate distro, set $distro
237 die "distro \`$1' not known"
244 while [ $# -gt 0 ] ; do
252 [ -f "$2" ] && . $2 || die "Config file not found"
258 builders="$builders ${b%:*}"
264 with="$with $(echo "$2" | tr ',' ' ')"
269 without="$without $(echo "$2" | tr ',' ' ')"
319 --no-install-br | -ni)
320 flags="$flags no-install-br"
341 --command-flags | -cf)
348 if [ "$command" = - ]; then
349 echo >&2 "Reading command from STDIN"
358 if [ "$post_command" = - ]; then
359 echo >&2 "Reading post_command from STDIN"
367 command="poldek -evt $2"
372 command="for a in $2; do poldek -ev --noask \$a; done"
377 command="poldek --up; poldek -uv $2"
388 command_flags="no-chroot"
397 -df | --distfiles-fetch | --distfiles-fetch-request)
411 die "unknown knob: $1"
423 builder_email="builder-ac@pld-linux.org"
424 default_builders="ac-*"
425 default_branch="AC-branch"
426 url="http://ep09.pld-linux.org:1289/"
427 control_url="http://ep09.pld-linux.org/~buildsrc"
429 ac-java) # fake "distro" for java available ac architectures
430 builder_email="builder-ac@pld-linux.org"
431 default_builders="ac-i586 ac-i686 ac-athlon ac-amd64"
432 default_branch="AC-branch"
433 url="http://ep09.pld-linux.org:1289/"
435 ac-xen) # fake "distro" for xen-enabled architectures
436 builder_email="builder-ac@pld-linux.org"
437 default_builders="ac-i686 ac-athlon ac-amd64"
438 default_branch="AC-branch"
441 builder_email="builderti@ep09.pld-linux.org"
442 default_builders="ti-*"
443 url="http://ep09.pld-linux.org:1231/"
444 control_url="http://ep09.pld-linux.org/~builderti"
447 builder_email="buildertidev@ep09.pld-linux.org"
448 default_builders="ti-dev-*"
449 url="http://ep09.pld-linux.org:1232/"
450 control_url="http://ep09.pld-linux.org/~buildertidev"
453 builder_email="builderth@pld-linux.org"
454 default_builders="th-*"
455 url="http://src.th.pld-linux.org:1234/"
456 control_url="http://src.th.pld-linux.org"
458 th-java) # fake "distro" for java available th architectures
459 builder_email="builderth@pld-linux.org"
460 default_builders="th-x86_64 th-athlon th-i686"
461 url="http://src.th.pld-linux.org:1234/"
464 builder_email="builderaidath@ep09.pld-linux.org"
465 default_builders="aidath-*"
468 die "distro \`$distro' not known"
472 # need to do this after distro selection
474 skip=$(skip="$skip" control_url="$control_url" python -c '
482 from xml.dom import minidom
484 skip = os.environ.get("skip").split(",");
485 control_url = os.environ.get("control_url")
487 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
490 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
491 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
492 f = urllib2.urlopen(req)
494 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
497 sio = StringIO.StringIO()
501 f = gzip.GzipFile(fileobj = sio)
503 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
504 d = minidom.parseString(xml)
507 for c in d.documentElement.childNodes:
508 if c.nodeName != "group":
510 q.append(c.attributes["id"].value)
515 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
518 print >> sys.stderr, "- Check %s: OK" % s
521 print string.join(skip, ",")
527 command_flags="no-chroot"
528 builders="$distro-src"
531 branch=${branch:-$default_branch}
533 specs=`for s in $specs; do
539 *.spec:*) # spec with branch
542 *.spec) # spec without branch
543 echo $(basename $s):$branch
545 *:*) # package name with branch
546 basename $s | sed -e 's/:/.spec:/'
548 *) # just package name
549 echo $(basename $s).spec:$branch
554 if [ "$df_fetch" = "yes" ]; then
559 if [ "$upgrade_macros" = "yes" ]; then
560 command="poldek --up; poldek -uv rpm-build-macros"
561 builders="$distro-src"
566 if [[ "$requester" != *@* ]] ; then
567 requester="$requester@pld-linux.org"
570 if [ -z "$builders" ] ; then
571 builders="$default_builders"
574 if [ "$f_upgrade" = "yes" ] ; then
575 flags="$flags upgrade"
578 if [ "$build_mode" = "test" ] ; then
579 if [ "$f_upgrade" = "yes" ] ; then
580 die "--upgrade and --test-build are mutually exclusive"
582 flags="$flags test-build"
585 if [ -z "$build_mode" ] ; then
586 # missing build mode, builders go crazy when you proceed"
587 die "please specify build mode"
596 if [ -z "$specs" -a -z "$command" ]; then
597 die "no packages to build or command to invoke specified"
603 echo "<group id='$id' no='0' flags='$flags'>"
604 echo " <time>$(date +%s)</time>"
605 msg "Using priority $priority"
606 echo " <priority>$priority</priority>"
607 if [ -n "$jobs" ]; then
608 msg "Using jobs $jobs"
609 echo " <maxjobs>$jobs</maxjobs>"
611 msg "Build mode: $build_mode"
612 if [ -z "$url" ]; then
613 msg "Using email $builder_email"
623 local name branch builders_xml
625 for b in $builders; do
626 msg "Builder: $(red $b)"
627 builders_xml="$builders_xml <builder>$b</builder>"
630 if [ "$command" ]; then
632 echo -E >&2 "* Command: $command"
633 echo " <batch id='$bid' depends-on=''>"
634 echo " <command flags='$command_flags'>"
635 echo -E "$command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
637 echo " <info></info>"
643 if [ "$f_upgrade" = "yes" ] ; then
644 msg "Upgrade mode: $f_upgrade"
649 if [ "$s" = "^" ]; then
653 if [ "$no_depend" = yes ]; then
657 echo " <batch id='$bid' depends-on='$depend'>"
659 name=$(echo "$s" | sed -e 's|:.*||')
660 branch=$(echo "$s" | sed -e 's|.*:||')
661 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
662 echo " <spec>$name</spec>"
663 echo " <branch>$branch</branch>"
664 echo " ${kernel:+<kernel>$kernel</kernel>}"
665 echo " ${target:+<target>$target</target>}"
666 echo " <info></info>"
669 echo " <with>$b</with>"
671 for b in $without; do
672 echo " <without>$b</without>"
679 # let next job depend on previous
683 if [ "$post_command" ]; then
685 if [ "$no_depend" = yes ]; then
688 echo -E >&2 "* Post-Command: $post_command"
689 echo " <batch id='$bid' depends-on='$depend'>"
690 echo " <command flags='$command_flags'>"
691 echo -E "$post_command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
693 echo " <info></info>"
703 # make request first, so the STDERR/STDOUT streams won't be mixed
706 if [ "$verbose" = "yes" ]; then
712 Subject: build request
713 Message-Id: <$id@$(hostname)>
714 X-New-PLD-Builder: request
715 X-Requester-Version: \$Id$
717 $(echo -E "$req" | gpg --clearsign --default-key $default_key $gpg_opts)
721 gen_email | send_request