summaryrefslogtreecommitdiff
path: root/script/build/grub/payload
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-25 02:57:45 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-25 02:57:45 +0100
commite94ba1f7c0f83bfcd20d56795d788ad4b7c8d550 (patch)
tree678aec8edd6a230be1947113ef714a16846af9b1 /script/build/grub/payload
parentb727f9666b457666efaa861caeb7d1ed73e646c3 (diff)
build/grub/payload: split up main()
also: the grub-mkstandalone command didn't have a || at the end, even though it did specify an err call. This has been corrected, so that the command now defers to err() under fault conditions. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build/grub/payload')
-rwxr-xr-xscript/build/grub/payload45
1 files changed, 25 insertions, 20 deletions
diff --git a/script/build/grub/payload b/script/build/grub/payload
index b9e5ff75..a21e8f68 100755
--- a/script/build/grub/payload
+++ b/script/build/grub/payload
@@ -5,10 +5,9 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
-. "include/err.sh"
-
grubcfgsdir="config/grub"
+. "include/err.sh"
. "${grubcfgsdir}/modules.list"
main()
@@ -16,7 +15,27 @@ main()
printf "Creating GRUB payloads and configuration files\n"
handle_dependencies
+ build_keymap_configs
+ build_grub_payload
+}
+
+handle_dependencies()
+{
+ [ -d "grub/" ] || \
+ ./update project repo grub || \
+ err "handle_dependencies: cannot fetch grub"
+ [ -f "grub/grub-mkstandalone" ] || \
+ ./build grub utils || \
+ err "handle_dependencies: cannot build grub utils"
+ [ -d "elf/grub" ] || \
+ mkdir -p elf/grub || \
+ err "handle_dependencies: cannot mkdir elf/grub"
+ rm -f elf/grub/* || \
+ err "handle_dependencies: cannot rm inside: elf/grub/"
+}
+build_keymap_configs()
+{
for keylayoutfile in "${grubcfgsdir}/keymap/"*.gkb; do
[ -f "${keylayoutfile}" ] || continue
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
@@ -25,7 +44,10 @@ main()
"elf/grub/keymap_${keymap}.cfg" || \
err "make_keymapcfgs: cannot create elf/grub/keymap_${keymap}.cfg"
done
+}
+build_grub_payload()
+{
grub/grub-mkstandalone \
--grub-mkimage="grub/grub-mkimage" \
-O i386-coreboot \
@@ -47,25 +69,8 @@ main()
"/boot/grub/layouts/usdvorak.gkb=${grubcfgsdir}/keymap/usdvorak.gkb" \
"/boot/grub/layouts/usqwerty.gkb=${grubcfgsdir}/keymap/usqwerty.gkb" \
"/boot/grub/grub.cfg=${grubcfgsdir}/config/grub_memdisk.cfg" \
- "/boot/grub/grub_default.cfg=${grubcfgsdir}/config/grub.cfg" \
+ "/boot/grub/grub_default.cfg=${grubcfgsdir}/config/grub.cfg" || \
err "build_grub_elf: cannot build grub payload (grub-mkstandalone)"
-
- printf "\nDone! Check elf/grub/\n\n"
-}
-
-handle_dependencies()
-{
- [ -d "grub/" ] || \
- ./update project repo grub || \
- err "handle_dependencies: cannot fetch grub"
- [ -f "grub/grub-mkstandalone" ] || \
- ./build grub utils || \
- err "handle_dependencies: cannot build grub utils"
- [ -d "elf/grub" ] || \
- mkdir -p elf/grub || \
- err "handle_dependencies: cannot mkdir elf/grub"
- rm -f elf/grub/* || \
- err "handle_dependencies: cannot rm inside: elf/grub/"
}
main $@