3 # prevent "*" from being expanded in builders var
20 if [ -x /usr/bin/python ]; then
23 echo "No python present, using mail mode"
27 if [ -n "$HOME_ETC" ]; then
28 USER_CFG=$HOME_ETC/.requestrc
30 USER_CFG=$HOME/.requestrc
33 if [ ! -f "$USER_CFG" ]; then
34 echo "Creating config file $USER_CFG. You *must* edit it."
37 requester=deviloper@pld-linux.org
38 default_key=deviloper@pld-linux.org
39 send_mode="$send_mode"
41 mailer="/usr/sbin/sendmail -t"
44 url="http://src.th.pld-linux.org:1234/"
52 if [ -f "$USER_CFG" ]; then
55 if [ "${distro:+set}" = "set" ]; then
60 # internal options, not to be overriden
66 c_star=$(tput setaf 2)
70 echo >&2 "${c_star}*${c_norm} $*"
73 echo "${c_red}$*${c_norm}"
82 # switch to mail mode, if no url set
83 [ -z "$url" ] && send_mode="mail"
87 msg "Sending using mail mode"
91 msg "Sending using http mode to $url"
93 import sys, socket, urllib2
96 data = sys.stdin.read()
98 socket.setdefaulttimeout(10)
99 req = urllib2.Request(url, data)
100 f = urllib2.urlopen(req)
103 print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
105 print >> sys.stdout, "Request queued via HTTP."
111 # simple df_fetcher, based on packages/fetchsrc_request
112 # TODO: tcp (smtp) mode
113 # TODO: adjust for ~/.requestrc config
118 local MAILER='/usr/sbin/sendmail'
119 # MAILER='/usr/bin/msmtp'
124 #VIA_ARGS="some additional flags"
126 # VIA_ARGS='-a gmail'
129 local DMAIL="distfiles@pld-linux.org"
131 local HOST=$(hostname -f)
132 local LOGIN=${requester%@*}
134 for spec in $specs; do
135 local SPEC=$(echo "$spec" | sed -e 's|:.*||')
136 local BRANCH=$(echo "$spec" | sed -e 's|.*:||')
137 echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}"
138 cat <<-EOF | "$MAILER" -t -i $VIA_ARGS
140 From: $LOGIN <$LOGIN@$HOST>
141 Subject: fetchsrc_request notify
143 X-distfiles-request: yes
154 # autotag from rpm-build-macros
155 # displays latest used tag for a specfile
161 # ensure package ends with .spec
163 local gitdir=$(dirname $s)/.git
164 out=$(git --git-dir="$gitdir" for-each-ref --count=1 --sort=-committerdate refs/tags/auto/$dist \
165 --format='%(refname:short)')
170 # get autotag for specs
171 # WARNING: This may checkout some files from CVS
173 local pkg spec rpmdir
175 rpmdir=$(rpm -E %_topdir)
180 # strip .spec extension
182 # checkout only if missing
183 if [ ! -e $pkg/$pkg.spec ]; then
184 $rpmdir/builder -g $pkg -ns -r HEAD 1>&2
186 if [ ! -e $pkg/$pkg.spec ]; then
187 # just print it out, to fallback to base pkg name
190 autotag $pkg/$pkg.spec
197 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
199 Mandatory arguments to long options are mandatory for short options too.
201 --config-file /path/to/config/file
202 Source additional config file (after $USER_CFG), useful when
203 when sending build requests to Ac/Th from the same account
205 Try to use latest auto-tag for the spec when building
206 WARNING: This will checkout new files to your packages dir
207 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
208 Sends request to given builders (in 'version-arch' format)
209 --with VALUE, --without VALUE
210 Build package with(out) a given bcond
212 set alt_kernel to VALUE
214 set --target to VALUE
215 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
216 mark build ids on src builder to be skipped
218 specify default branch for specs in request
220 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
221 ftp tree and won't be upgraded on builders.
223 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
224 (and later moved by release manager staff to ready/ and main ftp tree)
226 Forces package upgrade (for use with -c or -q, not -t)
228 Disables package upgrade (for use with -r)
230 Do not install missing BuildRequires (--nodeps)
232 Do not add dependency of build jobs, each job in batch runs itself
234 Number of parallel jobs for single build
236 -d, --dist DISTRIBUTION_ID
237 Specify value for \$dist
238 -df, --distfiles-fetch[-request] PACKAGE
239 Send distfiles request to fetch sources for PACKAGE
243 Executes a given command on builders (prepended to build jobs if build jobs included)
245 Executes a given command on builders (appended to build jobs if build jobs included)
247 shortcut for --command poldek -evt ARGS
249 shortcut for --command poldek -ev --noask ARGS
251 shortcut for --command poldek --up -Uv ARGS
253 Updates builders infrastructure (outside chroot)
255 Updates rpm-build-macros on src builder
257 shortcut for --command rpm -q ARGS
258 -g, --gpg-opts "opts"
259 Pass additional options to gpg binary
261 sets request priority (default 2)
263 Displays this help message
268 # validate distro, set $dist
286 die "dist \`$1' not known"
293 while [ $# -gt 0 ] ; do
295 -d | --dist | --distro)
301 [ -f "$2" ] && . $2 || die "Config file not found"
307 builders="$builders ${b%:*}"
317 with="$with $(echo "$2" | tr ',' ' ')"
322 without="$without $(echo "$2" | tr ',' ' ')"
372 --no-install-br | -ni)
373 flags="$flags no-install-br"
394 --command-flags | -cf)
401 if [ "$command" = - ]; then
402 echo >&2 "Reading command from STDIN"
411 if [ "$post_command" = - ]; then
412 echo >&2 "Reading post_command from STDIN"
420 command="poldek -evt $2"
425 command="for a in $2; do poldek -ev --noask \$a; done"
430 command="poldek --up; poldek -uv $2"
441 command_flags="no-chroot"
450 -df | --distfiles-fetch | --distfiles-fetch-request)
464 die "unknown knob: $1"
476 builder_email="builder-ac@pld-linux.org"
477 default_builders="ac-*"
478 default_branch="AC-branch"
479 url="http://ep09.pld-linux.org:1289/"
480 control_url="http://ep09.pld-linux.org/~buildsrc"
482 ac-java) # fake "dist" for java available ac architectures
483 builder_email="builder-ac@pld-linux.org"
484 default_builders="ac-i586 ac-i686 ac-athlon ac-amd64"
485 default_branch="AC-branch"
486 url="http://ep09.pld-linux.org:1289/"
488 ac-xen) # fake "dist" for xen-enabled architectures
489 builder_email="builder-ac@pld-linux.org"
490 default_builders="ac-i686 ac-athlon ac-amd64"
491 default_branch="AC-branch"
494 builder_email="builderti@ep09.pld-linux.org"
495 default_builders="ti-*"
496 url="http://ep09.pld-linux.org:1231/"
497 control_url="http://ep09.pld-linux.org/~builderti"
500 builder_email="buildertidev@ep09.pld-linux.org"
501 default_builders="ti-dev-*"
502 url="http://ep09.pld-linux.org:1232/"
503 control_url="http://ep09.pld-linux.org/~buildertidev"
506 builder_email="builderth@pld-linux.org"
507 default_builders="th-*"
508 url="http://src.th.pld-linux.org:1234/"
509 control_url="http://src.th.pld-linux.org"
511 th-java) # fake "dist" for java available th architectures
512 builder_email="builderth@pld-linux.org"
513 default_builders="th-x86_64 th-athlon th-i686"
514 url="http://src.th.pld-linux.org:1234/"
517 builder_email="builderaidath@ep09.pld-linux.org"
518 default_builders="aidath-*"
521 die "dist \`$dist' not known"
525 # need to do this after dist selection
527 skip=$(skip="$skip" control_url="$control_url" python -c '
535 from xml.dom import minidom
537 skip = os.environ.get("skip").split(",");
538 control_url = os.environ.get("control_url")
540 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
543 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
544 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
545 f = urllib2.urlopen(req)
547 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
550 sio = StringIO.StringIO()
554 f = gzip.GzipFile(fileobj = sio)
556 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
557 d = minidom.parseString(xml)
560 for c in d.documentElement.childNodes:
561 if c.nodeName != "group":
563 q.append(c.attributes["id"].value)
568 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
571 print >> sys.stderr, "- Check %s: OK" % s
574 print string.join(skip, ",")
580 command_flags="no-chroot"
584 branch=${branch:-$default_branch}
586 specs=`for s in $specs; do
589 # skip marker - pass it along
592 *.spec:*) # spec with branch
595 *.spec) # spec without branch
596 echo $(basename $s):$branch
598 *:*) # package name with branch
599 basename $s | sed -e 's/:/.spec:/'
601 *) # just package name
602 echo $(basename $s).spec:$branch
607 if [ "$autotag" = "yes" ]; then
608 msg "Auto autotag build enabled"
609 specs=$(get_autotag $specs)
612 if [ "$df_fetch" = "yes" ]; then
617 if [ "$upgrade_macros" = "yes" ]; then
618 command="poldek --up; poldek -uv rpm-build-macros"
624 if [[ "$requester" != *@* ]] ; then
625 requester="$requester@pld-linux.org"
628 if [ -z "$builders" ] ; then
629 builders="$default_builders"
632 if [ "$f_upgrade" = "yes" ] ; then
633 flags="$flags upgrade"
636 if [ "$build_mode" = "test" ] ; then
637 if [ "$f_upgrade" = "yes" ] ; then
638 die "--upgrade and --test-build are mutually exclusive"
640 flags="$flags test-build"
643 if [ -z "$build_mode" ] ; then
644 # missing build mode, builders go crazy when you proceed"
645 die "please specify build mode"
654 if [ -z "$specs" -a -z "$command" ]; then
655 die "no packages to build or command to invoke specified"
661 echo "<group id='$id' no='0' flags='$flags'>"
662 echo " <time>$(date +%s)</time>"
663 msg "Using priority $priority"
664 echo " <priority>$priority</priority>"
665 if [ -n "$jobs" ]; then
666 msg "Using jobs $jobs"
667 echo " <maxjobs>$jobs</maxjobs>"
669 if [ -z "$url" ]; then
670 msg "Using email $builder_email"
675 if [ "$build_mode" = "ready" ]; then
676 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
678 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
687 local name branch builders_xml
689 for b in $builders; do
690 msg "Builder: $(red $b)"
691 builders_xml="$builders_xml <builder>$b</builder>"
694 if [ "$command" ]; then
696 echo -E >&2 "* Command: $command"
697 echo " <batch id='$bid' depends-on=''>"
698 echo " <command flags='$command_flags'>"
699 echo -E "$command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
701 echo " <info></info>"
707 if [ "$f_upgrade" = "yes" ] ; then
708 msg "Upgrade mode: $f_upgrade"
713 if [ "$s" = "^" ]; then
717 if [ "$no_depend" = yes ]; then
721 echo " <batch id='$bid' depends-on='$depend'>"
723 name=$(echo "$s" | sed -e 's|:.*||')
724 branch=$(echo "$s" | sed -e 's|.*:||')
725 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
726 echo " <spec>$name</spec>"
727 echo " <branch>$branch</branch>"
728 echo " ${kernel:+<kernel>$kernel</kernel>}"
729 echo " ${target:+<target>$target</target>}"
730 echo " <info></info>"
733 echo " <with>$b</with>"
735 for b in $without; do
736 echo " <without>$b</without>"
743 # let next job depend on previous
747 if [ "$post_command" ]; then
749 if [ "$no_depend" = yes ]; then
752 echo -E >&2 "* Post-Command: $post_command"
753 echo " <batch id='$bid' depends-on='$depend'>"
754 echo " <command flags='$command_flags'>"
755 echo -E "$post_command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
757 echo " <info></info>"
767 # make request first, so the STDERR/STDOUT streams won't be mixed
772 if [ "$verbose" = "yes" ]; then
779 Subject: build request
780 Message-Id: <$id@$(hostname)>
781 X-New-PLD-Builder: request
782 X-Requester-Version: \$Id$
786 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
790 gen_email | send_request