grub 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env bash
  2. # generate GRUB ELF files (coreboot payload) and configuration files
  3. #
  4. # Copyright (C) 2014, 2015, 2020, 2021 Leah Rowe <info@minifree.org>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. [ "x${DEBUG+set}" = 'xset' ] && set -v
  20. set -u -e
  21. # This is where GRUB is expected to be (outside of the grub-assemble, instead in main checkout)
  22. source "resources/grub/modules.list"
  23. printf "Creating GRUB payloads and configuration files\n"
  24. if [ ! -d "grub/" ]; then
  25. ./download grub
  26. fi
  27. if [ ! -f "grub/grub-mkstandalone" ]; then
  28. ./build module grub
  29. fi
  30. [ ! -d "payload/" ] && mkdir -p payload/
  31. [ ! -d "payload/grub" ] && mkdir -p payload/grub/
  32. rm -f payload/grub/*
  33. # Separate GRUB payload per keymap. This saves space in the ROM, otherwise
  34. # a lot of space would be used if every keymap was stored in a single image
  35. for keylayoutfile in resources/grub/keymap/*.gkb; do
  36. if [ ! -f "${keylayoutfile}" ]; then
  37. continue
  38. fi
  39. keymap="${keylayoutfile##resources/grub/keymap/}"
  40. keymap="${keymap%.gkb}"
  41. grub/grub-mkstandalone \
  42. --grub-mkimage="grub/grub-mkimage" \
  43. -O i386-coreboot \
  44. -o payload/grub/grub_${keymap}.elf \
  45. -d grub/grub-core/ \
  46. --fonts= --themes= --locales= \
  47. --modules="${grub_modules}" \
  48. --install-modules="${grub_install_modules}" \
  49. /boot/grub/grub.cfg=resources/grub/config/grub_memdisk.cfg \
  50. /boot/grub/layouts/${keymap}.gkb=${keylayoutfile}
  51. if [ "${keymap}" = "usqwerty" ]; then
  52. cp resources/grub/config/grub.cfg payload/grub/grub_usqwerty.cfg
  53. else
  54. sed "s/usqwerty/${keymap}/" < resources/grub/config/grub.cfg > payload/grub/grub_${keymap}.cfg
  55. fi
  56. sed "s/grubtest.cfg/grub.cfg/" < payload/grub/grub_${keymap}.cfg > payload/grub/grub_${keymap}_test.cfg
  57. printf "Generated: 'payload/grub/grub_%s.elf' and configs.'\n" "${keymap}"
  58. done
  59. printf "Done! Check payload/grub/ to see the files.\n\n"