summaryrefslogtreecommitdiff
path: root/resources/scripts/build
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-05-20 20:07:22 +0100
committerLeah Rowe <leah@libreboot.org>2023-05-20 20:07:22 +0100
commit8e206be7c842e2e6487d6b57b573b2d198b6b960 (patch)
tree65b993acc8742d1825c3afb37febaae548f58616 /resources/scripts/build
parentdb7e81612ade9e0a89b312e536c47d612f8e1088 (diff)
build/payload/grub: split logic into functions
main() on top top-down logic Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'resources/scripts/build')
-rwxr-xr-xresources/scripts/build/payload/grub58
1 files changed, 39 insertions, 19 deletions
diff --git a/resources/scripts/build/payload/grub b/resources/scripts/build/payload/grub
index 020a5cbc..de644006 100755
--- a/resources/scripts/build/payload/grub
+++ b/resources/scripts/build/payload/grub
@@ -22,33 +22,55 @@
set -u -e
grubcfgsdir="resources/grub"
+keymap=""
. "${grubcfgsdir}/modules.list"
-printf "Creating GRUB payloads and configuration files\n"
+main()
+{
+ printf "Creating GRUB payloads and configuration files\n"
-if [ ! -d "grub/" ]; then
- ./download grub
-fi
+ [ ! -d "grub/" ] && \
+ ./download grub
+ [ ! -f "grub/grub-mkstandalone" ] && \
+ ./build module grub
+ [ ! -d "payload/" ] && \
+ mkdir -p payload/
+ [ ! -d "payload/grub" ] && \
+ mkdir -p payload/grub/
-if [ ! -f "grub/grub-mkstandalone" ]; then
- ./build module grub
-fi
+ rm -f payload/grub/*
-[ ! -d "payload/" ] && mkdir -p payload/
-[ ! -d "payload/grub" ] && mkdir -p payload/grub/
+ # Separate GRUB payload per keymap to save space in ROM.
-rm -f payload/grub/*
+ for keylayoutfile in ${grubcfgsdir}/keymap/*.gkb; do
+ build_grub_payload "${keylayoutfile}"
+ done
-# Separate GRUB payload per keymap to save space in ROM.
+ printf "Done! Check payload/grub/ to see the files.\n\n"
+}
+
+build_grub_payload()
+{
+ keylayoutfile=${1}
-for keylayoutfile in ${grubcfgsdir}/keymap/*.gkb; do
if [ ! -f "${keylayoutfile}" ]; then
continue
fi
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
keymap="${keymap%.gkb}"
+ build_grub_elf "${keylayoutfile}"
+ create_grub_configs
+
+ printf "Created 'payload/grub/grub_%s.elf' and configs.'\n" \
+ "${keymap}"
+}
+
+build_grub_elf()
+{
+ keylayoutfile=${1}
+
gcfg="/boot/grub/grub.cfg=${grubcfgsdir}"
gcfg="${gcfg}/config/grub_memdisk.cfg"
grubk="/boot/grub/layouts/${keymap}.gkb=${keylayoutfile}"
@@ -61,8 +83,10 @@ for keylayoutfile in ${grubcfgsdir}/keymap/*.gkb; do
--modules="${grub_modules}" \
--install-modules="${grub_install_modules}" \
${gcfg} ${grubk}
+}
-
+create_grub_configs()
+{
if [ "${keymap}" = "usqwerty" ]; then
cp ${grubcfgsdir}/config/grub.cfg \
payload/grub/grub_usqwerty.cfg
@@ -71,13 +95,9 @@ for keylayoutfile in ${grubcfgsdir}/keymap/*.gkb; do
< ${grubcfgsdir}/config/grub.cfg \
> payload/grub/grub_${keymap}.cfg
fi
-
sed "s/grubtest.cfg/grub.cfg/" \
< payload/grub/grub_${keymap}.cfg \
> payload/grub/grub_${keymap}_test.cfg
+}
- printf "Created 'payload/grub/grub_%s.elf' and configs.'\n" \
- "${keymap}"
-done
-
-printf "Done! Check payload/grub/ to see the files.\n\n"
+main $@