summaryrefslogtreecommitdiff
path: root/script/build/grub/utils
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-10-01 06:33:43 +0100
committerLeah Rowe <leah@libreboot.org>2023-10-01 22:47:02 +0100
commit8c03b886c4d4b9bcfb1cb30b3704b8af561c2f45 (patch)
tree828eb1ad589300517e9a41581eee4b5d9605d3e8 /script/build/grub/utils
parent5f914a4d00da5ab9324c55eaecc40aa2ee000f63 (diff)
Greatly simplify error handling in shell scripts
Instead of having detailed error messages, run most commands through a function that calls err() under fault conditions. Where detail is still required, err() is still called manually. Where it isn't, the error message is simply whatever command was executed to cause the error. This results in a massive sloccount reduction for lbmk; specifically, 178 sloc reduction, or a 8.1% reduction. The total sloccount is now 2022, for shell scripts. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build/grub/utils')
-rwxr-xr-xscript/build/grub/utils20
1 files changed, 7 insertions, 13 deletions
diff --git a/script/build/grub/utils b/script/build/grub/utils
index 3c463e6d..edb78bb1 100755
--- a/script/build/grub/utils
+++ b/script/build/grub/utils
@@ -10,25 +10,19 @@ set -u -e
main()
{
- [ -d "grub/" ] || ./update project repo grub || err "cannot fetch grub"
+ [ -d "grub/" ] || x_ ./update project repo grub
build_grub
}
build_grub()
{
(
- cd grub/ || \
- err "build_grub: cd"
- [ ! -d Makefile ] || make distclean || \
- err "build_grub: make-distclean"
- ./bootstrap --gnulib-srcdir=gnulib/ --no-git || \
- err "build_grub: gnulib bootstrap"
- ./autogen.sh || \
- err "build_grub: autogen.sh"
- ./configure --with-platform=coreboot || \
- err "build_grub: autoconf"
- make -j$(nproc) FS_PAYLOAD_MODULES="" || \
- err "build_grub: make"
+ x_ cd grub/
+ [ ! -d Makefile ] || x_ make distclean
+ x_ ./bootstrap --gnulib-srcdir=gnulib/ --no-git
+ x_ ./autogen.sh
+ x_ ./configure --with-platform=coreboot
+ x_ make -j$(nproc) FS_PAYLOAD_MODULES=""
)
}