summaryrefslogtreecommitdiff
path: root/resources/scripts/build/coreboot/utils
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-08-24 00:30:07 +0100
committerLeah Rowe <leah@libreboot.org>2023-08-24 00:31:19 +0100
commit8f4f0e00ec3c307599f7f27777e3e92c1f9f6e4e (patch)
tree39ec749c16892b69cda00b6241714f475a1989b6 /resources/scripts/build/coreboot/utils
parent4c6c7d1088eb9dc0c9b2eeeb64febeeb78038583 (diff)
use the new coding style in scripts
there were stragglers left over from the last audit, and these stragglers still exist even after all the major re-factoring as of late the new style is: bsd-like coding style and error handling. verbose yet simple error handling. we use an "err" function in a way reminiscent of most C programs that you see in openbsd base (err.h) this style is very clean, resulting in readable code Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'resources/scripts/build/coreboot/utils')
-rwxr-xr-xresources/scripts/build/coreboot/utils28
1 files changed, 15 insertions, 13 deletions
diff --git a/resources/scripts/build/coreboot/utils b/resources/scripts/build/coreboot/utils
index e24378d3..d381f9e2 100755
--- a/resources/scripts/build/coreboot/utils
+++ b/resources/scripts/build/coreboot/utils
@@ -21,10 +21,12 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
-printf "Building coreboot utils\n"
+. "include/err.sh"
main()
{
+ printf "Building coreboot utils\n"
+
if [ $# -gt 0 ]; then
for board in "${@}"; do
build_for_mainboard ${board} || \
@@ -45,28 +47,28 @@ build_for_mainboard() {
[ -f "resources/coreboot/${board}/target.cfg" ] || continue
tree="undefined"
. "resources/coreboot/${board}/target.cfg" # source
- if [ "${tree}" = "undefined" ]; then
- printf "build/cbutils: improper tree definition for '%s'" \
- "${board}"
- return 1
- fi
- buildutils "${tree}" || return 1
+ [ "${tree}" = "undefined" ] && \
+ err "build/cbutils: improper tree definition for '${board}'"
+ buildutils "${tree}"
}
buildutils() {
tree="${1}"
[ -d "coreboot/${tree}/" ] || \
- ./fetch_trees coreboot $tree || return 1
+ ./fetch_trees coreboot $tree || \
+ err "cannot fetch ${tree}"
for util in cbfstool ifdtool; do
[ -f "cbutils/${tree}/${util}" ] && continue
[ -d "cbutils/${tree}" ] || \
- mkdir -p "cbutils/${tree}" || return 1
+ mkdir -p "cbutils/${tree}" || \
+ err "cannot create directory, cbutils/${tree}"
utildir="coreboot/${tree}/util/${util}"
- make distclean -C "${utildir}" || return 1
- make -j$(nproc) -C "${utildir}" || return 1
- mv "${utildir}/${util}" "cbutils/${tree}" || return 1
- make distclean -C "${utildir}" || return 1
+ make distclean -C "${utildir}" || err "cannot clean ${utildir}"
+ make -j$(nproc) -C "${utildir}" || err "cannot build ${utildir}"
+ cp "${utildir}/${util}" "cbutils/${tree}" || \
+ err "cannot copy util, ${util}, to cbutils/${tree}/"
+ make distclean -C "${utildir}" || err "can't clean ${utildir}"
done
}