2
0

util.sh 18 KB

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