diff options
author | Leah Rowe <leah@libreboot.org> | 2023-08-28 18:10:35 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-08-29 02:03:16 +0100 |
commit | eb54e427e6f0d447a120c55165e797e73d123396 (patch) | |
tree | 8ddd38178b99d1c73bee84c1ebcda7196fccdde7 /script/build/grub/payload | |
parent | c6fd4d2ad33a6407a442eb20f31e34cf7aabd352 (diff) |
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build/grub/payload')
-rwxr-xr-x | script/build/grub/payload | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/script/build/grub/payload b/script/build/grub/payload index 63849bac..f8a49b64 100755 --- a/script/build/grub/payload +++ b/script/build/grub/payload @@ -24,7 +24,6 @@ set -u -e . "include/err.sh" grubcfgsdir="resources/grub" -keymap="" . "${grubcfgsdir}/modules.list" @@ -34,13 +33,40 @@ main() handle_dependencies - # Separate GRUB payload per keymap to save space in ROM. - for keylayoutfile in ${grubcfgsdir}/keymap/*.gkb; do + for keylayoutfile in "${grubcfgsdir}/keymap/"*.gkb; do [ -f "${keylayoutfile}" ] || continue - build_grub_payloads "${keylayoutfile}" + keymap="${keylayoutfile##${grubcfgsdir}/keymap/}" + keymap="${keymap%.gkb}" + printf "keymap %s\n" "${keymap}" > \ + "elf/grub/keymap_${keymap}.cfg" || \ + err "make_keymapcfgs: cannot create elf/grub/keymap_${keymap}.cfg" done - printf "Done! Check elf/grub/ to see the files.\n\n" + grub/grub-mkstandalone \ + --grub-mkimage="grub/grub-mkimage" \ + -O i386-coreboot \ + -o "elf/grub/grub.elf" \ + -d grub/grub-core/ \ + --fonts= --themes= --locales= \ + --modules="${grub_modules}" \ + --install-modules="${grub_install_modules}" \ + "/boot/grub/layouts/colemak.gkb=${grubcfgsdir}/keymap/colemak.gkb" \ + "/boot/grub/layouts/deqwertz.gkb=${grubcfgsdir}/keymap/deqwertz.gkb" \ + "/boot/grub/layouts/esqwerty.gkb=${grubcfgsdir}/keymap/esqwerty.gkb" \ + "/boot/grub/layouts/frazerty.gkb=${grubcfgsdir}/keymap/frazerty.gkb" \ + "/boot/grub/layouts/frdvbepo.gkb=${grubcfgsdir}/keymap/frdvbepo.gkb" \ + "/boot/grub/layouts/itqwerty.gkb=${grubcfgsdir}/keymap/itqwerty.gkb" \ + "/boot/grub/layouts/svenska.gkb=${grubcfgsdir}/keymap/svenska.gkb" \ + "/boot/grub/layouts/trqwerty.gkb=${grubcfgsdir}/keymap/trqwerty.gkb" \ + "/boot/grub/layouts/ukdvorak.gkb=${grubcfgsdir}/keymap/ukdvorak.gkb" \ + "/boot/grub/layouts/ukqwerty.gkb=${grubcfgsdir}/keymap/ukqwerty.gkb" \ + "/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" \ + err "build_grub_elf: cannot build grub payload (grub-mkstandalone)" + + printf "\nDone! Check elf/grub/\n\n" } handle_dependencies() @@ -58,47 +84,4 @@ handle_dependencies() err "handle_dependencies: cannot rm inside: elf/grub/" } -build_grub_payloads() -{ - keylayoutfile=${1} - [ -f "${keylayoutfile}" ] || continue - - keymap="${keylayoutfile##${grubcfgsdir}/keymap/}" - keymap="${keymap%.gkb}" - - build_grub_elf "${keylayoutfile}" - create_grub_config - - printf "Created 'elf/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}" - grub/grub-mkstandalone \ - --grub-mkimage="grub/grub-mkimage" \ - -O i386-coreboot \ - -o "elf/grub/grub_${keymap}.elf" \ - -d grub/grub-core/ \ - --fonts= --themes= --locales= \ - --modules="${grub_modules}" \ - --install-modules="${grub_install_modules}" \ - "${gcfg}" "${grubk}" || \ - err "build_grub_elf: cannot build grub payload (grub-mkstandalone)" -} - -create_grub_config() -{ - sed "s/usqwerty/${keymap}/" < "${grubcfgsdir}/config/grub.cfg" \ - > "elf/grub/grub_${keymap}.cfg" || \ - err "create_grub_config: sed failed: grub.cfg" - sed "s/grubtest.cfg/grub.cfg/" < "elf/grub/grub_${keymap}.cfg" \ - > "elf/grub/grub_${keymap}_test.cfg" || \ - err "create_grub_config: sed failed: grubtest.cfg" -} - main $@ |