unify err functions across scripts

include/err.sh

this new handling also does mundane things,
such as tell you what script b0rked

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2023-08-23 18:56:31 +01:00
parent b3fbcdf66e
commit 57adbc6eb1
17 changed files with 127 additions and 175 deletions
+10 -15
View File
@@ -24,6 +24,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
. "include/err.sh"
projectname="$(cat projectname)"
buildpath=""
mode=""
@@ -31,8 +33,8 @@ option=""
main()
{
[ "${0##*/}" = "lbmk" ] && die "Don't run this script directly."
[ $# -lt 1 ] && die "Too few arguments. Try: ${0} help"
[ "${0##*/}" = "lbmk" ] && err "Don't run this script directly."
[ $# -lt 1 ] && err "Too few arguments. Try: ${0} help"
buildpath="./resources/scripts/${0##*/}"
@@ -41,7 +43,7 @@ main()
[ "${mode}" = "help" ] && usage ${0} && exit 0
[ $# -lt 2 ] && usage ${0} && exit 1
if [ "${mode}" = "dependencies" ]; then
install_dependencies $@ || die "Could not install dependencies"
install_dependencies $@ || err "Could not install dependencies"
exit 0
else
./resources/scripts/misc/versioncheck
@@ -62,13 +64,13 @@ main()
*)
if [ ! -d "${buildpath}/${mode}" ]; then
usage $0
die "Invalid mode '${mode}'. Run: ${0} help"
err "Invalid mode '${mode}'. Run: ${0} help"
elif [ ! -f "${buildpath}/${mode}/${option}" ]; then
usage $0
printf "Invalid option for '%s'." ${mode}
die "Run: ${0} ${mode} list'."
err "Run: ${0} ${mode} list'."
fi
"${buildpath}/${mode}/${option}" $@ || die "lbmk error"
"${buildpath}/${mode}/${option}" $@ || err "lbmk error"
esac
./.gitcheck clean
@@ -76,12 +78,12 @@ main()
install_dependencies()
{
[ -f "resources/dependencies/${2}" ] || die "Unsupported target"
[ -f "resources/dependencies/${2}" ] || err "Unsupported target"
aur_notice=""
. "resources/dependencies/${2}"
${pkg_add} ${pkglist} || die "Error installing dependencies"
${pkg_add} ${pkglist} || err "Error installing dependencies"
[ "${aur_notice}" != "" ] && \
printf "You must install these AUR packages: %s\n" \
"${aur_notice}" 1>&2
@@ -120,11 +122,4 @@ listmodes()
done
}
die()
{
./.gitcheck clean
printf "Error: %s\n" "${@}" 1>&2
exit 1
}
main $@