build/grub/*: move common strings to variables

also general cleanup of these scripts

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-09-25 03:06:43 +01:00
parent e94ba1f7c0
commit 42c9d7d28c
2 changed files with 22 additions and 23 deletions

View File

@ -5,15 +5,15 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v [ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e set -u -e
elfdir="elf/grub"
grubcfgsdir="config/grub" grubcfgsdir="config/grub"
layoutdir="/boot/grub/layouts"
. "include/err.sh" . "include/err.sh"
. "${grubcfgsdir}/modules.list" . "${grubcfgsdir}/modules.list"
main() main()
{ {
printf "Creating GRUB payloads and configuration files\n"
handle_dependencies handle_dependencies
build_keymap_configs build_keymap_configs
build_grub_payload build_grub_payload
@ -27,11 +27,11 @@ handle_dependencies()
[ -f "grub/grub-mkstandalone" ] || \ [ -f "grub/grub-mkstandalone" ] || \
./build grub utils || \ ./build grub utils || \
err "handle_dependencies: cannot build grub utils" err "handle_dependencies: cannot build grub utils"
[ -d "elf/grub" ] || \ [ -d "${elfdir}" ] || \
mkdir -p elf/grub || \ mkdir -p "${elfdir}" || \
err "handle_dependencies: cannot mkdir elf/grub" err "handle_dependencies: cannot mkdir ${elfdir}"
rm -f elf/grub/* || \ rm -f "${elfdir}/"* || \
err "handle_dependencies: cannot rm inside: elf/grub/" err "handle_dependencies: cannot rm inside: ${elfdir}/"
} }
build_keymap_configs() build_keymap_configs()
@ -41,8 +41,8 @@ build_keymap_configs()
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}" keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
keymap="${keymap%.gkb}" keymap="${keymap%.gkb}"
printf "keymap %s\n" "${keymap}" > \ printf "keymap %s\n" "${keymap}" > \
"elf/grub/keymap_${keymap}.cfg" || \ "${elfdir}/keymap_${keymap}.cfg" || \
err "make_keymapcfgs: cannot create elf/grub/keymap_${keymap}.cfg" err "mk_keymap: can't make ${elfdir}/keymap_${keymap}.cfg"
done done
} }
@ -51,23 +51,23 @@ build_grub_payload()
grub/grub-mkstandalone \ grub/grub-mkstandalone \
--grub-mkimage="grub/grub-mkimage" \ --grub-mkimage="grub/grub-mkimage" \
-O i386-coreboot \ -O i386-coreboot \
-o "elf/grub/grub.elf" \ -o "${elfdir}/grub.elf" \
-d grub/grub-core/ \ -d grub/grub-core/ \
--fonts= --themes= --locales= \ --fonts= --themes= --locales= \
--modules="${grub_modules}" \ --modules="${grub_modules}" \
--install-modules="${grub_install_modules}" \ --install-modules="${grub_install_modules}" \
"/boot/grub/layouts/colemak.gkb=${grubcfgsdir}/keymap/colemak.gkb" \ "${layoutdir}/colemak.gkb=${grubcfgsdir}/keymap/colemak.gkb" \
"/boot/grub/layouts/deqwertz.gkb=${grubcfgsdir}/keymap/deqwertz.gkb" \ "${layoutdir}/deqwertz.gkb=${grubcfgsdir}/keymap/deqwertz.gkb" \
"/boot/grub/layouts/esqwerty.gkb=${grubcfgsdir}/keymap/esqwerty.gkb" \ "${layoutdir}/esqwerty.gkb=${grubcfgsdir}/keymap/esqwerty.gkb" \
"/boot/grub/layouts/frazerty.gkb=${grubcfgsdir}/keymap/frazerty.gkb" \ "${layoutdir}/frazerty.gkb=${grubcfgsdir}/keymap/frazerty.gkb" \
"/boot/grub/layouts/frdvbepo.gkb=${grubcfgsdir}/keymap/frdvbepo.gkb" \ "${layoutdir}/frdvbepo.gkb=${grubcfgsdir}/keymap/frdvbepo.gkb" \
"/boot/grub/layouts/itqwerty.gkb=${grubcfgsdir}/keymap/itqwerty.gkb" \ "${layoutdir}/itqwerty.gkb=${grubcfgsdir}/keymap/itqwerty.gkb" \
"/boot/grub/layouts/svenska.gkb=${grubcfgsdir}/keymap/svenska.gkb" \ "${layoutdir}/svenska.gkb=${grubcfgsdir}/keymap/svenska.gkb" \
"/boot/grub/layouts/trqwerty.gkb=${grubcfgsdir}/keymap/trqwerty.gkb" \ "${layoutdir}/trqwerty.gkb=${grubcfgsdir}/keymap/trqwerty.gkb" \
"/boot/grub/layouts/ukdvorak.gkb=${grubcfgsdir}/keymap/ukdvorak.gkb" \ "${layoutdir}/ukdvorak.gkb=${grubcfgsdir}/keymap/ukdvorak.gkb" \
"/boot/grub/layouts/ukqwerty.gkb=${grubcfgsdir}/keymap/ukqwerty.gkb" \ "${layoutdir}/ukqwerty.gkb=${grubcfgsdir}/keymap/ukqwerty.gkb" \
"/boot/grub/layouts/usdvorak.gkb=${grubcfgsdir}/keymap/usdvorak.gkb" \ "${layoutdir}/usdvorak.gkb=${grubcfgsdir}/keymap/usdvorak.gkb" \
"/boot/grub/layouts/usqwerty.gkb=${grubcfgsdir}/keymap/usqwerty.gkb" \ "${layoutdir}/usqwerty.gkb=${grubcfgsdir}/keymap/usqwerty.gkb" \
"/boot/grub/grub.cfg=${grubcfgsdir}/config/grub_memdisk.cfg" \ "/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)" err "build_grub_elf: cannot build grub payload (grub-mkstandalone)"

View File

@ -10,7 +10,6 @@ set -u -e
main() main()
{ {
printf "Building GRUB\n"
[ -d "grub/" ] || ./update project repo grub || err "cannot fetch grub" [ -d "grub/" ] || ./update project repo grub || err "cannot fetch grub"
build_grub build_grub
} }