X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=version-gen.sh;h=841c084617ef273f32826cc3fc534097d1596cbe;hb=HEAD;hp=8797e49673f730de5fdb3380b5c90672e1800264;hpb=b64b24b7a0cfbbf8eca8ec2520f78ee7345102dc;p=template.git diff --git a/version-gen.sh b/version-gen.sh index 8797e49..841c084 100755 --- a/version-gen.sh +++ b/version-gen.sh @@ -2,17 +2,43 @@ DEFAULT_VERSION="0.0.0.git" -VERSION="$( git describe 2> /dev/null | sed -e 's/foobar-//' )" +VERSION="$( git describe --tags 2> /dev/null \ + | sed -e 's/foobar-//' || true )" if test -z "$VERSION"; then VERSION="$DEFAULT_VERSION" else - git update-index -q --refresh - if test -n "$( git diff-index --name-only HEAD )"; then + git update-index -q --refresh || true + if test -n "$( git diff-index --name-only HEAD || true )"; then VERSION="$VERSION-dirty" fi fi VERSION="$( echo "$VERSION" | sed -e 's/-/./g' )" -echo -n "$VERSION" +if test "x`uname -s`" = "xAIX" || test "x`uname -s`" = "xSunOS" ; then + echo "$VERSION\c" +else + echo -n "$VERSION" +fi + +OLD_VERSION="" +if test -e version; then + OLD_VERSION=$( sed -ne 's/^VERSION="\(.*\)"/\1/p' version ) +fi + +if test "$OLD_VERSION" != "$VERSION"; then + VERSION_MAJOR=$( echo $VERSION | cut -d'.' -f1 ) + VERSION_MINOR=$( echo $VERSION | cut -d'.' -f2 ) + VERSION_PATCH=$( echo $VERSION | cut -d'.' -f3 ) + VERSION_EXTRA="\"$( echo $VERSION | cut -d'.' -f4- )\"" + test -z "$VERSION_EXTRA" || VERSION_EXTRA=".$VERSION_EXTRA" + ( + echo "VERSION=\"$VERSION\"" + echo "VERSION_MAJOR=$VERSION_MAJOR" + echo "VERSION_MINOR=$VERSION_MINOR" + echo "VERSION_PATCH=$VERSION_PATCH" + echo "VERSION_EXTRA=\"$VERSION_EXTRA\"" + echo "VERSION_STRING=\"$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH\"" + ) > version +fi