summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
Diffstat (limited to 'util')
-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"