5 # prevent "*" from being expanded in builders var
24 if [ -x /usr/bin/python ]; then
27 echo "No python present, using mail mode"
31 if [ -n "$HOME_ETC" ]; then
32 USER_CFG=$HOME_ETC/.requestrc
34 USER_CFG=$HOME/.requestrc
37 if [ ! -f "$USER_CFG" ]; then
38 echo "Creating config file $USER_CFG. You *must* edit it."
41 requester=deviloper@tld-linux.org
42 default_key=deviloper@tld-linux.org
43 send_mode="$send_mode"
45 mailer="/usr/lib/sendmail -t"
48 url="http://kraz.tld-linux.org:1231/"
56 if [ -f "$USER_CFG" ]; then
59 if [ "${distro:+set}" = "set" ]; then
64 # internal options, not to be overriden
72 c_star=$(tput setaf 2)
76 echo >&2 "${c_star}*${c_norm} $*"
79 echo "${c_red}$*${c_norm}"
88 # switch to mail mode, if no url set
89 [ -z "$url" ] && send_mode="mail"
91 if [ -n "$wait" ]; then
92 msg "Waiting $wait seconds before sending request"
94 msg "Wait has ended, proceeding!"
99 msg "Sending using mail mode"
103 msg "Sending using HTTP mode to $url"
105 import sys, socket, urllib2
108 data = sys.stdin.read()
110 socket.setdefaulttimeout(30)
111 req = urllib2.Request(url, data)
112 f = urllib2.urlopen(req)
115 print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
117 print >> sys.stdout, "Request queued via HTTP."
123 # htmlspecialchars: escape <, > and &
126 echo -E "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
129 # simple df_fetcher, based on packages/fetchsrc_request
130 # TODO: tcp (smtp) mode
131 # TODO: adjust for ~/.requestrc config
136 local MAILER='/usr/lib/sendmail'
137 # MAILER='/usr/bin/msmtp'
142 #VIA_ARGS="some additional flags"
144 # VIA_ARGS='-a gmail'
147 local DMAIL="df@tld-linux.org"
149 local HOST=$(hostname -f)
150 local LOGIN=${requester%@*}
153 for spec in $specs; do
154 SPEC=$(echo "$spec" | sed -e 's|:.*||')
156 BRANCH=$(echo "$spec" | sed -e 's|.*:||')
157 echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}"
158 cat <<-EOF | "$MAILER" -t -i $VIA_ARGS
160 From: $LOGIN <$LOGIN@$HOST>
161 Subject: fetchsrc_request notify
162 X-distfiles-request: yes
173 # autotag from rpm-build-macros
174 # displays latest used tag for a specfile
180 # ensure package ends with .spec
183 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
184 --format='%(refname:short)')
189 # get autotag for specs
190 # WARNING: This may checkout some files from VCS
192 local pkg spec rpmdir
194 rpmdir=$(rpm -E %_topdir)
199 # strip .spec extension
201 # checkout only if missing
202 if [ ! -e $pkg/$pkg.spec ]; then
203 $rpmdir/builder -g $pkg -ns -r HEAD 1>&2
205 if [ ! -e $pkg/$pkg.spec ]; then
206 # just print it out, to fallback to base pkg name
216 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
222 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
224 Mandatory arguments to long options are mandatory for short options too.
226 --config-file /path/to/config/file
227 Source additional config file (after $USER_CFG), useful when
228 when sending build requests to Ac/Th from the same account
230 Try to use latest auto-tag for the spec when building
231 WARNING: This will checkout new files to your packages dir
232 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
233 Sends request to given builders (in 'version-arch' format)
234 --with VALUE, --without VALUE
235 Build package with(out) a given bcond
237 set alt_kernel to VALUE
239 set --target to VALUE
240 -D "NAME VALUE"|--define "NAME VALUE"
241 define macro named NAME with value VALUE
242 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
243 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
245 specify default branch for specs in request
247 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
248 ftp tree and won't be upgraded on builders.
250 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
251 (and later moved by release manager staff to ready/ and main ftp tree)
253 Forces package upgrade (for use with -c or -q, not -t)
255 Bump package release, see also --relup
257 Set commit message for relup
259 Disables package upgrade (for use with -r)
261 Do not install missing BuildRequires (--nodeps)
263 Do not add dependency of build jobs, each job in batch runs itself
265 Number of parallel jobs for single build
267 -d, --dist DISTRIBUTION_ID
268 Specify value for \$dist
269 -df, --distfiles-fetch[-request] PACKAGE
270 Send distfiles request to fetch sources for PACKAGE
274 Executes a given command on builders (prepended to build jobs if build jobs included)
276 Executes a given command on builders (appended to build jobs if build jobs included)
278 shortcut for --command poldek -evt ARGS
280 shortcut for --command poldek -ev --noask ARGS
282 shortcut for --command poldek --up -Uv ARGS
284 Updates builders infrastructure (outside chroot)
286 Updates rpm-build-macros on src builder
288 Updates ~/rpm/rpm-build-tools on builder
290 Override the requester
292 shortcut for --command rpm -q ARGS
293 -g, --gpg-opts "opts"
294 Pass additional options to gpg binary
296 sets request priority (default 2)
298 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
299 This may be useful if you just commited package and want to send it
300 for test build after distfiles has fetched the file.
302 Displays this help message
304 Verbose. Print some more debug on screen
309 # validate distro, set $dist
317 die "dist \`$1' not known"
324 while [ $# -gt 0 ]; do
326 -d | --dist | --distro)
332 [ -f "$2" ] && . $2 || die "Config file not found"
338 builders="$builders ${b%:*}"
357 with="$with $(echo "$2" | tr ',' ' ')"
362 without="$without $(echo "$2" | tr ',' ' ')"
384 define="$define$cr$name=$value"
419 --no-install-br | -ni)
420 flags="$flags no-install-br"
446 --command-flags | -cf)
453 if [ "$command" = - ]; then
454 echo >&2 "Reading command from STDIN"
463 if [ "$post_command" = - ]; then
464 echo >&2 "Reading post_command from STDIN"
472 command="poldek -evt $2"
477 command="for a in $2; do poldek -ev --noask \$a; done"
482 command="poldek --up; poldek -uv $2"
493 command_flags="no-chroot"
503 upgrade_scripts='yes'
506 -df | --distfiles-fetch | --distfiles-fetch-request)
520 requester_override="$2"
525 die "unknown knob: $1"
537 builder_email="builderti@kraz.tld-linux.org"
538 default_builders="ti-*"
539 url="http://kraz.tld-linux.org:1231/"
540 control_url="http://kraz.tld-linux.org/~builderti"
543 builder_email="buildertidev@kraz.tld-linux.org"
544 default_builders="ti-dev-*"
545 url="http://kraz.tld-linux.org:1232/"
546 control_url="http://kraz.tld-linux.org/~buildertidev"
549 die "dist \`$dist' not known"
553 # need to do this after dist selection
555 skip=$(skip="$skip" control_url="$control_url" python -c '
563 from xml.dom import minidom
565 skip = os.environ.get("skip").split(",");
566 control_url = os.environ.get("control_url")
568 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
571 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
572 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
573 f = urllib2.urlopen(req)
575 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
578 sio = StringIO.StringIO()
582 f = gzip.GzipFile(fileobj = sio)
584 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
585 d = minidom.parseString(xml)
588 for c in d.documentElement.childNodes:
589 if c.nodeName != "group":
591 q.append(c.attributes["id"].value)
596 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
599 print >> sys.stderr, "- Check %s: OK" % s
602 print string.join(skip, ",")
608 command_flags="no-chroot"
612 branch=${branch:-$default_branch}
614 specs=`for s in $specs; do
617 # skip marker - pass it along
620 *:*) # package name with branch
621 _specfile=$(basename ${s%:*})
622 echo ${_specfile%.spec}.spec:${s##*:}
624 *) # just package name
625 echo $(basename ${s%.spec}).spec:$branch
630 if [ "$relup" = "yes" ]; then
631 msg "Auto relup enabled"
632 relup ${message:+-m "$message"} $specs
635 if [ "$autotag" = "yes" ]; then
636 msg "Auto autotag build enabled"
637 specs=$(get_autotag $specs)
640 if [ "$df_fetch" = "yes" ]; then
645 if [ "$upgrade_macros" = "yes" ]; then
646 command="poldek --up; poldek -uv rpm-build-macros"
652 if [ "$upgrade_scripts" = "yes" ]; then
653 command="cd ~/rpm/rpm-build-tools && git pull"
654 command_flags=as-builder
660 if [[ "$requester" != *@* ]] ; then
661 requester="$requester@tld-linux.org"
664 if [ -z "$builders" ] ; then
665 builders="$default_builders"
668 if [ "$f_upgrade" = "yes" ] ; then
669 flags="$flags upgrade"
672 if [ "$build_mode" = "test" ] ; then
673 if [ "$f_upgrade" = "yes" ] ; then
674 die "--upgrade and --test-build are mutually exclusive"
676 flags="$flags test-build"
679 if [ -z "$build_mode" ] ; then
680 # missing build mode, builders go crazy when you proceed"
681 die "please specify build mode"
690 if [ -z "$specs" -a -z "$command" ]; then
691 die "no packages to build or command to invoke specified"
697 echo "<group id='$id' no='0' flags='$flags'>"
698 echo " <time>$(date +%s)</time>"
699 msg "Using priority $priority"
700 echo " <priority>$priority</priority>"
701 if [ -n "$jobs" ]; then
702 msg "Using jobs $jobs"
703 echo " <maxjobs>$jobs</maxjobs>"
705 if [ -z "$url" ]; then
706 msg "Using email $builder_email"
711 if [ "$build_mode" = "ready" ]; then
712 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
714 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
717 if [ -n "$requester_override" ] ; then
718 echo " <requester>$requester_override</requester>"
727 local name branch builders_xml
729 for b in $builders; do
730 msg "Builder: $(red $b)"
731 builders_xml="$builders_xml <builder>$b</builder>"
734 if [ "$command" ]; then
736 echo -E >&2 "* Command: $command"
737 echo " <batch id='$bid' depends-on=''>"
738 echo " <command flags='$command_flags'>"
741 echo " <info></info>"
747 if [ "$f_upgrade" = "yes" ] ; then
748 msg "Upgrade mode: $f_upgrade"
753 if [ "$s" = "^" ]; then
757 if [ "$no_depend" = yes ]; then
761 echo " <batch id='$bid' depends-on='$depend'>"
763 name=$(echo "$s" | sed -e 's|:.*||')
764 branch=$(echo "$s" | sed -e 's|.*:||')
765 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
766 echo " <spec>$name</spec>"
767 echo " <branch>$branch</branch>"
768 echo " ${kernel:+<kernel>$kernel</kernel>}"
769 echo " ${target:+<target>$target</target>}"
773 [ -z "$b" ] && continue
776 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
777 msg "- define $b=$value"
781 echo " <info></info>"
784 echo " <with>$b</with>"
786 for b in $without; do
787 echo " <without>$b</without>"
794 # let next job depend on previous
798 if [ "$post_command" ]; then
800 if [ "$no_depend" = yes ]; then
803 echo -E >&2 "* Post-Command: $post_command"
804 echo " <batch id='$bid' depends-on='$depend'>"
805 echo " <command flags='$command_flags'>"
808 echo " <info></info>"
818 # make request first, so the STDERR/STDOUT streams won't be mixed
823 if [ "$verbose" = "yes" ]; then
830 Subject: build request
831 Message-Id: <$id@$(hostname)>
832 X-New-TLD-Builder: request
833 X-Requester-Version: $VERSION
837 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
841 gen_email | send_request