X-Git-Url: https://git.distorted.org.uk/~mdw/profile/blobdiff_plain/816af8ee2ef4512bc57def6d3e3e8a09c0d87f53..675455c2159ddadcc96a04b470d9516d54bd7fe7:/bin/mdw-build diff --git a/bin/mdw-build b/bin/mdw-build index 650f0c1..2af71e3 100755 --- a/bin/mdw-build +++ b/bin/mdw-build @@ -58,8 +58,11 @@ set -e unset checkout checkoutrev unset setup setupcmd +unset sign signkey +unset sbuild sbuildsrv +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 +70,23 @@ 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 sbuild sbuildsrv +default_depends sign signkey +default_depends upload uploadpath +default_depends dput dputtarget : ${DEB_BUILD_OPTIONS=parallel=4}; export DEB_BUILD_OPTIONS ###-------------------------------------------------------------------------- @@ -85,7 +96,7 @@ prog=${0##*/} usage () { cat <&2 "$prog: $want not set"; exit 1 ;; + esac +} for opt; do case "$opt" in checkout) checkout=yes checkoutrev=HEAD ;; @@ -121,12 +143,20 @@ 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#*=} ;; + sbuild) maybe_set sbuild sbuildsrv ;; + sbuild=*) sbuild=yes sbuildsrv=${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 | nosbuild | nosign) eval "${opt#no}=no" ;; *) @@ -211,7 +241,8 @@ while [ ! -f configure.ac -a ! -f configure.in -a \ esac cd .. done -assign srcpath $(pwd) +assign toppath $(pwd) +assign srcpath $toppath ## Build any necessary qualifiers. qual= sep=. @@ -258,7 +289,7 @@ case "$debian,$(yesno [ -d $srcpath/debian ])" in debver=none ;; yes,yes) - debver=$(dpkg-parsechangelog | sed -n 's/^Version: //p' | tr \~ -) + debver=$(dpkg-parsechangelog | sed -n 's/^Version: //p') debsrc=$(dpkg-parsechangelog | sed -n 's/^Source: //p') debname=$(git config user.name) debemail=$(git config user.email) ;; @@ -272,19 +303,26 @@ case "$checkout" in assign srcpath $releasepath/_source cd $srcpath run git checkout -b mdw-build $checkoutrev - gitver=$(git describe --abbrev=4) + assign gitversion "$(git describe --abbrev=4)" ;; esac ## Check the version number. hack_dch_p=no -case "$gitver,$debver" in +case "$gitversion,$debver" in none,* | *,none) ;; *) - if [ "$gitver" != "$debver" ]; then - warn "Git version $gitver doesn't match Debian version $debver" + dvref=$(echo "$debver" | tr '~' '_') + if [ "$gitversion" = "$dvref" ]; then + assign debversion "$debver" + else + warn "Git version $gitversion doesn't match Debian version $debver" hack_dch=yes + dver=$(echo $gitversion | sed 's/-/+/; s/-/./g') + case $debver in *~) dver=$debver$dver ;; esac + assign debversion "$dver" + now=$(date -R) fi ;; esac @@ -349,10 +387,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 @@ -363,10 +400,8 @@ case "$debian" in cd $distdir case $hack_dch in yes) - dver=$(echo $gitver | sed 's/-/+/; s/-/./g') - now=$(date -R) cat - debian/changelog >debian/changelog.new <