]>
Commit | Line | Data |
---|---|---|
4ce0f57a TC |
1 | #!/bin/bash |
2 | ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- | |
3 | ##### Author: Travis Cross <tc@traviscross.com> | |
4 | ||
495dd7e5 TC |
5 | set -e |
6 | ||
38379a5f TC |
7 | ddir="." |
8 | [ -n "${0%/*}" ] && ddir="${0%/*}" | |
0bab77bf TC |
9 | cd $ddir/../ |
10 | ||
11 | #### lib | |
6c754892 | 12 | |
6e01f317 TC |
13 | err () { |
14 | echo "$0 error: $1" >&2 | |
15 | exit 1 | |
16 | } | |
17 | ||
15a67097 TC |
18 | announce () { |
19 | cat >&2 <<EOF | |
20 | ||
21 | ######################################################################## | |
22 | ## $1 | |
23 | ######################################################################## | |
24 | ||
25 | EOF | |
26 | } | |
27 | ||
6e01f317 TC |
28 | xread () { |
29 | local xIFS="$IFS" | |
30 | IFS='' | |
31 | read $@ | |
32 | local ret=$? | |
33 | IFS="$xIFS" | |
34 | return $ret | |
35 | } | |
36 | ||
0bab77bf TC |
37 | mk_dver () { echo "$1" | sed -e 's/-/~/g'; } |
38 | mk_uver () { echo "$1" | sed -e 's/-.*$//' -e 's/~/-/'; } | |
39 | dsc_source () { dpkg-parsechangelog | grep '^Source:' | awk '{print $2}'; } | |
40 | dsc_ver () { dpkg-parsechangelog | grep '^Version:' | awk '{print $2}'; } | |
41 | up_ver () { mk_uver "$(dsc_ver)"; } | |
42 | dsc_base () { echo "$(dsc_source)_$(dsc_ver)"; } | |
43 | up_base () { echo "$(dsc_source)-$(up_ver)"; } | |
44 | ||
45 | find_distro () { | |
46 | case "$1" in | |
47 | experimental) echo "sid";; | |
48 | unstable) echo "sid";; | |
94b1dfab WK |
49 | testing) echo "stretch";; |
50 | stable) echo "jessie";; | |
51 | oldstable) echo "wheezy";; | |
0bab77bf TC |
52 | *) echo "$1";; |
53 | esac | |
54 | } | |
55 | ||
56 | find_suite () { | |
57 | case "$1" in | |
58 | sid) echo "unstable";; | |
94b1dfab WK |
59 | stretch) echo "testing";; |
60 | jessie) echo "stable";; | |
61 | wheezy) echo "oldstable";; | |
0bab77bf TC |
62 | *) echo "$1";; |
63 | esac | |
64 | } | |
65 | ||
66 | #### debian/rules helpers | |
67 | ||
4ce0f57a | 68 | create_dbg_pkgs () { |
6c754892 | 69 | for x in $ddir/*; do |
4ce0f57a TC |
70 | test ! -d $x && continue |
71 | test "$x" = "tmp" -o "$x" = "source" && continue | |
72 | test ! "$x" = "${x%-dbg}" && continue | |
73 | test ! -d $x/usr/lib/debug && continue | |
74 | mkdir -p $x-dbg/usr/lib | |
75 | mv $x/usr/lib/debug $x-dbg/usr/lib/ | |
76 | done | |
77 | } | |
78 | ||
18de2447 TC |
79 | cwget () { |
80 | local url="$1" f="${1##*/}" | |
81 | echo "fetching: $url to $f" >&2 | |
82 | if [ -n "$FS_FILES_DIR" ]; then | |
83 | if ! [ -s "$FS_FILES_DIR/$f" ]; then | |
84 | (cd $FS_FILES_DIR && wget -N "$url") | |
85 | fi | |
86 | cp -a $FS_FILES_DIR/$f . | |
87 | else | |
88 | wget -N "$url" | |
89 | fi | |
90 | } | |
91 | ||
92 | getlib () { | |
0bab77bf TC |
93 | local url="$1" f="${1##*/}" |
94 | cwget "$url" | |
95 | tar -xv --no-same-owner --no-same-permissions -f "$f" | |
96 | rm -f "$f" && mkdir -p $f && touch $f/.download-stamp | |
18de2447 TC |
97 | } |
98 | ||
18de2447 | 99 | getlibs () { |
18de2447 | 100 | # get pinned libraries |
57325714 BW |
101 | getlib http://files.freeswitch.org/downloads/libs/sphinxbase-0.8.tar.gz |
102 | getlib http://files.freeswitch.org/downloads/libs/pocketsphinx-0.8.tar.gz | |
0bab77bf | 103 | getlib http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz |
0bab77bf TC |
104 | getlib http://download.zeromq.org/zeromq-2.1.9.tar.gz \ |
105 | || getlib http://download.zeromq.org/historic/zeromq-2.1.9.tar.gz | |
106 | getlib http://files.freeswitch.org/downloads/libs/freeradius-client-1.1.6.tar.gz | |
b7623326 | 107 | getlib http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2 |
18de2447 TC |
108 | } |
109 | ||
0bab77bf TC |
110 | check_repo_clean () { |
111 | git diff-index --quiet --cached HEAD \ | |
112 | || err "uncommitted changes present" | |
113 | git diff-files --quiet \ | |
114 | || err "unclean working tree" | |
115 | git diff-index --quiet HEAD \ | |
116 | || err "unclean repository" | |
117 | ! git ls-files --other --error-unmatch . >/dev/null 2>&1 \ | |
118 | || err "untracked files or build products present" | |
18de2447 TC |
119 | } |
120 | ||
b1682194 | 121 | get_last_release_ver () { |
83125dad | 122 | grep -m1 -e '^AC_INIT' configure.ac \ |
b1682194 TC |
123 | | cut -d, -f2 \ |
124 | | sed -e 's/\[//' -e 's/\]//' -e 's/ //g' | |
125 | } | |
126 | ||
127 | get_nightly_version () { | |
128 | local commit="$(git rev-list -n1 --abbrev=10 --abbrev-commit HEAD)" | |
5fd7643a | 129 | echo "$(get_last_release_ver)+git~$(date -u '+%Y%m%dT%H%M%SZ')~$commit" |
b1682194 TC |
130 | } |
131 | ||
53c24a93 TC |
132 | get_nightly_revision_human () { |
133 | echo "git $(git rev-list -n1 --abbrev=7 --abbrev-commit HEAD) $(date -u '+%Y-%m-%d %H:%M:%SZ')" | |
134 | } | |
135 | ||
8d366f7f | 136 | create_orig () { |
d3cb7036 | 137 | { |
a5d696d5 | 138 | set -e |
d3cb7036 | 139 | local OPTIND OPTARG |
9b33b053 | 140 | local uver="" hrev="" bundle_deps=true modules_list="" zl=9e |
0a50536a | 141 | while getopts 'bm:nv:z:' o "$@"; do |
d3cb7036 | 142 | case "$o" in |
0a50536a | 143 | m) modules_list="$OPTARG";; |
d3cb7036 TC |
144 | n) uver="nightly";; |
145 | v) uver="$OPTARG";; | |
146 | z) zl="$OPTARG";; | |
147 | esac | |
148 | done | |
149 | shift $(($OPTIND-1)) | |
53c24a93 TC |
150 | if [ -z "$uver" ] || [ "$uver" = "nightly" ]; then |
151 | uver="$(get_nightly_version)" | |
152 | hrev="$(get_nightly_revision_human)" | |
153 | fi | |
d3cb7036 TC |
154 | local treeish="$1" dver="$(mk_dver "$uver")" |
155 | local orig="../freeswitch_$dver.orig.tar.xz" | |
156 | [ -n "$treeish" ] || treeish="HEAD" | |
157 | check_repo_clean | |
158 | git reset --hard "$treeish" | |
159 | mv .gitattributes .gitattributes.orig | |
0a50536a TC |
160 | local -a args=(-e '\bdebian-ignore\b') |
161 | test "$modules_list" = "non-dfsg" || args+=(-e '\bdfsg-nonfree\b') | |
162 | grep .gitattributes.orig "${args[@]}" \ | |
d3cb7036 TC |
163 | | while xread l; do |
164 | echo "$l export-ignore" >> .gitattributes | |
165 | done | |
166 | if $bundle_deps; then | |
167 | (cd libs && getlibs) | |
168 | git add -f libs | |
169 | fi | |
83125dad | 170 | ./build/set-fs-version.sh "$uver" "$hrev" && git add configure.ac |
d18a7ffa | 171 | echo "$uver" > .version && git add -f .version |
d3cb7036 TC |
172 | git commit --allow-empty -m "nightly v$uver" |
173 | git archive -v \ | |
174 | --worktree-attributes \ | |
175 | --format=tar \ | |
176 | --prefix=freeswitch-$uver/ \ | |
177 | HEAD \ | |
178 | | xz -c -${zl}v > $orig | |
179 | mv .gitattributes.orig .gitattributes | |
180 | git reset --hard HEAD^ && git clean -fdx | |
181 | } 1>&2 | |
0bab77bf | 182 | echo $orig |
8d366f7f TC |
183 | } |
184 | ||
2365f41f TC |
185 | set_modules_quicktest () { |
186 | cat > debian/modules.conf <<EOF | |
187 | applications/mod_commands | |
188 | EOF | |
189 | } | |
190 | ||
8d366f7f | 191 | create_dsc () { |
d3cb7036 | 192 | { |
a5d696d5 | 193 | set -e |
e364450a | 194 | local OPTIND OPTARG modules_conf="" modules_list="" speed="normal" suite_postfix="" suite_postfix_p=false zl=9 |
63734bcd TC |
195 | local modules_add="" |
196 | while getopts 'f:m:p:s:u:z:' o "$@"; do | |
2365f41f | 197 | case "$o" in |
f840eecd | 198 | f) modules_conf="$OPTARG";; |
2365f41f | 199 | m) modules_list="$OPTARG";; |
63734bcd | 200 | p) modules_add="$modules_add $OPTARG";; |
25287f38 | 201 | s) speed="$OPTARG";; |
e364450a | 202 | u) suite_postfix="$OPTARG"; suite_postfix_p=true; ;; |
c8df04fc | 203 | z) zl="$OPTARG";; |
2365f41f TC |
204 | esac |
205 | done | |
206 | shift $(($OPTIND-1)) | |
d3cb7036 TC |
207 | local distro="$(find_distro $1)" orig="$2" |
208 | local suite="$(find_suite $distro)" | |
209 | local orig_ver="$(echo "$orig" | sed -e 's/^.*_//' -e 's/\.orig\.tar.*$//')" | |
210 | local dver="${orig_ver}-1~${distro}+1" | |
e364450a | 211 | $suite_postfix_p && { suite="${distro}${suite_postfix}"; } |
d3cb7036 TC |
212 | [ -x "$(which dch)" ] \ |
213 | || err "package devscripts isn't installed" | |
f840eecd TC |
214 | if [ -n "$modules_conf" ]; then |
215 | cp $modules_conf debian/modules.conf | |
216 | fi | |
0a50536a | 217 | local bootstrap_args="" |
2365f41f | 218 | if [ -n "$modules_list" ]; then |
0a50536a TC |
219 | if [ "$modules_list" = "non-dfsg" ]; then |
220 | bootstrap_args="-mnon-dfsg" | |
221 | else set_modules_${modules_list}; fi | |
2365f41f | 222 | fi |
63734bcd TC |
223 | if test -n "$modules_add"; then |
224 | for x in $modules_add; do | |
225 | bootstrap_args="$bootstrap_args -p${x}" | |
226 | done | |
227 | fi | |
0a50536a | 228 | (cd debian && ./bootstrap.sh -c $distro $bootstrap_args) |
25287f38 TC |
229 | case "$speed" in |
230 | paranoid) sed -i ./debian/rules \ | |
231 | -e '/\.stamp-bootstrap:/{:l2 n; /\.\/bootstrap.sh -j/{s/ -j//; :l3 n; b l3}; b l2};' ;; | |
232 | reckless) sed -i ./debian/rules \ | |
233 | -e '/\.stamp-build:/{:l2 n; /make/{s/$/ -j/; :l3 n; b l3}; b l2};' ;; | |
234 | esac | |
c8df04fc | 235 | [ "$zl" -ge "1" ] || zl=1 |
25287f38 | 236 | git add debian/rules |
d3cb7036 TC |
237 | dch -b -m -v "$dver" --force-distribution -D "$suite" "Nightly build." |
238 | git add debian/changelog && git commit -m "nightly v$orig_ver" | |
c8df04fc | 239 | dpkg-source -i.* -Zxz -z${zl} -b . |
d3cb7036 TC |
240 | dpkg-genchanges -S > ../$(dsc_base)_source.changes |
241 | local dsc="../$(dsc_base).dsc" | |
242 | git reset --hard HEAD^ && git clean -fdx | |
243 | } 1>&2 | |
0bab77bf | 244 | echo $dsc |
8d366f7f TC |
245 | } |
246 | ||
8fb3f54c TC |
247 | fmt_debug_hook () { |
248 | cat <<'EOF' | |
249 | #!/bin/bash | |
250 | export debian_chroot="cow" | |
251 | cd /tmp/buildd/*/debian/.. | |
252 | /bin/bash < /dev/tty > /dev/tty 2> /dev/tty | |
253 | EOF | |
254 | } | |
255 | ||
a8b68a14 TC |
256 | get_sources () { |
257 | local tgt_distro="$1" | |
258 | while read type path distro components; do | |
259 | test "$type" = deb || continue | |
8e058ade WK |
260 | prefix=`echo $distro | awk -F/ '{print $1}'` |
261 | suffix="`echo $distro | awk -F/ '{print $2}'`" | |
262 | if test -n "$suffix" ; then full="$tgt_distro/$suffix" ; else full="$tgt_distro" ; fi | |
263 | printf "$type $path $full $components\n" | |
4738da13 | 264 | done < "$2" |
a8b68a14 TC |
265 | } |
266 | ||
267 | get_mirrors () { | |
4738da13 WK |
268 | file=${2-/etc/apt/sources.list} |
269 | announce "Using apt sources file: $file" | |
270 | get_sources "$1" "$file" | tr '\n' '|' | head -c-1; echo | |
a8b68a14 TC |
271 | } |
272 | ||
0bab77bf | 273 | build_debs () { |
d3cb7036 | 274 | { |
a5d696d5 | 275 | set -e |
cf68dc73 | 276 | local OPTIND OPTARG debug_hook=false hookdir="" cow_build_opts="" |
967245bf WK |
277 | local keep_pbuilder_config=false keyring="" custom_keyring="/tmp/fs.asc" |
278 | local use_custom_sources=true | |
279 | local custom_sources_file="/tmp/fs.sources.list" | |
4738da13 | 280 | while getopts 'BbdK:kT:t' o "$@"; do |
d3cb7036 | 281 | case "$o" in |
cf68dc73 | 282 | B) cow_build_opts="--debbuildopts '-B'";; |
ed9ff6e3 | 283 | b) cow_build_opts="--debbuildopts '-b'";; |
d3cb7036 | 284 | d) debug_hook=true;; |
33b4eef5 | 285 | k) keep_pbuilder_config=true;; |
4738da13 | 286 | K) custom_keyring="$OPTARG";; |
967245bf WK |
287 | t) custom_sources_file="/etc/apt/sources.list";; |
288 | T) custom_sources_file="$OPTARG";; | |
d3cb7036 TC |
289 | esac |
290 | done | |
291 | shift $(($OPTIND-1)) | |
967245bf WK |
292 | if [ "$custom_sources_file" == "" ]; then |
293 | # Caller has explicitly set the custom sources file to empty string. They must intend to not use additional mirrors. | |
294 | use_custom_sources=false | |
295 | fi | |
7ac881fb | 296 | if [[ "$custom_source_file" == "/tmp/fs.sources.list" && ! -e "/tmp/fs.sources.list" ]]; then |
967245bf WK |
297 | echo "deb http://files.freeswitch.org/repo/deb/debian/ jessie main" >> "/tmp/fs.sources.list" |
298 | fi | |
7ac881fb | 299 | if [[ "$custom_keyring" == "/tmp/fs.asc" && ! -r "/tmp/fs.asc" ]]; then |
967245bf WK |
300 | cat << EOF > "/tmp/fs.asc" |
301 | -----BEGIN PGP PUBLIC KEY BLOCK----- | |
302 | Version: GnuPG v1.4.12 (GNU/Linux) | |
303 | ||
304 | mQGiBE8jEfIRBAC+Cca0fPQxhyhn0NMsPaMQJgTvqhWb5/f4Mel++kosmUQQ4fJq | |
305 | 4U9NFvpfNyLp5MoHpnlDfAb+e57B2sr47NOJLTh83yQIAnvU+8O0Q4kvMaiiesX5 | |
306 | CisApLBs6Vx28y7VWmLsY3vWu8mC7M+PORKfpBV8DWy/7569wQPx2SCsIwCgzv2T | |
307 | 8YsnYsSVRrrmh46J1o4/ngsD/13ETX4ws/wNN+82RdqUxu7fjc0fNbUAb6XYddAb | |
308 | 1hrw5npQulgUNWkpnVmIDRHDXLNMeT8nZDkxsA8AsT+u7ACfPFa2o3R8w9zOPSO+ | |
309 | oSO0+Puhop2+z1gm6lmfMKq9HpeXG3yt/8zsEVUmOYT9m+vYEVghfpXtACVYheDq | |
310 | LzUuA/9E9HBiNPVhJ/mEpOk9bZ1gpwr3mjlpUbvX5aGwTJJ+YoTfZOCL7go3uQHn | |
311 | /sT35WoJ23wJCRlW0SYTFJqCoris9AhI+qw7xRTw9wb+txSI96uhafUUMCn6GLkN | |
312 | +yAixqDwNHKkdax3GSGJtLB0t67QoBDIpcGog7ZfRMvWP3QLNLQ4RnJlZVNXSVRD | |
313 | SCBQYWNrYWdlIFNpZ25pbmcgS2V5IDxwYWNrYWdlc0BmcmVlc3dpdGNoLm9yZz6I | |
314 | YgQTEQIAIgUCTyMR8gIbAwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQ127c | |
315 | dyXgEM879ACffY0HFi+mACtfFYmX/Uk/qGELSP4An1B8D5L4dLFFr1zV9YawQUbz | |
316 | O9/MuQENBE8jEfIQBAC7vnn855YDuz1gTsUMYDxfIRH5KPmDDEAf1WXoD3QG4qOQ | |
317 | xVW5nhp/bolh2CacAxdOjZePdhGkkdNOBpcu9NlTNRru0myGN8etbnzP3O5dq0io | |
318 | VMf23C5u9KPbxwRWS+WFtC4CRFn6DafDI1qa3Gv3CkiBWtKR0Wid2SQLzl3mVwAF | |
319 | EQP9HlwGjhBfFA26LlSMPhSo0Ll+sdcOJupJ21zmGeg7c0GpBnzDzyyJg04gbahs | |
320 | xWtW3Y/+B4LGM97o6lnu0OQI7MX5gY1G4Jgu6pgYv8tQd5XyU/CAJUA5VWTxUMIi | |
321 | JP6qlzm1bz4AAPmGw4mkS1u4N+vai21Zl4iyFIQFeiuU/K2ISQQYEQIACQUCTyMR | |
322 | 8gIbDAAKCRDXbtx3JeAQzxReAJ4uvms1n7xV3CcJPQlM7ndX5MZU3QCgxp8zubcL | |
323 | /SsMvw7XApSHFs5ooYc= | |
324 | =Xc8P | |
325 | -----END PGP PUBLIC KEY BLOCK----- | |
326 | EOF | |
327 | fi | |
328 | ||
d3cb7036 TC |
329 | local distro="$(find_distro $1)" dsc="$2" arch="$3" |
330 | if [ -z "$distro" ] || [ "$distro" = "auto" ]; then | |
331 | if ! (echo "$dsc" | grep -e '-[0-9]*~[a-z]*+[0-9]*'); then | |
332 | err "no distro specified or found" | |
333 | fi | |
334 | local x="$(echo $dsc | sed -e 's/^[^-]*-[0-9]*~//' -e 's/+[^+]*$//')" | |
335 | distro="$(find_distro $x)" | |
0bab77bf | 336 | fi |
d3cb7036 TC |
337 | [ -n "$arch" ] || arch="$(dpkg-architecture | grep '^DEB_BUILD_ARCH=' | cut -d'=' -f2)" |
338 | [ -x "$(which cowbuilder)" ] \ | |
339 | || err "package cowbuilder isn't installed" | |
340 | local cow_img=/var/cache/pbuilder/base-$distro-$arch.cow | |
4738da13 WK |
341 | if [ -e "$custom_keyring" ]; then |
342 | keyring="$custom_keyring" | |
343 | else | |
344 | keyring="$(mktemp /tmp/keyringXXXXXXXX.asc)" | |
345 | apt-key exportall > "$keyring" | |
346 | fi | |
d3cb7036 | 347 | cow () { |
e78c4405 | 348 | if ! $use_custom_sources; then |
019b1ae3 | 349 | echo "Using system sources $keyring $distro $custom_sources_file" |
a8b68a14 TC |
350 | cowbuilder "$@" \ |
351 | --distribution $distro \ | |
352 | --architecture $arch \ | |
353 | --basepath $cow_img | |
354 | else | |
019b1ae3 | 355 | echo "Using custom sources $keyring $distro $custom_sources_file" |
a8b68a14 TC |
356 | cowbuilder "$@" \ |
357 | --distribution $distro \ | |
358 | --architecture $arch \ | |
359 | --basepath $cow_img \ | |
360 | --keyring "$keyring" \ | |
4738da13 | 361 | --othermirror "$(get_mirrors $distro $custom_sources_file)" |
a8b68a14 | 362 | fi |
d3cb7036 TC |
363 | } |
364 | if ! [ -d $cow_img ]; then | |
365 | announce "Creating base $distro-$arch image..." | |
afb4a200 | 366 | local x=30 |
8a4a8f6f | 367 | while ! cow --create; do |
afb4a200 | 368 | [ $x -lt 1 ] && break; sleep 120; x=$((x-1)) |
8a4a8f6f | 369 | done |
d3cb7036 TC |
370 | fi |
371 | announce "Updating base $distro-$arch image..." | |
afb4a200 | 372 | local x=30 |
33b4eef5 TC |
373 | local opts="--override-config" |
374 | $keep_pbuilder_config && opts="" | |
375 | while ! cow --update $opts; do | |
afb4a200 | 376 | [ $x -lt 1 ] && break; sleep 120; x=$((x-1)) |
9b79922a | 377 | done |
d3cb7036 TC |
378 | announce "Building $distro-$arch DEBs from $dsc..." |
379 | if $debug_hook; then | |
380 | mkdir -p .hooks | |
381 | fmt_debug_hook > .hooks/C10shell | |
382 | chmod +x .hooks/C10shell | |
383 | hookdir=$(pwd)/.hooks | |
384 | fi | |
b4816ae9 TC |
385 | cow --build $dsc \ |
386 | --hookdir "$hookdir" \ | |
992e0566 TC |
387 | --buildresult ../ \ |
388 | $cow_build_opts | |
95a94175 WK |
389 | if [ ! -e "$custom_keyring" ]; then |
390 | # Cleanup script created temporary file | |
391 | rm -f $keyring | |
392 | fi | |
d3cb7036 | 393 | } 1>&2 |
337c9d43 | 394 | echo ${dsc%.dsc}_${arch}.changes |
15a67097 TC |
395 | } |
396 | ||
505cd294 TC |
397 | default_distros () { |
398 | local host_distro="Debian" | |
399 | test -z "$(which lsb_release)" || host_distro="$(lsb_release -is)" | |
400 | case "$host_distro" in | |
401 | Debian) echo "sid jessie wheezy" ;; | |
402 | Ubuntu) echo "utopic trusty" ;; | |
430433a6 | 403 | *) err "Unknown host distribution \"$host_distro\"" ;; |
505cd294 TC |
404 | esac |
405 | } | |
406 | ||
496b9a9c TC |
407 | build_all () { |
408 | local OPTIND OPTARG | |
671fc3bc | 409 | local orig_opts="" dsc_opts="" deb_opts="" modlist="" |
383b77a1 | 410 | local archs="" distros="" orig="" depinst=false par=false |
67ed8f42 | 411 | while getopts 'a:bc:df:ijkK:l:m:no:p:s:tT:u:v:z:' o "$@"; do |
496b9a9c TC |
412 | case "$o" in |
413 | a) archs="$archs $OPTARG";; | |
414 | b) orig_opts="$orig_opts -b";; | |
415 | c) distros="$distros $OPTARG";; | |
416 | d) deb_opts="$deb_opts -d";; | |
f840eecd | 417 | f) dsc_opts="$dsc_opts -f$OPTARG";; |
383b77a1 | 418 | i) depinst=true;; |
6679e3f5 | 419 | j) par=true;; |
33b4eef5 | 420 | k) deb_opts="$deb_opts -k";; |
67ed8f42 | 421 | K) deb_opts="$deb_opts -K$OPTARG";; |
671fc3bc | 422 | l) modlist="$OPTARG";; |
0a50536a | 423 | m) orig_opts="$orig_opts -m$OPTARG"; dsc_opts="$dsc_opts -m$OPTARG";; |
e38f0a1b | 424 | n) orig_opts="$orig_opts -n";; |
f79a37a3 | 425 | o) orig="$OPTARG";; |
63734bcd | 426 | p) dsc_opts="$dsc_opts -p$OPTARG";; |
25287f38 | 427 | s) dsc_opts="$dsc_opts -s$OPTARG";; |
a8b68a14 | 428 | t) deb_opts="$deb_opts -t";; |
67ed8f42 | 429 | T) deb_opts="$deb_opts -T$OPTARG";; |
e364450a | 430 | u) dsc_opts="$dsc_opts -u$OPTARG";; |
496b9a9c | 431 | v) orig_opts="$orig_opts -v$OPTARG";; |
c8df04fc | 432 | z) orig_opts="$orig_opts -z$OPTARG"; dsc_opts="$dsc_opts -z$OPTARG";; |
496b9a9c TC |
433 | esac |
434 | done | |
435 | shift $(($OPTIND-1)) | |
436 | [ -n "$archs" ] || archs="amd64 i386" | |
505cd294 | 437 | [ -n "$distros" ] || distros="$(default_distros)" |
383b77a1 TC |
438 | ! $depinst || aptitude install -y \ |
439 | rsync git less cowbuilder ccache \ | |
440 | devscripts equivs build-essential | |
f79a37a3 | 441 | [ -n "$orig" ] || orig="$(create_orig $orig_opts HEAD | tail -n1)" |
671fc3bc TC |
442 | if [ -n "$modlist" ]; then |
443 | local modtmp="$(mktemp /tmp/modules-XXXXXXXXXX.conf)" | |
444 | > $modtmp | |
445 | for m in "$modlist"; do printf '%s\n' "$m" >> $modtmp; done | |
446 | dsc_opts="$dsc_opts -f${modtmp}"; fi | |
447 | [ -n "$orig" ] || orig="$(create_orig $orig_opts HEAD | tail -n1)" | |
6679e3f5 TC |
448 | mkdir -p ../log |
449 | > ../log/changes | |
450 | echo; echo; echo; echo | |
73b34cb3 | 451 | trap 'echo "Killing children...">&2; for x in $(jobs -p); do kill $x; done' EXIT |
496b9a9c | 452 | if [ "${orig:0:2}" = ".." ]; then |
9a0032e9 | 453 | echo "true" > ../log/builds-ok |
496b9a9c | 454 | for distro in $distros; do |
6679e3f5 TC |
455 | echo "Creating $distro dsc..." >&2 |
456 | local dsc="$(create_dsc $dsc_opts $distro $orig 2>../log/$distro | tail -n1)" | |
457 | echo "Done creating $distro dsc." >&2 | |
496b9a9c | 458 | if [ "${dsc:0:2}" = ".." ]; then |
ed9ff6e3 | 459 | local lopts="-b" |
496b9a9c | 460 | for arch in $archs; do |
6679e3f5 TC |
461 | { |
462 | echo "Building $distro-$arch debs..." >&2 | |
cf68dc73 | 463 | local changes="$(build_debs $lopts $deb_opts $distro $dsc $arch 2>../log/$distro-$arch | tail -n1)" |
6679e3f5 TC |
464 | echo "Done building $distro-$arch debs." >&2 |
465 | if [ "${changes:0:2}" = ".." ]; then | |
466 | echo "$changes" >> ../log/changes | |
9a0032e9 TC |
467 | else |
468 | echo "false" > ../log/builds-ok | |
6679e3f5 TC |
469 | fi |
470 | } & | |
471 | $par || wait | |
c15613e0 | 472 | lopts="-B" |
496b9a9c TC |
473 | done |
474 | fi | |
475 | done | |
6679e3f5 | 476 | ! $par || wait |
496b9a9c | 477 | fi |
671fc3bc | 478 | [ -z "$modlist" ] || rm -f $modtmp |
73b34cb3 | 479 | trap - EXIT |
6679e3f5 | 480 | cat ../log/changes |
9a0032e9 | 481 | test "$(cat ../log/builds-ok)" = true || exit 1 |
496b9a9c TC |
482 | } |
483 | ||
f3c2180c TC |
484 | usage () { |
485 | cat >&2 <<EOF | |
486 | $0 [opts] [cmd] [cmd-opts] | |
487 | ||
488 | options: | |
489 | ||
490 | -d Enable debugging mode. | |
491 | ||
492 | commands: | |
493 | ||
494 | archive-orig | |
495 | ||
496 | build-all | |
497 | ||
860d2aca TC |
498 | [ This must be run as root! ] |
499 | ||
f3c2180c | 500 | -a Specify architectures |
f3c2180c TC |
501 | -c Specify distributions |
502 | -d Enable cowbuilder debug hook | |
f840eecd TC |
503 | -f <modules.conf> |
504 | Build only modules listed in this file | |
383b77a1 | 505 | -i Auto install build deps on host system |
f3c2180c | 506 | -j Build debs in parallel |
33b4eef5 | 507 | -k Don't override pbuilder image configurations |
4738da13 | 508 | -K [/path/to/keyring.asc] |
9cff1eb7 | 509 | Use custom keyring file for sources.list in build environment |
4738da13 | 510 | in the format of: apt-key exportall > /path/to/file.asc |
671fc3bc | 511 | -l <modules> |
0a50536a | 512 | -m [ quicktest | non-dfsg ] |
f3c2180c | 513 | Choose custom list of modules to build |
e38f0a1b | 514 | -n Nightly build |
f79a37a3 TC |
515 | -o <orig-file> |
516 | Specify existing .orig.tar.xz file | |
63734bcd TC |
517 | -p <module> |
518 | Include otherwise avoided module | |
f3c2180c TC |
519 | -s [ paranoid | reckless ] |
520 | Set FS bootstrap/build -j flags | |
9fe91d7c | 521 | -t Use system /etc/apt/sources.list in build environment(does not include /etc/apt/sources.list.d/*.list) |
4738da13 WK |
522 | -T [/path/to/sources.list] |
523 | Use custom /etc/apt/sources.list in build environment | |
e364450a TC |
524 | -u <suite-postfix> |
525 | Specify a custom suite postfix | |
f3c2180c TC |
526 | -v Set version |
527 | -z Set compression level | |
528 | ||
529 | build-debs <distro> <dsc-file> <architecture> | |
530 | ||
860d2aca TC |
531 | [ This must be run as root! ] |
532 | ||
cf68dc73 | 533 | -B Binary architecture-dependent build |
ed9ff6e3 | 534 | -b Binary-only build |
f3c2180c | 535 | -d Enable cowbuilder debug hook |
33b4eef5 | 536 | -k Don't override pbuilder image configurations |
4738da13 | 537 | -K [/path/to/keyring.asc] |
9cff1eb7 | 538 | Use custom keyring file for sources.list in build environment |
4738da13 | 539 | in the format of: apt-key exportall > /path/to/file.asc |
a8b68a14 | 540 | -t Use system /etc/apt/sources.list in build environment |
4738da13 WK |
541 | -T [/path/to/sources.list] |
542 | Use custom /etc/apt/sources.list in build environment | |
f3c2180c TC |
543 | |
544 | create-dbg-pkgs | |
545 | ||
546 | create-dsc <distro> <orig-file> | |
547 | ||
f840eecd TC |
548 | -f <modules.conf> |
549 | Build only modules listed in this file | |
0a50536a | 550 | -m [ quicktest | non-dfsg ] |
f3c2180c | 551 | Choose custom list of modules to build |
63734bcd TC |
552 | -p <module> |
553 | Include otherwise avoided module | |
f3c2180c TC |
554 | -s [ paranoid | reckless ] |
555 | Set FS bootstrap/build -j flags | |
e364450a TC |
556 | -u <suite-postfix> |
557 | Specify a custom suite postfix | |
c8df04fc | 558 | -z Set compression level |
f3c2180c TC |
559 | |
560 | create-orig <treeish> | |
561 | ||
0a50536a TC |
562 | -m [ quicktest | non-dfsg ] |
563 | Choose custom list of modules to build | |
f3c2180c TC |
564 | -n Nightly build |
565 | -v Set version | |
566 | -z Set compression level | |
567 | ||
568 | EOF | |
569 | exit 1 | |
570 | } | |
571 | ||
572 | while getopts 'dh' o "$@"; do | |
0bab77bf TC |
573 | case "$o" in |
574 | d) set -vx;; | |
f3c2180c | 575 | h) usage;; |
0bab77bf TC |
576 | esac |
577 | done | |
578 | shift $(($OPTIND-1)) | |
15a67097 | 579 | |
f3c2180c | 580 | cmd="$1"; [ -n "$cmd" ] || usage |
b281e134 TC |
581 | shift |
582 | case "$cmd" in | |
0bab77bf | 583 | archive-orig) archive_orig "$@" ;; |
496b9a9c | 584 | build-all) build_all "$@" ;; |
0bab77bf | 585 | build-debs) build_debs "$@" ;; |
b281e134 | 586 | create-dbg-pkgs) create_dbg_pkgs ;; |
8d366f7f | 587 | create-dsc) create_dsc "$@" ;; |
18de2447 | 588 | create-orig) create_orig "$@" ;; |
f3c2180c | 589 | *) usage ;; |
b281e134 | 590 | esac |