summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rwxr-xr-xscript/build/boot/roms_helper134
-rwxr-xr-xscript/build/grub/payload79
2 files changed, 82 insertions, 131 deletions
diff --git a/script/build/boot/roms_helper b/script/build/boot/roms_helper
index 5dea7fc0..64de5843 100755
--- a/script/build/boot/roms_helper
+++ b/script/build/boot/roms_helper
@@ -68,6 +68,8 @@ displaymode=""
cbcfg=""
targetdir=""
+grubelf="elf/grub/grub.elf"
+
main()
{
while [ $# -gt 0 ]; do
@@ -215,34 +217,21 @@ build_dependency_grub()
[ "${payload_grub}" != "y" ] && \
[ "${payload_seabios_withgrub}" != "y" ] && return 0
- if [ -f "elf/grub/grub_usqwerty.cfg" ]; then
- sha1sumcmd="sha1sum resources/grub/config/grub.cfg"
- grubrefchecksum="$(${sha1sumcmd} | awk '{print $1}')"
-
- sha1sumcmd="sha1sum elf/grub/grub_usqwerty.cfg"
- grubbuildchecksum="$(${sha1sumcmd} | awk '{print $1}')"
-
- [ "${grubrefchecksum}" != "${grubbuildchecksum}" ] && \
- printf "GRUB change detected. Re-building.\n" 1>&2
- else
- printf "GRUB not built yet. Building now.\n" 1>&2
- fi
- for keymapfile in "${kmapdir}"/*; do
+ rebuild_grub="n"
+ [ ! -f "${grubelf}" ] && rebuild_grub="y"
+ for keymapfile in "${kmapdir}"/*.gkb; do
+ [ "${rebuild_grub}" = "y" ] || break
[ -f "${keymapfile}" ] || continue
keymap="${keymapfile##*/}"
keymap="${keymap%.gkb}"
-
- grubelf="elf/grub/grub_${keymap}.elf"
- grubcfg="elf/grub/grub_${keymap}.cfg"
- grubtestcfg="elf/grub/grub_${keymap}_test.cfg"
-
- if [ ! -f "${grubelf}" ] || [ ! -f "${grubcfg}" ] || \
- [ ! -f "${grubtestcfg}" ]; then
- ./build grub payload || \
- err "cannot build grub payload"
- fi
+ [ ! -f "elf/grub/keymap_${keymap}.cfg" ] && \
+ rebuild_grub="y" && break
done
+ if [ "${rebuild_grub}" = "y" ]; then
+ ./build grub payload || \
+ err "build_dependency_grub: cannot build grub payload"
+ fi
}
build_dependency_uboot()
@@ -324,7 +313,8 @@ build_seabios_roms()
{
if [ "${payload_seabios_withgrub}" = "y" ]; then
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
- cp "${corebootrom}" "${tmprom}"
+ cp "${corebootrom}" "${tmprom}" || \
+ err "build_seabios_roms: cannot copy to tmprom"
build_grub_roms "${tmprom}" "${initmode}" \
"${displaymode}" "seabios_withgrub" || \
err "build_roms: cannot build grub roms, seabios w/grub"
@@ -356,18 +346,50 @@ build_grub_roms() {
displaymode="${3}"
firstpayloadname="${4}" # allow values: grub, seabios, seabios_withgrub
+ grubelf_cbfs="fallback/payload"
+
x=${tmprompath}
y=${initmode}
if [ "${payload_grub_withseabios}" = "y" ] && \
[ "${firstpayloadname}" = "grub" ]; then
mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}")" "${tmprompath}"
- elif [ "${payload_seabios_withgrub}" ] && \
+ elif [ "${payload_seabios_withgrub}" = "y" ] && \
[ "${firstpayloadname}" != "grub" ]; then
mv "$(mkSeabiosRom "${x}" "fallback/payload" "$y")" \
"${tmprompath}" || \
err "build_grub_roms: cannot move SeaBIOS ROM to tmprom"
+ grubelf_cbfs="img/grub2"
fi
+ # we only need insert grub.elf once, for each coreboot config:
+ "${cbfstool}" "${tmprompath}" add-payload -f "${grubelf}" \
+ -n ${grubelf_cbfs} -c lzma || \
+ err "build_grub_roms: cannot add grub payload to tmprom"
+
+ # we only need insert background.png once, for each coreboot config:
+ if [ "${displaymode}" = "vesafb" ] || \
+ [ "${displaymode}" = "corebootfb" ]; then
+ backgroundfile="background1280x800.png"
+ if [ "${board}" = "x60" ] \
+ || [ "${board}" = "t60_intelgpu" ]; then
+ # TODO: don't hardcode this. do it in target.cfg
+ backgroundfile="background1024x768.png"
+ fi
+ backgroundfile="resources/grub/background/${backgroundfile}"
+ "${cbfstool}" "${tmprompath}" add -f ${backgroundfile} \
+ -n background.png -t raw || \
+ err "build_grub_roms: cannot add background.png to tmprom"
+
+ fi
+
+ tmpscancfg=$(mktemp -t coreboot_rom.XXXXXXXXXX) ||
+ err "mkGrubRom: cannot create temporary scan.cfg"
+ printf "set grub_scan_disk=\"%s\"\n" "${grub_scan_disk}" > \
+ "${tmpscancfg}" || \
+ err "mkGrubRom: cannot insert into temporary scan.cfg"
+ "${cbfstool}" "${tmprompath}" add -f "${tmpscancfg}" -n scan.cfg \
+ -t raw || err "mkGrubROM: cannot insert scan.cfg into CBFS"
+
keymaps=""
if [ -z ${keyboard_layouts} ]; then
for kmapfile in "${kmapdir}"/*; do
@@ -386,16 +408,7 @@ build_grub_roms() {
keymap="${keymapfile##*/}"
keymap="${keymap%.gkb}"
- grub_path_in_cbfs="fallback/payload"
- [ "${firstpayloadname}" = "grub" ] || \
- grub_path_in_cbfs="img/grub2"
-
- # evil bofh rfc 2646 compliance hack
- x=${keymap}
- y=${tmprompath}
- z=${grub_path_in_cbfs}
-
- tmpgrubrom="$(mkGrubRom "${x}" "${y}" "${z}")"
+ tmpgrubrom="$(mkGrubRom "${keymap}" "${tmprompath}")"
if [ "${initmode}" = "normal" ]; then
newrompath="${romdir}/${firstpayloadname}_${board}_"
@@ -415,61 +428,16 @@ build_grub_roms() {
mkGrubRom() {
target_keymap="${1}"
target_cbrom="${2}"
- target_grubelf_cbfs_path="${3}" # e.g. fallback/payload
- grubelf="elf/grub/grub_${target_keymap}.elf"
- grubcfg="elf/grub/grub_${target_keymap}.cfg"
- grubtestcfg="elf/grub/grub_${target_keymap}_test.cfg"
+ keymapcfg="elf/grub/keymap_${target_keymap}.cfg"
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) || \
err "mkGrubRom: cannot create tmprom"
cp "${target_cbrom}" "${tmprom}" || \
err "mkGrubRom: cannot copy to tmprom"
- "${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \
- -n ${target_grubelf_cbfs_path} -c lzma || \
- err "mkGrubRom: cannot add grub payload to tmprom"
-
- tmpgrubcfg=$(mktemp -t grub.cfg.XXXXXXXXXX)
- tmpgrubtestcfg=$(mktemp -t grubtest.cfg.XXXXXXXXXX)
- if [ "${grub_scan_disk}" = "ahci" ]; then
- sed \
- 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \
- "${grubcfg}" > "${tmpgrubcfg}" || err "mkGrubRom: sed1"
- sed \
- 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \
- "${grubtestcfg}" > "${tmpgrubtestcfg}" || \
- err "mkGrubRom: sed2"
- elif [ "${grub_scan_disk}" = "ata" ]; then
- sed \
- 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \
- "${grubcfg}" > "${tmpgrubcfg}" || err "mkGrubRom: sed3"
- sed \
- 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \
- "${grubtestcfg}" > "${tmpgrubtestcfg}" || \
- err "mkGrubRom: sed4"
- else
- cp "${grubcfg}" "${tmpgrubcfg}" || err "mkGrubRom: grub.cfg cp"
- cp "${grubtestcfg}" "${tmpgrubtestcfg}" || \
- err "mkGrubRom: grubtest.cfg cp"
- fi
-
- "${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw || \
- err "mkGrubRom: cannot add grub.cfg to tmprom"
-
- "${cbfstool}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg \
- -t raw || err "mkGrubRom: cannot add grubtest.cfg to tmprom"
- rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}" || \
- err "mkGrubRom: cannot remove tmp grub.cfg / grubtest.cfg"
-
- backgroundfile="background1280x800.png"
- if [ "${board}" = "x60" ] || [ "${board}" = "t60_intelgpu" ]; then
- # TODO: don't hardcode this. do it in target.cfg per board
- backgroundfile="background1024x768.png"
- fi
- backgroundfile="resources/grub/background/${backgroundfile}"
- "${cbfstool}" "${tmprom}" add -f ${backgroundfile} -n background.png \
- -t raw || err "mkGrubRom: cannot add background.png to tmprom"
+ "${cbfstool}" "${tmprom}" add -f "${keymapcfg}" -n keymap.cfg -t raw \
+ || err "mkGrubRom: cannot add keymap.cfg to tmprom"
printf "%s\n" "${tmprom}"
}
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 $@