include/err.sh: checkgit,checkversion
call these as functions, instead of executing scripts Signed-off-by: Leah Rowe <leah@libreboot.org>btrfsvols
parent
e638c3e411
commit
fbd464b4f7
27
checkgit
27
checkgit
|
@ -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 $@
|
|
34
checkversion
34
checkversion
|
@ -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
|
|
|
@ -8,6 +8,37 @@ xx_() {
|
||||||
[ $# -lt 1 ] || ${@} || fail "non-zero exit status: ${@}"
|
[ $# -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()
|
||||||
{
|
{
|
||||||
_setvars=""
|
_setvars=""
|
||||||
|
|
10
lbmk
10
lbmk
|
@ -12,12 +12,10 @@ set -u -e
|
||||||
. "include/export.sh"
|
. "include/export.sh"
|
||||||
. "include/option.sh"
|
. "include/option.sh"
|
||||||
|
|
||||||
read projectname < projectname
|
|
||||||
linkpath="${0}"
|
linkpath="${0}"
|
||||||
linkname="${linkpath##*/}"
|
linkname="${linkpath##*/}"
|
||||||
buildpath="./script/${linkname}"
|
buildpath="./script/${linkname}"
|
||||||
mode=""
|
eval "$(setvars "" mode option project version versiondate)"
|
||||||
option=""
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
@ -25,8 +23,8 @@ main()
|
||||||
initialise_command $@
|
initialise_command $@
|
||||||
shift 2
|
shift 2
|
||||||
|
|
||||||
./checkgit || fail "Please read: https://libreboot.org/docs/build/"
|
check_git
|
||||||
./checkversion || fail "Cannot check ${projectname} version"
|
check_project
|
||||||
|
|
||||||
execute_command $@
|
execute_command $@
|
||||||
lbmk_exit 0
|
lbmk_exit 0
|
||||||
|
@ -101,7 +99,7 @@ usage()
|
||||||
Example: ./build grub list, which would yield:
|
Example: ./build grub list, which would yield:
|
||||||
$(./build grub list)
|
$(./build grub list)
|
||||||
|
|
||||||
Refer to ${projectname} documentation for more info.
|
Refer to ${project} documentation for more info.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@ download_only_list="pico-serprog stm32-vserprog"
|
||||||
|
|
||||||
dirlist="config util script include util-fw"
|
dirlist="config util script include util-fw"
|
||||||
linklist="build update handle" # symlinks in main directory, to script: lbmk
|
linklist="build update handle" # symlinks in main directory, to script: lbmk
|
||||||
filelist="lbmk README.md COPYING version versiondate projectname checkgit"
|
filelist="lbmk README.md COPYING version versiondate projectname"
|
||||||
filelist="${filelist} checkversion"
|
|
||||||
|
|
||||||
version="version-unknown"
|
version="version-unknown"
|
||||||
versiondate="version-date-unknown"
|
versiondate="version-date-unknown"
|
||||||
|
|
Loading…
Reference in New Issue