gen.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/bash
  2. # grub-assemble gen.sh: generate GRUB ELF files (coreboot payloads)
  3. #
  4. # Copyright (C) 2014, 2015 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. if [ $# != 1 ]; then
  22. printf "Usage: ./gen.sh mode\n"
  23. printf "Example: ./gen.sh vesafb\n"
  24. printf "Example: ./gen.sh txtmode\n"
  25. printf "You need to specify exactly 1 argument\n"
  26. exit 1
  27. fi
  28. if [ -f "../../../versiondate" ]; then
  29. # _src release archive is being used
  30. versiondate="$(cat ../../../versiondate)"
  31. else
  32. # git repo is being used
  33. versiondate="$(git show -s --format=%ct)"
  34. fi
  35. # This is where GRUB is expected to be (outside of the grub-assemble, instead in main checkout)
  36. grubdir="../../../grub"
  37. source "modules.conf"
  38. list_keymaps () {
  39. for keylayout in keymap/original/*; do
  40. keymap="${keylayout##*/}"
  41. printf "/boot/grub/layouts/%s.gkb=keymap/%s.gkb " "${keymap}" "${keymap}"
  42. done
  43. }
  44. keymaps=$(list_keymaps)
  45. printf "Creating GRUB ELF executable for configuration '%s'\n" "${1}"
  46. if [ "${1}" = "vesafb" ]; then
  47. # Generate the grub.elf (vesafb)
  48. $grubdir/grub-mkstandalone \
  49. --grub-mkimage="${grubdir}/grub-mkimage" \
  50. -O i386-coreboot \
  51. -o "grub_vesafb.elf" \
  52. -d "${grubdir}/grub-core/" \
  53. --fonts= --themes= --locales= \
  54. --modules="${grub_modules}" \
  55. --install-modules="${grub_install_modules}" \
  56. /boot/grub/grub.cfg="../../../resources/grub/config/grub_memdisk.cfg" \
  57. /dejavusansmono.pf2="../../../resources/grub/font/dejavusansmono.pf2" \
  58. ${keymaps}
  59. elif [ "${1}" = "txtmode" ]
  60. then
  61. # Generate the grub.elf (txtmode)
  62. "${grubdir}/grub-mkstandalone" \
  63. --grub-mkimage="${grubdir}/grub-mkimage" \
  64. -O i386-coreboot \
  65. -o "grub_txtmode.elf" \
  66. -d "${grubdir}/grub-core/" \
  67. --fonts= --themes= --locales= \
  68. --modules="${grub_modules}" \
  69. --install-modules="${grub_install_modules}" \
  70. /boot/grub/grub.cfg="../../../resources/grub/config/grub_memdisk.cfg" \
  71. /memtest.bin="../../../memtest86plus/memtest.bin" \
  72. ${keymaps}
  73. else
  74. printf "grub-assemble gen.sh: invalid mode '%s'\n" "${1}"
  75. exit 1
  76. fi
  77. printf "\n\n"