summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-10-07 02:36:46 +0100
committerLeah Rowe <leah@libreboot.org>2023-10-07 02:46:47 +0100
commitfa8e204f144ebe318f6173d2570dd90d50dace87 (patch)
tree945341ccd5d308cf7a24fd75d53ba83aaf691a7f /include
parent24584296a8f93f3bd9d81bd050e3b4ec33fcfaf2 (diff)
unified projectname/version/versiondate handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rwxr-xr-xinclude/err.sh26
1 files changed, 18 insertions, 8 deletions
diff --git a/include/err.sh b/include/err.sh
index a2780e10..b0ff827b 100755
--- a/include/err.sh
+++ b/include/err.sh
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org>
+version=""; versiondate=""; projectname=""
+
x_() {
[ $# -lt 1 ] || ${@} || err "non-zero exit status: ${@}"
}
@@ -27,24 +29,29 @@ git_err()
check_project()
{
- _fail="${1}"
- read project < projectname
+ read projectname < projectname || :
- [ -f version ] && read version < version
+ [ ! -f version ] || read version < version || :
version_="${version}"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="${version_}"
- [ -f versiondate ] && read versiondate < versiondate
+ [ ! -f versiondate ] || read versiondate < versiondate || :
versiondate_="${versiondate}"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="${versiondate_}"
- [ -z ${versiondate} ] && "${_fail}" "Unknown version date"
- [ -z ${version} ] && "${_fail}" "Unknown version"
+ [ ! -z ${versiondate} ] || fail "Unknown version date" || \
+ err "Unknown version date"
+ [ ! -z ${version} ] || fail "Unknown version" || \
+ err "Unknown version"
+ [ ! -z ${projectname} ] || fail "Unknown project" || \
+ err "Unknown project"
- printf "%s\n" "${version}" > version
- printf "%s\n" "${versiondate}" > versiondate
+ xx_ printf "%s\n" "${version}" > version || \
+ x_ printf "%s\n" "${version}" > version
+ xx_ printf "%s\n" "${versiondate}" > versiondate || \
+ x_ printf "%s\n" "${versiondate}" > versiondate
}
setvars()
@@ -64,3 +71,6 @@ err()
printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
exit 1
}
+
+check_git
+check_project