]> arthur.barton.de Git - bup.git/blob - configure-version
Update base_version to 0.34~ for 0.34 development
[bup.git] / configure-version
1 #!/usr/bin/env bash
2
3 set -euo pipefail
4
5 top="$(pwd)"
6 readonly top
7
8 usage()
9 {
10     echo 'Usage: ./configure-version [--update | --clean]'
11 }
12
13 update-cpy()
14 {
15     declare -r cpy=lib/bup/_checkout.py
16     rm -f $cpy.tmp-$$
17     local hash date desc
18     hash=$(git log -1 --pretty=format:%H)
19     date=$(git log -1 --pretty=format:%ci)
20     desc=$(git describe --always --match="[0-9]*")
21     cat > $cpy.tmp-$$ <<-EOF
22         COMMIT='$hash'
23         NAMES='(tag: $desc)'
24         DATE='$date'
25         EOF
26     if ! test -e $cpy || ! cmp -s $cpy $cpy.tmp-$$; then
27         mv $cpy.tmp-$$ $cpy;
28     fi
29     rm -f $cpy.tmp-$$
30 }
31
32 if test "$#" -ne 1; then
33     usage 1>&2; exit 1
34 fi
35
36 if ! test -f lib/bup/bupsplit.c; then
37     echo 'error: cannot find bup source tree' 1>&2
38     exit 1
39 fi
40
41 case "$1" in
42     --update)
43         rc=0
44         grep -q -F '$Format' lib/bup/_release.py || rc=$?
45         case $rc in
46             0) update-cpy
47                ;;
48             1) if test -d .git; then
49                    echo 'error: detected release, but found ./.git' 1>&2
50                    exit 1
51                fi
52                echo "Detected release tree; skipping version configuration" 1>&2
53                exit 0
54                ;;
55             *)
56                 echo 'error: grep failed' 1>&2
57                 exit 1
58         esac
59         ;;
60     --clean)
61         rm -f lib/bup/_checkout.py lib/bup/_checkout.pyc lib/bup/_checkout.py.tmp-*
62         ;;
63     *)
64         usage 1>&2; exit 1
65         ;;
66 esac