diff --git a/make/scripts/version-info.py b/make/scripts/version-info.py index 7e7c22d58..f84ba23b8 100644 --- a/make/scripts/version-info.py +++ b/make/scripts/version-info.py @@ -158,6 +158,20 @@ class Repo: else: return clean + def label(self): + """Return package label (tag if defined, or date-hash if no tag)""" + if self._tag == None: + return ''.join([self.time('%Y%m%d'), "-", self.hash(8, 'untagged'), self.dirty()]) + else: + return ''.join([self.tag(''), self.dirty()]) + + def revision(self): + """Return full revison string (tag if defined, or branch:hash date time if no tag""" + if self._tag == None: + return ''.join([self.branch('no-branch'), ":", self.hash(8, 'no-hash'), self.dirty(), self.time(' %Y%m%d %H:%M')]) + else: + return ''.join([self.tag(''), self.dirty()]) + def info(self): """Print some repository info""" print "path: ", self.path() @@ -169,6 +183,8 @@ class Repo: print "branch: ", self.branch() print "commit tag: ", self.tag('') print "dirty: ", self.dirty('yes', 'no') + print "label: ", self.label() + print "revision: ", self.revision() def file_from_template(tpl_name, out_name, dict): """Create or update file from template using dictionary @@ -380,10 +396,15 @@ string given. TAG = r.tag(''), TAG_OR_BRANCH = r.tag(r.branch('unreleased')), TAG_OR_HASH8 = r.tag(r.hash(8, 'untagged')), + LABEL = r.label(), + REVISION = r.revision(), DIRTY = r.dirty(), FWTAG = xtrim(r.tag(r.branch('unreleased')), r.dirty(), 25), UNIXTIME = r.time(), DATE = r.time('%Y%m%d'), + DAY=r.time('%d'), + MONTH=r.time('%m'), + YEAR=r.time('%Y'), DATETIME = r.time('%Y%m%d %H:%M'), BOARD_TYPE = args.type, BOARD_REVISION = args.revision, diff --git a/package/Makefile b/package/Makefile index f7e2d1568..495431da8 100644 --- a/package/Makefile +++ b/package/Makefile @@ -14,13 +14,7 @@ ROOT_DIR := $(realpath $(WHEREAMI)/../) # Set up some macros BUILD_DIR := $(ROOT_DIR)/build VERSION_CMD := python $(ROOT_DIR)/make/scripts/version-info.py --path="$(ROOT_DIR)" -# If there is a tag, use it for label instead of date-hash string -PACKAGE_TAG := $(shell $(VERSION_CMD) --format=\$${TAG}) -ifneq ($(PACKAGE_TAG),) -PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${TAG}\$${DIRTY}) -else -PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${DATE}-\$${TAG_OR_HASH8}\$${DIRTY}) -endif +PACKAGE_LBL := $(shell $(VERSION_CMD) --format=\$${LABEL}) PACKAGE_DIR := $(BUILD_DIR)/package-$(PACKAGE_LBL) FW_DIR := $(PACKAGE_DIR)/firmware-$(PACKAGE_LBL) BL_DIR := $(FW_DIR)/bootloaders