5 # prevent "*" from being expanded in builders var
24 if [ -x /usr/bin/python3 ]; 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, ssl
106 from urllib import request
109 _create_unverified_https_context = ssl._create_unverified_context
110 except AttributeError:
113 ssl._create_default_https_context = _create_unverified_https_context
116 data = sys.stdin.read().encode("utf-8")
118 socket.setdefaulttimeout(30)
119 req = request.Request(url, data=data)
120 f = request.urlopen(req)
122 except Exception as e:
123 print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr)
125 print("Request queued via HTTP.", file=sys.stdout)
131 # htmlspecialchars: escape <, > and &
134 printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
137 # simple df_fetcher, based on packages/fetchsrc_request
138 # TODO: tcp (smtp) mode
139 # TODO: adjust for ~/.requestrc config
144 local MAILER='/usr/lib/sendmail'
145 # MAILER='/usr/bin/msmtp'
150 #VIA_ARGS="some additional flags"
152 # VIA_ARGS='-a gmail'
155 local DMAIL="df@tld-linux.org"
157 local HOST=$(hostname -f)
158 local LOGIN=${requester%@*}
161 for spec in $specs; do
162 SPEC=$(echo "$spec" | sed -e 's|:.*||')
164 BRANCH=$(echo "$spec" | sed -e 's|.*:||')
165 echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}"
166 cat <<-EOF | "$MAILER" -t -i $VIA_ARGS
168 From: $LOGIN <$LOGIN@$HOST>
169 Subject: fetchsrc_request notify
170 X-distfiles-request: yes
181 # get package revision for specs
183 local pkgrev pkg spec rpmdir
185 rpmdir=$(rpm -E %_topdir)
190 # strip .spec extension
192 wget http://pkgrevs.tld-linux.org/list/$pkg -O /tmp/$pkg.tags 1>/dev/null 2>&1
193 pkgrev=$(head -n 1 /tmp/$pkg.tags)
195 if [ "x$pkgrev" = "x" ]; then
198 echo "$pkg.spec:$pkgrev"
204 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
210 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
212 Mandatory arguments to long options are mandatory for short options too.
214 --config-file /path/to/config/file
215 Source additional config file (after $USER_CFG), useful when
216 when sending build requests to Ac/Th from the same account
218 Try to use latest auto-tag for the spec when building
219 WARNING: This will checkout new files to your packages dir
220 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
221 Sends request to given builders (in 'version-arch' format)
222 --with VALUE, --without VALUE
223 Build package with(out) a given bcond
225 set alt_kernel to VALUE
227 set --target to VALUE
228 -D "NAME VALUE"|--define "NAME VALUE"
229 define macro named NAME with value VALUE
230 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
231 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
233 specify default branch for specs in request
235 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
236 ftp tree and won't be upgraded on builders.
238 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
239 (and later moved by release manager staff to ready/ and main ftp tree)
241 Forces package upgrade (for use with -c or -q, not -t)
243 Bump package release, see also --relup
245 Set commit message for relup
247 Disables package upgrade (for use with -r)
249 Do not install missing BuildRequires (--nodeps)
251 Do not add dependency of build jobs, each job in batch runs itself
253 Number of parallel jobs for single build
255 -d, --dist DISTRIBUTION_ID
256 Specify value for \$dist
257 -df, --distfiles-fetch[-request] PACKAGE
258 Send distfiles request to fetch sources for PACKAGE
262 Executes a given command on builders (prepended to build jobs if build jobs included)
264 Executes a given command on builders (appended to build jobs if build jobs included)
266 shortcut for --command poldek -evt ARGS
268 shortcut for --command poldek -ev --noask ARGS
270 shortcut for --command poldek --up -Uv ARGS
272 Updates builders infrastructure (outside chroot)
274 Updates rpm-build-macros on src builder
276 Updates ~/rpm/rpm-build-tools on builder
278 Override the requester
280 shortcut for --command rpm -q ARGS
281 -g, --gpg-opts "opts"
282 Pass additional options to gpg binary
284 sets request priority (default 2)
286 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
287 This may be useful if you just commited package and want to send it
288 for test build after distfiles has fetched the file.
290 Displays this help message
292 Verbose. Print some more debug on screen
297 # validate distro, set $dist
305 die "dist \`$1' not known"
312 while [ $# -gt 0 ]; do
314 -d | --dist | --distro)
320 [ -f "$2" ] && . $2 || die "Config file not found"
326 builders="$builders ${b%:*}"
345 with="$with $(echo "$2" | tr ',' ' ')"
350 without="$without $(echo "$2" | tr ',' ' ')"
372 define="$define$cr$name=$value"
407 --no-install-br | -ni)
408 flags="$flags no-install-br"
434 --command-flags | -cf)
441 if [ "$command" = - ]; then
442 echo >&2 "Reading command from STDIN"
451 if [ "$post_command" = - ]; then
452 echo >&2 "Reading post_command from STDIN"
460 command="poldek -evt $2"
465 command="for a in $2; do poldek -ev --noask \$a; done"
470 command="poldek --up; poldek -uv $2"
481 command_flags="no-chroot"
491 upgrade_scripts='yes'
494 -df | --distfiles-fetch | --distfiles-fetch-request)
508 requester_override="$2"
513 die "unknown knob: $1"
525 builder_email="builderti@src.tld-linux.org"
526 default_builders="ti-*"
527 url="https://src.tld-linux.org:1241/"
528 control_url="http://src.tld-linux.org/~builderti"
531 builder_email="buildertidev@src.tld-linux.org"
532 default_builders="ti-dev-*"
533 url="https://src.tld-linux.org:1242/"
534 control_url="http://src.tld-linux.org/~buildertidev"
537 die "dist \`$dist' not known"
541 # need to do this after dist selection
543 skip=$(skip="$skip" control_url="$control_url" python3 -c '
549 from urllib import request
550 from io import BytesIO
551 from xml.dom import minidom
553 skip = os.environ.get("skip").split(",");
554 control_url = os.environ.get("control_url")
556 print("* Check queue_id-s against %s" % control_url, file=sys.stderr)
559 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
560 req = request.Request(url=control_url + "/queue.gz", headers=headers)
561 f = request.urlopen(req)
562 except Exception as e:
563 print("Fetch error %s: %s" % (control_url + "/queue.gz", e), file=sys.stderr)
570 f = gzip.GzipFile(fileobj = sio)
572 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read().decode("utf-8")).group(1)
573 d = minidom.parseString(xml)
576 for c in d.documentElement.childNodes:
577 if c.nodeName != "group":
579 q.append(c.attributes["id"].value)
584 print("- Check %s: ERROR: Not valid queue-id" % s, file=sys.stderr)
587 print("- Check %s: OK" % s, file=sys.stderr)
590 print(",".join(skip))
596 command_flags="no-chroot"
600 branch=${branch:-$default_branch}
602 specs=`for s in $specs; do
605 # skip marker - pass it along
608 *:*) # package name with branch
609 _specfile=$(basename ${s%:*})
610 echo ${_specfile%.spec}.spec:${s##*:}
612 *) # just package name
613 echo $(basename ${s%.spec}).spec:$branch
618 if [ "$relup" = "yes" ]; then
619 msg "Auto relup enabled"
620 relup ${message:+-m "$message"} $specs
623 if [ "$pkgrevision" = "yes" ]; then
624 msg "Package revision build enabled"
625 specs=$(get_pkgrevision $specs)
628 if [ "$df_fetch" = "yes" ]; then
633 if [ "$upgrade_macros" = "yes" ]; then
634 command="poldek --up; poldek -uv rpm-build-macros"
640 if [ "$upgrade_scripts" = "yes" ]; then
641 command="cd ~/rpm/rpm-build-tools && git pull"
642 command_flags=as-builder
648 if [[ "$requester" != *@* ]] ; then
649 requester="$requester@tld-linux.org"
652 if [ -z "$builders" ] ; then
653 builders="$default_builders"
656 if [ "$f_upgrade" = "yes" ] ; then
657 flags="$flags upgrade"
660 if [ "$build_mode" = "test" ] ; then
661 if [ "$f_upgrade" = "yes" ] ; then
662 die "--upgrade and --test-build are mutually exclusive"
664 flags="$flags test-build"
667 if [ -z "$build_mode" ] ; then
668 # missing build mode, builders go crazy when you proceed"
669 die "please specify build mode"
678 if [ -z "$specs" -a -z "$command" ]; then
679 die "no packages to build or command to invoke specified"
685 echo "<group id='$id' no='0' flags='$flags'>"
686 echo " <time>$(date +%s)</time>"
687 msg "Using priority $priority"
688 echo " <priority>$priority</priority>"
689 if [ -n "$jobs" ]; then
690 msg "Using jobs $jobs"
691 echo " <maxjobs>$jobs</maxjobs>"
693 if [ -z "$url" ]; then
694 msg "Using email $builder_email"
699 if [ "$build_mode" = "ready" ]; then
700 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
702 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
705 if [ -n "$requester_override" ] ; then
706 echo " <requester>$requester_override</requester>"
715 local name branch builders_xml
717 for b in $builders; do
718 msg "Builder: $(red $b)"
719 builders_xml="$builders_xml <builder>$b</builder>"
722 if [ "$command" ]; then
724 printf "%s\n" "* Command: $command" >&2
725 echo " <batch id='$bid' depends-on=''>"
726 echo " <command flags='$command_flags'>"
729 echo " <info></info>"
735 if [ "$f_upgrade" = "yes" ] ; then
736 msg "Upgrade mode: $f_upgrade"
741 if [ "$s" = "^" ]; then
745 if [ "$no_depend" = yes ]; then
749 echo " <batch id='$bid' depends-on='$depend'>"
751 name=$(echo "$s" | sed -e 's|:.*||')
752 branch=$(echo "$s" | sed -e 's|.*:||')
753 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
754 echo " <spec>$name</spec>"
755 echo " <branch>$branch</branch>"
756 echo " ${kernel:+<kernel>$kernel</kernel>}"
757 echo " ${target:+<target>$target</target>}"
761 [ -z "$b" ] && continue
764 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
765 msg "- define $b=$value"
769 echo " <info></info>"
772 echo " <with>$b</with>"
774 for b in $without; do
775 echo " <without>$b</without>"
782 # let next job depend on previous
786 if [ "$post_command" ]; then
788 if [ "$no_depend" = yes ]; then
791 printf "%s\n" "* Post-Command: $post_command" >&2
792 echo " <batch id='$bid' depends-on='$depend'>"
793 echo " <command flags='$command_flags'>"
796 echo " <info></info>"
806 # make request first, so the STDERR/STDOUT streams won't be mixed
811 if [ "$verbose" = "yes" ]; then
818 Subject: build request
819 Message-Id: <$id@$(hostname)>
820 X-New-TLD-Builder: request
821 X-Requester-Version: $VERSION
825 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
829 gen_email | send_request