]> git.pld-linux.org Git - projects/pld-builder.new.git/blob - client/make-request.sh
kernel 5.15.is new longterm
[projects/pld-builder.new.git] / client / make-request.sh
1 #!/bin/sh
2 # vim:noet:ts=4:sw=4
3 VERSION=1.89
4
5 # prevent "*" from being expanded in builders var
6 set -f
7
8 builders=
9 with=
10 without=
11 flags=
12 command=
13 command_flags=
14 gpg_opts=
15 default_branch='HEAD'
16 dist=
17 url=
18 no_depend=no
19 verbose=no
20 autotag=no
21 requester_override=
22 relup=no
23
24 if [ -x /usr/bin/python ]; then
25         send_mode="python"
26 else
27         echo "No python present, using mail mode"
28         send_mode="mail"
29 fi
30
31 if [ -n "$HOME_ETC" ]; then
32         USER_CFG=$HOME_ETC/.requestrc
33 else
34         USER_CFG=$HOME/.requestrc
35 fi
36
37 if [ ! -f "$USER_CFG" ]; then
38         echo "Creating config file $USER_CFG. You *must* edit it."
39         cat > $USER_CFG <<EOF
40 priority=2
41 requester=deviloper@pld-linux.org
42 default_key=deviloper@pld-linux.org
43 send_mode="$send_mode"
44 url="$url"
45 mailer="/usr/lib/sendmail -t"
46 gpg_opts=""
47 dist=th
48 url="https://srcbuilder.pld-linux.org:1235/"
49
50 # defaults:
51 f_upgrade=yes
52 EOF
53 exit
54 fi
55
56 if [ -f "$USER_CFG" ]; then
57         . $USER_CFG
58         # legacy fallback
59         if [ "${distro:+set}" = "set" ]; then
60                 dist=$distro
61         fi
62 fi
63
64 # internal options, not to be overriden
65 specs=
66 df_fetch=no
67 upgrade_macros=no
68 upgrade_scripts=no
69 cr=$(printf "\r")
70
71 # Set colors
72 c_star=$(tput setaf 2)
73 c_red=$(tput setaf 1)
74 c_norm=$(tput op)
75 msg() {
76         echo >&2 "${c_star}*${c_norm} $*"
77 }
78 red() {
79         echo "${c_red}$*${c_norm}"
80 }
81
82 die() {
83         echo >&2 "$0: $*"
84         exit 1
85 }
86
87 send_request() {
88         # switch to mail mode, if no url set
89         [ -z "$url" ] && send_mode="mail"
90
91         if [ -n "$wait" ]; then
92                 msg "Waiting $wait seconds before sending request"
93                 sleep $wait
94                 msg "Wait has ended, proceeding!"
95         fi
96
97         case "$send_mode" in
98         "mail")
99                 msg "Sending using mail mode"
100                 cat - | $mailer
101                 ;;
102         *)
103                 msg "Sending using HTTP mode to $url"
104                 cat - | python3 -c '
105 import sys, socket
106 from urllib import request
107
108 try:
109         data = sys.stdin.read().encode("utf-8")
110         url = sys.argv[1]
111         socket.setdefaulttimeout(30)
112         req = request.Request(url, data=data)
113         f = request.urlopen(req)
114         f.close()
115 except Exception as e:
116         print("Problem while sending request via HTTP: %s: %s" % (url, e), file=sys.stderr)
117         sys.exit(1)
118 print("Request queued via HTTP.", file=sys.stdout)
119 ' "$url"
120                 ;;
121         esac
122 }
123
124 # htmlspecialchars: escape <, > and &
125 hsc() {
126         local input=$1
127         printf "%s\n" "$input" | sed -e 's,&,\&amp;,g;s,<,\&lt;,g;s,>,\&gt;,g'
128 }
129
130 # simple df_fetcher, based on packages/fetchsrc_request
131 # TODO: tcp (smtp) mode
132 # TODO: adjust for ~/.requestrc config
133 df_fetch() {
134         local specs="$@"
135
136         # Sending by
137         local MAILER='/usr/lib/sendmail'
138         # MAILER='/usr/bin/msmtp'
139         # Sending via
140         local VIA="SENDMAIL"
141         #VIA="localhost"
142         local VIA_ARGS=""
143         #VIA_ARGS="some additional flags"
144         # e.g. for msmtp:
145         # VIA_ARGS='-a gmail'
146         #
147         # DISTFILES EMAIL
148         local DMAIL="distfiles@cvs.pld-linux.org"
149
150         local HOST=$(hostname -f)
151         local LOGIN=${requester%@*}
152
153         local SPEC BRANCH
154         for spec in $specs; do
155                 SPEC=$(echo "$spec" | sed -e 's|:.*||')
156                 SPEC=${SPEC%.spec}
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
160                         To: $DMAIL
161                         From: $LOGIN <$LOGIN@$HOST>
162                         Subject: fetchsrc_request notify
163                         X-distfiles-request: yes
164                         X-Login: $LOGIN
165                         X-Package: $SPEC
166                         X-Branch: $BRANCH
167                         X-Flags: force-reply
168
169                         .
170                         EOF
171         done
172 }
173
174 # autotag from rpm-build-macros
175 # displays latest used tag for a specfile
176 autotag() {
177         local out s
178         for s in "$@"; do
179                 # strip branches
180                 s=${s%:*}
181                 # ensure package ends with .spec
182                 s=${s%.spec}.spec
183                 git fetch --tags
184                 out=$(git for-each-ref --count=1 --sort=-authordate refs/tags/auto/$dist \
185                         --format='%(refname:short)')
186                 echo "$s:$out"
187         done
188 }
189
190 # get autotag for specs
191 # WARNING: This may checkout some files from VCS
192 get_autotag() {
193         local pkg spec rpmdir gitdir
194
195         rpmdir=$(rpm -E %_topdir 2> /dev/null)
196         for pkg in "$@"; do
197                 # strip branches
198                 pkg=${pkg%:*}
199                 # strip .spec extension
200                 pkg=${pkg%.spec}
201
202                 if [ -n "$rpmdir" ]; then
203                         cd $rpmdir
204                 else
205                         gitdir=$(mktemp -d) || exit 1
206                         cd $gitdir
207                         git clone --depth=1 git://git.pld-linux.org/packages/$pkg
208                 fi
209
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
213                 fi
214                 if [ ! -e $pkg/$pkg.spec ]; then
215                         # just print it out, to fallback to base pkg name
216                         echo "$pkg"
217                 else
218                         cd $pkg
219                         autotag $pkg.spec
220                 fi
221
222                 [ -d "$gitdir" ] && rm -rf "$gitdir"
223         done
224 }
225
226 relup() {
227         local script=$(dirname $(rpm -E %_topdir))/rpm-build-tools/relup.sh
228         $script -u -i "$@"
229 }
230
231 usage() {
232         cat <<EOF
233 Usage: make-request.sh [OPTION] ... [SPECFILE] ....
234
235 Mandatory arguments to long options are mandatory for short options too.
236
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
240       -a
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
247       --kernel VALUE
248             set alt_kernel to VALUE
249       --target 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)
255       --branch VALUE
256             specify default branch for specs in request
257       -t, --test-build
258             Performs a 'test-build'. Package will be uploaded to hidden .test-builds/
259             ftp tree and won't be upgraded on builders.
260       -r, --ready-build
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)
263       -u, --upgrade
264             Forces package upgrade (for use with -c or -q, not -t)
265       --relup
266             Bump package release, see also --relup
267       -m, --message
268             Set commit message for relup
269       -n, --no-upgrade
270             Disables package upgrade (for use with -r)
271       -ni, --no-install-br
272             Do not install missing BuildRequires (--nodeps)
273       -nd, --no-depend
274             Do not add dependency of build jobs, each job in batch runs itself
275       -j, --jobs
276             Number of parallel jobs for single build
277       -f, --flag
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
282       -cf, --command-flag
283             Not yet documented
284       -c, --command
285             Executes a given command on builders (prepended to build jobs if build jobs included)
286       -C, --post-command
287             Executes a given command on builders (appended to build jobs if build jobs included)
288       --test-remove-pkg
289             shortcut for --command poldek -evt ARGS
290       --remove-pkg
291             shortcut for --command poldek -ev --noask ARGS
292       --upgrade-pkg
293             shortcut for --command poldek --up -Uv ARGS
294       --pull
295             Updates builders infrastructure (outside chroot)
296       --update-macros
297             Updates rpm-build-macros on src builder
298       --update-scripts
299             Updates ~/rpm/rpm-build-tools on builder
300       --requester username
301             Override the requester
302       -q
303             shortcut for --command rpm -q ARGS
304       -g, --gpg-opts "opts"
305             Pass additional options to gpg binary
306       -p, --priority VALUE
307             sets request priority (default 2)
308       -w SECONDS
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.
312       -h, --help
313             Displays this help message
314       -v
315             Verbose. Print some more debug on screen
316 EOF
317         exit 0
318 }
319
320 # validate distro, set $dist
321 set_dist() {
322         case "$1" in
323         ac)
324                 ;;
325         ac-java|ac-xen)
326                 ;;
327         ti)
328                 ;;
329         ti-dev)
330                 ;;
331         th)
332                 ;;
333         th-java)
334                 ;;
335         aidath)
336                 ;;
337         *)
338                 die "dist \`$1' not known"
339                 ;;
340         esac
341
342         dist=$1
343 }
344
345 while [ $# -gt 0 ]; do
346         case "$1" in
347                 -d | --dist | --distro)
348                         set_dist $2
349                         shift
350                         ;;
351
352                 --config-file)
353                         [ -f "$2" ] && . $2 || die "Config file not found"
354                         shift
355                         ;;
356
357                 --builder | -b)
358                         for b in $2; do
359                                 builders="$builders ${b%:*}"
360                         done
361                         shift
362                         ;;
363
364                 -a)
365                         autotag=yes
366                         ;;
367
368                 -m)
369                         shift
370                         message=$1
371                         ;;
372
373                 --relup)
374                         relup=yes
375                         ;;
376
377                 --with)
378                         with="$with $(echo "$2" | tr ',' ' ')"
379                         shift
380                         ;;
381
382                 --without)
383                         without="$without $(echo "$2" | tr ',' ' ')"
384                         shift
385                         ;;
386
387                 --test-build | -t)
388                         build_mode=test
389                         f_upgrade=no
390                         ;;
391
392                 --kernel)
393                         kernel=$2
394                         shift
395                         ;;
396
397                 --target)
398                         target=$2
399                         shift
400                         ;;
401
402                 -D|--define)
403                         value=${2#* }
404                         name=${2%% *}
405                         define="$define$cr$name=$value"
406                         shift
407                         ;;
408
409                 -s|--skip)
410                         skip="$2"
411                         shift
412                         ;;
413
414                 --branch)
415                         branch=$2
416                         shift
417                         ;;
418
419                 --priority | -p)
420                         priority=$2
421                         shift
422                         ;;
423
424                 --ready-build | -r)
425                         build_mode=ready
426                         ;;
427
428                 --upgrade | -u)
429                         f_upgrade=yes
430                         ;;
431
432                 --no-upgrade | -n)
433                         f_upgrade=no
434                         ;;
435
436                 --no-depend | -nd)
437                         no_depend=yes
438                         ;;
439
440                 --no-install-br | -ni)
441                         flags="$flags no-install-br"
442                         ;;
443
444                 -j | --jobs)
445                         jobs="$2"
446                         shift
447                         ;;
448
449                 -j*)
450                         jobs="${1#-j}"
451                         ;;
452
453                 -w)
454                         wait="$2"
455                         shift
456                         ;;
457
458                 -v)
459                         verbose=yes
460                         ;;
461
462                 --flag | -f)
463                         flags="$flags $2"
464                         shift
465                         ;;
466
467                 --command-flags | -cf)
468                         command_flags="$2"
469                         shift
470                         ;;
471
472                 --command | -c)
473                         command="$2"
474                         if [ "$command" = - ]; then
475                                 echo >&2 "Reading command from STDIN"
476                                 echo >&2 "---"
477                                 command=$(cat)
478                                 echo >&2 "---"
479                         fi
480                         shift
481                         ;;
482                 --post-command | -C)
483                         post_command="$2"
484                         if [ "$post_command" = - ]; then
485                                 echo >&2 "Reading post_command from STDIN"
486                                 echo >&2 "---"
487                                 post_command=$(cat)
488                                 echo >&2 "---"
489                         fi
490                         shift
491                         ;;
492                 --test-remove-pkg)
493                         command="poldek -evt $2"
494                         f_upgrade=no
495                         shift
496                         ;;
497                 --remove-pkg)
498                         command="for a in $2; do poldek -ev --noask \$a; done"
499                         f_upgrade=no
500                         shift
501                         ;;
502                 --upgrade-pkg|-Uhv)
503                         command="poldek --up; poldek -uv $2"
504                         f_upgrade=no
505                         shift
506                         ;;
507                 -q)
508                         command="rpm -q $2"
509                         f_upgrade=no
510                         shift
511                         ;;
512
513                 --pull)
514                         command_flags="no-chroot"
515                         command="git pull"
516                         f_upgrade=no
517                         ;;
518
519                 --update-macros)
520                         upgrade_macros="yes"
521                         ;;
522
523                 --update-scripts)
524                         upgrade_scripts='yes'
525                         ;;
526
527                 -df | --distfiles-fetch | --distfiles-fetch-request)
528                         df_fetch=yes
529                         ;;
530
531                 --gpg-opts | -g)
532                         gpg_opts="$2"
533                         shift
534                         ;;
535
536                 --help | -h)
537                         usage
538                         ;;
539
540                 --requester)
541                         requester_override="$2"
542                         shift
543                         ;;
544
545                 -*)
546                         die "unknown knob: $1"
547                         ;;
548
549                 *:* | *)
550                         specs="$specs $1"
551                         ;;
552         esac
553         shift
554 done
555
556 case "$dist" in
557 ac)
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"
563         ;;
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/"
569         ;;
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"
574         ;;
575 ti)
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"
580         ;;
581 ti-dev)
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"
586         ;;
587 th)
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/"
592         ;;
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/"
597         ;;
598 aidath)
599         builder_email="builderaidath@ep09.pld-linux.org"
600         default_builders="aidath-*"
601         ;;
602 *)
603         die "dist \`$dist' not known"
604         ;;
605 esac
606
607 # need to do this after dist selection
608 if [ "$skip" ]; then
609         skip=$(skip="$skip" control_url="$control_url" python3 -c '
610 import sys
611 import gzip
612 import re
613 import os
614 import string
615 from urllib import request
616 from io import BytesIO
617 from xml.dom import minidom
618
619 skip = os.environ.get("skip").split(",");
620 control_url = os.environ.get("control_url")
621
622 print("* Check queue_id-s against %s" % control_url, file=sys.stderr)
623
624 try:
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)
630         sys.exit(1)
631
632 sio = BytesIO()
633 sio.write(f.read())
634 f.close()
635 sio.seek(0)
636 f = gzip.GzipFile(fileobj = sio)
637
638 xml = re.compile("(<queue>.*?</queue>)", re.DOTALL).match(f.read().decode("utf-8")).group(1)
639 d = minidom.parseString(xml)
640
641 q = []
642 for c in d.documentElement.childNodes:
643         if c.nodeName != "group":
644                 continue
645         q.append(c.attributes["id"].value)
646
647 err = 0
648 for s in skip:
649         if s not in q:
650                 print("- Check %s: ERROR: Not valid queue-id" % s, file=sys.stderr)
651                 err = 1
652         else:
653                 print("- Check %s: OK" % s, file=sys.stderr)
654 if err == 1:
655         sys.exit(1)
656 print(",".join(skip))
657 ') || exit $?
658         f_upgrade=no
659         build_mode=test
660         priority=-1
661         command="skip:$skip"
662         command_flags="no-chroot"
663         builders="$dist-src"
664 fi
665
666 branch=${branch:-$default_branch}
667
668 specs=`for s in $specs; do
669         case "$s" in
670         ^)
671                 # skip marker - pass it along
672                 echo $s
673                 ;;
674         *:*) # package name with branch
675                 _specfile=$(basename ${s%:*})
676                 echo ${_specfile%.spec}.spec:${s##*:}
677                 ;;
678         *) # just package name
679                 echo $(basename ${s%.spec}).spec:$branch
680                 ;;
681         esac
682 done`
683
684 if [ "$relup" = "yes" ]; then
685         msg "Auto relup enabled"
686         relup ${message:+-m "$message"} $specs
687 fi
688
689 if [ "$autotag" = "yes" ]; then
690         msg "Auto autotag build enabled"
691         specs=$(get_autotag $specs)
692 fi
693
694 if [ "$df_fetch" = "yes" ]; then
695         df_fetch $specs
696         exit 0
697 fi
698
699 if [ "$upgrade_macros" = "yes" ]; then
700         command="poldek --up; poldek -uv rpm-build-macros"
701         builders="$dist-src"
702         f_upgrade=no
703         build_mode=test
704 fi
705
706 if [ "$upgrade_scripts" = "yes" ]; then
707         command="cd ~/rpm/rpm-build-tools && git pull"
708         command_flags=as-builder
709         builders="$dist-src"
710         f_upgrade=no
711         build_mode=test
712 fi
713
714 if [[ "$requester" != *@* ]] ; then
715         requester="$requester@pld-linux.org"
716 fi
717
718 if [ -z "$builders" ] ; then
719         builders="$default_builders"
720 fi
721
722 if [ "$f_upgrade" = "yes" ] ; then
723         flags="$flags upgrade"
724 fi
725
726 if [ "$build_mode" = "test" ] ; then
727         if [ "$f_upgrade" = "yes" ] ; then
728                 die "--upgrade and --test-build are mutually exclusive"
729         fi
730         flags="$flags test-build"
731 fi
732
733 if [ -z "$build_mode" ] ; then
734         # missing build mode, builders go crazy when you proceed"
735         die "please specify build mode"
736 fi
737
738
739 ok=
740 for s in $specs; do
741         ok=1
742 done
743
744 if [ -z "$specs" -a -z "$command" ]; then
745         die "no packages to build or command to invoke specified"
746 fi
747
748 id=$(uuidgen)
749
750 gen_req() {
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>"
758         fi
759         if [ -z "$url" ]; then
760                 msg "Using email $builder_email"
761         else
762                 msg "Using URL $url"
763         fi
764
765         if [ "$build_mode" = "ready" ]; then
766                 msg "Build mode: $(tput setaf 2)$build_mode$c_norm"
767         else
768                 msg "Build mode: $(tput setaf 3)$build_mode$c_norm"
769         fi
770
771         if [ -n "$requester_override" ] ; then
772                 echo "  <requester>$requester_override</requester>"
773         fi
774
775         msg "Queue-ID: $id"
776         echo
777
778         # job to depend on
779         local depend=
780         local b i=1 val
781         local name branch builders_xml
782
783         for b in $builders; do
784                 msg "Builder: $(red $b)"
785                 builders_xml="$builders_xml <builder>$b</builder>"
786         done
787
788         if [ "$command" ]; then
789                 bid=$(uuidgen)
790                 printf "%s\n" "* Command: $command" >&2
791                 echo "  <batch id='$bid' depends-on=''>"
792                 echo "           <command flags='$command_flags'>"
793                 hsc "$command"
794                 echo "</command>"
795                 echo "           <info></info>"
796                 echo "$builders_xml"
797                 echo "  </batch>"
798                 depend=$bid
799         fi
800
801         if [ "$f_upgrade" = "yes" ] ; then
802                 msg "Upgrade mode: $f_upgrade"
803         fi
804
805         for s in $specs; do
806                 # skip marker
807                 if [ "$s" = "^" ]; then
808                         depend=
809                         continue
810                 fi
811                 if [ "$no_depend" = yes ]; then
812                         depend=
813                 fi
814                 bid=$(uuidgen)
815                 echo "  <batch id='$bid' depends-on='$depend'>"
816
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>}"
824
825                 oIFS=$IFS; IFS=$cr
826                 for b in $define; do
827                         [ -z "$b" ] && continue
828                         value=${b#*=}
829                         b=${b%%=*}
830                         echo "           <define name='$(hsc $b)'>$(hsc "$value")</define>"
831                         msg "- define $b=$value"
832                 done
833                 IFS=$oIFS
834
835                 echo "           <info></info>"
836                 echo
837                 for b in $with; do
838                         echo "           <with>$b</with>"
839                 done
840                 for b in $without; do
841                         echo "           <without>$b</without>"
842                 done
843                 echo
844                 echo "$builders_xml"
845                 echo "  </batch>"
846                 i=$((i+1))
847
848                 # let next job depend on previous
849                 depend=$bid
850         done
851
852         if [ "$post_command" ]; then
853                 bid=$(uuidgen)
854                 if [ "$no_depend" = yes ]; then
855                         depend=
856                 fi
857                 printf "%s\n" "* Post-Command: $post_command" >&2
858                 echo "  <batch id='$bid' depends-on='$depend'>"
859                 echo "           <command flags='$command_flags'>"
860                 hsc "$post_command"
861                 echo "</command>"
862                 echo "           <info></info>"
863                 echo "$builders_xml"
864                 echo "  </batch>"
865                 depend=$bid
866         fi
867
868         echo "</group>"
869 }
870
871 gen_email () {
872         # make request first, so the STDERR/STDOUT streams won't be mixed
873         local tmpd tmp req
874         tmpd=$(mktemp -d)
875         tmp=$tmpd/req
876         gen_req > $tmp
877
878         if [ "$verbose" = "yes" ]; then
879                 cat $tmp >&2
880         fi
881
882         cat <<-EOF
883         From: $requester
884         To: $builder_email
885         Subject: build request
886         Message-Id: <$id@$(hostname)>
887         X-New-PLD-Builder: request
888         X-Requester-Version: $VERSION
889
890         EOF
891
892         gpg --clearsign --default-key $default_key $gpg_opts --output=$tmpd/sign $tmp
893
894         if [ "$verbose" = "yes" ]; then
895                 cat >&2 $tmpd/sign
896         fi
897
898         cat $tmpd/sign
899         rm -rf $tmpd
900 }
901
902 gen_email | send_request
This page took 0.105698 seconds and 3 git commands to generate.