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://kraz.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)
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 echo -E "$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 # autotag from rpm-build-macros
181 # displays latest used tag for a specfile
187 # ensure package ends with .spec
190 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
191 --format='%(refname:short)')
196 # get autotag for specs
197 # WARNING: This may checkout some files from VCS
199 local pkg spec rpmdir
201 rpmdir=$(rpm -E %_topdir)
206 # strip .spec extension
208 # checkout only if missing
209 if [ ! -e $pkg/$pkg.spec ]; then
210 $rpmdir/builder -g $pkg -ns -r HEAD 1>&2
212 if [ ! -e $pkg/$pkg.spec ]; then
213 # just print it out, to fallback to base pkg name
223 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
229 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
231 Mandatory arguments to long options are mandatory for short options too.
233 --config-file /path/to/config/file
234 Source additional config file (after $USER_CFG), useful when
235 when sending build requests to Ac/Th from the same account
237 Try to use latest auto-tag for the spec when building
238 WARNING: This will checkout new files to your packages dir
239 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
240 Sends request to given builders (in 'version-arch' format)
241 --with VALUE, --without VALUE
242 Build package with(out) a given bcond
244 set alt_kernel to VALUE
246 set --target to VALUE
247 -D "NAME VALUE"|--define "NAME VALUE"
248 define macro named NAME with value VALUE
249 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
250 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
252 specify default branch for specs in request
254 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
255 ftp tree and won't be upgraded on builders.
257 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
258 (and later moved by release manager staff to ready/ and main ftp tree)
260 Forces package upgrade (for use with -c or -q, not -t)
262 Bump package release, see also --relup
264 Set commit message for relup
266 Disables package upgrade (for use with -r)
268 Do not install missing BuildRequires (--nodeps)
270 Do not add dependency of build jobs, each job in batch runs itself
272 Number of parallel jobs for single build
274 -d, --dist DISTRIBUTION_ID
275 Specify value for \$dist
276 -df, --distfiles-fetch[-request] PACKAGE
277 Send distfiles request to fetch sources for PACKAGE
281 Executes a given command on builders (prepended to build jobs if build jobs included)
283 Executes a given command on builders (appended to build jobs if build jobs included)
285 shortcut for --command poldek -evt ARGS
287 shortcut for --command poldek -ev --noask ARGS
289 shortcut for --command poldek --up -Uv ARGS
291 Updates builders infrastructure (outside chroot)
293 Updates rpm-build-macros on src builder
295 Updates ~/rpm/rpm-build-tools on builder
297 Override the requester
299 shortcut for --command rpm -q ARGS
300 -g, --gpg-opts "opts"
301 Pass additional options to gpg binary
303 sets request priority (default 2)
305 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
306 This may be useful if you just commited package and want to send it
307 for test build after distfiles has fetched the file.
309 Displays this help message
311 Verbose. Print some more debug on screen
316 # validate distro, set $dist
324 die "dist \`$1' not known"
331 while [ $# -gt 0 ]; do
333 -d | --dist | --distro)
339 [ -f "$2" ] && . $2 || die "Config file not found"
345 builders="$builders ${b%:*}"
364 with="$with $(echo "$2" | tr ',' ' ')"
369 without="$without $(echo "$2" | tr ',' ' ')"
391 define="$define$cr$name=$value"
426 --no-install-br | -ni)
427 flags="$flags no-install-br"
453 --command-flags | -cf)
460 if [ "$command" = - ]; then
461 echo >&2 "Reading command from STDIN"
470 if [ "$post_command" = - ]; then
471 echo >&2 "Reading post_command from STDIN"
479 command="poldek -evt $2"
484 command="for a in $2; do poldek -ev --noask \$a; done"
489 command="poldek --up; poldek -uv $2"
500 command_flags="no-chroot"
510 upgrade_scripts='yes'
513 -df | --distfiles-fetch | --distfiles-fetch-request)
527 requester_override="$2"
532 die "unknown knob: $1"
544 builder_email="builderti@kraz.tld-linux.org"
545 default_builders="ti-*"
546 url="https://kraz.tld-linux.org:1241/"
547 control_url="http://kraz.tld-linux.org/~builderti"
550 builder_email="buildertidev@kraz.tld-linux.org"
551 default_builders="ti-dev-*"
552 url="https://kraz.tld-linux.org:1242/"
553 control_url="http://kraz.tld-linux.org/~buildertidev"
556 die "dist \`$dist' not known"
560 # need to do this after dist selection
562 skip=$(skip="$skip" control_url="$control_url" python -c '
570 from xml.dom import minidom
572 skip = os.environ.get("skip").split(",");
573 control_url = os.environ.get("control_url")
575 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
578 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
579 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
580 f = urllib2.urlopen(req)
582 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
585 sio = StringIO.StringIO()
589 f = gzip.GzipFile(fileobj = sio)
591 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
592 d = minidom.parseString(xml)
595 for c in d.documentElement.childNodes:
596 if c.nodeName != "group":
598 q.append(c.attributes["id"].value)
603 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
606 print >> sys.stderr, "- Check %s: OK" % s
609 print string.join(skip, ",")
615 command_flags="no-chroot"
619 branch=${branch:-$default_branch}
621 specs=`for s in $specs; do
624 # skip marker - pass it along
627 *:*) # package name with branch
628 _specfile=$(basename ${s%:*})
629 echo ${_specfile%.spec}.spec:${s##*:}
631 *) # just package name
632 echo $(basename ${s%.spec}).spec:$branch
637 if [ "$relup" = "yes" ]; then
638 msg "Auto relup enabled"
639 relup ${message:+-m "$message"} $specs
642 if [ "$autotag" = "yes" ]; then
643 msg "Auto autotag build enabled"
644 specs=$(get_autotag $specs)
647 if [ "$df_fetch" = "yes" ]; then
652 if [ "$upgrade_macros" = "yes" ]; then
653 command="poldek --up; poldek -uv rpm-build-macros"
659 if [ "$upgrade_scripts" = "yes" ]; then
660 command="cd ~/rpm/rpm-build-tools && git pull"
661 command_flags=as-builder
667 if [[ "$requester" != *@* ]] ; then
668 requester="$requester@tld-linux.org"
671 if [ -z "$builders" ] ; then
672 builders="$default_builders"
675 if [ "$f_upgrade" = "yes" ] ; then
676 flags="$flags upgrade"
679 if [ "$build_mode" = "test" ] ; then
680 if [ "$f_upgrade" = "yes" ] ; then
681 die "--upgrade and --test-build are mutually exclusive"
683 flags="$flags test-build"
686 if [ -z "$build_mode" ] ; then
687 # missing build mode, builders go crazy when you proceed"
688 die "please specify build mode"
697 if [ -z "$specs" -a -z "$command" ]; then
698 die "no packages to build or command to invoke specified"
704 echo "<group id='$id' no='0' flags='$flags'>"
705 echo " <time>$(date +%s)</time>"
706 msg "Using priority $priority"
707 echo " <priority>$priority</priority>"
708 if [ -n "$jobs" ]; then
709 msg "Using jobs $jobs"
710 echo " <maxjobs>$jobs</maxjobs>"
712 if [ -z "$url" ]; then
713 msg "Using email $builder_email"
718 if [ "$build_mode" = "ready" ]; then
719 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
721 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
724 if [ -n "$requester_override" ] ; then
725 echo " <requester>$requester_override</requester>"
734 local name branch builders_xml
736 for b in $builders; do
737 msg "Builder: $(red $b)"
738 builders_xml="$builders_xml <builder>$b</builder>"
741 if [ "$command" ]; then
743 echo -E >&2 "* Command: $command"
744 echo " <batch id='$bid' depends-on=''>"
745 echo " <command flags='$command_flags'>"
748 echo " <info></info>"
754 if [ "$f_upgrade" = "yes" ] ; then
755 msg "Upgrade mode: $f_upgrade"
760 if [ "$s" = "^" ]; then
764 if [ "$no_depend" = yes ]; then
768 echo " <batch id='$bid' depends-on='$depend'>"
770 name=$(echo "$s" | sed -e 's|:.*||')
771 branch=$(echo "$s" | sed -e 's|.*:||')
772 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
773 echo " <spec>$name</spec>"
774 echo " <branch>$branch</branch>"
775 echo " ${kernel:+<kernel>$kernel</kernel>}"
776 echo " ${target:+<target>$target</target>}"
780 [ -z "$b" ] && continue
783 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
784 msg "- define $b=$value"
788 echo " <info></info>"
791 echo " <with>$b</with>"
793 for b in $without; do
794 echo " <without>$b</without>"
801 # let next job depend on previous
805 if [ "$post_command" ]; then
807 if [ "$no_depend" = yes ]; then
810 echo -E >&2 "* Post-Command: $post_command"
811 echo " <batch id='$bid' depends-on='$depend'>"
812 echo " <command flags='$command_flags'>"
815 echo " <info></info>"
825 # make request first, so the STDERR/STDOUT streams won't be mixed
830 if [ "$verbose" = "yes" ]; then
837 Subject: build request
838 Message-Id: <$id@$(hostname)>
839 X-New-TLD-Builder: request
840 X-Requester-Version: $VERSION
844 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
848 gen_email | send_request