From 8d51cb05d9745643f2dfaa6ef35938db9d2d47f6 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Sat, 13 Apr 2019 11:19:20 +0530 Subject: build-aux/pkg-version: provide option for depth=1 Change-Id: I385063b757ae71db70f22a2f7c94e6abeedff426 updates: bz#1701337 Signed-off-by: Amar Tumballi --- build-aux/pkg-version | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'build-aux/pkg-version') diff --git a/build-aux/pkg-version b/build-aux/pkg-version index 83d4a5f9136..7c57c639a5c 100755 --- a/build-aux/pkg-version +++ b/build-aux/pkg-version @@ -3,7 +3,11 @@ # 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]*"` + +# One thing to note, If one does 'git clone --depth N glusterfs.git', +# the git describe command doesn't work. Hence you notice below that +# we have added timestamp as version (YYYY.MM.DD) and release (HH.mmss) +PKG_VERSION=`cat VERSION 2> /dev/null || git describe --tags --match "v[0-9]*" 2>/dev/null` get_version() { @@ -18,7 +22,11 @@ get_version() sub(/^v/,"") ; print $1 }' - echo $PKG_VERSION | awk "$AWK_VERSION" | tr -cd '[:alnum:].' + version=$(echo $PKG_VERSION | awk "$AWK_VERSION" | tr -cd '[:alnum:].') + if [ "x${version}" == "x" ] ; then + version=$(date +%Y.%m.%d | tr -d '\n') + fi + echo $version | tr -d '\n' } get_release() @@ -37,7 +45,11 @@ get_release() else if (NF == 4) print $2, $3, "git" substr($4, 2) }' - echo $PKG_VERSION | awk "$AWK_RELEASE" | tr -cd '[:alnum:].' + release=$(echo $PKG_VERSION | awk "$AWK_RELEASE" | tr -cd '[:alnum:].') + if [ "x${release}" == "x" ] ; then + release=$(date +%H.%M%S | tr -d '\n') + fi + echo $release | tr -d '\n' } if test "x$1" = "x--full"; then -- cgit