]>
Commit | Line | Data |
---|---|---|
1344b6f1 MM |
1 | #!/bin/sh |
2 | ||
864cdeb5 MM |
3 | builders= |
4 | specs= | |
5 | with= | |
6 | without= | |
7 | flags= | |
8 | command= | |
9 | command_flags= | |
544ca060 | 10 | |
e29fbd39 AG |
11 | if [ -n "$HOME_ETC" ]; then |
12 | USER_CFG=$HOME_ETC/.requestrc | |
544ca060 | 13 | else |
e29fbd39 AG |
14 | USER_CFG=$HOME/.requestrc |
15 | fi; | |
16 | ||
17 | if [ -f "$USER_CFG" ]; then | |
18 | . $USER_CFG | |
19 | else | |
20 | echo "Creating config file $USER_CFG. You *must* edit it." | |
21 | cat >$USER_CFG <<EOF | |
1344b6f1 | 22 | priority=2 |
771f742d | 23 | requester=deviloper |
544ca060 | 24 | default_key=deviloper@pld-linux.org |
771f742d | 25 | builder_email=builderth@ep09.pld-linux.org |
1344b6f1 | 26 | mailer="/usr/sbin/sendmail -t" |
771f742d | 27 | default_builders="th-*" |
1344b6f1 | 28 | |
a757e911 | 29 | # defaults: |
771f742d | 30 | f_upgrade=yes |
a757e911 | 31 | |
544ca060 MM |
32 | EOF |
33 | exit | |
34 | fi | |
35 | ||
a757e911 MM |
36 | die () { |
37 | echo "$0: $*" 1>&2 | |
38 | exit 1 | |
39 | } | |
1344b6f1 | 40 | |
586a5f1f AG |
41 | usage() { |
42 | echo "Usage: make-request.sh [OPTION] ... [SPECFILE] ...." | |
43 | echo "" | |
44 | echo "Mandatory arguments to long options are mandatory for short options too." | |
d3200d79 AG |
45 | echo " -C --config-file /path/to/config/file" |
46 | echo " Source additional config file (after $USER_CFG), useful when" | |
47 | echo " when sending build requests to Ac/Th from the same account" | |
db22a5da | 48 | echo " -b 'BUILDER BUILDER ...' --builder='BUILDER BUILDER ...'" |
586a5f1f AG |
49 | echo " Sends request to given builders" |
50 | echo " --with VALUE --without VALUE" | |
51 | echo " Build package with(out) a given bcond" | |
e936beda | 52 | echo " -t --test-build" |
84a20e23 MM |
53 | echo " Performs a test build. No upgrades on builders, no tagging." |
54 | echo " -r --ready-build" | |
55 | echo " Ac compatibility. \"Ready\" build" | |
586a5f1f | 56 | echo " -u --upgrade" |
84a20e23 | 57 | echo " Forces package upgrade" |
586a5f1f | 58 | echo " -n --no-upgrade" |
e936beda | 59 | echo " Disables package upgrade" |
586a5f1f AG |
60 | echo " -ni -no-install-br" |
61 | echo " Do not install missing BuildRequires (--nodeps)" | |
62 | echo " -f --flag" | |
63 | echo " -cf --command-flag" | |
64 | echo " Not yet documented" | |
65 | echo " -c --command" | |
66 | echo " Executes a given command on builders" | |
67 | echo " --cvsup" | |
68 | echo " Updates builders infrastructure (outside chroot)" | |
1b630d82 | 69 | echo " -p --priority VALUE" |
97decef3 | 70 | echo " sets request priority (default 2)" |
586a5f1f AG |
71 | echo " -h --help" |
72 | echo " Displays this help message" | |
73 | exit 0; | |
74 | } | |
75 | ||
76 | ||
1344b6f1 MM |
77 | while [ $# -gt 0 ] ; do |
78 | case "$1" in | |
d3200d79 AG |
79 | --config-file | -C ) |
80 | [ -f $2 ] && . $2 || die "Config file not found" | |
81 | shift | |
82 | ;; | |
a757e911 | 83 | --builder | -b ) |
1344b6f1 MM |
84 | builders="$builders $2" |
85 | shift | |
86 | ;; | |
c4aa0539 | 87 | |
1344b6f1 MM |
88 | --with ) |
89 | with="$with $2" | |
90 | shift | |
91 | ;; | |
92 | ||
93 | --without ) | |
94 | without="$without $2" | |
95 | shift | |
96 | ;; | |
a757e911 | 97 | |
e936beda MM |
98 | --test-build | -t ) |
99 | build_mode=test | |
100 | f_upgrade=no | |
101 | ;; | |
102 | ||
84a20e23 MM |
103 | --ready-build | -r ) |
104 | build_mode=ready | |
105 | f_upgrade=yes | |
106 | ;; | |
107 | ||
1b630d82 | 108 | --priority | -p ) |
97decef3 | 109 | priority=$2 |
110 | shift | |
111 | ;; | |
112 | ||
a757e911 MM |
113 | --upgrade | -u ) |
114 | f_upgrade=yes | |
115 | ;; | |
116 | ||
117 | --no-upgrade | -n ) | |
544ca060 | 118 | f_upgrade=no |
a757e911 MM |
119 | ;; |
120 | ||
5d25d4e4 MM |
121 | --no-install-br | -ni ) |
122 | flags="$flags no-install-br" | |
123 | ;; | |
124 | ||
a757e911 MM |
125 | --flag | -f ) |
126 | flags="$flags $2" | |
127 | shift | |
128 | ;; | |
c4aa0539 MM |
129 | |
130 | --command-flags | -cf ) | |
131 | command_flags="$2" | |
132 | shift | |
133 | ;; | |
134 | ||
135 | --command | -c ) | |
136 | command="$2" | |
137 | shift | |
138 | ;; | |
31900458 MM |
139 | |
140 | --cvsup ) | |
141 | command_flags="no-chroot" | |
142 | command="cvs up" | |
143 | ;; | |
586a5f1f AG |
144 | |
145 | --help | -h ) | |
146 | usage | |
147 | ;; | |
1344b6f1 MM |
148 | |
149 | -* ) | |
a757e911 | 150 | die "unknown knob: $1" |
1344b6f1 | 151 | ;; |
c4aa0539 | 152 | |
1344b6f1 MM |
153 | *:* ) |
154 | specs="$specs $1" | |
155 | ;; | |
156 | ||
157 | * ) | |
158 | specs="$specs $1:HEAD" | |
159 | ;; | |
160 | esac | |
161 | shift | |
162 | done | |
163 | ||
878677a8 MM |
164 | specs=`for s in $specs ; do |
165 | case "$s" in | |
166 | *.spec:* ) echo "$s" ;; | |
167 | * ) echo "$s" | sed -e 's/:/.spec:/' ;; | |
168 | esac | |
169 | done` | |
1344b6f1 | 170 | |
2f470d17 MK |
171 | if [[ "$requester" != *@* ]] ; then |
172 | requester="$requester@pld-linux.org" | |
173 | fi | |
174 | ||
a757e911 MM |
175 | if [ "$builders" = "" ] ; then |
176 | builders="$default_builders" | |
177 | fi | |
178 | ||
544ca060 | 179 | if [ "$f_upgrade" = "yes" ] ; then |
a757e911 MM |
180 | flags="$flags upgrade" |
181 | fi | |
182 | ||
e936beda MM |
183 | if [ "$build_mode" = "test" ] ; then |
184 | if [ "$f_upgrade" = "yes" ] ; then | |
185 | die "--upgrade and --test-build are mutually exclusive" | |
186 | fi | |
187 | flags="$flags test-build" | |
188 | fi | |
189 | ||
280b1afd MM |
190 | ok= |
191 | for s in $specs ; do | |
192 | ok=1 | |
193 | done | |
194 | ||
195 | if [ "$ok" = "" ] ; then | |
c4aa0539 MM |
196 | if [ "$command" = "" ] ; then |
197 | die "no specs passed" | |
198 | fi | |
199 | else | |
200 | if [ "$command" != "" ] ; then | |
201 | die "cannot pass specs and --command" | |
202 | fi | |
280b1afd MM |
203 | fi |
204 | ||
1344b6f1 MM |
205 | id=$(uuidgen) |
206 | ||
207 | gen_req() { | |
a757e911 | 208 | echo "<group id='$id' no='0' flags='$flags'>" |
1344b6f1 MM |
209 | echo " <time>$(date +%s)</time>" |
210 | echo " <priority>$priority</priority>" | |
211 | echo | |
212 | ||
c4aa0539 MM |
213 | if [ "$command" != "" ] ; then |
214 | bid=$(uuidgen) | |
215 | echo " <batch id='$bid' depends-on=''>" | |
216 | echo " <command flags='$command_flags'>$command</command>" | |
217 | echo " <info></info>" | |
218 | for b in $builders ; do | |
219 | echo " <builder>$b</builder>" | |
220 | done | |
221 | echo " </batch>" | |
222 | else | |
223 | ||
30dbf6a3 MM |
224 | # first id: |
225 | fid= | |
1344b6f1 | 226 | for s in $specs ; do |
30dbf6a3 MM |
227 | bid=$(uuidgen) |
228 | echo " <batch id='$bid' depends-on='$fid'>" | |
229 | [ "$fid" = "" ] && fid="$bid" | |
1344b6f1 MM |
230 | name=$(echo "$s" | sed -e 's|:.*||') |
231 | branch=$(echo "$s" | sed -e 's|.*:||') | |
232 | echo " <spec>$name</spec>" | |
233 | echo " <branch>$branch</branch>" | |
864cdeb5 | 234 | echo " <info></info>" |
1344b6f1 MM |
235 | echo |
236 | for b in $with ; do | |
237 | echo " <with>$b</with>" | |
238 | done | |
239 | for b in $without ; do | |
240 | echo " <without>$b</without>" | |
241 | done | |
242 | echo | |
243 | for b in $builders ; do | |
244 | echo " <builder>$b</builder>" | |
245 | done | |
246 | echo " </batch>" | |
247 | done | |
c4aa0539 MM |
248 | |
249 | fi | |
30dbf6a3 | 250 | |
1344b6f1 MM |
251 | echo "</group>" |
252 | } | |
253 | ||
254 | gen_email () { | |
255 | cat <<EOF | |
2f470d17 | 256 | From: $requester |
1344b6f1 MM |
257 | To: $builder_email |
258 | Subject: build request | |
259 | Message-Id: <$id@$(hostname)> | |
260 | X-New-PLD-Builder: request | |
2d28916b | 261 | X-Requester-Version: \$Id$ |
1344b6f1 MM |
262 | |
263 | $(gen_req | gpg --clearsign --default-key $default_key) | |
264 | EOF | |
265 | } | |
266 | ||
8454c165 | 267 | gen_email | $mailer |