Updating the changelog in the VERSION file, and version_sync.
[shapes.git] / source / SHAPES-VERSION-GEN
blobd293933aa06142cdcd137dbe4e300a0fdabde5ce
1 #!/bin/sh
3 # This file is part of Shapes.
5 # Shapes is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # any later version.
10 # Shapes is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Shapes. If not, see <http://www.gnu.org/licenses/>.
18 # Copyright 2008 Gustaf Hendeby
20 LF='
22 if test $# -lt 1
23 then
24 DIR='..'
25 else
26 DIR=$1
29 SVF=SHAPES-VERSION-FILE
30 SVF_DEF=$DIR/VERSION
31 SVF_DIST=version
32 VN=$(sed -e '2,$ d' < $SVF_DEF)
33 VD=$(date +"%Y-%m-%d %T %z")
35 if test -f $SVF_DIST
36 then
37 VN=$(sed -e '/NUMBER/! d' -e 's/VERSION_NUMBER := //' < $SVF_DIST)
38 VD=$(sed -e '/DATE/! d' -e 's/VERSION_DATE := //' < $SVF_DIST)
39 elif test -d $DIR/.git &&
40 VN=$(cd ${DIR} && git describe --abbrev=4 HEAD 2>/dev/null) &&
41 case "$VN" in
42 *$LF*) (exit 1) ;;
43 [0-9]*) : ;;
44 esac
45 then
46 if test -z "$(cd ${DIR} && git diff-index --name-only HEAD)"
47 then
48 VD=$(cd ${DIR} && git show --quiet --pretty="format:%ci" HEAD)
49 else
50 VN="$VN-dirty"
54 if test -r $SVF
55 then
56 FVN=$(sed -e '/NUMBER/! d' -e 's/VERSION_NUMBER := //' < $SVF)
57 FVD=$(sed -e '/DATE/! d' -e 's/VERSION_DATE := //' < $SVF)
58 else
59 FVN=undef
60 FVD=undef
63 VDcmp=$(echo "$VD" | sed -e 's/\([0-9]\{2\}:[0-9]\{2\}\):[0-9.]*/\1/g')
64 FVDcmp=$(echo "$FVD" | sed -e 's/\([0-9]\{2\}:[0-9]\{2\}\):[0-9.]*/\1/g')
65 test "$VDcmp" = "$FVDcmp" -a "$VN" = "$FVN" || {
66 echo >&2 "\
67 VERSION_NUMBER := ${VN}
68 VERSION_DATE := ${VD}"
69 echo "\
70 VERSION_NUMBER := ${VN}
71 VERSION_DATE := ${VD}" > $SVF