2023-06-13 11:09:01 +00:00
|
|
|
#!/usr/bin/env sh
|
2023-09-25 01:19:30 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2023-09-25 01:27:26 +00:00
|
|
|
# SPDX-FileCopyrightText: 2014,2015,2020,2021,2023 Leah Rowe <leah@libreboot.org>
|
2021-05-18 12:56:12 +00:00
|
|
|
|
|
|
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
|
|
|
set -u -e
|
|
|
|
|
2023-10-06 21:59:36 +00:00
|
|
|
. "include/err.sh"
|
|
|
|
|
2023-09-25 02:06:43 +00:00
|
|
|
elfdir="elf/grub"
|
2023-09-04 01:36:41 +00:00
|
|
|
grubcfgsdir="config/grub"
|
2023-09-25 02:06:43 +00:00
|
|
|
layoutdir="/boot/grub/layouts"
|
2023-05-20 18:55:11 +00:00
|
|
|
|
2023-06-13 11:09:01 +00:00
|
|
|
. "${grubcfgsdir}/modules.list"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-05-20 19:07:22 +00:00
|
|
|
main()
|
|
|
|
{
|
2023-08-23 23:30:07 +00:00
|
|
|
handle_dependencies
|
2023-09-25 01:57:45 +00:00
|
|
|
build_keymap_configs
|
|
|
|
build_grub_payload
|
2023-10-07 05:08:03 +00:00
|
|
|
printf "GRUB files now available under directory: %s\n" "${elfdir}"
|
2023-09-25 01:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
handle_dependencies()
|
|
|
|
{
|
2023-10-19 23:17:30 +00:00
|
|
|
[ -d "src/grub" ] || x_ ./update trees -f grub
|
2023-10-06 21:59:36 +00:00
|
|
|
[ -f "src/grub/grub-mkstandalone" ] || build_grub_utils
|
|
|
|
x_ mkdir -p "${elfdir}"
|
2023-10-22 11:31:55 +00:00
|
|
|
rm -f "${elfdir}/"* || err "!rm elf, handle_, ${elfdir}/"
|
2023-09-25 01:57:45 +00:00
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-10-06 00:34:14 +00:00
|
|
|
build_grub_utils()
|
|
|
|
{
|
|
|
|
(
|
2023-10-06 21:59:36 +00:00
|
|
|
x_ cd "src/grub"
|
2023-10-06 00:34:14 +00:00
|
|
|
[ ! -d Makefile ] || x_ make distclean
|
|
|
|
x_ ./bootstrap --gnulib-srcdir=gnulib/ --no-git
|
|
|
|
x_ ./autogen.sh
|
|
|
|
x_ ./configure --with-platform=coreboot
|
2023-10-22 11:31:55 +00:00
|
|
|
make -j$(nproc) FS_PAYLOAD_MODULES="" || err "!mk grub utils"
|
2023-10-06 00:34:14 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-09-25 01:57:45 +00:00
|
|
|
build_keymap_configs()
|
|
|
|
{
|
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>
2023-08-28 17:10:35 +00:00
|
|
|
for keylayoutfile in "${grubcfgsdir}/keymap/"*.gkb; do
|
2023-08-23 23:30:07 +00:00
|
|
|
[ -f "${keylayoutfile}" ] || continue
|
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>
2023-08-28 17:10:35 +00:00
|
|
|
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
|
|
|
|
keymap="${keymap%.gkb}"
|
2023-10-22 11:31:55 +00:00
|
|
|
printf "keymap %s\n" "${keymap}" > \
|
|
|
|
"${elfdir}/keymap_${keymap}.cfg" || err "!insert keymap"
|
2023-05-20 19:07:22 +00:00
|
|
|
done
|
2023-09-25 01:57:45 +00:00
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-09-25 01:57:45 +00:00
|
|
|
build_grub_payload()
|
|
|
|
{
|
2023-10-06 21:59:36 +00:00
|
|
|
./src/grub/grub-mkstandalone \
|
|
|
|
--grub-mkimage="src/grub/grub-mkimage" \
|
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>
2023-08-28 17:10:35 +00:00
|
|
|
-O i386-coreboot \
|
2023-09-25 02:06:43 +00:00
|
|
|
-o "${elfdir}/grub.elf" \
|
2023-10-06 21:59:36 +00:00
|
|
|
-d "src/grub/grub-core/" \
|
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>
2023-08-28 17:10:35 +00:00
|
|
|
--fonts= --themes= --locales= \
|
|
|
|
--modules="${grub_modules}" \
|
|
|
|
--install-modules="${grub_install_modules}" \
|
2023-09-25 02:06:43 +00:00
|
|
|
"${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" \
|
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>
2023-08-28 17:10:35 +00:00
|
|
|
"/boot/grub/grub.cfg=${grubcfgsdir}/config/grub_memdisk.cfg" \
|
2023-09-25 01:57:45 +00:00
|
|
|
"/boot/grub/grub_default.cfg=${grubcfgsdir}/config/grub.cfg" || \
|
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>
2023-08-28 17:10:35 +00:00
|
|
|
err "build_grub_elf: cannot build grub payload (grub-mkstandalone)"
|
2023-08-23 23:30:07 +00:00
|
|
|
}
|
|
|
|
|
2023-05-20 19:07:22 +00:00
|
|
|
main $@
|