X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/profile/blobdiff_plain/816af8ee2ef4512bc57def6d3e3e8a09c0d87f53..5a91acc5db3aa9fe92a4b31d64aa2500bf3446a1:/bin/mdw-build diff --git a/bin/mdw-build b/bin/mdw-build index 650f0c1..572aa75 100755 --- a/bin/mdw-build +++ b/bin/mdw-build @@ -58,8 +58,10 @@ set -e unset checkout checkoutrev unset setup setupcmd +unset sign signkey +unset upload uploadpath unset dput dputtarget -unset build distcheck debian upload clean vpath native +unset build distcheck debian clean vpath native for i in \ "/etc/mdw-build.conf" \ "${XDG_CONFIG_HOME-$HOME/.config}/mdw-build.conf" \ @@ -67,15 +69,22 @@ for i in \ do if [ -f "$i" ]; then . "$i"; fi done +default_depends () { + var=$1 want=$2 + eval "p=\${$var+t} q=\${$want+t}" + case $p,$q in t,*) ;; *,t) eval "$var=yes" ;; *) eval "$var=no" ;; esac +} : ${checkout=yes} ${checkoutrev=HEAD} : ${build=test} : ${setup=yes} ${setupcmd=mdw-setup} : ${distcheck=yes} : ${debian=yes} -: ${upload=yes} : ${clean=yes} : ${vpath=yes} : ${native=yes} +default_depends sign signkey +default_depends upload uploadpath +default_depends dput dputtarget : ${DEB_BUILD_OPTIONS=parallel=4}; export DEB_BUILD_OPTIONS ###-------------------------------------------------------------------------- @@ -94,9 +103,11 @@ Build options: [no]setup[=RUNE] [no]distcheck [no]debian - [no]upload + [no]upload[=SERVER:PATH] + [no]dput[=TARGET] [no]clean [no]vpath + [no]sign[=KEYID] [no]native EOF } @@ -113,6 +124,14 @@ done shift $((OPTIND - 1)) ## Parse the build options. +maybe_set () { + var=$1 want=$2 + eval "p=\${$want+t}\${$want-nil}" + case $p in + t) eval $var=yes ;; + nil) echo >&2 "$prog: $want not set"; exit 1 ;; + esac +} for opt; do case "$opt" in checkout) checkout=yes checkoutrev=HEAD ;; @@ -121,12 +140,18 @@ for opt; do norelease) build=test ;; setup) setup=yes setupcmd=mdw-setup ;; setup=*) setup=yes setupcmd=${opt#*=} ;; - - distcheck | debian | upload | clean | vpath | native) + upload) maybe_set upload uploadpath ;; + upload=*) upload=yes uploadpath=${opt#*=} ;; + sign) maybe_set sign signkey ;; + sign=*) sign=yes signkey=${opt#*=} ;; + dput) maybe_set dput dputtarget ;; + dput=*) dput=yes dputtarget=${opt#*=} ;; + + distcheck | debian | clean | vpath | native) eval "$opt=yes" ;; nocheckout | nosetup | nodistcheck | nodebian | \ - noupload | noclean | novpath | nonative) + noupload | nodput | noclean | novpath | nonative | nosign) eval "${opt#no}=no" ;; *) @@ -349,10 +374,9 @@ case $native in esac run mv $buildpath/$distdir.tar.gz . -case $build in - release) - run gpg -u$(mdw-conf releasekey) -ab -o$distdir.tar.gz.gpg \ - $distdir.tar.gz +case $build,$sign in + release,yes) + run gpg -u$signkey -ab -o$distdir.tar.gz.gpg $distdir.tar.gz ;; esac @@ -376,24 +400,21 @@ EOF mv debian/changelog.new debian/changelog ;; esac - run dpkg-buildpackage -k$(mdw-conf releasekey) + case $build,$sign in + release,yes) run dpkg-buildpackage -k$signkey ;; + no,*) run dpkg-buildpackage -us -uc ;; + esac ;; esac ## Maybe upload Debian packages. cd $releasepath case "$upload,$build" in - yes,test) - info "Test build: not uploading." - ;; - yes,release) - run rsync $distdir.tar.gz $distdir.tar.gz.gpg \ - $(mdw-conf upload-target ftp.distorted.org.uk:~ftp/pub/mdw/) - case "$debian" in - yes) - run dput -f $(mdw-conf dput-target distorted) *.changes - ;; - esac + yes,test) info "Test build: not uploading." ;; + yes,release) run rsync $distdir.tar.gz $distdir.tar.gz.gpg $uploadpath ;; +esac +case "$debian,$upload,$dput,$build" in + yes,yes,yes,release) run dput -f $dputtarget *.changes ;; esac ## Tidy up.