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 atag pkg spec rpmdir
201 rpmdir=$(rpm -E %_topdir)
206 # strip .spec extension
208 wget http://pkgrevs.tld-linux.org/list/$pkg -O /tmp/$pkg.tags 1>/dev/null 2>&1
209 atag=$(head -n 1 /tmp/$pkg.tags)
211 if [ "x$atag" = "x" ]; then
214 echo "$pkg.spec:$atag"
220 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
226 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
228 Mandatory arguments to long options are mandatory for short options too.
230 --config-file /path/to/config/file
231 Source additional config file (after $USER_CFG), useful when
232 when sending build requests to Ac/Th from the same account
234 Try to use latest auto-tag for the spec when building
235 WARNING: This will checkout new files to your packages dir
236 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
237 Sends request to given builders (in 'version-arch' format)
238 --with VALUE, --without VALUE
239 Build package with(out) a given bcond
241 set alt_kernel to VALUE
243 set --target to VALUE
244 -D "NAME VALUE"|--define "NAME VALUE"
245 define macro named NAME with value VALUE
246 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
247 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
249 specify default branch for specs in request
251 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
252 ftp tree and won't be upgraded on builders.
254 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
255 (and later moved by release manager staff to ready/ and main ftp tree)
257 Forces package upgrade (for use with -c or -q, not -t)
259 Bump package release, see also --relup
261 Set commit message for relup
263 Disables package upgrade (for use with -r)
265 Do not install missing BuildRequires (--nodeps)
267 Do not add dependency of build jobs, each job in batch runs itself
269 Number of parallel jobs for single build
271 -d, --dist DISTRIBUTION_ID
272 Specify value for \$dist
273 -df, --distfiles-fetch[-request] PACKAGE
274 Send distfiles request to fetch sources for PACKAGE
278 Executes a given command on builders (prepended to build jobs if build jobs included)
280 Executes a given command on builders (appended to build jobs if build jobs included)
282 shortcut for --command poldek -evt ARGS
284 shortcut for --command poldek -ev --noask ARGS
286 shortcut for --command poldek --up -Uv ARGS
288 Updates builders infrastructure (outside chroot)
290 Updates rpm-build-macros on src builder
292 Updates ~/rpm/rpm-build-tools on builder
294 Override the requester
296 shortcut for --command rpm -q ARGS
297 -g, --gpg-opts "opts"
298 Pass additional options to gpg binary
300 sets request priority (default 2)
302 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
303 This may be useful if you just commited package and want to send it
304 for test build after distfiles has fetched the file.
306 Displays this help message
308 Verbose. Print some more debug on screen
313 # validate distro, set $dist
321 die "dist \`$1' not known"
328 while [ $# -gt 0 ]; do
330 -d | --dist | --distro)
336 [ -f "$2" ] && . $2 || die "Config file not found"
342 builders="$builders ${b%:*}"
361 with="$with $(echo "$2" | tr ',' ' ')"
366 without="$without $(echo "$2" | tr ',' ' ')"
388 define="$define$cr$name=$value"
423 --no-install-br | -ni)
424 flags="$flags no-install-br"
450 --command-flags | -cf)
457 if [ "$command" = - ]; then
458 echo >&2 "Reading command from STDIN"
467 if [ "$post_command" = - ]; then
468 echo >&2 "Reading post_command from STDIN"
476 command="poldek -evt $2"
481 command="for a in $2; do poldek -ev --noask \$a; done"
486 command="poldek --up; poldek -uv $2"
497 command_flags="no-chroot"
507 upgrade_scripts='yes'
510 -df | --distfiles-fetch | --distfiles-fetch-request)
524 requester_override="$2"
529 die "unknown knob: $1"
541 builder_email="builderti@kraz.tld-linux.org"
542 default_builders="ti-*"
543 url="https://kraz.tld-linux.org:1241/"
544 control_url="http://kraz.tld-linux.org/~builderti"
547 builder_email="buildertidev@kraz.tld-linux.org"
548 default_builders="ti-dev-*"
549 url="https://kraz.tld-linux.org:1242/"
550 control_url="http://kraz.tld-linux.org/~buildertidev"
553 die "dist \`$dist' not known"
557 # need to do this after dist selection
559 skip=$(skip="$skip" control_url="$control_url" python -c '
567 from xml.dom import minidom
569 skip = os.environ.get("skip").split(",");
570 control_url = os.environ.get("control_url")
572 print >> sys.stderr, "* Check queue_id-s against %s" % control_url
575 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
576 req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
577 f = urllib2.urlopen(req)
579 print >> sys.stderr, "Fetch error %s: %s" % (control_url + "/queue.gz", e)
582 sio = StringIO.StringIO()
586 f = gzip.GzipFile(fileobj = sio)
588 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read()).group(1)
589 d = minidom.parseString(xml)
592 for c in d.documentElement.childNodes:
593 if c.nodeName != "group":
595 q.append(c.attributes["id"].value)
600 print >> sys.stderr, "- Check %s: ERROR: Not valid queue-id" % s
603 print >> sys.stderr, "- Check %s: OK" % s
606 print string.join(skip, ",")
612 command_flags="no-chroot"
616 branch=${branch:-$default_branch}
618 specs=`for s in $specs; do
621 # skip marker - pass it along
624 *:*) # package name with branch
625 _specfile=$(basename ${s%:*})
626 echo ${_specfile%.spec}.spec:${s##*:}
628 *) # just package name
629 echo $(basename ${s%.spec}).spec:$branch
634 if [ "$relup" = "yes" ]; then
635 msg "Auto relup enabled"
636 relup ${message:+-m "$message"} $specs
639 if [ "$autotag" = "yes" ]; then
640 msg "Auto autotag build enabled"
641 specs=$(get_autotag $specs)
644 if [ "$df_fetch" = "yes" ]; then
649 if [ "$upgrade_macros" = "yes" ]; then
650 command="poldek --up; poldek -uv rpm-build-macros"
656 if [ "$upgrade_scripts" = "yes" ]; then
657 command="cd ~/rpm/rpm-build-tools && git pull"
658 command_flags=as-builder
664 if [[ "$requester" != *@* ]] ; then
665 requester="$requester@tld-linux.org"
668 if [ -z "$builders" ] ; then
669 builders="$default_builders"
672 if [ "$f_upgrade" = "yes" ] ; then
673 flags="$flags upgrade"
676 if [ "$build_mode" = "test" ] ; then
677 if [ "$f_upgrade" = "yes" ] ; then
678 die "--upgrade and --test-build are mutually exclusive"
680 flags="$flags test-build"
683 if [ -z "$build_mode" ] ; then
684 # missing build mode, builders go crazy when you proceed"
685 die "please specify build mode"
694 if [ -z "$specs" -a -z "$command" ]; then
695 die "no packages to build or command to invoke specified"
701 echo "<group id='$id' no='0' flags='$flags'>"
702 echo " <time>$(date +%s)</time>"
703 msg "Using priority $priority"
704 echo " <priority>$priority</priority>"
705 if [ -n "$jobs" ]; then
706 msg "Using jobs $jobs"
707 echo " <maxjobs>$jobs</maxjobs>"
709 if [ -z "$url" ]; then
710 msg "Using email $builder_email"
715 if [ "$build_mode" = "ready" ]; then
716 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
718 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
721 if [ -n "$requester_override" ] ; then
722 echo " <requester>$requester_override</requester>"
731 local name branch builders_xml
733 for b in $builders; do
734 msg "Builder: $(red $b)"
735 builders_xml="$builders_xml <builder>$b</builder>"
738 if [ "$command" ]; then
740 echo -E >&2 "* Command: $command"
741 echo " <batch id='$bid' depends-on=''>"
742 echo " <command flags='$command_flags'>"
745 echo " <info></info>"
751 if [ "$f_upgrade" = "yes" ] ; then
752 msg "Upgrade mode: $f_upgrade"
757 if [ "$s" = "^" ]; then
761 if [ "$no_depend" = yes ]; then
765 echo " <batch id='$bid' depends-on='$depend'>"
767 name=$(echo "$s" | sed -e 's|:.*||')
768 branch=$(echo "$s" | sed -e 's|.*:||')
769 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
770 echo " <spec>$name</spec>"
771 echo " <branch>$branch</branch>"
772 echo " ${kernel:+<kernel>$kernel</kernel>}"
773 echo " ${target:+<target>$target</target>}"
777 [ -z "$b" ] && continue
780 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
781 msg "- define $b=$value"
785 echo " <info></info>"
788 echo " <with>$b</with>"
790 for b in $without; do
791 echo " <without>$b</without>"
798 # let next job depend on previous
802 if [ "$post_command" ]; then
804 if [ "$no_depend" = yes ]; then
807 echo -E >&2 "* Post-Command: $post_command"
808 echo " <batch id='$bid' depends-on='$depend'>"
809 echo " <command flags='$command_flags'>"
812 echo " <info></info>"
822 # make request first, so the STDERR/STDOUT streams won't be mixed
827 if [ "$verbose" = "yes" ]; then
834 Subject: build request
835 Message-Id: <$id@$(hostname)>
836 X-New-TLD-Builder: request
837 X-Requester-Version: $VERSION
841 gpg --clearsign --default-key $default_key $gpg_opts --output=- $tmp
845 gen_email | send_request