From b5db6435e5dec85498e3b78f76d33b6cfbc63815 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 21 Sep 2021 17:55:44 +0200 Subject: [PATCH] build: pass GLUON_VERSION and GLUON_SITE_VERSION to build A helper script is introduced to get the version from `git describe`. --- Makefile | 4 ++++ scripts/getversion.sh | 12 ++++++++++++ targets/generic | 2 ++ 3 files changed, 18 insertions(+) create mode 100755 scripts/getversion.sh diff --git a/Makefile b/Makefile index b49ebe80..760335a2 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,9 @@ $(eval $(call mkabspath,GLUON_PACKAGEDIR)) $(eval $(call mkabspath,GLUON_TARGETSDIR)) $(eval $(call mkabspath,GLUON_PATCHESDIR)) +GLUON_VERSION := $(shell scripts/getversion.sh '.') +GLUON_SITE_VERSION := $(shell scripts/getversion.sh '$(GLUON_SITEDIR)') + GLUON_MULTIDOMAIN ?= 0 GLUON_AUTOREMOVE ?= 0 GLUON_DEBUG ?= 0 @@ -64,6 +67,7 @@ src-link gluon_base ../../package endef GLUON_VARS = \ + GLUON_VERSION GLUON_SITE_VERSION \ GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_AUTOREMOVE GLUON_DEBUG GLUON_MINIFY GLUON_DEPRECATED \ GLUON_DEVICES GLUON_TARGETSDIR GLUON_PATCHESDIR GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR GLUON_DEBUGDIR \ GLUON_SITEDIR GLUON_RELEASE GLUON_AUTOUPDATER_BRANCH GLUON_AUTOUPDATER_ENABLED GLUON_LANGS GLUON_BASE_FEEDS \ diff --git a/scripts/getversion.sh b/scripts/getversion.sh new file mode 100755 index 00000000..cbb7cf60 --- /dev/null +++ b/scripts/getversion.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ $# -ne 1 ]; then + echo >&2 "Usage: getversion.sh " + exit 1 +fi + +cd "$1" || exit 1 + +git --git-dir=.git describe --always --abbrev=7 --dirty=+ 2>/dev/null && exit 0 + +echo unknown diff --git a/targets/generic b/targets/generic index cd72112f..b0943d9b 100644 --- a/targets/generic +++ b/targets/generic @@ -2,6 +2,8 @@ assert(env.GLUON_LANGS) config('GLUON_SITEDIR', env.GLUON_SITEDIR) +config('GLUON_VERSION', env.GLUON_VERSION) +config('GLUON_SITE_VERSION', env.GLUON_SITE_VERSION) config('GLUON_RELEASE', env.GLUON_RELEASE) try_config('GLUON_AUTOUPDATER_BRANCH', env.GLUON_AUTOUPDATER_BRANCH)