]>
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 |
2f470d17 | 23 | requester=deviloper@pld-linux.org |
544ca060 MM |
24 | default_key=deviloper@pld-linux.org |
25 | builder_email=builder-ac@pld-linux.org | |
1344b6f1 | 26 | mailer="/usr/sbin/sendmail -t" |
544ca060 | 27 | default_builders="ac-*" |
1344b6f1 | 28 | |
a757e911 MM |
29 | # defaults: |
30 | build_mode=ready | |
31 | f_upgrade=yes | |
32 | ||
544ca060 MM |
33 | EOF |
34 | exit | |
35 | fi | |
36 | ||
a757e911 MM |
37 | die () { |
38 | echo "$0: $*" 1>&2 | |
39 | exit 1 | |
40 | } | |
1344b6f1 MM |
41 | |
42 | while [ $# -gt 0 ] ; do | |
43 | case "$1" in | |
a757e911 | 44 | --builder | -b ) |
1344b6f1 MM |
45 | builders="$builders $2" |
46 | shift | |
47 | ;; | |
c4aa0539 | 48 | |
1344b6f1 MM |
49 | --with ) |
50 | with="$with $2" | |
51 | shift | |
52 | ;; | |
53 | ||
54 | --without ) | |
55 | without="$without $2" | |
56 | shift | |
57 | ;; | |
a757e911 MM |
58 | |
59 | --test-build | -t ) | |
60 | build_mode=test | |
544ca060 | 61 | f_upgrade=no |
a757e911 MM |
62 | ;; |
63 | ||
64 | --ready-build | -r ) | |
65 | build_mode=ready | |
66 | ;; | |
67 | ||
68 | --upgrade | -u ) | |
69 | f_upgrade=yes | |
70 | ;; | |
71 | ||
72 | --no-upgrade | -n ) | |
544ca060 | 73 | f_upgrade=no |
a757e911 MM |
74 | ;; |
75 | ||
5d25d4e4 MM |
76 | --no-install-br | -ni ) |
77 | flags="$flags no-install-br" | |
78 | ;; | |
79 | ||
a757e911 MM |
80 | --flag | -f ) |
81 | flags="$flags $2" | |
82 | shift | |
83 | ;; | |
c4aa0539 MM |
84 | |
85 | --command-flags | -cf ) | |
86 | command_flags="$2" | |
87 | shift | |
88 | ;; | |
89 | ||
90 | --command | -c ) | |
91 | command="$2" | |
92 | shift | |
93 | ;; | |
31900458 MM |
94 | |
95 | --cvsup ) | |
96 | command_flags="no-chroot" | |
97 | command="cvs up" | |
98 | ;; | |
1344b6f1 MM |
99 | |
100 | -* ) | |
a757e911 | 101 | die "unknown knob: $1" |
1344b6f1 | 102 | ;; |
c4aa0539 | 103 | |
1344b6f1 MM |
104 | *:* ) |
105 | specs="$specs $1" | |
106 | ;; | |
107 | ||
108 | * ) | |
109 | specs="$specs $1:HEAD" | |
110 | ;; | |
111 | esac | |
112 | shift | |
113 | done | |
114 | ||
878677a8 MM |
115 | specs=`for s in $specs ; do |
116 | case "$s" in | |
117 | *.spec:* ) echo "$s" ;; | |
118 | * ) echo "$s" | sed -e 's/:/.spec:/' ;; | |
119 | esac | |
120 | done` | |
1344b6f1 | 121 | |
2f470d17 MK |
122 | if [[ "$requester" != *@* ]] ; then |
123 | requester="$requester@pld-linux.org" | |
124 | fi | |
125 | ||
a757e911 MM |
126 | if [ "$builders" = "" ] ; then |
127 | builders="$default_builders" | |
128 | fi | |
129 | ||
544ca060 | 130 | if [ "$f_upgrade" = "yes" ] ; then |
a757e911 MM |
131 | flags="$flags upgrade" |
132 | fi | |
133 | ||
134 | if [ "$build_mode" = "test" ] ; then | |
544ca060 | 135 | if [ "$f_upgrade" = "yes" ] ; then |
a757e911 MM |
136 | die "--upgrade and --test-build are mutually exclusive" |
137 | fi | |
138 | flags="$flags test-build" | |
1344b6f1 MM |
139 | fi |
140 | ||
280b1afd MM |
141 | ok= |
142 | for s in $specs ; do | |
143 | ok=1 | |
144 | done | |
145 | ||
146 | if [ "$ok" = "" ] ; then | |
c4aa0539 MM |
147 | if [ "$command" = "" ] ; then |
148 | die "no specs passed" | |
149 | fi | |
150 | else | |
151 | if [ "$command" != "" ] ; then | |
152 | die "cannot pass specs and --command" | |
153 | fi | |
280b1afd MM |
154 | fi |
155 | ||
1344b6f1 MM |
156 | id=$(uuidgen) |
157 | ||
158 | gen_req() { | |
a757e911 | 159 | echo "<group id='$id' no='0' flags='$flags'>" |
1344b6f1 MM |
160 | echo " <time>$(date +%s)</time>" |
161 | echo " <priority>$priority</priority>" | |
162 | echo | |
163 | ||
c4aa0539 MM |
164 | if [ "$command" != "" ] ; then |
165 | bid=$(uuidgen) | |
166 | echo " <batch id='$bid' depends-on=''>" | |
167 | echo " <command flags='$command_flags'>$command</command>" | |
168 | echo " <info></info>" | |
169 | for b in $builders ; do | |
170 | echo " <builder>$b</builder>" | |
171 | done | |
172 | echo " </batch>" | |
173 | else | |
174 | ||
30dbf6a3 MM |
175 | # first id: |
176 | fid= | |
1344b6f1 | 177 | for s in $specs ; do |
30dbf6a3 MM |
178 | bid=$(uuidgen) |
179 | echo " <batch id='$bid' depends-on='$fid'>" | |
180 | [ "$fid" = "" ] && fid="$bid" | |
1344b6f1 MM |
181 | name=$(echo "$s" | sed -e 's|:.*||') |
182 | branch=$(echo "$s" | sed -e 's|.*:||') | |
183 | echo " <spec>$name</spec>" | |
184 | echo " <branch>$branch</branch>" | |
864cdeb5 | 185 | echo " <info></info>" |
1344b6f1 MM |
186 | echo |
187 | for b in $with ; do | |
188 | echo " <with>$b</with>" | |
189 | done | |
190 | for b in $without ; do | |
191 | echo " <without>$b</without>" | |
192 | done | |
193 | echo | |
194 | for b in $builders ; do | |
195 | echo " <builder>$b</builder>" | |
196 | done | |
197 | echo " </batch>" | |
198 | done | |
c4aa0539 MM |
199 | |
200 | fi | |
30dbf6a3 | 201 | |
1344b6f1 MM |
202 | echo "</group>" |
203 | } | |
204 | ||
205 | gen_email () { | |
206 | cat <<EOF | |
2f470d17 | 207 | From: $requester |
1344b6f1 MM |
208 | To: $builder_email |
209 | Subject: build request | |
210 | Message-Id: <$id@$(hostname)> | |
211 | X-New-PLD-Builder: request | |
212 | X-Requester-Version: $Id$ | |
213 | ||
214 | $(gen_req | gpg --clearsign --default-key $default_key) | |
215 | EOF | |
216 | } | |
217 | ||
8454c165 | 218 | gen_email | $mailer |