gen.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. --fixed-time ${versiondate} \
  55. --modules="${grub_modules}" \
  56. --install-modules="${grub_install_modules}" \
  57. /boot/grub/grub.cfg="../../../resources/grub/config/grub_memdisk.cfg" \
  58. /dejavusansmono.pf2="../../../resources/grub/font/dejavusansmono.pf2" \
  59. ${keymaps}
  60. elif [ "${1}" = "txtmode" ]
  61. then
  62. # Generate the grub.elf (txtmode)
  63. "${grubdir}/grub-mkstandalone" \
  64. --grub-mkimage="${grubdir}/grub-mkimage" \
  65. -O i386-coreboot \
  66. -o "grub_txtmode.elf" \
  67. -d "${grubdir}/grub-core/" \
  68. --fonts= --themes= --locales= \
  69. --fixed-time ${versiondate} \
  70. --modules="${grub_modules}" \
  71. --install-modules="${grub_install_modules}" \
  72. /boot/grub/grub.cfg="../../../resources/grub/config/grub_memdisk.cfg" \
  73. /memtest.bin="../../../memtest86plus/memtest.bin" \
  74. ${keymaps}
  75. else
  76. printf "grub-assemble gen.sh: invalid mode '%s'\n" "${1}"
  77. exit 1
  78. fi
  79. printf "\n\n"