summaryrefslogtreecommitdiff
path: root/script/build/grub
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-10-20 00:17:30 +0100
committerLeah Rowe <leah@libreboot.org>2023-10-20 01:00:38 +0100
commit8d9aeef3de28bcb908e33b804517bdeacce7be38 (patch)
treeda6c27fa43780232300898052005617ea155aba2 /script/build/grub
parent0b98c9b00c6b99940555cff25f7c6858745a560c (diff)
lbmk: use 2-level directory structure in script/
as opposed to the current 3-level structure. recent build system simplifications have enabled this change, thus: ./build fw coreboot -> ./build roms ./build fw grub -> ./build grub ./build fw serprog -> ./build serprog ./update project release -> ./update release ./update project trees -> ./update trees ./update vendor download -> ./vendor download ./update vendor inject -> ./vendor inject alper criticised that the commands were too long, so i made them shorter! Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build/grub')
-rwxr-xr-xscript/build/grub82
1 files changed, 82 insertions, 0 deletions
diff --git a/script/build/grub b/script/build/grub
new file mode 100755
index 00000000..ba0845d3
--- /dev/null
+++ b/script/build/grub
@@ -0,0 +1,82 @@
+#!/usr/bin/env sh
+# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-FileCopyrightText: 2014,2015,2020,2021,2023 Leah Rowe <leah@libreboot.org>
+
+[ "x${DEBUG+set}" = 'xset' ] && set -v
+set -u -e
+
+. "include/err.sh"
+
+elfdir="elf/grub"
+grubcfgsdir="config/grub"
+layoutdir="/boot/grub/layouts"
+
+. "${grubcfgsdir}/modules.list"
+
+main()
+{
+ handle_dependencies
+ build_keymap_configs
+ build_grub_payload
+ printf "GRUB files now available under directory: %s\n" "${elfdir}"
+}
+
+handle_dependencies()
+{
+ [ -d "src/grub" ] || x_ ./update trees -f grub
+ [ -f "src/grub/grub-mkstandalone" ] || build_grub_utils
+ x_ mkdir -p "${elfdir}"
+ x_ rm -f "${elfdir}/"*
+}
+
+build_grub_utils()
+{
+ (
+ x_ cd "src/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=""
+ )
+}
+
+build_keymap_configs()
+{
+ for keylayoutfile in "${grubcfgsdir}/keymap/"*.gkb; do
+ [ -f "${keylayoutfile}" ] || continue
+ keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
+ keymap="${keymap%.gkb}"
+ x_ printf "keymap %s\n" "${keymap}" > \
+ "${elfdir}/keymap_${keymap}.cfg"
+ done
+}
+
+build_grub_payload()
+{
+ ./src/grub/grub-mkstandalone \
+ --grub-mkimage="src/grub/grub-mkimage" \
+ -O i386-coreboot \
+ -o "${elfdir}/grub.elf" \
+ -d "src/grub/grub-core/" \
+ --fonts= --themes= --locales= \
+ --modules="${grub_modules}" \
+ --install-modules="${grub_install_modules}" \
+ "${layoutdir}/colemak.gkb=${grubcfgsdir}/keymap/colemak.gkb" \
+ "${layoutdir}/deqwertz.gkb=${grubcfgsdir}/keymap/deqwertz.gkb" \
+ "${layoutdir}/esqwerty.gkb=${grubcfgsdir}/keymap/esqwerty.gkb" \
+ "${layoutdir}/frazerty.gkb=${grubcfgsdir}/keymap/frazerty.gkb" \
+ "${layoutdir}/frdvbepo.gkb=${grubcfgsdir}/keymap/frdvbepo.gkb" \
+ "${layoutdir}/itqwerty.gkb=${grubcfgsdir}/keymap/itqwerty.gkb" \
+ "${layoutdir}/svenska.gkb=${grubcfgsdir}/keymap/svenska.gkb" \
+ "${layoutdir}/trqwerty.gkb=${grubcfgsdir}/keymap/trqwerty.gkb" \
+ "${layoutdir}/ukdvorak.gkb=${grubcfgsdir}/keymap/ukdvorak.gkb" \
+ "${layoutdir}/ukqwerty.gkb=${grubcfgsdir}/keymap/ukqwerty.gkb" \
+ "${layoutdir}/usdvorak.gkb=${grubcfgsdir}/keymap/usdvorak.gkb" \
+ "${layoutdir}/usqwerty.gkb=${grubcfgsdir}/keymap/usqwerty.gkb" \
+ "/boot/grub/grub.cfg=${grubcfgsdir}/config/grub_memdisk.cfg" \
+ "/boot/grub/grub_default.cfg=${grubcfgsdir}/config/grub.cfg" || \
+ err "build_grub_elf: cannot build grub payload (grub-mkstandalone)"
+}
+
+main $@