123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #!/bin/bash
- # generate GRUB ELF files (coreboot payload) and configuration files
- #
- # Copyright (C) 2014, 2015, 2020, 2021 Leah Rowe <info@minifree.org>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- [ "x${DEBUG+set}" = 'xset' ] && set -v
- set -u -e
- # This is where GRUB is expected to be (outside of the grub-assemble, instead in main checkout)
- source "resources/grub/modules.list"
- printf "Creating GRUB payloads and configuration files\n"
- if [ ! -d "grub/" ]; then
- ./download grub
- fi
- if [ ! -f "grub/grub-mkstandalone" ]; then
- ./build module grub
- fi
- [ ! -d "payload/" ] && mkdir -p payload/
- [ ! -d "payload/grub" ] && mkdir -p payload/grub/
- rm -f payload/grub/*
- # This creates a grub.elf, which will be used with both
- # text mode and vesa startup in coreboot
- # This will reduce memdisk usage, important to mitigate bug with memdisk too big
- # Make GRUB payload executables for each supported keyboard layout.
- # Each payload will be applicable to text mode or corebootfb configuration in coreboot
- for keylayoutfile in resources/grub/keymap/*; do
- if [ ! -f "${keylayoutfile}" ]; then
- continue
- fi
- keymap="${keylayoutfile##*/}"
- keymap="${keymap%.gkb}"
- grub/grub-mkstandalone \
- --grub-mkimage="grub/grub-mkimage" \
- -O i386-coreboot \
- -o payload/grub/grub_${keymap}.elf \
- -d grub/grub-core/ \
- --fonts= --themes= --locales= \
- --modules="${grub_modules}" \
- --install-modules="${grub_install_modules}" \
- /boot/grub/grub.cfg=resources/grub/config/grub_memdisk.cfg \
- /boot/grub/layouts/${keymap}.gkb=resources/grub/keymap/${keymap}.gkb
- printf "Generated: 'payload/grub/grub_%s.elf'\n" "${keymap}"
- done
- # Now generate the configs. One pair of configs for each keyboard layout.
- # In each pair there is a configuration for text mode, and one for corebootfb
- for romtype in txtmode corebootfb; do
- # GRUB configuration files
- for keylayoutfile in resources/grub/keymap/*; do
- if [ ! -f "${keylayoutfile}" ]; then
- continue
- fi
- keymap="${keylayoutfile##*/}"
- keymap="${keymap%.gkb}"
- cat resources/grub/config/extra/{common,"${romtype}"}.cfg > payload/grub/grub_${keymap}_${romtype}.cfg
- printf "keymap %s\n" "${keymap}" >> payload/grub/grub_${keymap}_${romtype}.cfg
- cat resources/grub/config/menuentries/{common,${romtype}}.cfg >> payload/grub/grub_${keymap}_${romtype}.cfg
- # grubtest.cfg should be able to switch back to grub.cfg
- sed "s/grubtest.cfg/grub.cfg/" < payload/grub/grub_${keymap}_${romtype}.cfg > payload/grub/grub_${keymap}_${romtype}_test.cfg
- printf "Generated 'payload/grub/grub_%s_%s.cfg'\n" "${keymap}" "${romtype}"
- printf "Generated 'payload/grub/grub_%s_%s_test.cfg'\n" "${keymap}" "${romtype}"
- done
- done
- ./download dejavusansmono || touch osbmk_error
- if [ -f osbmk_error ]; then
- rm -f osbmk_error
- printf "ERROR: build/payload/grub: Problem downloading dejavusansmono\n"
- exit 1
- fi
- ./grub/grub-mkfont -o payload/grub/dejavusansmono.pf2 dejavusansmono/ttf/DejaVuSansMono.ttf \
- || touch osbmk_error
- if [ -f osbmk_error ]; then
- rm -f osbmk_error
- rm -f payload/grub/dejavusansmono.pf2
- printf "ERROR: build/payload/grub: Problem generating dejavu font\n"
- exit 1
- fi
- printf "Generated 'payload/grub/dejavusansmono.pf2'\n"
- printf "Done! Check payload/grub/ to see the files.\n\n"
|