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="https://src.tld-linux.org:1241/"
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, ssl
108 _create_unverified_https_context = ssl._create_unverified_context
109 except AttributeError:
112 ssl._create_default_https_context = _create_unverified_https_context
115 data = sys.stdin.read()
117 socket.setdefaulttimeout(30)
118 req = urllib2.Request(url, data)
119 f = urllib2.urlopen(req)
121 except Exception as e:
122 print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
124 print >> sys.stdout, "Request queued via HTTP."
130 # htmlspecialchars: escape <, > and &
133 printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
136 # simple df_fetcher, based on packages/fetchsrc_request
137 # TODO: tcp (smtp) mode
138 # TODO: adjust for ~/.requestrc config
143 local MAILER='/usr/lib/sendmail'
144 # MAILER='/usr/bin/msmtp'
149 #VIA_ARGS="some additional flags"
151 # VIA_ARGS='-a gmail'
154 local DMAIL="df@tld-linux.org"
156 local HOST=$(hostname -f)
157 local LOGIN=${requester%@*}
160 for spec in $specs; do
161 SPEC=$(echo "$spec" | sed -e 's|:.*||')
163 BRANCH=$(echo "$spec" | sed -e 's|.*:||')
164 echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}"
165 cat <<-EOF | "$MAILER" -t -i $VIA_ARGS
167 From: $LOGIN <$LOGIN@$HOST>
168 Subject: fetchsrc_request notify
169 X-distfiles-request: yes
180 # get package revision for specs
182 local pkgrev pkg spec rpmdir
184 rpmdir=$(rpm -E %_topdir)
189 # strip .spec extension
191 wget http://pkgrevs.tld-linux.org/list/$pkg -O /tmp/$pkg.tags 1>/dev/null 2>&1
192 pkgrev=$(head -n 1 /tmp/$pkg.tags)
194 if [ "x$pkgrev" = "x" ]; then
197 echo "$pkg.spec:$pkgrev"
203 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
209 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
211 Mandatory arguments to long options are mandatory for short options too.
213 --config-file /path/to/config/file
214 Source additional config file (after $USER_CFG), useful when
215 when sending build requests to Ac/Th from the same account
217 Try to use latest auto-tag for the spec when building
218 WARNING: This will checkout new files to your packages dir
219 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
220 Sends request to given builders (in 'version-arch' format)
221 --with VALUE, --without VALUE
222 Build package with(out) a given bcond
224 set alt_kernel to VALUE
226 set --target to VALUE
227 -D "NAME VALUE"|--define "NAME VALUE"
228 define macro named NAME with value VALUE
229 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
230 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
232 specify default branch for specs in request
234 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
235 ftp tree and won't be upgraded on builders.
237 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
238 (and later moved by release manager staff to ready/ and main ftp tree)
240 Forces package upgrade (for use with -c or -q, not -t)
242 Bump package release, see also --relup
244 Set commit message for relup
246 Disables package upgrade (for use with -r)
248 Do not install missing BuildRequires (--nodeps)
250 Do not add dependency of build jobs, each job in batch runs itself
252 Number of parallel jobs for single build
254 -d, --dist DISTRIBUTION_ID
255 Specify value for \$dist
256 -df, --distfiles-fetch[-request] PACKAGE
257 Send distfiles request to fetch sources for PACKAGE
261 Executes a given command on builders (prepended to build jobs if build jobs included)
263 Executes a given command on builders (appended to build jobs if build jobs included)
265 shortcut for --command poldek -evt ARGS
267 shortcut for --command poldek -ev --noask ARGS
269 shortcut for --command poldek --up -Uv ARGS
271 Updates builders infrastructure (outside chroot)
273 Updates rpm-build-macros on src builder
275 Updates ~/rpm/rpm-build-tools on builder
277 Override the requester
279 shortcut for --command rpm -q ARGS
280 -g, --gpg-opts "opts"
281 Pass additional options to gpg binary
283 sets request priority (default 2)
285 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
286 This may be useful if you just commited package and want to send it
287 for test build after distfiles has fetched the file.
289 Displays this help message
291 Verbose. Print some more debug on screen
296 # validate distro, set $dist
304 die "dist \`$1' not known"
311 while [ $# -gt 0 ]; do
313 -d | --dist | --distro)
319 [ -f "$2" ] && . $2 || die "Config file not found"
325 builders="$builders ${b%:*}"
344 with="$with $(echo "$2" | tr ',' ' ')"
349 without="$without $(echo "$2" | tr ',' ' ')"
371 define="$define$cr$name=$value"
406 --no-install-br | -ni)
407 flags="$flags no-install-br"
433 --command-flags | -cf)
440 if [ "$command" = - ]; then
441 echo >&2 "Reading command from STDIN"
450 if [ "$post_command" = - ]; then
451 echo >&2 "Reading post_command from STDIN"
459 command="poldek -evt $2"
464 command="for a in $2; do poldek -ev --noask \$a; done"
469 command="poldek --up; poldek -uv $2"
480 command_flags="no-chroot"
490 upgrade_scripts='yes'
493 -df | --distfiles-fetch | --distfiles-fetch-request)
507 requester_override="$2"
512 die "unknown knob: $1"
524 builder_email="builderti@src.tld-linux.org"
525 default_builders="ti-*"
526 url="https://src.tld-linux.org:1241/"
527 control_url="http://src.tld-linux.org/~builderti"
530 builder_email="buildertidev@src.tld-linux.org"
531 default_builders="ti-dev-*"
532 url="https://src.tld-linux.org:1242/"
533 control_url="http://src.tld-linux.org/~buildertidev"
536 die "dist \`$dist' not known"
540 # need to do this after dist selection
542 skip=$(skip="$skip" control_url="$control_url" python -c '
550 from xml.dom import minidom
552 skip = os.environ.get("skip").split(",");
553 control_url = os.environ.get("control_url")
555 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
558 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
559 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
560 f = urllib2.urlopen(req)
562 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
565 sio = StringIO.StringIO()
569 f = gzip.GzipFile(fileobj = sio)
571 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
572 d = minidom.parseString(xml)
575 for c in d.documentElement.childNodes:
576 if c.nodeName != "group":
578 q.append(c.attributes["id"].value)
583 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
586 print >> sys.stderr, "- Check %s: OK" % s
589 print string.join(skip, ",")
595 command_flags="no-chroot"
599 branch=${branch:-$default_branch}
601 specs=`for s in $specs; do
604 # skip marker - pass it along
607 *:*) # package name with branch
608 _specfile=$(basename ${s%:*})
609 echo ${_specfile%.spec}.spec:${s##*:}
611 *) # just package name
612 echo $(basename ${s%.spec}).spec:$branch
617 if [ "$relup" = "yes" ]; then
618 msg "Auto relup enabled"
619 relup ${message:+-m "$message"} $specs
622 if [ "$pkgrevision" = "yes" ]; then
623 msg "Package revision build enabled"
624 specs=$(get_pkgrevision $specs)
627 if [ "$df_fetch" = "yes" ]; then
632 if [ "$upgrade_macros" = "yes" ]; then
633 command="poldek --up; poldek -uv rpm-build-macros"
639 if [ "$upgrade_scripts" = "yes" ]; then
640 command="cd ~/rpm/rpm-build-tools && git pull"
641 command_flags=as-builder
647 if [[ "$requester" != *@* ]] ; then
648 requester="$requester@tld-linux.org"
651 if [ -z "$builders" ] ; then
652 builders="$default_builders"
655 if [ "$f_upgrade" = "yes" ] ; then
656 flags="$flags upgrade"
659 if [ "$build_mode" = "test" ] ; then
660 if [ "$f_upgrade" = "yes" ] ; then
661 die "--upgrade and --test-build are mutually exclusive"
663 flags="$flags test-build"
666 if [ -z "$build_mode" ] ; then
667 # missing build mode, builders go crazy when you proceed"
668 die "please specify build mode"
677 if [ -z "$specs" -a -z "$command" ]; then
678 die "no packages to build or command to invoke specified"
684 echo "<group id='$id' no='0' flags='$flags'>"
685 echo " <time>$(date +%s)</time>"
686 msg "Using priority $priority"
687 echo " <priority>$priority</priority>"
688 if [ -n "$jobs" ]; then
689 msg "Using jobs $jobs"
690 echo " <maxjobs>$jobs</maxjobs>"
692 if [ -z "$url" ]; then
693 msg "Using email $builder_email"
698 if [ "$build_mode" = "ready" ]; then
699 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
701 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
704 if [ -n "$requester_override" ] ; then
705 echo " <requester>$requester_override</requester>"
714 local name branch builders_xml
716 for b in $builders; do
717 msg "Builder: $(red $b)"
718 builders_xml="$builders_xml <builder>$b</builder>"
721 if [ "$command" ]; then
723 printf "%s\n" "* Command: $command" >&2
724 echo " <batch id='$bid' depends-on=''>"
725 echo " <command flags='$command_flags'>"
728 echo " <info></info>"
734 if [ "$f_upgrade" = "yes" ] ; then
735 msg "Upgrade mode: $f_upgrade"
740 if [ "$s" = "^" ]; then
744 if [ "$no_depend" = yes ]; then
748 echo " <batch id='$bid' depends-on='$depend'>"
750 name=$(echo "$s" | sed -e 's|:.*||')
751 branch=$(echo "$s" | sed -e 's|.*:||')
752 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
753 echo " <spec>$name</spec>"
754 echo " <branch>$branch</branch>"
755 echo " ${kernel:+<kernel>$kernel</kernel>}"
756 echo " ${target:+<target>$target</target>}"
760 [ -z "$b" ] && continue
763 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
764 msg "- define $b=$value"
768 echo " <info></info>"
771 echo " <with>$b</with>"
773 for b in $without; do
774 echo " <without>$b</without>"
781 # let next job depend on previous
785 if [ "$post_command" ]; then
787 if [ "$no_depend" = yes ]; then
790 printf "%s\n" "* Post-Command: $post_command" >&2
791 echo " <batch id='$bid' depends-on='$depend'>"
792 echo " <command flags='$command_flags'>"
795 echo " <info></info>"
805 # make request first, so the STDERR/STDOUT streams won't be mixed
810 if [ "$verbose" = "yes" ]; then
817 Subject: build request
818 Message-Id: <$id@$(hostname)>
819 X-New-TLD-Builder: request
820 X-Requester-Version: $VERSION
824 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
828 gen_email | send_request