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@pld-linux.org
42 default_key=deviloper@pld-linux.org
43 send_mode="$send_mode"
45 mailer="/usr/lib/sendmail -t"
48 url="https://srcbuilder.pld-linux.org:1235/"
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"
106 from urllib import request
109 data = sys.stdin.read().encode("utf-8")
111 socket.setdefaulttimeout(30)
112 req = request.Request(url, data=data)
113 f = request.urlopen(req)
115 except Exception as e:
116 print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr)
118 print("Request queued via HTTP.", file=sys.stdout)
124 # htmlspecialchars: escape <, > and &
127 printf "%s\n" "$input" | sed -e 's,&,\&,g;s,<,\<,g;s,>,\>,g'
130 # simple df_fetcher, based on packages/fetchsrc_request
131 # TODO: tcp (smtp) mode
132 # TODO: adjust for ~/.requestrc config
137 local MAILER='/usr/lib/sendmail'
138 # MAILER='/usr/bin/msmtp'
143 #VIA_ARGS="some additional flags"
145 # VIA_ARGS='-a gmail'
148 local DMAIL="distfiles@cvs.pld-linux.org"
150 local HOST=$(hostname -f)
151 local LOGIN=${requester%@*}
154 for spec in $specs; do
155 SPEC=$(echo "$spec" | sed -e 's|:.*||')
157 BRANCH=$(echo "$spec" | sed -e 's|.*:||')
158 echo >&2 "Distfiles Request: $SPEC:$BRANCH via $MAILER ${VIA_ARGS:+ ($VIA_ARGS)}"
159 cat <<-EOF | "$MAILER" -t -i $VIA_ARGS
161 From: $LOGIN <$LOGIN@$HOST>
162 Subject: fetchsrc_request notify
163 X-distfiles-request: yes
174 # autotag from rpm-build-macros
175 # displays latest used tag for a specfile
181 # ensure package ends with .spec
184 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
185 --format='%(refname:short)')
190 # get autotag for specs
191 # WARNING: This may checkout some files from VCS
193 local pkg spec rpmdir gitdir
195 rpmdir=$(rpm -E %_topdir 2> /dev/null)
199 # strip .spec extension
202 if [ -n "$rpmdir" ]; then
205 gitdir=$(mktemp -d) || exit 1
207 git clone --depth=1 git://git.pld-linux.org/packages/$pkg
210 # checkout only if missing
211 if [ ! -e $pkg/$pkg.spec -a -x $rpmdir/builder ]; then
212 $rpmdir/builder -g $pkg -ns -r HEAD 1>&2
214 if [ ! -e $pkg/$pkg.spec ]; then
215 # just print it out, to fallback to base pkg name
222 [ -d "$gitdir" ] && rm -rf "$gitdir"
227 local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
233 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
235 Mandatory arguments to long options are mandatory for short options too.
237 --config-file /path/to/config/file
238 Source additional config file (after $USER_CFG), useful when
239 when sending build requests to Ac/Th from the same account
241 Try to use latest auto-tag for the spec when building
242 WARNING: This will checkout new files to your packages dir
243 -b 'BUILDER BUILDER ...', --builder='BUILDER BUILDER ...'
244 Sends request to given builders (in 'version-arch' format)
245 --with VALUE, --without VALUE
246 Build package with(out) a given bcond
248 set alt_kernel to VALUE
250 set --target to VALUE
251 -D "NAME VALUE"|--define "NAME VALUE"
252 define macro named NAME with value VALUE
253 -s BUILD_ID, --skip BUILD_ID[,BUILD_ID][,BUILD_ID]
254 mark build ids on src builder to be skipped (instructs srcbuilder to create 'skipme' file)
256 specify default branch for specs in request
258 Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
259 ftp tree and won't be upgraded on builders.
261 Preforms a 'ready' build. Package will be built and uploaded to test/ ftp tree
262 (and later moved by release manager staff to ready/ and main ftp tree)
264 Forces package upgrade (for use with -c or -q, not -t)
266 Bump package release, see also --relup
268 Set commit message for relup
270 Disables package upgrade (for use with -r)
272 Do not install missing BuildRequires (--nodeps)
274 Do not add dependency of build jobs, each job in batch runs itself
276 Number of parallel jobs for single build
278 -d, --dist DISTRIBUTION_ID
279 Specify value for \$dist
280 -df, --distfiles-fetch[-request] PACKAGE
281 Send distfiles request to fetch sources for PACKAGE
285 Executes a given command on builders (prepended to build jobs if build jobs included)
287 Executes a given command on builders (appended to build jobs if build jobs included)
289 shortcut for --command poldek -evt ARGS
291 shortcut for --command poldek -ev --noask ARGS
293 shortcut for --command poldek --up -Uv ARGS
295 Updates builders infrastructure (outside chroot)
297 Updates rpm-build-macros on src builder
299 Updates ~/rpm/rpm-build-tools on builder
301 Override the requester
303 shortcut for --command rpm -q ARGS
304 -g, --gpg-opts "opts"
305 Pass additional options to gpg binary
307 sets request priority (default 2)
309 Wait SECONDS before sending actual request. Note: gpg passphrase is still asked immediately.
310 This may be useful if you just commited package and want to send it
311 for test build after distfiles has fetched the file.
313 Displays this help message
315 Verbose. Print some more debug on screen
320 # validate distro, set $dist
338 die "dist \`$1' not known"
345 while [ $# -gt 0 ]; do
347 -d | --dist | --distro)
353 [ -f "$2" ] && . $2 || die "Config file not found"
359 builders="$builders ${b%:*}"
378 with="$with $(echo "$2" | tr ',' ' ')"
383 without="$without $(echo "$2" | tr ',' ' ')"
405 define="$define$cr$name=$value"
440 --no-install-br | -ni)
441 flags="$flags no-install-br"
467 --command-flags | -cf)
474 if [ "$command" = - ]; then
475 echo >&2 "Reading command from STDIN"
484 if [ "$post_command" = - ]; then
485 echo >&2 "Reading post_command from STDIN"
493 command="poldek -evt $2"
498 command="for a in $2; do poldek -ev --noask \$a; done"
503 command="poldek --up; poldek -uv $2"
514 command_flags="no-chroot"
524 upgrade_scripts='yes'
527 -df | --distfiles-fetch | --distfiles-fetch-request)
541 requester_override="$2"
546 die "unknown knob: $1"
558 default_branch="AC-branch"
559 builder_email="builder-ac@pld-linux.org"
560 default_builders="ac-*"
561 url="http://ep09.pld-linux.org:1289/"
562 control_url="http://ep09.pld-linux.org/~buildsrc"
564 ac-java) # fake "dist" for java available ac architectures
565 builder_email="builder-ac@pld-linux.org"
566 default_builders="ac-i586 ac-i686 ac-athlon ac-amd64"
567 default_branch="AC-branch"
568 url="http://ep09.pld-linux.org:1289/"
570 ac-xen) # fake "dist" for xen-enabled architectures
571 builder_email="builder-ac@pld-linux.org"
572 default_builders="ac-i686 ac-athlon ac-amd64"
573 default_branch="AC-branch"
576 builder_email="builderti@ep09.pld-linux.org"
577 default_builders="ti-*"
578 url="http://ep09.pld-linux.org:1231/"
579 control_url="http://ep09.pld-linux.org/~builderti"
582 builder_email="buildertidev@ep09.pld-linux.org"
583 default_builders="ti-dev-*"
584 url="http://ep09.pld-linux.org:1232/"
585 control_url="http://ep09.pld-linux.org/~buildertidev"
588 builder_email="builderth@pld-linux.org"
589 default_builders="th-*"
590 url="https://srcbuilder.pld-linux.org:1235/"
591 control_url="https://srcbuilder.pld-linux.org/th/"
593 th-java) # fake "dist" for java available th architectures
594 builder_email="builderth@pld-linux.org"
595 default_builders="th-x86_64 th-athlon th-i686"
596 url="https://srcbuilder.pld-linux.org:1235/"
599 builder_email="builderaidath@ep09.pld-linux.org"
600 default_builders="aidath-*"
603 die "dist \`$dist' not known"
607 # need to do this after dist selection
609 skip=$(skip="$skip" control_url="$control_url" python3 -c '
615 from urllib import request
616 from io import BytesIO
617 from xml.dom import minidom
619 skip = os.environ.get("skip").split(",");
620 control_url = os.environ.get("control_url")
622 print("* Check queue_id-s against %s" % control_url, file=sys.stderr)
625 headers = { "Cache-Control": "no-cache", "Pragma": "no-cache" }
626 req = request.Request(url=control_url + "/queue.gz", headers=headers)
627 f = request.urlopen(req)
628 except Exception as e:
629 print("Fetch error %s: %s" % (control_url + "/queue.gz", e), file=sys.stderr)
636 f = gzip.GzipFile(fileobj = sio)
638 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read().decode("utf-8")).group(1)
639 d = minidom.parseString(xml)
642 for c in d.documentElement.childNodes:
643 if c.nodeName != "group":
645 q.append(c.attributes["id"].value)
650 print("- Check %s: ERROR: Not valid queue-id" % s, file=sys.stderr)
653 print("- Check %s: OK" % s, file=sys.stderr)
656 print(",".join(skip))
662 command_flags="no-chroot"
666 branch=${branch:-$default_branch}
668 specs=`for s in $specs; do
671 # skip marker - pass it along
674 *:*) # package name with branch
675 _specfile=$(basename ${s%:*})
676 echo ${_specfile%.spec}.spec:${s##*:}
678 *) # just package name
679 echo $(basename ${s%.spec}).spec:$branch
684 if [ "$relup" = "yes" ]; then
685 msg "Auto relup enabled"
686 relup ${message:+-m "$message"} $specs
689 if [ "$autotag" = "yes" ]; then
690 msg "Auto autotag build enabled"
691 specs=$(get_autotag $specs)
694 if [ "$df_fetch" = "yes" ]; then
699 if [ "$upgrade_macros" = "yes" ]; then
700 command="poldek --up; poldek -uv rpm-build-macros"
706 if [ "$upgrade_scripts" = "yes" ]; then
707 command="cd ~/rpm/rpm-build-tools && git pull"
708 command_flags=as-builder
714 if [[ "$requester" != *@* ]] ; then
715 requester="$requester@pld-linux.org"
718 if [ -z "$builders" ] ; then
719 builders="$default_builders"
722 if [ "$f_upgrade" = "yes" ] ; then
723 flags="$flags upgrade"
726 if [ "$build_mode" = "test" ] ; then
727 if [ "$f_upgrade" = "yes" ] ; then
728 die "--upgrade and --test-build are mutually exclusive"
730 flags="$flags test-build"
733 if [ -z "$build_mode" ] ; then
734 # missing build mode, builders go crazy when you proceed"
735 die "please specify build mode"
744 if [ -z "$specs" -a -z "$command" ]; then
745 die "no packages to build or command to invoke specified"
751 echo "<group id='$id' no='0' flags='$flags'>"
752 echo " <time>$(date +%s)</time>"
753 msg "Using priority $priority"
754 echo " <priority>$priority</priority>"
755 if [ -n "$jobs" ]; then
756 msg "Using jobs $jobs"
757 echo " <maxjobs>$jobs</maxjobs>"
759 if [ -z "$url" ]; then
760 msg "Using email $builder_email"
765 if [ "$build_mode" = "ready" ]; then
766 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
768 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
771 if [ -n "$requester_override" ] ; then
772 echo " <requester>$requester_override</requester>"
781 local name branch builders_xml
783 for b in $builders; do
784 msg "Builder: $(red $b)"
785 builders_xml="$builders_xml <builder>$b</builder>"
788 if [ "$command" ]; then
790 printf "%s\n" "* Command: $command" >&2
791 echo " <batch id='$bid' depends-on=''>"
792 echo " <command flags='$command_flags'>"
795 echo " <info></info>"
801 if [ "$f_upgrade" = "yes" ] ; then
802 msg "Upgrade mode: $f_upgrade"
807 if [ "$s" = "^" ]; then
811 if [ "$no_depend" = yes ]; then
815 echo " <batch id='$bid' depends-on='$depend'>"
817 name=$(echo "$s" | sed -e 's|:.*||')
818 branch=$(echo "$s" | sed -e 's|.*:||')
819 msg "Adding #$i $name:$branch${kernel:+ alt_kernel=$kernel}${target:+ target=$target}${depend:+ depends on $depend}"
820 echo " <spec>$name</spec>"
821 echo " <branch>$branch</branch>"
822 echo " ${kernel:+<kernel>$kernel</kernel>}"
823 echo " ${target:+<target>$target</target>}"
827 [ -z "$b" ] && continue
830 echo " <define name='$(hsc $b)'>$(hsc "$value")</define>"
831 msg "- define $b=$value"
835 echo " <info></info>"
838 echo " <with>$b</with>"
840 for b in $without; do
841 echo " <without>$b</without>"
848 # let next job depend on previous
852 if [ "$post_command" ]; then
854 if [ "$no_depend" = yes ]; then
857 printf "%s\n" "* Post-Command: $post_command" >&2
858 echo " <batch id='$bid' depends-on='$depend'>"
859 echo " <command flags='$command_flags'>"
862 echo " <info></info>"
872 # make request first, so the STDERR/STDOUT streams won't be mixed
878 if [ "$verbose" = "yes" ]; then
885 Subject: build request
886 Message-Id: <$id@$(hostname)>
887 X-New-PLD-Builder: request
888 X-Requester-Version: $VERSION
892 gpg --clearsign --default-key $default_key $gpg_opts --output=$tmpd/sign $tmp
894 if [ "$verbose" = "yes" ]; then
902 gen_email | send_request