summaryrefslogtreecommitdiff
path: root/resources/scripts/build/grub
diff options
context:
space:
mode:
Diffstat (limited to 'resources/scripts/build/grub')
-rwxr-xr-xresources/scripts/build/grub/payload34
1 files changed, 20 insertions, 14 deletions
diff --git a/resources/scripts/build/grub/payload b/resources/scripts/build/grub/payload
index 4886a874..7f1d239f 100755
--- a/resources/scripts/build/grub/payload
+++ b/resources/scripts/build/grub/payload
@@ -21,6 +21,8 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+. "include/err.sh"
+
grubcfgsdir="resources/grub"
keymap=""
@@ -30,26 +32,29 @@ main()
{
printf "Creating GRUB payloads and configuration files\n"
- [ ! -d "grub/" ] && \
- ./fetch grub
- [ ! -f "grub/grub-mkstandalone" ] && \
- ./build grub utils
- [ ! -d "elf/" ] && \
- mkdir -p elf/
- [ ! -d "elf/grub" ] && \
- mkdir -p elf/grub/
-
- rm -f elf/grub/*
+ handle_dependencies
# Separate GRUB payload per keymap to save space in ROM.
-
for keylayoutfile in ${grubcfgsdir}/keymap/*.gkb; do
+ [ -f "${keylayoutfile}" ] || continue
build_grub_payloads "${keylayoutfile}"
done
printf "Done! Check elf/grub/ to see the files.\n\n"
}
+handle_dependencies()
+{
+ [ -d "grub/" ] || \
+ ./fetch grub || err "cannot fetch grub"
+ [ -f "grub/grub-mkstandalone" ] || \
+ ./build grub utils || err "cannot build grub utils"
+ [ -d "elf/grub" ] || \
+ mkdir -p elf/grub || err "cannot create directory, elf/grub"
+
+ rm -f elf/grub/* || err "cannot delete files in directory, elf/grub/"
+}
+
build_grub_payloads()
{
keylayoutfile=${1}
@@ -79,15 +84,16 @@ build_grub_elf()
--fonts= --themes= --locales= \
--modules="${grub_modules}" \
--install-modules="${grub_install_modules}" \
- ${gcfg} ${grubk}
+ ${gcfg} ${grubk} || \
+ err "cannot create grub payload (grub-mkstandalone)"
}
create_grub_config()
{
sed "s/usqwerty/${keymap}/" < ${grubcfgsdir}/config/grub.cfg \
- > elf/grub/grub_${keymap}.cfg
+ > elf/grub/grub_${keymap}.cfg || err "sed failed: grub.cfg"
sed "s/grubtest.cfg/grub.cfg/" < elf/grub/grub_${keymap}.cfg \
- > elf/grub/grub_${keymap}_test.cfg
+ > elf/grub/grub_${keymap}_test.cfg || err "sed failed: grubtest.cfg"
}
main $@