summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheckgit27
-rwxr-xr-xcheckversion34
-rwxr-xr-xinclude/err.sh31
-rwxr-xr-xlbmk10
-rwxr-xr-xscript/build/release/src3
5 files changed, 36 insertions, 69 deletions
diff --git a/checkgit b/checkgit
deleted file mode 100755
index a1f900c3..00000000
--- a/checkgit
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env sh
-# SPDX-License-Identifier: MIT
-# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
-
-. "include/err.sh"
-
-read projectname < projectname
-
-main()
-{
- which git 1>/dev/null 2>/dev/null || \
- fail "git not installed. please install git-scm."
- git config --global user.name 1>/dev/null 2>/dev/null || \
- fail "git config --global user.name \"John Doe\""
- git config --global user.email 1>/dev/null 2>/dev/null || \
- fail "git config --global user.email \"john.doe@example.com\""
-}
-
-fail()
-{
- printf "You must configure Git, before using %s's build system. Do:\n" \
- "${projectname}" 1>&2
- printf "%s\n\n" "${1}" 1>&2
- err "Misconfigured git-scm"
-}
-
-main $@
diff --git a/checkversion b/checkversion
deleted file mode 100755
index b7193fc9..00000000
--- a/checkversion
+++ /dev/null
@@ -1,34 +0,0 @@
-#!/usr/bin/env sh
-# SPDX-License-Identifier: GPL-3.0-or-later
-# SPDX-FileCopyrightText: 2021 Leah Rowe <leah@libreboot.org>
-
-[ "x${DEBUG+set}" = 'xset' ] && set -v
-set -u
-
-. "include/err.sh"
-
-read project < projectname
-
-version="version-unknown"
-[ -f version ] && read version < version
-version_="${version}"
-if [ -e ".git" ]; then
- version="$(git describe --tags HEAD 2>&1)" || \
- version="git-$(git rev-parse HEAD 2>&1)" || \
- version="${version_}"
- printf "%s\n" "${version}" > version
-fi
-
-versiondate="version-date-unknown"
-[ -f versiondate ] && read versiondate < versiondate
-versiondate_="${versiondate}"
-if [ -e ".git" ]; then
- versiondate="$(git show --no-patch --no-notes --pretty='%ct' HEAD)" || \
- versiondate="${versiondate_}"
- printf "%s\n" "${versiondate}" > versiondate
-fi
-
-if [ "${versiondate}" = "version-date-unknown" ] || \
- [ "${version}" = "version-unknown" ]; then
- err "cannot determine ${projectname} revision"
-fi
diff --git a/include/err.sh b/include/err.sh
index 10e5db9b..ac27d636 100755
--- a/include/err.sh
+++ b/include/err.sh
@@ -8,6 +8,37 @@ xx_() {
[ $# -lt 1 ] || ${@} || fail "non-zero exit status: ${@}"
}
+check_git()
+{
+ which git 1>/dev/null 2>/dev/null || \
+ err "git not installed. please install git-scm."
+ git config --global user.name 1>/dev/null 2>/dev/null || \
+ err "git config --global user.name \"John Doe\""
+ git config --global user.email 1>/dev/null 2>/dev/null || \
+ err "git config --global user.email \"john.doe@example.com\""
+}
+
+check_project()
+{
+ read project < projectname
+
+ [ -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
+ versiondate_="${versiondate}"
+ [ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
+ --pretty='%ct' HEAD)" || versiondate="${versiondate_}"
+
+ [ -z ${versiondate} ] && err "Unknown version date"
+ [ -z ${version} ] && err "Unknown version"
+
+ printf "%s\n" "${version}" > version
+ printf "%s\n" "${versiondate}" > versiondate
+}
+
setvars()
{
_setvars=""
diff --git a/lbmk b/lbmk
index f4544418..6ccf4db5 100755
--- a/lbmk
+++ b/lbmk
@@ -12,12 +12,10 @@ set -u -e
. "include/export.sh"
. "include/option.sh"
-read projectname < projectname
linkpath="${0}"
linkname="${linkpath##*/}"
buildpath="./script/${linkname}"
-mode=""
-option=""
+eval "$(setvars "" mode option project version versiondate)"
main()
{
@@ -25,8 +23,8 @@ main()
initialise_command $@
shift 2
- ./checkgit || fail "Please read: https://libreboot.org/docs/build/"
- ./checkversion || fail "Cannot check ${projectname} version"
+ check_git
+ check_project
execute_command $@
lbmk_exit 0
@@ -101,7 +99,7 @@ usage()
Example: ./build grub list, which would yield:
$(./build grub list)
- Refer to ${projectname} documentation for more info.
+ Refer to ${project} documentation for more info.
EOF
}
diff --git a/script/build/release/src b/script/build/release/src
index 6dae201c..6c7d3190 100755
--- a/script/build/release/src
+++ b/script/build/release/src
@@ -16,8 +16,7 @@ download_only_list="pico-serprog stm32-vserprog"
dirlist="config util script include util-fw"
linklist="build update handle" # symlinks in main directory, to script: lbmk
-filelist="lbmk README.md COPYING version versiondate projectname checkgit"
-filelist="${filelist} checkversion"
+filelist="lbmk README.md COPYING version versiondate projectname"
version="version-unknown"
versiondate="version-date-unknown"