coreboot 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #!/bin/bash
  2. # helper script: downloads coreboot and patches/deblobs it
  3. #
  4. # Copyright (C) 2014, 2015, 2016 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 libreboot_src or libreboot git.
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. if [ -f "version" ]; then
  25. # _src release archive is being used
  26. version="libreboot-$(cat version)"
  27. else
  28. # git repo is being used
  29. version="libreboot-$(git describe --tags HEAD)"
  30. fi
  31. make_coreboot_src_directory() {
  32. payload="${1}"
  33. cbrevision="${2}"
  34. vbootrevision="${3}"
  35. firmwarepath="${4}" # libreboot_src/coreboot/
  36. (
  37. cd "${firmwarepath}/"
  38. # copy coreboot directory there
  39. rm -Rf "${payload:?}/${cbrevision:?}/"
  40. if [ ! -d "${payload}/" ]; then
  41. mkdir -p "${payload}/"
  42. fi
  43. cp -R "coreboot/" "${payload}/${cbrevision}/"
  44. # We need to reset that revision of coreboot to the specified revision
  45. cd "${payload}/${cbrevision}/"
  46. git reset --hard ${cbrevision}
  47. if [ "${vbootrevision}" != "no_vboot_revision" ]; then
  48. # reset vboot revision. in practise, we always use the same
  49. # vboot revision on all boards that use a given coreboot revision
  50. cd "3rdparty/vboot/"
  51. git reset --hard ${vbootrevision}
  52. fi
  53. )
  54. }
  55. printf "Downloading coreboot, patching coreboot and deblobbing coreboot\n"
  56. # This grabs current base used, and applies patches
  57. # This is also used to run the deblob scripts.
  58. # Remove the old version that may exist
  59. # ------------------------------------------------------------------------------
  60. rm -Rf "coreboot/"
  61. mkdir "coreboot/"
  62. cd "coreboot/"
  63. # Get latest coreboot:
  64. # ------------------------------------------------------------------------------
  65. # download it using git
  66. git clone https://review.coreboot.org/coreboot || git clone https://github.com/coreboot/coreboot.git
  67. # there are modifications required
  68. cd "coreboot/"
  69. # Define a common version (based on the libreboot version)
  70. # Most likely redundant, because the build system needs to update
  71. # this every time when building a ROM image anyway
  72. printf '%s\n' "${version}" >".coreboot-version"
  73. # vboot submodule is needed
  74. # ------------------------------------------------------------------------------
  75. git submodule update --init --checkout -- 3rdparty/vboot/
  76. # Create branches, with patches in each branch
  77. # Create separate coreboot source directories *for each board*
  78. # ------------------------------------------------------------------------------
  79. for payloads in ../../resources/libreboot/config/*; do
  80. if [ ! -d "${payloads}/" ]; then
  81. continue
  82. fi
  83. payload="${payloads##*/}"
  84. for boardconfig in ../../resources/libreboot/config/${payload}/*; do
  85. if [ ! -d "${boardconfig}/" ]; then
  86. continue
  87. fi
  88. cbrevision=$(cat "${boardconfig}/cbrevision")
  89. vbootrevision=$(cat "${boardconfig}/vbootrevision")
  90. # the same vboot revision is always used for coreboot revision,
  91. # so we don't need to wworry about checking for that here
  92. if [ -d "../${cbrevision}/${cbrevision}" ]; then
  93. continue
  94. # the directory already exists, no need to recreate it
  95. fi
  96. make_coreboot_src_directory ${cbrevision} ${cbrevision} ${vbootrevision} ..
  97. done
  98. done
  99. # go back to _src/coreboot/ (containing all coreboot directories)
  100. cd "../"
  101. # delete the gitted one (not needed anymore)
  102. rm -Rf "coreboot/"
  103. # Run coreboot-libre deblob scripts
  104. # ------------------------------------------------------------------------------
  105. printf "Deleting .git* in coreboot/ (history inside .git contains the blobs that were deleted)\n"
  106. rm -Rf */*/.git*
  107. rm -Rf */*/3rdparty/*/.git*
  108. # Delete crossgcc from non-crossgcc coreboot archives
  109. # (the build system will create symlinks later when building the ROM images)
  110. for payload in *; do
  111. if [ "${payload##*/}" != "crossgcc" ]; then
  112. rm -Rf ${payload:?}/*/util/crossgcc/
  113. fi
  114. done
  115. cd "../"
  116. printf "Deblobbing coreboot\n"
  117. ./resources/utilities/coreboot-libre/deblob
  118. printf "\n\n"