aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2015-05-22 13:52:56 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-06-01 17:15:56 +1000
commitf88b687a0d705001d4d9150d78328ca05b882225 (patch)
tree59305fed8052ac676a699586e26c8ab84a19f6bf
parent43eee0f2056c36b942365087ee5a49b50e87388e (diff)
downloadskiboot-f88b687a0d705001d4d9150d78328ca05b882225.zip
skiboot-f88b687a0d705001d4d9150d78328ca05b882225.tar.gz
skiboot-f88b687a0d705001d4d9150d78328ca05b882225.tar.bz2
Have make_version be able to generate versions for tools
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@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--Makefile.main2
-rwxr-xr-xmake_version.sh32
2 files changed, 30 insertions, 4 deletions
diff --git a/Makefile.main b/Makefile.main
index 7687d9e..7924cf6 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 860c124..f640869 100755
--- a/make_version.sh
+++ b/make_version.sh
@@ -1,11 +1,37 @@
#!/bin/bash
-if test -e .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 -e .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