]>
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";; | |
d91947f5 | 49 | experimental) echo "bookworm";; |
46efa0cd AV |
50 | testing) echo "bullseye";; |
51 | stable) echo "buster";; | |
52 | oldstable) echo "stretch";; | |
0bab77bf TC |
53 | *) echo "$1";; |
54 | esac | |
55 | } | |
56 | ||
57 | find_suite () { | |
58 | case "$1" in | |
59 | sid) echo "unstable";; | |
d91947f5 | 60 | bookworm) echo "experimental";; |
46efa0cd AV |
61 | bullseye) echo "testing";; |
62 | buster) echo "stable";; | |
63 | stretch) echo "oldstable";; | |
0bab77bf TC |
64 | *) echo "$1";; |
65 | esac | |
66 | } | |
67 | ||
68 | #### debian/rules helpers | |
69 | ||
4ce0f57a | 70 | create_dbg_pkgs () { |
6c754892 | 71 | for x in $ddir/*; do |
4ce0f57a TC |
72 | test ! -d $x && continue |
73 | test "$x" = "tmp" -o "$x" = "source" && continue | |
74 | test ! "$x" = "${x%-dbg}" && continue | |
75 | test ! -d $x/usr/lib/debug && continue | |
76 | mkdir -p $x-dbg/usr/lib | |
77 | mv $x/usr/lib/debug $x-dbg/usr/lib/ | |
78 | done | |
79 | } | |
80 | ||
18de2447 TC |
81 | cwget () { |
82 | local url="$1" f="${1##*/}" | |
83 | echo "fetching: $url to $f" >&2 | |
84 | if [ -n "$FS_FILES_DIR" ]; then | |
85 | if ! [ -s "$FS_FILES_DIR/$f" ]; then | |
86 | (cd $FS_FILES_DIR && wget -N "$url") | |
87 | fi | |
88 | cp -a $FS_FILES_DIR/$f . | |
89 | else | |
90 | wget -N "$url" | |
91 | fi | |
92 | } | |
93 | ||
94 | getlib () { | |
0bab77bf TC |
95 | local url="$1" f="${1##*/}" |
96 | cwget "$url" | |
97 | tar -xv --no-same-owner --no-same-permissions -f "$f" | |
98 | rm -f "$f" && mkdir -p $f && touch $f/.download-stamp | |
18de2447 TC |
99 | } |
100 | ||
18de2447 | 101 | getlibs () { |
18de2447 | 102 | # get pinned libraries |
57325714 BW |
103 | getlib http://files.freeswitch.org/downloads/libs/sphinxbase-0.8.tar.gz |
104 | getlib http://files.freeswitch.org/downloads/libs/pocketsphinx-0.8.tar.gz | |
0bab77bf | 105 | getlib http://files.freeswitch.org/downloads/libs/communicator_semi_6000_20080321.tar.gz |
96af4c26 AV |
106 | #getlib http://download.zeromq.org/zeromq-2.1.9.tar.gz \ |
107 | # || getlib http://download.zeromq.org/historic/zeromq-2.1.9.tar.gz | |
348ce5ff | 108 | getlib http://files.freeswitch.org/downloads/libs/freeradius-client-1.1.7.tar.gz |
717f597c | 109 | #getlib http://files.freeswitch.org/downloads/libs/v8-3.24.14.tar.bz2 |
18de2447 TC |
110 | } |
111 | ||
0bab77bf TC |
112 | check_repo_clean () { |
113 | git diff-index --quiet --cached HEAD \ | |
114 | || err "uncommitted changes present" | |
115 | git diff-files --quiet \ | |
116 | || err "unclean working tree" | |
117 | git diff-index --quiet HEAD \ | |
118 | || err "unclean repository" | |
119 | ! git ls-files --other --error-unmatch . >/dev/null 2>&1 \ | |
120 | || err "untracked files or build products present" | |
18de2447 TC |
121 | } |
122 | ||
b1682194 | 123 | get_last_release_ver () { |
83125dad | 124 | grep -m1 -e '^AC_INIT' configure.ac \ |
b1682194 TC |
125 | | cut -d, -f2 \ |
126 | | sed -e 's/\[//' -e 's/\]//' -e 's/ //g' | |
127 | } | |
128 | ||
129 | get_nightly_version () { | |
130 | local commit="$(git rev-list -n1 --abbrev=10 --abbrev-commit HEAD)" | |
5fd7643a | 131 | echo "$(get_last_release_ver)+git~$(date -u '+%Y%m%dT%H%M%SZ')~$commit" |
b1682194 TC |
132 | } |
133 | ||
53c24a93 TC |
134 | get_nightly_revision_human () { |
135 | echo "git $(git rev-list -n1 --abbrev=7 --abbrev-commit HEAD) $(date -u '+%Y-%m-%d %H:%M:%SZ')" | |
136 | } | |
137 | ||
8d366f7f | 138 | create_orig () { |
d3cb7036 | 139 | { |
a5d696d5 | 140 | set -e |
d3cb7036 | 141 | local OPTIND OPTARG |
9b33b053 | 142 | local uver="" hrev="" bundle_deps=true modules_list="" zl=9e |
0a50536a | 143 | while getopts 'bm:nv:z:' o "$@"; do |
d3cb7036 | 144 | case "$o" in |
0a50536a | 145 | m) modules_list="$OPTARG";; |
d3cb7036 TC |
146 | n) uver="nightly";; |
147 | v) uver="$OPTARG";; | |
148 | z) zl="$OPTARG";; | |
149 | esac | |
150 | done | |
151 | shift $(($OPTIND-1)) | |
53c24a93 TC |
152 | if [ -z "$uver" ] || [ "$uver" = "nightly" ]; then |
153 | uver="$(get_nightly_version)" | |
154 | hrev="$(get_nightly_revision_human)" | |
155 | fi | |
d3cb7036 | 156 | local treeish="$1" dver="$(mk_dver "$uver")" |
32215578 | 157 | local orig="../freeswitch_$dver~$(lsb_release -sc).orig.tar.xz" |
d3cb7036 TC |
158 | [ -n "$treeish" ] || treeish="HEAD" |
159 | check_repo_clean | |
160 | git reset --hard "$treeish" | |
161 | mv .gitattributes .gitattributes.orig | |
0a50536a TC |
162 | local -a args=(-e '\bdebian-ignore\b') |
163 | test "$modules_list" = "non-dfsg" || args+=(-e '\bdfsg-nonfree\b') | |
164 | grep .gitattributes.orig "${args[@]}" \ | |
d3cb7036 TC |
165 | | while xread l; do |
166 | echo "$l export-ignore" >> .gitattributes | |
167 | done | |
168 | if $bundle_deps; then | |
169 | (cd libs && getlibs) | |
170 | git add -f libs | |
171 | fi | |
83125dad | 172 | ./build/set-fs-version.sh "$uver" "$hrev" && git add configure.ac |
d18a7ffa | 173 | echo "$uver" > .version && git add -f .version |
d3cb7036 TC |
174 | git commit --allow-empty -m "nightly v$uver" |
175 | git archive -v \ | |
176 | --worktree-attributes \ | |
177 | --format=tar \ | |
178 | --prefix=freeswitch-$uver/ \ | |
179 | HEAD \ | |
180 | | xz -c -${zl}v > $orig | |
181 | mv .gitattributes.orig .gitattributes | |
182 | git reset --hard HEAD^ && git clean -fdx | |
183 | } 1>&2 | |
0bab77bf | 184 | echo $orig |
8d366f7f TC |
185 | } |
186 | ||
2365f41f TC |
187 | set_modules_quicktest () { |
188 | cat > debian/modules.conf <<EOF | |
189 | applications/mod_commands | |
190 | EOF | |
191 | } | |
192 | ||
8d366f7f | 193 | create_dsc () { |
d3cb7036 | 194 | { |
a5d696d5 | 195 | set -e |
e364450a | 196 | local OPTIND OPTARG modules_conf="" modules_list="" speed="normal" suite_postfix="" suite_postfix_p=false zl=9 |
63734bcd | 197 | local modules_add="" |
689a3768 | 198 | while getopts 'a:f:m:p:s:u:z:' o "$@"; do |
2365f41f | 199 | case "$o" in |
689a3768 | 200 | a) avoid_mods_arch="$OPTARG";; |
f840eecd | 201 | f) modules_conf="$OPTARG";; |
2365f41f | 202 | m) modules_list="$OPTARG";; |
63734bcd | 203 | p) modules_add="$modules_add $OPTARG";; |
25287f38 | 204 | s) speed="$OPTARG";; |
3fca86c8 | 205 | u) suite_postfix="$OPTARG"; suite_postfix_p=true;; |
c8df04fc | 206 | z) zl="$OPTARG";; |
2365f41f TC |
207 | esac |
208 | done | |
209 | shift $(($OPTIND-1)) | |
d3cb7036 TC |
210 | local distro="$(find_distro $1)" orig="$2" |
211 | local suite="$(find_suite $distro)" | |
212 | local orig_ver="$(echo "$orig" | sed -e 's/^.*_//' -e 's/\.orig\.tar.*$//')" | |
213 | local dver="${orig_ver}-1~${distro}+1" | |
e364450a | 214 | $suite_postfix_p && { suite="${distro}${suite_postfix}"; } |
d3cb7036 TC |
215 | [ -x "$(which dch)" ] \ |
216 | || err "package devscripts isn't installed" | |
f840eecd TC |
217 | if [ -n "$modules_conf" ]; then |
218 | cp $modules_conf debian/modules.conf | |
219 | fi | |
0a50536a | 220 | local bootstrap_args="" |
2365f41f | 221 | if [ -n "$modules_list" ]; then |
0a50536a TC |
222 | if [ "$modules_list" = "non-dfsg" ]; then |
223 | bootstrap_args="-mnon-dfsg" | |
224 | else set_modules_${modules_list}; fi | |
2365f41f | 225 | fi |
63734bcd TC |
226 | if test -n "$modules_add"; then |
227 | for x in $modules_add; do | |
228 | bootstrap_args="$bootstrap_args -p${x}" | |
229 | done | |
230 | fi | |
689a3768 | 231 | (cd debian && ./bootstrap.sh -a "$avoid_mods_arch" -c $distro $bootstrap_args) |
25287f38 TC |
232 | case "$speed" in |
233 | paranoid) sed -i ./debian/rules \ | |
234 | -e '/\.stamp-bootstrap:/{:l2 n; /\.\/bootstrap.sh -j/{s/ -j//; :l3 n; b l3}; b l2};' ;; | |
235 | reckless) sed -i ./debian/rules \ | |
236 | -e '/\.stamp-build:/{:l2 n; /make/{s/$/ -j/; :l3 n; b l3}; b l2};' ;; | |
237 | esac | |
c8df04fc | 238 | [ "$zl" -ge "1" ] || zl=1 |
25287f38 | 239 | git add debian/rules |
d3cb7036 TC |
240 | dch -b -m -v "$dver" --force-distribution -D "$suite" "Nightly build." |
241 | git add debian/changelog && git commit -m "nightly v$orig_ver" | |
c8df04fc | 242 | dpkg-source -i.* -Zxz -z${zl} -b . |
d3cb7036 TC |
243 | dpkg-genchanges -S > ../$(dsc_base)_source.changes |
244 | local dsc="../$(dsc_base).dsc" | |
245 | git reset --hard HEAD^ && git clean -fdx | |
246 | } 1>&2 | |
0bab77bf | 247 | echo $dsc |
8d366f7f TC |
248 | } |
249 | ||
8fb3f54c | 250 | fmt_debug_hook () { |
9dbe81b5 | 251 | cat <<'EOF' |
8fb3f54c TC |
252 | #!/bin/bash |
253 | export debian_chroot="cow" | |
254 | cd /tmp/buildd/*/debian/.. | |
255 | /bin/bash < /dev/tty > /dev/tty 2> /dev/tty | |
256 | EOF | |
257 | } | |
258 | ||
a8b68a14 TC |
259 | get_sources () { |
260 | local tgt_distro="$1" | |
7f9e6f3e | 261 | while read type args path distro components; do |
a8b68a14 | 262 | test "$type" = deb || continue |
7f9e6f3e | 263 | if echo "$args" | grep -qv "\[" ; then components=$distro;distro=$path;path=$args;args=""; fi |
8e058ade WK |
264 | prefix=`echo $distro | awk -F/ '{print $1}'` |
265 | suffix="`echo $distro | awk -F/ '{print $2}'`" | |
266 | if test -n "$suffix" ; then full="$tgt_distro/$suffix" ; else full="$tgt_distro" ; fi | |
7f9e6f3e | 267 | printf "$type $args $path $full $components\n" |
4738da13 | 268 | done < "$2" |
a8b68a14 TC |
269 | } |
270 | ||
271 | get_mirrors () { | |
4738da13 WK |
272 | file=${2-/etc/apt/sources.list} |
273 | announce "Using apt sources file: $file" | |
274 | get_sources "$1" "$file" | tr '\n' '|' | head -c-1; echo | |
a8b68a14 TC |
275 | } |
276 | ||
0bab77bf | 277 | build_debs () { |
d3cb7036 | 278 | { |
a5d696d5 | 279 | set -e |
cf68dc73 | 280 | local OPTIND OPTARG debug_hook=false hookdir="" cow_build_opts="" |
717f597c | 281 | local keep_pbuilder_config=false keyring="" custom_keyring="/tmp/fs.gpg" |
967245bf | 282 | local use_custom_sources=true |
59a8dede | 283 | local custom_sources_file="/etc/apt/sources.list" |
4738da13 | 284 | while getopts 'BbdK:kT:t' o "$@"; do |
d3cb7036 | 285 | case "$o" in |
cf68dc73 | 286 | B) cow_build_opts="--debbuildopts '-B'";; |
ed9ff6e3 | 287 | b) cow_build_opts="--debbuildopts '-b'";; |
d3cb7036 | 288 | d) debug_hook=true;; |
33b4eef5 | 289 | k) keep_pbuilder_config=true;; |
4738da13 | 290 | K) custom_keyring="$OPTARG";; |
967245bf WK |
291 | t) custom_sources_file="/etc/apt/sources.list";; |
292 | T) custom_sources_file="$OPTARG";; | |
d3cb7036 TC |
293 | esac |
294 | done | |
295 | shift $(($OPTIND-1)) | |
dbddff88 | 296 | if [ "$custom_sources_file" == "/etc/apt/sources.list" ]; then |
9dbe81b5 TC |
297 | # If you are using the system sources, then it is reasonable that you expect to use all of the supplementary repos too |
298 | cat /etc/apt/sources.list > /tmp/fs.sources.list | |
299 | if [ "$(ls -A /etc/apt/sources.list.d)" ]; then | |
300 | for X in /etc/apt/sources.list.d/*; do cat $X >> /tmp/fs.sources.list; done | |
301 | fi | |
302 | custom_sources_file="/tmp/fs.sources.list" | |
bb79c578 AV |
303 | apt-key exportall > "/tmp/fs.tmp.gpg" |
304 | gpg --no-default-keyring --keyring /tmp/fs.tmp.keyring.gpg --import /tmp/fs.tmp.gpg | |
305 | gpg --no-default-keyring --keyring /tmp/fs.tmp.keyring.gpg --export > "/tmp/fs.gpg" | |
717f597c | 306 | custom_keyring="/tmp/fs.gpg" |
dbddff88 | 307 | fi |
967245bf | 308 | if [ "$custom_sources_file" == "" ]; then |
9dbe81b5 TC |
309 | # Caller has explicitly set the custom sources file to empty string. They must intend to not use additional mirrors. |
310 | use_custom_sources=false | |
967245bf | 311 | fi |
7ac881fb | 312 | if [[ "$custom_source_file" == "/tmp/fs.sources.list" && ! -e "/tmp/fs.sources.list" ]]; then |
f98da7d5 | 313 | echo "deb [trusted=yes] http://files.freeswitch.org/repo/deb/freeswitch-1.8/ stretch main" >> "/tmp/fs.sources.list" |
967245bf | 314 | fi |
717f597c | 315 | if [[ "$custom_keyring" == "/tmp/fs.gpg" && ! -r "/tmp/fs.gpg" ]]; then |
bb79c578 | 316 | cat << EOF > "/tmp/fs.tmp.gpg" |
967245bf | 317 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
967245bf | 318 | |
717f597c KR |
319 | mQINBFlVeA4BEADg3MkzUvnbuqG7S6ppt0BJIYx2WIlDzsj2EBPBBo7VpppWPGa/ |
320 | 5IDuCgSTVeNPffo6jlHk6HFK4g3r+oVJIDoSGE8bKHAeva/iQRUx5o56zXBVOu8q | |
321 | 3lkUQBjRD+14Ujz9pShNylNfIjgmUp/lg93JYHvIMVGp3AcQKr0dgkhw31NXV2D1 | |
322 | BOSXdx6SNcbIhjY1X4CQivrz+WfX6Lk6vfWTwF0qDC0f7TYSEKmR4Sxadx/3Pb+a | |
323 | +Hiu3BrYtpf99ldwjb2OsfHnRvdf57z+9cA6IEbA+5ergHgrMOVj8oRRCjWM2qNg | |
324 | 5aaJa5WfQsPNNQ41hvjYkdOJjI5mOUFEhX0+y0Gab7S5KCvNn8f5oGvcaYLjFfM4 | |
325 | syl2CbNx4mKfx+zJ43eH6GsU2N0VCk2lNZt0TV6p3AjZ4ofjj9YusQ6FczlWUgFW | |
326 | QlNQZsR5KXAhVu3ACKWsy2WSvfkSOMPpM4lAXJvHyqXh8kO+GsuedVgu8uOiAmkS | |
327 | acyPLohm0W87q2N/6xZ4OH7oMHQFos3hrknlESySN1iJz2qyuysL0yh77OWtdJH+ | |
328 | GIsnftEH33ggG69FHZRDouC60C2HwWxrOwngCSxFEdQppJZjI1H5wSIUOuywZ6a0 | |
329 | +mSe/ZnZKL/hYjy/ZQhGWdmliN8V0WF2MEesk1ouQg63bzxOYEo6Fpw6AwARAQAB | |
330 | tD1GcmVlU1dJVENIIFBhY2thZ2luZyBLZXkgKERlYmlhbiA5KSA8cGFja2FnZXNA | |
f98da7d5 AV |
331 | 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 | |
366 | Y4o4oqgePeTYzkxVYj8= | |
367 | =XPvO | |
967245bf WK |
368 | -----END PGP PUBLIC KEY BLOCK----- |
369 | EOF | |
bb79c578 AV |
370 | gpg --no-default-keyring --keyring /tmp/fs.tmp.keyring.gpg --import /tmp/fs.tmp.gpg |
371 | gpg --no-default-keyring --keyring /tmp/fs.tmp.keyring.gpg --export > "/tmp/fs.gpg" | |
967245bf WK |
372 | fi |
373 | ||
d3cb7036 TC |
374 | local distro="$(find_distro $1)" dsc="$2" arch="$3" |
375 | if [ -z "$distro" ] || [ "$distro" = "auto" ]; then | |
376 | if ! (echo "$dsc" | grep -e '-[0-9]*~[a-z]*+[0-9]*'); then | |
377 | err "no distro specified or found" | |
378 | fi | |
379 | local x="$(echo $dsc | sed -e 's/^[^-]*-[0-9]*~//' -e 's/+[^+]*$//')" | |
380 | distro="$(find_distro $x)" | |
0bab77bf | 381 | fi |
d3cb7036 TC |
382 | [ -n "$arch" ] || arch="$(dpkg-architecture | grep '^DEB_BUILD_ARCH=' | cut -d'=' -f2)" |
383 | [ -x "$(which cowbuilder)" ] \ | |
384 | || err "package cowbuilder isn't installed" | |
385 | local cow_img=/var/cache/pbuilder/base-$distro-$arch.cow | |
4738da13 WK |
386 | if [ -e "$custom_keyring" ]; then |
387 | keyring="$custom_keyring" | |
388 | else | |
389 | keyring="$(mktemp /tmp/keyringXXXXXXXX.asc)" | |
390 | apt-key exportall > "$keyring" | |
391 | fi | |
d3cb7036 | 392 | cow () { |
e78c4405 | 393 | if ! $use_custom_sources; then |
019b1ae3 | 394 | echo "Using system sources $keyring $distro $custom_sources_file" |
a8b68a14 TC |
395 | cowbuilder "$@" \ |
396 | --distribution $distro \ | |
397 | --architecture $arch \ | |
398 | --basepath $cow_img | |
399 | else | |
019b1ae3 | 400 | echo "Using custom sources $keyring $distro $custom_sources_file" |
a8b68a14 TC |
401 | cowbuilder "$@" \ |
402 | --distribution $distro \ | |
403 | --architecture $arch \ | |
404 | --basepath $cow_img \ | |
405 | --keyring "$keyring" \ | |
4738da13 | 406 | --othermirror "$(get_mirrors $distro $custom_sources_file)" |
a8b68a14 | 407 | fi |
d3cb7036 TC |
408 | } |
409 | if ! [ -d $cow_img ]; then | |
410 | announce "Creating base $distro-$arch image..." | |
afb4a200 | 411 | local x=30 |
8a4a8f6f | 412 | while ! cow --create; do |
afb4a200 | 413 | [ $x -lt 1 ] && break; sleep 120; x=$((x-1)) |
8a4a8f6f | 414 | done |
d3cb7036 TC |
415 | fi |
416 | announce "Updating base $distro-$arch image..." | |
afb4a200 | 417 | local x=30 |
33b4eef5 TC |
418 | local opts="--override-config" |
419 | $keep_pbuilder_config && opts="" | |
420 | while ! cow --update $opts; do | |
afb4a200 | 421 | [ $x -lt 1 ] && break; sleep 120; x=$((x-1)) |
9b79922a | 422 | done |
d3cb7036 TC |
423 | announce "Building $distro-$arch DEBs from $dsc..." |
424 | if $debug_hook; then | |
425 | mkdir -p .hooks | |
426 | fmt_debug_hook > .hooks/C10shell | |
427 | chmod +x .hooks/C10shell | |
428 | hookdir=$(pwd)/.hooks | |
429 | fi | |
b4816ae9 TC |
430 | cow --build $dsc \ |
431 | --hookdir "$hookdir" \ | |
992e0566 TC |
432 | --buildresult ../ \ |
433 | $cow_build_opts | |
95a94175 WK |
434 | if [ ! -e "$custom_keyring" ]; then |
435 | # Cleanup script created temporary file | |
436 | rm -f $keyring | |
437 | fi | |
d3cb7036 | 438 | } 1>&2 |
337c9d43 | 439 | echo ${dsc%.dsc}_${arch}.changes |
15a67097 TC |
440 | } |
441 | ||
505cd294 TC |
442 | default_distros () { |
443 | local host_distro="Debian" | |
444 | test -z "$(which lsb_release)" || host_distro="$(lsb_release -is)" | |
445 | case "$host_distro" in | |
f98da7d5 | 446 | Debian) echo "sid stretch jessie" ;; |
505cd294 | 447 | Ubuntu) echo "utopic trusty" ;; |
430433a6 | 448 | *) err "Unknown host distribution \"$host_distro\"" ;; |
505cd294 TC |
449 | esac |
450 | } | |
451 | ||
496b9a9c TC |
452 | build_all () { |
453 | local OPTIND OPTARG | |
671fc3bc | 454 | local orig_opts="" dsc_opts="" deb_opts="" modlist="" |
383b77a1 | 455 | local archs="" distros="" orig="" depinst=false par=false |
67ed8f42 | 456 | while getopts 'a:bc:df:ijkK:l:m:no:p:s:tT:u:v:z:' o "$@"; do |
496b9a9c TC |
457 | case "$o" in |
458 | a) archs="$archs $OPTARG";; | |
459 | b) orig_opts="$orig_opts -b";; | |
460 | c) distros="$distros $OPTARG";; | |
461 | d) deb_opts="$deb_opts -d";; | |
f840eecd | 462 | f) dsc_opts="$dsc_opts -f$OPTARG";; |
383b77a1 | 463 | i) depinst=true;; |
6679e3f5 | 464 | j) par=true;; |
33b4eef5 | 465 | k) deb_opts="$deb_opts -k";; |
67ed8f42 | 466 | K) deb_opts="$deb_opts -K$OPTARG";; |
671fc3bc | 467 | l) modlist="$OPTARG";; |
0a50536a | 468 | m) orig_opts="$orig_opts -m$OPTARG"; dsc_opts="$dsc_opts -m$OPTARG";; |
e38f0a1b | 469 | n) orig_opts="$orig_opts -n";; |
f79a37a3 | 470 | o) orig="$OPTARG";; |
63734bcd | 471 | p) dsc_opts="$dsc_opts -p$OPTARG";; |
25287f38 | 472 | s) dsc_opts="$dsc_opts -s$OPTARG";; |
a8b68a14 | 473 | t) deb_opts="$deb_opts -t";; |
67ed8f42 | 474 | T) deb_opts="$deb_opts -T$OPTARG";; |
e364450a | 475 | u) dsc_opts="$dsc_opts -u$OPTARG";; |
496b9a9c | 476 | v) orig_opts="$orig_opts -v$OPTARG";; |
c8df04fc | 477 | z) orig_opts="$orig_opts -z$OPTARG"; dsc_opts="$dsc_opts -z$OPTARG";; |
496b9a9c TC |
478 | esac |
479 | done | |
480 | shift $(($OPTIND-1)) | |
481 | [ -n "$archs" ] || archs="amd64 i386" | |
505cd294 | 482 | [ -n "$distros" ] || distros="$(default_distros)" |
383b77a1 TC |
483 | ! $depinst || aptitude install -y \ |
484 | rsync git less cowbuilder ccache \ | |
1d5b898a | 485 | devscripts equivs build-essential yasm |
f79a37a3 | 486 | [ -n "$orig" ] || orig="$(create_orig $orig_opts HEAD | tail -n1)" |
671fc3bc TC |
487 | if [ -n "$modlist" ]; then |
488 | local modtmp="$(mktemp /tmp/modules-XXXXXXXXXX.conf)" | |
489 | > $modtmp | |
490 | for m in "$modlist"; do printf '%s\n' "$m" >> $modtmp; done | |
491 | dsc_opts="$dsc_opts -f${modtmp}"; fi | |
492 | [ -n "$orig" ] || orig="$(create_orig $orig_opts HEAD | tail -n1)" | |
6679e3f5 | 493 | mkdir -p ../log |
24fb219f | 494 | > ../log/changes.txt |
6679e3f5 | 495 | echo; echo; echo; echo |
73b34cb3 | 496 | trap 'echo "Killing children...">&2; for x in $(jobs -p); do kill $x; done' EXIT |
496b9a9c | 497 | if [ "${orig:0:2}" = ".." ]; then |
24fb219f | 498 | echo "true" > ../log/builds-ok.txt |
496b9a9c | 499 | for distro in $distros; do |
6679e3f5 | 500 | echo "Creating $distro dsc..." >&2 |
24fb219f | 501 | local dsc="$(create_dsc $dsc_opts $distro $orig 2>../log/$distro.txt | tail -n1)" |
6679e3f5 | 502 | echo "Done creating $distro dsc." >&2 |
496b9a9c | 503 | if [ "${dsc:0:2}" = ".." ]; then |
ed9ff6e3 | 504 | local lopts="-b" |
496b9a9c | 505 | for arch in $archs; do |
6679e3f5 TC |
506 | { |
507 | echo "Building $distro-$arch debs..." >&2 | |
24fb219f | 508 | local changes="$(build_debs $lopts $deb_opts $distro $dsc $arch 2>../log/$distro-$arch.txt | tail -n1)" |
6679e3f5 TC |
509 | echo "Done building $distro-$arch debs." >&2 |
510 | if [ "${changes:0:2}" = ".." ]; then | |
24fb219f | 511 | echo "$changes" >> ../log/changes.txt |
9a0032e9 | 512 | else |
24fb219f | 513 | echo "false" > ../log/builds-ok.txt |
6679e3f5 TC |
514 | fi |
515 | } & | |
516 | $par || wait | |
c15613e0 | 517 | lopts="-B" |
496b9a9c TC |
518 | done |
519 | fi | |
520 | done | |
6679e3f5 | 521 | ! $par || wait |
496b9a9c | 522 | fi |
671fc3bc | 523 | [ -z "$modlist" ] || rm -f $modtmp |
73b34cb3 | 524 | trap - EXIT |
24fb219f WK |
525 | cat ../log/changes.txt |
526 | test "$(cat ../log/builds-ok.txt)" = true || exit 1 | |
496b9a9c TC |
527 | } |
528 | ||
f3c2180c TC |
529 | usage () { |
530 | cat >&2 <<EOF | |
531 | $0 [opts] [cmd] [cmd-opts] | |
532 | ||
533 | options: | |
534 | ||
535 | -d Enable debugging mode. | |
536 | ||
537 | commands: | |
538 | ||
539 | archive-orig | |
540 | ||
541 | build-all | |
542 | ||
860d2aca TC |
543 | [ This must be run as root! ] |
544 | ||
f3c2180c | 545 | -a Specify architectures |
f3c2180c TC |
546 | -c Specify distributions |
547 | -d Enable cowbuilder debug hook | |
f840eecd TC |
548 | -f <modules.conf> |
549 | Build only modules listed in this file | |
383b77a1 | 550 | -i Auto install build deps on host system |
f3c2180c | 551 | -j Build debs in parallel |
33b4eef5 | 552 | -k Don't override pbuilder image configurations |
4738da13 | 553 | -K [/path/to/keyring.asc] |
9cff1eb7 | 554 | Use custom keyring file for sources.list in build environment |
4738da13 | 555 | in the format of: apt-key exportall > /path/to/file.asc |
671fc3bc | 556 | -l <modules> |
0a50536a | 557 | -m [ quicktest | non-dfsg ] |
f3c2180c | 558 | Choose custom list of modules to build |
e38f0a1b | 559 | -n Nightly build |
f79a37a3 TC |
560 | -o <orig-file> |
561 | Specify existing .orig.tar.xz file | |
63734bcd TC |
562 | -p <module> |
563 | Include otherwise avoided module | |
f3c2180c TC |
564 | -s [ paranoid | reckless ] |
565 | Set FS bootstrap/build -j flags | |
9fe91d7c | 566 | -t Use system /etc/apt/sources.list in build environment(does not include /etc/apt/sources.list.d/*.list) |
4738da13 WK |
567 | -T [/path/to/sources.list] |
568 | Use custom /etc/apt/sources.list in build environment | |
e364450a TC |
569 | -u <suite-postfix> |
570 | Specify a custom suite postfix | |
f3c2180c TC |
571 | -v Set version |
572 | -z Set compression level | |
573 | ||
574 | build-debs <distro> <dsc-file> <architecture> | |
575 | ||
860d2aca TC |
576 | [ This must be run as root! ] |
577 | ||
cf68dc73 | 578 | -B Binary architecture-dependent build |
ed9ff6e3 | 579 | -b Binary-only build |
f3c2180c | 580 | -d Enable cowbuilder debug hook |
33b4eef5 | 581 | -k Don't override pbuilder image configurations |
4738da13 | 582 | -K [/path/to/keyring.asc] |
9cff1eb7 | 583 | Use custom keyring file for sources.list in build environment |
4738da13 | 584 | in the format of: apt-key exportall > /path/to/file.asc |
a8b68a14 | 585 | -t Use system /etc/apt/sources.list in build environment |
4738da13 WK |
586 | -T [/path/to/sources.list] |
587 | Use custom /etc/apt/sources.list in build environment | |
f3c2180c TC |
588 | |
589 | create-dbg-pkgs | |
590 | ||
591 | create-dsc <distro> <orig-file> | |
592 | ||
f840eecd TC |
593 | -f <modules.conf> |
594 | Build only modules listed in this file | |
0a50536a | 595 | -m [ quicktest | non-dfsg ] |
f3c2180c | 596 | Choose custom list of modules to build |
63734bcd TC |
597 | -p <module> |
598 | Include otherwise avoided module | |
f3c2180c TC |
599 | -s [ paranoid | reckless ] |
600 | Set FS bootstrap/build -j flags | |
e364450a TC |
601 | -u <suite-postfix> |
602 | Specify a custom suite postfix | |
c8df04fc | 603 | -z Set compression level |
f3c2180c TC |
604 | |
605 | create-orig <treeish> | |
606 | ||
0a50536a TC |
607 | -m [ quicktest | non-dfsg ] |
608 | Choose custom list of modules to build | |
f3c2180c TC |
609 | -n Nightly build |
610 | -v Set version | |
611 | -z Set compression level | |
612 | ||
613 | EOF | |
614 | exit 1 | |
615 | } | |
616 | ||
617 | while getopts 'dh' o "$@"; do | |
0bab77bf TC |
618 | case "$o" in |
619 | d) set -vx;; | |
f3c2180c | 620 | h) usage;; |
0bab77bf TC |
621 | esac |
622 | done | |
623 | shift $(($OPTIND-1)) | |
15a67097 | 624 | |
f3c2180c | 625 | cmd="$1"; [ -n "$cmd" ] || usage |
b281e134 TC |
626 | shift |
627 | case "$cmd" in | |
0bab77bf | 628 | archive-orig) archive_orig "$@" ;; |
496b9a9c | 629 | build-all) build_all "$@" ;; |
0bab77bf | 630 | build-debs) build_debs "$@" ;; |
b281e134 | 631 | create-dbg-pkgs) create_dbg_pkgs ;; |
8d366f7f | 632 | create-dsc) create_dsc "$@" ;; |
18de2447 | 633 | create-orig) create_orig "$@" ;; |
f3c2180c | 634 | *) usage ;; |
b281e134 | 635 | esac |