Skip to content

Commit

Permalink
versioning: Unify all versioning to match skiboot versions
Browse files Browse the repository at this point in the history
Previously there has been some uncertainty as to how separate binaries were
to be versioned compared to the firmware version as they could change (or
not change) out of sync with skiboot versioning. Historically pflash was
born with its own version which didn't help the issue.

It has been decided that make_version.sh should always return one version
which is shall be the skiboot firmware version, external binaries can
supply their own prefix which will be s/skiboot/$prefix/ but the default
behaviour is the git tag versioning.

The main reason for versioning here is so developers can identify which
version of the code someone is running, versions which closly match the
source tree are easiest to deal with. The idea with one version and
every binary getting a bump regardless of changes is that there is a lot of
shared code (libflash/libffs are a prime example) and even if an external
binary isn't explicitly updated it is possible that changes to shared code
may be missed.

This patch simplifies make_version.sh which had been updated to deal with
pflash- git tags.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
cyrilbur-ibm authored and stewartsmith committed Jul 31, 2015
1 parent 8692283 commit 3591fd3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Makefile.main
Expand Up @@ -156,7 +156,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 skiboot)
VERSION ?= $(shell cd $(SRC); GIT_DIR=$(SRC)/.git $(SRC)/make_version.sh)

.PHONY: VERSION-always
.version: VERSION-always
Expand Down
2 changes: 1 addition & 1 deletion external/pflash/rules.mk
Expand Up @@ -25,7 +25,7 @@ PFLASH_VERSION ?= $(shell ./make_version.sh $(EXE))

version.c: make_version.sh .version
@(if [ "a$(PFLASH_VERSION)" = "a" ]; then \
echo "#error You need to set SKIBOOT_VERSION environment variable" > $@ ;\
echo "#error You need to set PFLASH_VERSION environment variable" > $@ ;\
else \
echo "const char version[] = \"$(PFLASH_VERSION)\";" ;\
fi) > $@
Expand Down
37 changes: 15 additions & 22 deletions make_version.sh
@@ -1,35 +1,23 @@
#!/bin/bash

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 "$0 [ prefix ]"
echo -e "\t Optionally specify a prefix other than 'skiboot'"
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;
if [ "$1" = "-h" -o "$1" = "--help" ] ;
then
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" > stderr
fi
usage
exit 1;
fi

version=`git describe --exact-match --match "$TAG_PREFIX-*" 2>/dev/null`
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 [ -z "$version" ];
then
version=`git describe --match "$TAG_PREFIX-*" 2>/dev/null`
version=`git describe 2>/dev/null`
fi
if [ -z "$version" ];
then
Expand All @@ -51,6 +39,11 @@ then
version="$version-$diffsha"
fi

if [ $# -eq 1 ];
then
version=`echo $version | sed s/skiboot/$1/`
fi

echo $version
else
if [ ! -z "$SKIBOOT_VERSION" ];
Expand Down

0 comments on commit 3591fd3

Please sign in to comment.