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, urllib3, 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 http = urllib3.PoolManager(cert_reqs="CERT_NONE")
119 http.request("POST",url, body=data)
120 except Exception as e:
121 print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr)
123 print("Request queued via HTTP.", file=sys.stdout)
129 # htmlspecialchars: escape <, > and &
132 printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
135 # simple df_fetcher, based on packages/fetchsrc_request
136 # TODO: tcp (smtp) mode
137 # TODO: adjust for ~/.requestrc config
142 local MAILER='/usr/lib/sendmail'
143 # MAILER='/usr/bin/msmtp'
148 #VIA_ARGS="some additional flags"
150 # VIA_ARGS='-a gmail'
153 local DMAIL="df@tld-linux.org"
155 local HOST=$(hostname -f)
156 local LOGIN=${requester%@*}
159 for spec in $specs; do
160 SPEC=$(echo "$spec" | sed -e 's|:.*||')
162 BRANCH=$(echo "$spec" | sed -e 's|.*:||')
163 echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}"
164 cat <<-EOF | "$MAILER" -t -i $VIA_ARGS
166 From: $LOGIN <$LOGIN@$HOST>
167 Subject: fetchsrc_request notify
168 X-distfiles-request: yes
179 # get package revision for specs
181 local pkgrev pkg spec rpmdir
183 rpmdir=$(rpm -E %_topdir)
188 # strip .spec extension
190 wget http://pkgrevs.tld-linux.org/list/$pkg -O /tmp/$pkg.tags 1>/dev/null 2>&1
191 pkgrev=$(head -n 1 /tmp/$pkg.tags)
193 if [ "x$pkgrev" = "x" ]; then
196 echo "$pkg.spec:$pkgrev"
202 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
208 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
210 Mandatory arguments to long options are mandatory for short options too.
212 --config-file /path/to/config/file
213 Source additional config file (after $USER_CFG), useful when
214 when sending build requests to Ac/Th from the same account
216 Try to use latest auto-tag for the spec when building
217 WARNING: This will checkout new files to your packages dir
218 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
219 Sends request to given builders (in 'version-arch' format)
220 --with VALUE, --without VALUE
221 Build package with(out) a given bcond
223 set alt_kernel to VALUE
225 set --target to VALUE
226 -D "NAME VALUE"|--define "NAME VALUE"
227 define macro named NAME with value VALUE
228 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
229 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
231 specify default branch for specs in request
233 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
234 ftp tree and won't be upgraded on builders.
236 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
237 (and later moved by release manager staff to ready/ and main ftp tree)
239 Forces package upgrade (for use with -c or -q, not -t)
241 Bump package release, see also --relup
243 Set commit message for relup
245 Disables package upgrade (for use with -r)
247 Do not install missing BuildRequires (--nodeps)
249 Do not add dependency of build jobs, each job in batch runs itself
251 Number of parallel jobs for single build
253 -d, --dist DISTRIBUTION_ID
254 Specify value for \$dist
255 -df, --distfiles-fetch[-request] PACKAGE
256 Send distfiles request to fetch sources for PACKAGE
260 Executes a given command on builders (prepended to build jobs if build jobs included)
262 Executes a given command on builders (appended to build jobs if build jobs included)
264 shortcut for --command poldek -evt ARGS
266 shortcut for --command poldek -ev --noask ARGS
268 shortcut for --command poldek --up -Uv ARGS
270 Updates builders infrastructure (outside chroot)
272 Updates rpm-build-macros on src builder
274 Updates ~/rpm/rpm-build-tools on builder
276 Override the requester
278 shortcut for --command rpm -q ARGS
279 -g, --gpg-opts "opts"
280 Pass additional options to gpg binary
282 sets request priority (default 2)
284 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
285 This may be useful if you just commited package and want to send it
286 for test build after distfiles has fetched the file.
288 Displays this help message
290 Verbose. Print some more debug on screen
295 # validate distro, set $dist
303 die "dist \`$1' not known"
310 while [ $# -gt 0 ]; do
312 -d | --dist | --distro)
318 [ -f "$2" ] && . $2 || die "Config file not found"
324 builders="$builders ${b%:*}"
343 with="$with $(echo "$2" | tr ',' ' ')"
348 without="$without $(echo "$2" | tr ',' ' ')"
370 define="$define$cr$name=$value"
405 --no-install-br | -ni)
406 flags="$flags no-install-br"
432 --command-flags | -cf)
439 if [ "$command" = - ]; then
440 echo >&2 "Reading command from STDIN"
449 if [ "$post_command" = - ]; then
450 echo >&2 "Reading post_command from STDIN"
458 command="poldek -evt $2"
463 command="for a in $2; do poldek -ev --noask \$a; done"
468 command="poldek --up; poldek -uv $2"
479 command_flags="no-chroot"
489 upgrade_scripts='yes'
492 -df | --distfiles-fetch | --distfiles-fetch-request)
506 requester_override="$2"
511 die "unknown knob: $1"
523 builder_email="builderti@src.tld-linux.org"
524 default_builders="ti-*"
525 url="https://src.tld-linux.org:1241/"
526 control_url="http://src.tld-linux.org/~builderti"
529 builder_email="buildertidev@src.tld-linux.org"
530 default_builders="ti-dev-*"
531 url="https://src.tld-linux.org:1242/"
532 control_url="http://src.tld-linux.org/~buildertidev"
535 die "dist \`$dist' not known"
539 # need to do this after dist selection
541 skip=$(skip="$skip" control_url="$control_url" python3 -c '
549 from xml.dom import minidom
551 skip = os.environ.get("skip").split(",");
552 control_url = os.environ.get("control_url")
554 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
557 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
558 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
559 f = urllib2.urlopen(req)
561 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
564 sio = StringIO.StringIO()
568 f = gzip.GzipFile(fileobj = sio)
570 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
571 d = minidom.parseString(xml)
574 for c in d.documentElement.childNodes:
575 if c.nodeName != "group":
577 q.append(c.attributes["id"].value)
582 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
585 print >> sys.stderr, "- Check %s: OK" % s
588 print string.join(skip, ",")
594 command_flags="no-chroot"
598 branch=${branch:-$default_branch}
600 specs=`for s in $specs; do
603 # skip marker - pass it along
606 *:*) # package name with branch
607 _specfile=$(basename ${s%:*})
608 echo ${_specfile%.spec}.spec:${s##*:}
610 *) # just package name
611 echo $(basename ${s%.spec}).spec:$branch
616 if [ "$relup" = "yes" ]; then
617 msg "Auto relup enabled"
618 relup ${message:+-m "$message"} $specs
621 if [ "$pkgrevision" = "yes" ]; then
622 msg "Package revision build enabled"
623 specs=$(get_pkgrevision $specs)
626 if [ "$df_fetch" = "yes" ]; then
631 if [ "$upgrade_macros" = "yes" ]; then
632 command="poldek --up; poldek -uv rpm-build-macros"
638 if [ "$upgrade_scripts" = "yes" ]; then
639 command="cd ~/rpm/rpm-build-tools && git pull"
640 command_flags=as-builder
646 if [[ "$requester" != *@* ]] ; then
647 requester="$requester@tld-linux.org"
650 if [ -z "$builders" ] ; then
651 builders="$default_builders"
654 if [ "$f_upgrade" = "yes" ] ; then
655 flags="$flags upgrade"
658 if [ "$build_mode" = "test" ] ; then
659 if [ "$f_upgrade" = "yes" ] ; then
660 die "--upgrade and --test-build are mutually exclusive"
662 flags="$flags test-build"
665 if [ -z "$build_mode" ] ; then
666 # missing build mode, builders go crazy when you proceed"
667 die "please specify build mode"
676 if [ -z "$specs" -a -z "$command" ]; then
677 die "no packages to build or command to invoke specified"
683 echo "<group id='$id' no='0' flags='$flags'>"
684 echo " <time>$(date +%s)</time>"
685 msg "Using priority $priority"
686 echo " <priority>$priority</priority>"
687 if [ -n "$jobs" ]; then
688 msg "Using jobs $jobs"
689 echo " <maxjobs>$jobs</maxjobs>"
691 if [ -z "$url" ]; then
692 msg "Using email $builder_email"
697 if [ "$build_mode" = "ready" ]; then
698 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
700 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
703 if [ -n "$requester_override" ] ; then
704 echo " <requester>$requester_override</requester>"
713 local name branch builders_xml
715 for b in $builders; do
716 msg "Builder: $(red $b)"
717 builders_xml="$builders_xml <builder>$b</builder>"
720 if [ "$command" ]; then
722 printf "%s\n" "* Command: $command" >&2
723 echo " <batch id='$bid' depends-on=''>"
724 echo " <command flags='$command_flags'>"
727 echo " <info></info>"
733 if [ "$f_upgrade" = "yes" ] ; then
734 msg "Upgrade mode: $f_upgrade"
739 if [ "$s" = "^" ]; then
743 if [ "$no_depend" = yes ]; then
747 echo " <batch id='$bid' depends-on='$depend'>"
749 name=$(echo "$s" | sed -e 's|:.*||')
750 branch=$(echo "$s" | sed -e 's|.*:||')
751 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
752 echo " <spec>$name</spec>"
753 echo " <branch>$branch</branch>"
754 echo " ${kernel:+<kernel>$kernel</kernel>}"
755 echo " ${target:+<target>$target</target>}"
759 [ -z "$b" ] && continue
762 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
763 msg "- define $b=$value"
767 echo " <info></info>"
770 echo " <with>$b</with>"
772 for b in $without; do
773 echo " <without>$b</without>"
780 # let next job depend on previous
784 if [ "$post_command" ]; then
786 if [ "$no_depend" = yes ]; then
789 printf "%s\n" "* Post-Command: $post_command" >&2
790 echo " <batch id='$bid' depends-on='$depend'>"
791 echo " <command flags='$command_flags'>"
794 echo " <info></info>"
804 # make request first, so the STDERR/STDOUT streams won't be mixed
809 if [ "$verbose" = "yes" ]; then
816 Subject: build request
817 Message-Id: <$id@$(hostname)>
818 X-New-TLD-Builder: request
819 X-Requester-Version: $VERSION
823 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
827 gen_email | send_request