summaryrefslogtreecommitdiffstats
path: root/build-aux
diff options
context:
space:
mode:
authorBala.FA <barumuga@redhat.com>2014-02-27 12:39:43 +0530
committerVijay Bellur <vbellur@redhat.com>2014-04-10 04:52:28 -0700
commit4bacb40fc898ee9519cfe4e9ee50401ec466168c (patch)
treee29a334d809266428560f07c8a2b222f60085d94 /build-aux
parent8d7dde6b322483389c25cc0f056c8b27c79c160e (diff)
build: set version based on git tag or specific
This patch brings version and release number generated at build time using git tags or fixed content from VERSION file. With git tag, version/release number are got from output of 'git describe --tags --match "v[0-9]*"' command. This behavior can be overriden by having VERSION file with fixed version/release. The VERSION file should have text describing version and release for example something like 'v3.4.0-1' For testing this patch, its required to remove autom4te.cache directory to avoid seeing previously set version. BUG: 1074919 Change-Id: I8f68172e8b389b0ba0846e9adb4b597e67a909aa Signed-off-by: Bala.FA <barumuga@redhat.com> Reviewed-on: http://review.gluster.org/7164 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/pkg-version52
1 files changed, 52 insertions, 0 deletions
diff --git a/build-aux/pkg-version b/build-aux/pkg-version
new file mode 100755
index 00000000000..2be2a975621
--- /dev/null
+++ b/build-aux/pkg-version
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# To override version/release from git,
+# create VERSION file containing text with version/release
+# eg. v3.4.0-1
+PKG_VERSION=`cat VERSION 2> /dev/null || git describe --tags --match "v[0-9]*"`
+
+function get_version ()
+{
+ # tags and output versions:
+ # - v3.4.0 => 3.4.0 (upstream clean)
+ # - v3.4.0-1 => 3.4.0 (downstream clean)
+ # - v3.4.0-2-g34e62f => 3.4.0 (upstream dirty)
+ # - v3.4.0-1-2-g34e62f => 3.4.0 (downstream dirty)
+ AWK_VERSION='
+ BEGIN { FS="-" }
+ /^v[0-9]/ {
+ sub(/^v/,"") ; print $1
+ }'
+
+ echo $PKG_VERSION | awk "$AWK_VERSION" | tr -cd '[:alnum:].'
+}
+
+function get_release ()
+{
+ # tags and output releases:
+ # - v3.4.0 => 0 (upstream clean)
+ # - v3.4.0-1 => 1 (downstream clean)
+ # - v3.4.0-2-g34e62f1 => 2.git34e62f1 (upstream dirty)
+ # - v3.4.0-1-2-g34e62f1 => 1.2.git34e62f1 (downstream dirty)
+ AWK_RELEASE='
+ BEGIN { FS="-"; OFS="." }
+ /^v[0-9]/ {
+ if (NF == 1) print 0
+ else if (NF == 2) print $2
+ else if (NF == 3) print $2, "git" substr($3, 2)
+ else if (NF == 4) print $2, $3, "git" substr($4, 2)
+ }'
+
+ echo $PKG_VERSION | awk "$AWK_RELEASE" | tr -cd '[:alnum:].'
+}
+
+if test "x$1" = "x--full"; then
+ echo -n "v$(get_version)-$(get_release)"
+elif test "x$1" = "x--version"; then
+ get_version
+elif test "x$1" = "x--release"; then
+ get_release
+else
+ echo "usage: $0 [--full|--version|--release]"
+ exit 1
+fi