[PATCH 1/4] ndctl: switch to kernel versioning scheme

From: Dan Williams
Date: Tue Jul 25 2017 - 18:42:47 EST


Similar to perf, now that ndctl is part of the kernel source tree it
also shares the version number of the source tree. This is consistent
with the policy of not maintaining separate version numbers for drivers
within the kernel tree.

The version can be overridden by a local 'version' file, but now the
default version will no longer be hard coded. Instead, it is derived
from the kernel's 'kernelversion' Makefile target. The policy appending
'.git${abbrev_commit}', and optionally '.dirty', for off-label releases
is still the default when a git tree is available.

Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
---
tools/ndctl/git-version | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/ndctl/git-version b/tools/ndctl/git-version
index 8cc8d2f97bd6..a6461036ec8e 100755
--- a/tools/ndctl/git-version
+++ b/tools/ndctl/git-version
@@ -19,7 +19,7 @@ dirty() {
fi
}

-DEF_VER=57.1
+DEF_VER=$(MAKEFLAGS= make -sC ../.. kernelversion)

LF='
'
@@ -29,7 +29,7 @@ LF='
if test -f version; then
VN=$(cat version) || VN="$DEF_VER"
elif test -d ${GIT_DIR:-.git} -o -f .git &&
- VN=$(git describe --match "v[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
+ VN=$(git describe --match "v[4-9]*" --abbrev=7 HEAD 2>/dev/null) &&
case "$VN" in
*$LF*) (exit 1) ;;
v[0-9]*)
@@ -37,9 +37,9 @@ elif test -d ${GIT_DIR:-.git} -o -f .git &&
esac; then
VN=$(echo "$VN" | sed -e 's/-/./g');
else
- read COMMIT COMMIT_SUBJECT <<EOF
+ read COMMIT COMMIT_SUBJECT <<- EOF
$(git log --oneline --abbrev=8 -n1 HEAD 2>/dev/null)
-EOF
+ EOF
if [ -z $COMMIT ]; then
VN="${DEF_VER}+"
else