coreboot 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. # helper script: downloads coreboot and patches/deblobs it
  3. #
  4. # Copyright (C) 2014, 2015, 2016, 2020 Leah Rowe <info@minifree.org>
  5. # Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. # This script assumes that the working directory is the
  21. # root of retroboot_src or retroboot git.
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. printf "Downloading coreboot and (if exist in build system) applying patches\n"
  25. # Remove the old version that may exist
  26. # ------------------------------------------------------------------------------
  27. rm -Rf "coreboot/"
  28. mkdir "coreboot/"
  29. cd "coreboot/"
  30. # Get latest coreboot:
  31. # ------------------------------------------------------------------------------
  32. # download it using git
  33. git clone https://review.coreboot.org/coreboot || git clone https://github.com/coreboot/coreboot.git
  34. if [ ! -d "coreboot" ]; then
  35. printf "coreboot not downloaded; check network connection?\n\n"
  36. exit 1
  37. fi
  38. # Create a separate version of coreboot, for each board supported.
  39. # Each board defines which coreboot revision to use
  40. # ------------------------------------------------------------------------------
  41. for boards in ../resources/coreboot/*; do
  42. if [ ! -d "${boards}/" ]; then
  43. continue
  44. fi
  45. boardname="${boards##*/}"
  46. if [ -f "${boards}/symlink" ]; then
  47. ln -s $(cat ${boards}/symlink) ${boardname}
  48. continue
  49. fi
  50. cbrevision="$(cat ../resources/coreboot/${boardname}/cbrevision)"
  51. (
  52. cp -R coreboot ${boardname} # copy and make specific coreboot dir for that board
  53. cd ${boardname}/
  54. git reset --hard ${cbrevision}
  55. git submodule update --init --checkout
  56. for submodule in ../../resources/coreboot/${boardname}/revision/*; do
  57. if [ ! -f "${submodule}" ]; then
  58. continue
  59. fi
  60. module="${submodule##*/}"
  61. modulerevision="$(cat ${submodule})"
  62. (
  63. cd "3rdparty/${module}/"
  64. git reset --hard ${modulerevision}
  65. )
  66. done
  67. if [ -f "../../resources/coreboot/${boardname}/extra.sh" ]; then
  68. (
  69. "../../resources/coreboot/${boardname}/extra.sh"
  70. )
  71. fi
  72. # TODO: add support for custom patches to submodules
  73. for patch in ../../resources/coreboot/${boardname}/patches/*.patch; do
  74. if [ "${patch##*/}" = "*.patch" ]; then
  75. continue
  76. fi
  77. git am "${patch}" || continue
  78. done
  79. )
  80. done
  81. # reference coreboot archive no longer required
  82. # because we have created separate coreboot archives for each target
  83. rm -Rf "coreboot"
  84. cd ../
  85. printf "\n\n"