[Skiboot] [PATCH 1/4] Have make_version be able to generate versions for tools

Cyril Bur cyril.bur at au1.ibm.com
Fri May 22 13:52:56 AEST 2015


The goal here is to be able to set tags for versions to some of the userspace
tools that are kept in this repository.

For this to work, make_version must be able to generate a version for a tag
prefix not just the last tag in the repo.

The new usage of make_version is to specify a tag prefix when calling it so
that it knows what tag to look for. This option is ignored if not in a git
repository and the current behaviour of relying on a .version file or
$SKIBOOT_VERSION variable remains.

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 Makefile.main   |  2 +-
 make_version.sh | 32 +++++++++++++++++++++++++++++---
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/Makefile.main b/Makefile.main
index e67d4cf..b09de25 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -153,7 +153,7 @@ $(SUBDIRS):
 # Set V=1 if you want to see everything.
 include $(SRC)/Makefile.rules
 
-VERSION ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git $(SRC)/make_version.sh)
+VERSION ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git $(SRC)/make_version.sh skiboot)
 
 .PHONY: VERSION-always
 .version: VERSION-always
diff --git a/make_version.sh b/make_version.sh
index 1dfbe4c..5cbbf1b 100755
--- a/make_version.sh
+++ b/make_version.sh
@@ -1,11 +1,37 @@
 #!/bin/bash
 
-if test -d .git;
+usage() {
+	echo "$0 git-tag-prefix"
+	echo -e "\tIf inside git dir specify a tag prefix to use."
+	echo -e "\tWhere a prefix is anything before the first dash '-' character."
+	echo
+	if test -d .git || git rev-parse --is-inside-work-tree > /dev/null 2>&1;
+	then
+		echo "Possible tags include:"
+		git tag | cut -d '-' -f 1 | sort | uniq
+	fi
+}
+
+if test -d .git || git rev-parse --is-inside-work-tree > /dev/null 2>&1;
 then
-	version=`git describe --exact-match 2>/dev/null`
+	if [ $# -ne "1" ] ; then
+		usage
+		exit 1;
+	fi
+
+	TAG_PREFIX="$1"
+
+	#Check that there is at least one of such a prefix
+	if ! git tag | grep -q "$TAG_PREFIX" ; then
+		echo -e "There isn't a single gix tag with prefix '$TAG_PREFIX'\n"
+		usage
+		exit 1;
+	fi
+
+	version=`git describe --exact-match --match "$TAG_PREFIX-*" 2>/dev/null`
 	if [ -z "$version" ];
 	then
-		version=`git describe 2>/dev/null`
+		version=`git describe --match "$TAG_PREFIX-*" 2>/dev/null`
 	fi
 	if [ -z "$version" ];
 	then
-- 
1.9.1



More information about the Skiboot mailing list