5 # prevent "*" from being expanded in builders var
24 if [ -x /usr/bin/python3 ]; then
27 echo "No python3 present, aborting"
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"
47 url="https://giant.tld-linux.org:1241/"
55 if [ -f "$USER_CFG" ]; then
58 if [ "${distro:+set}" = "set" ]; then
63 # internal options, not to be overriden
70 c_star=$(tput setaf 2)
74 echo >&2 "${c_star}*${c_norm} $*"
77 echo "${c_red}$*${c_norm}"
86 if [ -n "$wait" ]; then
87 msg "Waiting $wait seconds before sending request"
89 msg "Wait has ended, proceeding!"
92 msg "Sending using HTTP mode to $url"
94 import sys, socket, ssl
95 from urllib import request
98 _create_unverified_https_context = ssl._create_unverified_context
99 except AttributeError:
102 ssl._create_default_https_context = _create_unverified_https_context
105 data = sys.stdin.read().encode("utf-8")
107 socket.setdefaulttimeout(30)
108 req = request.Request(url, data=data)
109 f = request.urlopen(req)
111 except Exception as e:
112 print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr)
114 print("Request queued via HTTP.", file=sys.stdout)
118 # htmlspecialchars: escape <, > and &
121 printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
124 # get package revision for specs
126 local pkgrev pkg spec rpmdir
128 rpmdir=$(rpm -E %_topdir)
133 # strip .spec extension
135 wget http://pkgrevs.tld-linux.org/list/$pkg -O /tmp/$pkg.tags 1>/dev/null 2>&1
136 pkgrev=$(head -n 1 /tmp/$pkg.tags)
138 if [ "x$pkgrev" = "x" ]; then
141 echo "$pkg.spec:$pkgrev"
147 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
153 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
155 Mandatory arguments to long options are mandatory for short options too.
157 --config-file /path/to/config/file
158 Source additional config file (after $USER_CFG), useful when
159 when sending build requests to Ac/Th from the same account
161 Try to use latest auto-tag for the spec when building
162 WARNING: This will checkout new files to your packages dir
163 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
164 Sends request to given builders (in 'version-arch' format)
165 --with VALUE, --without VALUE
166 Build package with(out) a given bcond
168 set alt_kernel to VALUE
170 set --target to VALUE
171 -D "NAME VALUE"|--define "NAME VALUE"
172 define macro named NAME with value VALUE
173 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
174 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
176 specify default branch for specs in request
178 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
179 ftp tree and won't be upgraded on builders.
181 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
182 (and later moved by release manager staff to ready/ and main ftp tree)
184 Forces package upgrade (for use with -c or -q, not -t)
186 Bump package release, see also --relup
188 Set commit message for relup
190 Disables package upgrade (for use with -r)
192 Do not install missing BuildRequires (--nodeps)
194 Do not add dependency of build jobs, each job in batch runs itself
196 Number of parallel jobs for single build
198 -d, --dist DISTRIBUTION_ID
199 Specify value for \$dist
200 -df, --distfiles-fetch[-request] PACKAGE
201 Send distfiles request to fetch sources for PACKAGE
205 Executes a given command on builders (prepended to build jobs if build jobs included)
207 Executes a given command on builders (appended to build jobs if build jobs included)
209 shortcut for --command poldek -evt ARGS
211 shortcut for --command poldek -ev --noask ARGS
213 shortcut for --command poldek --up -Uv ARGS
215 Updates builders infrastructure (outside chroot)
217 Updates rpm-build-macros on src builder
219 Updates ~/rpm/rpm-build-tools on builder
221 Override the requester
223 shortcut for --command rpm -q ARGS
224 -g, --gpg-opts "opts"
225 Pass additional options to gpg binary
227 sets request priority (default 2)
229 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
230 This may be useful if you just commited package and want to send it
231 for test build after distfiles has fetched the file.
233 Displays this help message
235 Verbose. Print some more debug on screen
240 # validate distro, set $dist
248 die "dist \`$1' not known"
255 while [ $# -gt 0 ]; do
257 -d | --dist | --distro)
263 [ -f "$2" ] && . $2 || die "Config file not found"
269 builders="$builders ${b%:*}"
288 with="$with $(echo "$2" | tr ',' ' ')"
293 without="$without $(echo "$2" | tr ',' ' ')"
315 define="$define$cr$name=$value"
350 --no-install-br | -ni)
351 flags="$flags no-install-br"
377 --command-flags | -cf)
384 if [ "$command" = - ]; then
385 echo >&2 "Reading command from STDIN"
394 if [ "$post_command" = - ]; then
395 echo >&2 "Reading post_command from STDIN"
403 command="poldek -evt $2"
408 command="for a in $2; do poldek -ev --noask \$a; done"
413 command="poldek --up; poldek -uv $2"
424 command_flags="no-chroot"
434 upgrade_scripts='yes'
447 requester_override="$2"
452 die "unknown knob: $1"
464 default_builders="ti-*"
465 url="https://giant.tld-linux.org:1241/"
466 control_url="http://src.tld-linux.org/~builderti"
469 default_builders="ti-dev-*"
470 url="https://giant.tld-linux.org:1242/"
471 control_url="http://src.tld-linux.org/~buildertidev"
474 die "dist \`$dist' not known"
478 # need to do this after dist selection
480 skip=$(skip="$skip" control_url="$control_url" python3 -c '
486 from urllib import request
487 from io import BytesIO
488 from xml.dom import minidom
490 skip = os.environ.get("skip").split(",");
491 control_url = os.environ.get("control_url")
493 print("* Check queue_id-s against %s" % control_url, file=sys.stderr)
496 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
497 req = request.Request(url=control_url + "/queue.gz", headers=headers)
498 f = request.urlopen(req)
499 except Exception as e:
500 print("Fetch error %s: %s" % (control_url + "/queue.gz", e), file=sys.stderr)
507 f = gzip.GzipFile(fileobj = sio)
509 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read().decode("utf-8")).group(1)
510 d = minidom.parseString(xml)
513 for c in d.documentElement.childNodes:
514 if c.nodeName != "group":
516 q.append(c.attributes["id"].value)
521 print("- Check %s: ERROR: Not valid queue-id" % s, file=sys.stderr)
524 print("- Check %s: OK" % s, file=sys.stderr)
527 print(",".join(skip))
533 command_flags="no-chroot"
537 branch=${branch:-$default_branch}
539 specs=`for s in $specs; do
542 # skip marker - pass it along
545 *:*) # package name with branch
546 _specfile=$(basename ${s%:*})
547 echo ${_specfile%.spec}.spec:${s##*:}
549 *) # just package name
550 echo $(basename ${s%.spec}).spec:$branch
555 if [ "$relup" = "yes" ]; then
556 msg "Auto relup enabled"
557 relup ${message:+-m "$message"} $specs
560 if [ "$pkgrevision" = "yes" ]; then
561 msg "Package revision build enabled"
562 specs=$(get_pkgrevision $specs)
565 if [ "$upgrade_macros" = "yes" ]; then
566 command="poldek --up; poldek -uv rpm-build-macros"
572 if [ "$upgrade_scripts" = "yes" ]; then
573 command="cd ~/rpm/rpm-build-tools && git pull"
574 command_flags=as-builder
580 if [[ "$requester" != *@* ]] ; then
581 requester="$requester@tld-linux.org"
584 if [ -z "$builders" ] ; then
585 builders="$default_builders"
588 if [ "$f_upgrade" = "yes" ] ; then
589 flags="$flags upgrade"
592 if [ "$build_mode" = "test" ] ; then
593 if [ "$f_upgrade" = "yes" ] ; then
594 die "--upgrade and --test-build are mutually exclusive"
596 flags="$flags test-build"
599 if [ -z "$build_mode" ] ; then
600 # missing build mode, builders go crazy when you proceed"
601 die "please specify build mode"
610 if [ -z "$specs" -a -z "$command" ]; then
611 die "no packages to build or command to invoke specified"
617 echo "<group id='$id' no='0' flags='$flags'>"
618 echo " <time>$(date +%s)</time>"
619 msg "Using priority $priority"
620 echo " <priority>$priority</priority>"
621 if [ -n "$jobs" ]; then
622 msg "Using jobs $jobs"
623 echo " <maxjobs>$jobs</maxjobs>"
627 if [ "$build_mode" = "ready" ]; then
628 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
630 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
633 if [ -n "$requester_override" ] ; then
634 echo " <requester>$requester_override</requester>"
643 local name branch builders_xml
645 for b in $builders; do
646 msg "Builder: $(red $b)"
647 builders_xml="$builders_xml <builder>$b</builder>"
650 if [ "$command" ]; then
652 printf "%s\n" "* Command: $command" >&2
653 echo " <batch id='$bid' depends-on=''>"
654 echo " <command flags='$command_flags'>"
657 echo " <info></info>"
663 if [ "$f_upgrade" = "yes" ] ; then
664 msg "Upgrade mode: $f_upgrade"
669 if [ "$s" = "^" ]; then
673 if [ "$no_depend" = yes ]; then
677 echo " <batch id='$bid' depends-on='$depend'>"
679 name=$(echo "$s" | sed -e 's|:.*||')
680 branch=$(echo "$s" | sed -e 's|.*:||')
681 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
682 echo " <spec>$name</spec>"
683 echo " <branch>$branch</branch>"
684 echo " ${kernel:+<kernel>$kernel</kernel>}"
685 echo " ${target:+<target>$target</target>}"
689 [ -z "$b" ] && continue
692 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
693 msg "- define $b=$value"
697 echo " <info></info>"
700 echo " <with>$b</with>"
702 for b in $without; do
703 echo " <without>$b</without>"
710 # let next job depend on previous
714 if [ "$post_command" ]; then
716 if [ "$no_depend" = yes ]; then
719 printf "%s\n" "* Post-Command: $post_command" >&2
720 echo " <batch id='$bid' depends-on='$depend'>"
721 echo " <command flags='$command_flags'>"
724 echo " <info></info>"
734 # make request first, so the STDERR/STDOUT streams won't be mixed
739 if [ "$verbose" = "yes" ]; then
746 Subject: build request
747 Message-Id: <$id@$(hostname)>
748 X-New-TLD-Builder: request
749 X-Requester-Version: $VERSION
753 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
757 gen_email | send_request