]> git.pld-linux.org Git - projects/pld-builder.new.git/blame - client/make-request.sh
- verbose on what command will be sent
[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 ;;
e728b34c
ER
235esac
236
237specs=`for s in $specs; do
9cc9841b
ER
238 case "$s" in
239 *.spec:*) # spec with branch
240 echo $s
241 ;;
242 *.spec) # spec without branch
243 echo $s:$default_branch
244 ;;
245 *:*) # package name with branch
246 echo $s | sed -e 's/:/.spec:/'
247 ;;
248 *) # just package name
249 echo $s.spec:$default_branch
250 ;;
251 esac
878677a8 252done`
1344b6f1 253
2f470d17 254if [[ "$requester" != *@* ]] ; then
9cc9841b 255 requester="$requester@pld-linux.org"
2f470d17
MK
256fi
257
a757e911 258if [ "$builders" = "" ] ; then
9cc9841b 259 builders="$default_builders"
a757e911
MM
260fi
261
544ca060 262if [ "$f_upgrade" = "yes" ] ; then
9cc9841b 263 flags="$flags upgrade"
a757e911
MM
264fi
265
e936beda 266if [ "$build_mode" = "test" ] ; then
9cc9841b
ER
267 if [ "$f_upgrade" = "yes" ] ; then
268 die "--upgrade and --test-build are mutually exclusive"
269 fi
270 flags="$flags test-build"
e936beda
MM
271fi
272
e728b34c
ER
273if [ -z "$build_mode" ] ; then
274 # missing build mode, builders go crazy when you proceed"
275 die "please specify build mode"
276fi
277
278
280b1afd 279ok=
e728b34c
ER
280for s in $specs; do
281 ok=1
280b1afd
MM
282done
283
284if [ "$ok" = "" ] ; then
9cc9841b
ER
285 if [ "$command" = "" ] ; then
286 die "no specs passed"
287 fi
c4aa0539 288else
9cc9841b
ER
289 if [ "$command" != "" ] ; then
290 die "cannot pass specs and --command"
291 fi
280b1afd
MM
292fi
293
1344b6f1
MM
294id=$(uuidgen)
295
296gen_req() {
9cc9841b
ER
297 echo "<group id='$id' no='0' flags='$flags'>"
298 echo " <time>$(date +%s)</time>"
299 echo " <priority>$priority</priority>"
300 echo
301
302 if [ "$command" != "" ] ; then
303 bid=$(uuidgen)
a32d5b77 304 echo >&2 "* Command: $command"
9cc9841b
ER
305 echo " <batch id='$bid' depends-on=''>"
306 echo " <command flags='$command_flags'>$command</command>"
307 echo " <info></info>"
308 for b in $builders ; do
309 echo " <builder>$b</builder>"
310 done
311 echo " </batch>"
312 else
313
314 echo >&2 "* Using priority $priority"
315 echo >&2 "* Using email $builder_email"
316 echo >&2 "* Build mode: $build_mode"
e728b34c
ER
317 if [ "$f_upgrade" = "yes" ] ; then
318 echo >&2 "* Upgrade mode: $f_upgrade"
319 fi
9cc9841b 320 echo >&2 "* Queue-ID: $id"
e728b34c 321
9cc9841b
ER
322 # first id:
323 fid=
e728b34c 324 i=1
9cc9841b
ER
325 for s in $specs; do
326 bid=$(uuidgen)
327 echo " <batch id='$bid' depends-on='$fid'>"
328 [ "$fid" = "" ] && fid="$bid"
329 name=$(echo "$s" | sed -e 's|:.*||')
330 branch=$(echo "$s" | sed -e 's|.*:||')
331 echo >&2 "* Adding #$i $name:$branch"
332 echo " <spec>$name</spec>"
333 echo " <branch>$branch</branch>"
334 echo " ${kernel:+<kernel>$kernel</kernel>}"
335 echo " <info></info>"
336 echo
337 for b in $with; do
338 echo " <with>$b</with>"
339 done
340 for b in $without; do
341 echo " <without>$b</without>"
342 done
343 echo
344 for b in $builders; do
345 echo " <builder>$b</builder>"
346 done
347 echo " </batch>"
e728b34c 348 i=$((i+1))
9cc9841b 349 done
c4aa0539 350
9cc9841b 351 fi
e728b34c 352
9cc9841b 353 echo "</group>"
1344b6f1
MM
354}
355
356gen_email () {
e728b34c
ER
357 # make request first, so the STDERR/STDOUT streams won't be mixed
358 local req=$(gen_req)
359
1344b6f1 360cat <<EOF
2f470d17 361From: $requester
1344b6f1
MM
362To: $builder_email
363Subject: build request
364Message-Id: <$id@$(hostname)>
365X-New-PLD-Builder: request
2d28916b 366X-Requester-Version: \$Id$
1344b6f1 367
e728b34c 368$(echo "$req" | gpg --clearsign --default-key $default_key $gpg_opts)
1344b6f1
MM
369EOF
370}
371
8454c165 372gen_email | $mailer
e728b34c 373
9cc9841b 374# vim:ts=2:sw=2
This page took 0.133327 seconds and 4 git commands to generate.