summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReka Norman <rekanorman@google.com>2022-12-15 15:04:11 +1100
committerMartin L Roth <gaumless@gmail.com>2022-12-17 20:37:22 +0000
commit5e780903063a1059725217bc9e44e230fbc4f15f (patch)
treeda7954c61441be3eca85e8a21b0316bb1f6c0c28
parentf7bb72333a56c2df111dd1f94b5bbc54ffabe4bd (diff)
util/genbuild_h: Only use version tags in expected format
With commit 0110e1abe0ba ("util/genbuild_h: Update printf %d to %s for sh compatability"), the ChromeOS coreboot build is failing with: In file included from src/lib/version.c:4: /build/nissa/tmp/portage/sys-boot/coreboot-0.0.1-r5473/work/build/nivviks/build.h:10:32: error: 'v1' undeclared here (not in a function) 10 | #define COREBOOT_MAJOR_VERSION v1 | ^~ src/lib/version.c:35:46: note: in expansion of macro 'COREBOOT_MAJOR_VERSION' 35 | const unsigned int coreboot_major_revision = COREBOOT_MAJOR_VERSION; | ^~~~~~~~~~~~~~~~~~~~~~ /build/nissa/tmp/portage/sys-boot/coreboot-0.0.1-r5473/work/build/nivviks/build.h:11:32: error: 'v9308' undeclared here (not in a function) 11 | #define COREBOOT_MINOR_VERSION v9308 | ^~~~~ src/lib/version.c:36:46: note: in expansion of macro 'COREBOOT_MINOR_VERSION' 36 | const unsigned int coreboot_minor_revision = COREBOOT_MINOR_VERSION; | ^~~~~~~~~~~~~~~~~~~~~~ This is because the ChromeOS coreboot repo has a tag which is not in the expected <major>.<minor> format: $ git tag v1.9308_26_0.0.22 Change genbuild_h.sh to only use the version from `git describe` if it's in the expected <major>.<minor> format. TEST=ChromeOS coreboot build now succeeds, with versions set to 0: #define COREBOOT_MAJOR_VERSION 0 #define COREBOOT_MINOR_VERSION 0 Building upstream coreboot, the versions are still set correctly: #define COREBOOT_MAJOR_VERSION 4 #define COREBOOT_MINOR_VERSION 18 Change-Id: I81b2317a83cdec4cc2aad60af2990e5e3f4ad694 Signed-off-by: Reka Norman <rekanorman@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/70770 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Usha P <usha.p@intel.com>
-rwxr-xr-xutil/genbuild_h/genbuild_h.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/util/genbuild_h/genbuild_h.sh b/util/genbuild_h/genbuild_h.sh
index ae21d6c478..b4878c6407 100755
--- a/util/genbuild_h/genbuild_h.sh
+++ b/util/genbuild_h/genbuild_h.sh
@@ -36,8 +36,12 @@ elif [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
TIMESOURCE=git
DATE="$(get_git_head_data %ct)"
VERSION="$(git describe)"
- MAJOR_VER="$(echo "${VERSION}" | sed 's/\([0-9]\)\.\([0-9][0-9]*\).*/\1/')"
- MINOR_VER="$(echo "${VERSION}" | sed 's/\([0-9]\)\.\([0-9][0-9]*\).*/\2/')"
+ # Only use the `git describe` output if the tag is in the expected <major>.<minor>
+ # format, e.g. 4.18. Forks of coreboot may have other tags in different formats.
+ if echo "${VERSION}" | grep -q "^[0-9]\.[0-9][0-9]*"; then
+ MAJOR_VER="$(echo "${VERSION}" | sed 's/\([0-9]\)\.\([0-9][0-9]*\).*/\1/')"
+ MINOR_VER="$(echo "${VERSION}" | sed 's/\([0-9]\)\.\([0-9][0-9]*\).*/\2/')"
+ fi
else
GITREV=Unknown
TIMESOURCE="date"