X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=blobdiff_plain;f=configure-version;h=0ce6101622179caae99ae3a535424a8361a8f28e;hp=87126b7ea855888bbf6c38c3dea48bd4c66a5934;hb=bf67f94dd4f4096de4eee07a7dc377d6c889a016;hpb=8ae556b8d341bb73d862f5af6a2b70e05fae3a4c diff --git a/configure-version b/configure-version index 87126b7..0ce6101 100755 --- a/configure-version +++ b/configure-version @@ -1,31 +1,64 @@ #!/usr/bin/env bash -set -eo pipefail +set -euo pipefail top="$(pwd)" -vpy=lib/bup/_version.py -readonly top vpy +readonly top usage() { echo 'Usage: ./configure-version [--update | --clean]' } +update-cpy() +{ + declare -r cpy=lib/bup/_checkout.py + rm -f $cpy.tmp-$$ + local hash date desc + hash=$(git log -1 --pretty=format:%H) + date=$(git log -1 --pretty=format:%ci) + desc=$(git describe --always --match="[0-9]*") + cat > $cpy.tmp-$$ <<-EOF + COMMIT='$hash' + NAMES='(tag: $desc)' + DATE='$date' + EOF + if ! test -e $cpy || ! cmp -s $cpy $cpy.tmp-$$; then + mv $cpy.tmp-$$ $cpy; + fi + rm -f $cpy.tmp-$$ +} + if test "$#" -ne 1; then usage 1>&2; exit 1 fi +if ! test -f lib/bup/bupsplit.c; then + echo 'error: cannot find bup source tree' 1>&2 + exit 1 +fi + case "$1" in --update) - rm -f $vpy.tmp-$$ - ./format-subst.pl $vpy.pre > $vpy.tmp-$$ - if ! test -e $vpy || ! cmp -s $vpy $vpy.tmp-$$; then - mv $vpy.tmp-$$ $vpy; - fi - rm -f $vpy.tmp-$$ + rc=0 + grep -q -F '$Format' lib/bup/_release.py || rc=$? + case $rc in + 0) update-cpy + ;; + 1) if test -d .git; then + echo 'error: detected release, but found ./.git' 1>&2 + exit 1 + fi + echo "Detected release tree; skipping version configuration" 1>&2 + exit 0 + ;; + *) + echo 'error: grep failed' 1>&2 + exit 1 + esac ;; --clean) - rm -f lib/bup/_version.py lib/bup/_version.pyc lib/bup/_version.py.tmp-* + rm -f lib/bup/_checkout.py lib/bup/_checkout.pyc lib/bup/_checkout.py.tmp-* ;; *) usage 1>&2; exit 1