summaryrefslogtreecommitdiffhomepage
path: root/scripts/version.sh
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2018-09-04 01:23:01 +0200
committerMichael Adam <obnox@samba.org>2018-09-05 00:56:31 +0200
commit9f4ed46c0adf6ce6cb8dd44aff611448b64a37a7 (patch)
treee91782c1343270743cd5b8376855019d50f8a7b7 /scripts/version.sh
parenta662c11b8d106e0a2f3379b89739ed4770c5bbd3 (diff)
build: add new version mechanism based on VERSION file and a version.sh script
If this is a git checkout, and git is available, then git describe is used. Otherwise, the new checked in VERSION file is taken for the version. This mechanism uses a version.sh script inspired by http://git.musl-libc.org/cgit/musl/tree/tools/version.sh Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'scripts/version.sh')
-rwxr-xr-xscripts/version.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/version.sh b/scripts/version.sh
new file mode 100755
index 0000000..9a965dc
--- /dev/null
+++ b/scripts/version.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)"
+GIT_DIR="${SCRIPT_DIR}/../.git"
+
+if test -d "${GIT_DIR}" ; then
+ if type git >/dev/null 2>&1 ; then
+ git describe --match '[0-9]*.[0-9]*.[0-9]*' 2>/dev/null \
+ | sed -e 's/-/-git-/'
+ else
+ sed 's/$/-git/' < VERSION
+ fi
+else
+ cat VERSION
+fi