grub 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/usr/bin/env bash
  2. # Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. arguments() {
  17. project_arguments_targets "${project}" "$@"
  18. }
  19. usage() {
  20. project_usage_actions "${project}"
  21. project_usage_arguments "${project}" "$@"
  22. }
  23. download() {
  24. local repository="${project}"
  25. project_download_git "${project}" "${repository}" 'https://git.savannah.gnu.org/r/grub.git' "$@"
  26. }
  27. download_check() {
  28. local repository="${project}"
  29. project_download_check_git "${project}" "${repository}" "$@"
  30. }
  31. extract() {
  32. project_extract "${project}" "$@"
  33. }
  34. extract_check() {
  35. project_extract_check "${project}" "$@"
  36. }
  37. update() {
  38. local repository="${project}"
  39. project_update_git "${project}" "${repository}" "$@"
  40. }
  41. update_check() {
  42. local repository="${project}"
  43. project_update_check_git "${project}" "${repository}" "$@"
  44. }
  45. build() {
  46. local repository="${project}"
  47. project_sources_directory_missing_empty_error "${project}" "${repository}" "$@"
  48. if git_project_check "${repository}"; then
  49. git_project_checkout "${project}" "${repository}" "$@"
  50. fi
  51. local project_path="$(project_path "${project}")"
  52. local sources_path="$(project_sources_path "${project}" "${repository}" "$@")"
  53. local build_path="$(project_build_path "${project}" "$@")"
  54. local -a grub_keymaps
  55. mapfile -t grub_install_modules < "${project_path}/${CONFIGS}/grub-install-modules"
  56. mapfile -t grub_load_modules < "${project_path}/${CONFIGS}/grub-load-modules"
  57. for keymap in "${project_path}/${CONFIGS}/keymap"/*; do
  58. if [[ -f "${keymap}" ]]; then
  59. grub_keymaps+=("/boot/grub/layouts/${keymap##*/}=${keymap}")
  60. fi
  61. done
  62. mkdir -p "${build_path}"
  63. (
  64. cd "${sources_path}"
  65. # Compile GRUB first
  66. ./autogen.sh
  67. ./configure --with-platform=coreboot
  68. make -j"${TASKS}"
  69. # Now compile GRUB ELF executable
  70. ./grub-mkstandalone \
  71. --grub-mkimage=./grub-mkimage \
  72. --fonts='' \
  73. --themes='' \
  74. --locales='' \
  75. --modules="${grub_load_modules[*]}" \
  76. --install-modules="${grub_install_modules[*]}" \
  77. --directory=grub-core \
  78. -O i386-coreboot \
  79. -o grub.elf \
  80. /boot/grub/grub.cfg="${project_path}/${CONFIGS}/grub.cfg" \
  81. "${grub_keymaps[@]}"
  82. # Copy the ELF to its build directory
  83. cp grub.elf "${build_path}"
  84. # Tidy up
  85. make clean
  86. )
  87. }
  88. build_check() {
  89. project_build_check "${project}" "$@"
  90. }
  91. install() {
  92. project_install "${project}" "$@"
  93. }
  94. install_check() {
  95. project_install_check "${project}" "$@"
  96. }
  97. release() {
  98. local repository="${project}"
  99. project_release_install_archive "${project}" "${IMAGES}" "$@"
  100. project_release_sources_git "${project}" "${repository}" "$@"
  101. }
  102. release_check() {
  103. local repository="${project}"
  104. project_release_install_archive_check "${project}" "${IMAGES}" "$@"
  105. project_release_check_sources_git "${project}" "${repository}" "$@"
  106. }
  107. clean() {
  108. project_clean "${project}" "$@"
  109. }