]> git.pld-linux.org Git - projects/pld-builder.new.git/blame - client/make-request.sh
- display builder info too
[projects/pld-builder.new.git] / client / make-request.sh
CommitLineData
1344b6f1
MM
1#!/bin/sh
2
864cdeb5
MM
3builders=
4specs=
5with=
6without=
7flags=
8command=
9command_flags=
16b5ec37 10gpg_opts=
e728b34c
ER
11default_branch='HEAD'
12distro=
544ca060 13
e29fbd39
AG
14if [ -n "$HOME_ETC" ]; then
15 USER_CFG=$HOME_ETC/.requestrc
544ca060 16else
e29fbd39 17 USER_CFG=$HOME/.requestrc
e728b34c 18fi
e29fbd39 19
e728b34c 20if [ ! -f "$USER_CFG" ]; then
e29fbd39 21 echo "Creating config file $USER_CFG. You *must* edit it."
e728b34c 22 cat >$USER_CFG <<'EOF'
1344b6f1 23priority=2
e728b34c 24requester=deviloper@pld-linux.org
544ca060 25default_key=deviloper@pld-linux.org
1344b6f1 26mailer="/usr/sbin/sendmail -t"
16b5ec37 27gpg_opts=""
e728b34c 28distro=th
1344b6f1 29
a757e911 30# defaults:
771f742d 31f_upgrade=yes
544ca060
MM
32EOF
33exit
34fi
35
e728b34c 36if [ -f "$USER_CFG" ]; then
9cc9841b 37 . $USER_CFG
e728b34c
ER
38fi
39
a757e911 40die () {
9cc9841b
ER
41 echo "$0: $*" 1>&2
42 exit 1
a757e911 43}
1344b6f1 44
586a5f1f 45usage() {
9cc9841b
ER
46 echo "Usage: make-request.sh [OPTION] ... [SPECFILE] ...."
47 echo ""
48 echo "Mandatory arguments to long options are mandatory for short options too."
49 echo " -C --config-file /path/to/config/file"
50 echo " Source additional config file (after $USER_CFG), useful when"
51 echo " when sending build requests to Ac/Th from the same account"
52 echo " -b 'BUILDER BUILDER ...' --builder='BUILDER BUILDER ...'"
53 echo " Sends request to given builders"
54 echo " --with VALUE --without VALUE"
55 echo " Build package with(out) a given bcond"
56 echo " --kernel VALUE"
57 echo " set alt_kernel to VALUE"
58 echo " -t --test-build"
59 echo " Performs a 'test-build'. Package will be uploaded to test/ tree"
60 echo " and won't be upgraded on builders"
61 echo " -r --ready-build"
62 echo " Build and upgrade package and upload it to ready/ tree"
63 echo " -u --upgrade"
64 echo " Forces package upgrade (for use with -t)"
65 echo " -n --no-upgrade"
66 echo " Disables package upgrade (for use with -r)"
67 echo " -ni -no-install-br"
68 echo " Do not install missing BuildRequires (--nodeps)"
69 echo " -f --flag"
70 echo " -d --distro"
71 echo " Specify value for \$distro"
72 echo " -cf --command-flag"
73 echo " Not yet documented"
74 echo " -c --command"
75 echo " Executes a given command on builders"
76 echo " --test-remove-pkg"
77 echo " shortcut for --command poldek -evt ARGS"
78 echo " --remove-pkg"
79 echo " shortcut for --command poldek -ev --noask ARGS"
80 echo " --upgrade-pkg"
81 echo " shortcut for --command poldek -uv ARGS"
82 echo " --cvsup"
83 echo " Updates builders infrastructure (outside chroot)"
84 echo " -q "
85 echo " shortcut for --command rpm -q ARGS"
86 echo " -g --gpg-opts \"opts\""
87 echo " Pass additional options to gpg binary"
88 echo " -p --priority VALUE"
89 echo " sets request priority (default 2)"
90 echo " -h --help"
91 echo " Displays this help message"
92 exit 0;
586a5f1f
AG
93}
94
95
1344b6f1 96while [ $# -gt 0 ] ; do
9cc9841b
ER
97 case "$1" in
98 --distro | -d )
99 distro=$2
100 shift
101 ;;
102
103 --config-file | -C )
104 [ -f $2 ] && . $2 || die "Config file not found"
105 shift
106 ;;
107
108 --builder | -b )
109 builders="$builders $2"
110 shift
111 ;;
112
113 --with )
114 with="$with $2"
115 shift
116 ;;
117
118 --without )
119 without="$without $2"
120 shift
121 ;;
122
123 --test-build | -t )
124 build_mode=test
125 f_upgrade=no
126 ;;
127
128 --kernel )
129 kernel=$2
130 shift
131 ;;
132
133 --priority | -p )
134 priority=$2
135 shift
136 ;;
137
138 --ready-build | -r )
139 build_mode=ready
140 ;;
141
142 --upgrade | -u )
143 f_upgrade=yes
144 ;;
145
146 --no-upgrade | -n )
147 f_upgrade=no
148 ;;
149
150 --no-install-br | -ni )
151 flags="$flags no-install-br"
152 ;;
153
154 --flag | -f )
155 flags="$flags $2"
156 shift
157 ;;
158
159 --command-flags | -cf )
160 command_flags="$2"
161 shift
162 ;;
163
164 --command | -c )
165 command="$2"
166 f_upgrade=no
167 shift
168 ;;
169 --test-remove-pkg)
170 command="poldek -evt $2"
171 f_upgrade=no
172 shift
173 ;;
174 --remove-pkg)
175 command="poldek -ev --noask $2"
176 f_upgrade=no
177 shift
178 ;;
179 --upgrade-pkg)
180 command="poldek -uv $2"
181 f_upgrade=no
182 shift
183 ;;
184 -q)
185 command="rpm -q $2"
186 f_upgrade=no
187 shift
188 ;;
189
190 --cvsup )
191 command_flags="no-chroot"
192 command="cvs up"
49a8a604 193 f_upgrade=no
9cc9841b
ER
194 ;;
195
196 --gpg-opts | -g )
197 gpg_opts="$2"
198 shift
199 ;;
200
201 --help | -h )
202 usage
203 ;;
204
205 -* )
206 die "unknown knob: $1"
207 ;;
208
209 *:* | * )
210 specs="$specs $1"
211 ;;
212 esac
213 shift
1344b6f1
MM
214done
215
e728b34c
ER
216case "$distro" in
217ac)
9cc9841b
ER
218 builder_email="builder-ac@pld-linux.org"
219 default_builders="ac-*"
220 default_branch="AC-branch"
221 ;;
b603979d 222ac-java) # fake "distro" for java available ac archidectures
9cc9841b
ER
223 builder_email="builder-ac@pld-linux.org"
224 default_builders="ac-i586 ac-i686 ac-athlon ac-amd64"
225 default_branch="AC-branch"
226 ;;
e728b34c 227ti)
9cc9841b
ER
228 builder_email="builderti@ep09.pld-linux.org"
229 default_builders="ti-*"
230 ;;
e728b34c 231th)
9cc9841b
ER
232 builder_email="builderth@ep09.pld-linux.org"
233 default_builders="th-*"
234 ;;
14b580de
ER
235*)
236 die "distro \`$distro' not known"
237 ;;
e728b34c
ER
238esac
239
240specs=`for s in $specs; do
9cc9841b
ER
241 case "$s" in
242 *.spec:*) # spec with branch
243 echo $s
244 ;;
245 *.spec) # spec without branch
246 echo $s:$default_branch
247 ;;
248 *:*) # package name with branch
249 echo $s | sed -e 's/:/.spec:/'
250 ;;
251 *) # just package name
252 echo $s.spec:$default_branch
253 ;;
254 esac
878677a8 255done`
1344b6f1 256
2f470d17 257if [[ "$requester" != *@* ]] ; then
9cc9841b 258 requester="$requester@pld-linux.org"
2f470d17
MK
259fi
260
14b580de 261if [ -z "$builders" ] ; then
9cc9841b 262 builders="$default_builders"
a757e911
MM
263fi
264
544ca060 265if [ "$f_upgrade" = "yes" ] ; then
9cc9841b 266 flags="$flags upgrade"
a757e911
MM
267fi
268
e936beda 269if [ "$build_mode" = "test" ] ; then
9cc9841b
ER
270 if [ "$f_upgrade" = "yes" ] ; then
271 die "--upgrade and --test-build are mutually exclusive"
272 fi
273 flags="$flags test-build"
e936beda
MM
274fi
275
e728b34c
ER
276if [ -z "$build_mode" ] ; then
277 # missing build mode, builders go crazy when you proceed"
278 die "please specify build mode"
279fi
280
281
280b1afd 282ok=
e728b34c
ER
283for s in $specs; do
284 ok=1
280b1afd
MM
285done
286
287if [ "$ok" = "" ] ; then
9cc9841b
ER
288 if [ "$command" = "" ] ; then
289 die "no specs passed"
290 fi
c4aa0539 291else
9cc9841b
ER
292 if [ "$command" != "" ] ; then
293 die "cannot pass specs and --command"
294 fi
280b1afd
MM
295fi
296
1344b6f1
MM
297id=$(uuidgen)
298
299gen_req() {
9cc9841b
ER
300 echo "<group id='$id' no='0' flags='$flags'>"
301 echo " <time>$(date +%s)</time>"
302 echo " <priority>$priority</priority>"
303 echo
304
305 if [ "$command" != "" ] ; then
306 bid=$(uuidgen)
a32d5b77 307 echo >&2 "* Command: $command"
9cc9841b
ER
308 echo " <batch id='$bid' depends-on=''>"
309 echo " <command flags='$command_flags'>$command</command>"
310 echo " <info></info>"
14b580de
ER
311 for b in $builders; do
312 echo >&2 "* Builder: $b"
9cc9841b
ER
313 echo " <builder>$b</builder>"
314 done
315 echo " </batch>"
316 else
317
318 echo >&2 "* Using priority $priority"
319 echo >&2 "* Using email $builder_email"
320 echo >&2 "* Build mode: $build_mode"
e728b34c
ER
321 if [ "$f_upgrade" = "yes" ] ; then
322 echo >&2 "* Upgrade mode: $f_upgrade"
323 fi
9cc9841b 324 echo >&2 "* Queue-ID: $id"
e728b34c 325
9cc9841b
ER
326 # first id:
327 fid=
e728b34c 328 i=1
9cc9841b
ER
329 for s in $specs; do
330 bid=$(uuidgen)
331 echo " <batch id='$bid' depends-on='$fid'>"
332 [ "$fid" = "" ] && fid="$bid"
333 name=$(echo "$s" | sed -e 's|:.*||')
334 branch=$(echo "$s" | sed -e 's|.*:||')
335 echo >&2 "* Adding #$i $name:$branch"
336 echo " <spec>$name</spec>"
337 echo " <branch>$branch</branch>"
338 echo " ${kernel:+<kernel>$kernel</kernel>}"
339 echo " <info></info>"
340 echo
341 for b in $with; do
342 echo " <with>$b</with>"
343 done
344 for b in $without; do
345 echo " <without>$b</without>"
346 done
347 echo
348 for b in $builders; do
14b580de 349 echo >&2 "* Builder: $b"
9cc9841b
ER
350 echo " <builder>$b</builder>"
351 done
352 echo " </batch>"
e728b34c 353 i=$((i+1))
9cc9841b 354 done
c4aa0539 355
9cc9841b 356 fi
e728b34c 357
9cc9841b 358 echo "</group>"
1344b6f1
MM
359}
360
361gen_email () {
e728b34c
ER
362 # make request first, so the STDERR/STDOUT streams won't be mixed
363 local req=$(gen_req)
364
1344b6f1 365cat <<EOF
2f470d17 366From: $requester
1344b6f1
MM
367To: $builder_email
368Subject: build request
369Message-Id: <$id@$(hostname)>
370X-New-PLD-Builder: request
2d28916b 371X-Requester-Version: \$Id$
1344b6f1 372
e728b34c 373$(echo "$req" | gpg --clearsign --default-key $default_key $gpg_opts)
1344b6f1
MM
374EOF
375}
376
8454c165 377gen_email | $mailer
e728b34c 378
9cc9841b 379# vim:ts=2:sw=2
This page took 0.086192 seconds and 4 git commands to generate.