blob: 5fa47c00525f237ceaf9b31215bb6414eb71f3bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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}"
rm -f "${elfdir}/"* || err "!rm elf, handle_, ${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
make -j$(nproc) FS_PAYLOAD_MODULES="" || err "!mk grub utils"
) || err "grub build error"
}
build_keymap_configs()
{
for keylayoutfile in "${grubcfgsdir}/keymap/"*.gkb; do
[ -f "${keylayoutfile}" ] || continue
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
keymap="${keymap%.gkb}"
printf "keymap %s\n" "${keymap}" > \
"${elfdir}/keymap_${keymap}.cfg" || err "!insert keymap"
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 $@
|