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 out=$(cvs status -v $s | awk "!/Sticky/&&/auto-$dist-/{if (!a++) print \$1}")
168 # get autotag for specs
169 # WARNING: This may checkout some files from CVS
171 local pkg spec rpmdir
173 rpmdir=$(rpm -E %_topdir)
178 # strip .spec extension
180 # checkout only if missing
181 if [ ! -e $pkg/$pkg.spec ]; then
182 $rpmdir/builder -g $pkg -ns -r HEAD 1>&2
184 if [ ! -e $pkg/$pkg.spec ]; then
185 # just print it out, to fallback to base pkg name
188 autotag $pkg/$pkg.spec
195 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
197 Mandatory arguments to long options are mandatory for short options too.
199 --config-file /path/to/config/file
200 Source additional config file (after $USER_CFG), useful when
201 when sending build requests to Ac/Th from the same account
203 Try to use latest auto-tag for the spec when building
204 WARNING: This will checkout new files to your packages dir
205 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
206 Sends request to given builders (in 'version-arch' format)
207 --with VALUE, --without VALUE
208 Build package with(out) a given bcond
210 set alt_kernel to VALUE
212 set --target to VALUE
213 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
214 mark build ids on src builder to be skipped
216 specify default branch for specs in request
218 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
219 ftp tree and won't be upgraded on builders.
221 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
222 (and later moved by release manager staff to ready/ and main ftp tree)
224 Forces package upgrade (for use with -c or -q, not -t)
226 Disables package upgrade (for use with -r)
228 Do not install missing BuildRequires (--nodeps)
230 Do not add dependency of build jobs, each job in batch runs itself
232 Number of parallel jobs for single build
234 -d, --dist DISTRIBUTION_ID
235 Specify value for \$dist
236 -df, --distfiles-fetch[-request] PACKAGE
237 Send distfiles request to fetch sources for PACKAGE
241 Executes a given command on builders (prepended to build jobs if build jobs included)
243 Executes a given command on builders (appended to build jobs if build jobs included)
245 shortcut for --command poldek -evt ARGS
247 shortcut for --command poldek -ev --noask ARGS
249 shortcut for --command poldek --up -Uv ARGS
251 Updates builders infrastructure (outside chroot)
253 Updates rpm-build-macros on src builder
255 shortcut for --command rpm -q ARGS
256 -g, --gpg-opts "opts"
257 Pass additional options to gpg binary
259 sets request priority (default 2)
261 Displays this help message
266 # validate distro, set $dist
284 die "dist \`$1' not known"
291 while [ $# -gt 0 ] ; do
293 -d | --dist | --distro)
299 [ -f "$2" ] && . $2 || die "Config file not found"
305 builders="$builders ${b%:*}"
315 with="$with $(echo "$2" | tr ',' ' ')"
320 without="$without $(echo "$2" | tr ',' ' ')"
370 --no-install-br | -ni)
371 flags="$flags no-install-br"
392 --command-flags | -cf)
399 if [ "$command" = - ]; then
400 echo >&2 "Reading command from STDIN"
409 if [ "$post_command" = - ]; then
410 echo >&2 "Reading post_command from STDIN"
418 command="poldek -evt $2"
423 command="for a in $2; do poldek -ev --noask \$a; done"
428 command="poldek --up; poldek -uv $2"
439 command_flags="no-chroot"
448 -df | --distfiles-fetch | --distfiles-fetch-request)
462 die "unknown knob: $1"
474 builder_email="builder-ac@pld-linux.org"
475 default_builders="ac-*"
476 default_branch="AC-branch"
477 url="http://ep09.pld-linux.org:1289/"
478 control_url="http://ep09.pld-linux.org/~buildsrc"
480 ac-java) # fake "dist" for java available ac architectures
481 builder_email="builder-ac@pld-linux.org"
482 default_builders="ac-i586 ac-i686 ac-athlon ac-amd64"
483 default_branch="AC-branch"
484 url="http://ep09.pld-linux.org:1289/"
486 ac-xen) # fake "dist" for xen-enabled architectures
487 builder_email="builder-ac@pld-linux.org"
488 default_builders="ac-i686 ac-athlon ac-amd64"
489 default_branch="AC-branch"
492 builder_email="builderti@kraz.tld-linux.org"
493 default_builders="ti-*"
494 url="http://kraz.tld-linux.org:1231/"
495 control_url="http://kraz.tld-linux.org/~builderti"
498 builder_email="buildertidev@kraz.tld-linux.org"
499 default_builders="ti-dev-*"
500 url="http://kraz.tld-linux.org:1232/"
501 control_url="http://kraz.tld-linux.org/~buildertidev"
504 builder_email="builderth@pld-linux.org"
505 default_builders="th-*"
506 url="http://src.th.pld-linux.org:1234/"
507 control_url="http://src.th.pld-linux.org"
509 th-java) # fake "dist" for java available th architectures
510 builder_email="builderth@pld-linux.org"
511 default_builders="th-x86_64 th-athlon th-i686"
512 url="http://src.th.pld-linux.org:1234/"
515 builder_email="builderaidath@ep09.pld-linux.org"
516 default_builders="aidath-*"
519 die "dist \`$dist' not known"
523 # need to do this after dist selection
525 skip=$(skip="$skip" control_url="$control_url" python -c '
533 from xml.dom import minidom
535 skip = os.environ.get("skip").split(",");
536 control_url = os.environ.get("control_url")
538 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
541 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
542 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
543 f = urllib2.urlopen(req)
545 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
548 sio = StringIO.StringIO()
552 f = gzip.GzipFile(fileobj = sio)
554 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
555 d = minidom.parseString(xml)
558 for c in d.documentElement.childNodes:
559 if c.nodeName != "group":
561 q.append(c.attributes["id"].value)
566 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
569 print >> sys.stderr, "- Check %s: OK" % s
572 print string.join(skip, ",")
578 command_flags="no-chroot"
582 branch=${branch:-$default_branch}
584 specs=`for s in $specs; do
587 # skip marker - pass it along
590 *.spec:*) # spec with branch
593 *.spec) # spec without branch
594 echo $(basename $s):$branch
596 *:*) # package name with branch
597 basename $s | sed -e 's/:/.spec:/'
599 *) # just package name
600 echo $(basename $s).spec:$branch
605 if [ "$autotag" = "yes" ]; then
606 msg "Auto autotag build enabled"
607 specs=$(get_autotag $specs)
610 if [ "$df_fetch" = "yes" ]; then
615 if [ "$upgrade_macros" = "yes" ]; then
616 command="poldek --up; poldek -uv rpm-build-macros"
622 if [[ "$requester" != *@* ]] ; then
623 requester="$requester@pld-linux.org"
626 if [ -z "$builders" ] ; then
627 builders="$default_builders"
630 if [ "$f_upgrade" = "yes" ] ; then
631 flags="$flags upgrade"
634 if [ "$build_mode" = "test" ] ; then
635 if [ "$f_upgrade" = "yes" ] ; then
636 die "--upgrade and --test-build are mutually exclusive"
638 flags="$flags test-build"
641 if [ -z "$build_mode" ] ; then
642 # missing build mode, builders go crazy when you proceed"
643 die "please specify build mode"
652 if [ -z "$specs" -a -z "$command" ]; then
653 die "no packages to build or command to invoke specified"
659 echo "<group id='$id' no='0' flags='$flags'>"
660 echo " <time>$(date +%s)</time>"
661 msg "Using priority $priority"
662 echo " <priority>$priority</priority>"
663 if [ -n "$jobs" ]; then
664 msg "Using jobs $jobs"
665 echo " <maxjobs>$jobs</maxjobs>"
667 if [ -z "$url" ]; then
668 msg "Using email $builder_email"
673 if [ "$build_mode" = "ready" ]; then
674 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
676 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
685 local name branch builders_xml
687 for b in $builders; do
688 msg "Builder: $(red $b)"
689 builders_xml="$builders_xml <builder>$b</builder>"
692 if [ "$command" ]; then
694 echo -E >&2 "* Command: $command"
695 echo " <batch id='$bid' depends-on=''>"
696 echo " <command flags='$command_flags'>"
697 echo -E "$command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
699 echo " <info></info>"
705 if [ "$f_upgrade" = "yes" ] ; then
706 msg "Upgrade mode: $f_upgrade"
711 if [ "$s" = "^" ]; then
715 if [ "$no_depend" = yes ]; then
719 echo " <batch id='$bid' depends-on='$depend'>"
721 name=$(echo "$s" | sed -e 's|:.*||')
722 branch=$(echo "$s" | sed -e 's|.*:||')
723 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
724 echo " <spec>$name</spec>"
725 echo " <branch>$branch</branch>"
726 echo " ${kernel:+<kernel>$kernel</kernel>}"
727 echo " ${target:+<target>$target</target>}"
728 echo " <info></info>"
731 echo " <with>$b</with>"
733 for b in $without; do
734 echo " <without>$b</without>"
741 # let next job depend on previous
745 if [ "$post_command" ]; then
747 if [ "$no_depend" = yes ]; then
750 echo -E >&2 "* Post-Command: $post_command"
751 echo " <batch id='$bid' depends-on='$depend'>"
752 echo " <command flags='$command_flags'>"
753 echo -E "$post_command" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
755 echo " <info></info>"
765 # make request first, so the STDERR/STDOUT streams won't be mixed
770 if [ "$verbose" = "yes" ]; then
777 Subject: build request
778 Message-Id: <$id@$(hostname)>
779 X-New-PLD-Builder: request
780 X-Requester-Version: \$Id$
784 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
788 gen_email | send_request