-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion-gen.sh
executable file
·44 lines (37 loc) · 1.16 KB
/
version-gen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /bin/sh
DEFAULT_VERSION="0.0.0.git"
VERSION="$( git describe --tags 2> /dev/null \
| sed -e 's/postrr-//' || true )"
if test -z "$VERSION"; then
VERSION="$DEFAULT_VERSION"
else
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' )"
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