coreboot 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. #!/bin/bash
  2. # helper script: builds the dependencies that coreboot needs before building a ROM image
  3. #
  4. # Copyright (C) 2014, 2015, 2016 Leah Woods <info@minifree.org>
  5. # Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
  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 root
  21. # of git or release archive
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. # Build utilities needed in coreboot directory
  25. # --------------------------------------------------------------------
  26. printf "Building the utilities in coreboot\n"
  27. for payloads in resources/libreboot/config/*; do
  28. if [ ! -d "${payloads}/" ]; then
  29. continue
  30. fi
  31. payload="${payloads##*/}"
  32. for boardconfig in resources/libreboot/config/${payload}/*; do
  33. if [ ! -d "${boardconfig}/" ]; then
  34. continue
  35. fi
  36. boardname="${boardconfig##*/}"
  37. cbrevision=$(cat "${boardconfig}/cbrevision")
  38. vbootrevision=$(cat "${boardconfig}/vbootrevision")
  39. reused_coreboot_patches="resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}/reused.list"
  40. reused_vboot_patches="resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}/reused.list"
  41. for reused_patches in "${reused_coreboot_patches}" "${reused_vboot_patches}"; do
  42. if [ -f "${reused_patches}" ]; then
  43. for patch in $(cat "${reused_patches}"); do
  44. if [ ! -f "./${patch}" ]; then
  45. printf "%s listed in %s does not exist\n" "${patch}" "${reused_patches}"
  46. exit 1
  47. fi
  48. done
  49. fi
  50. done
  51. done
  52. done
  53. # sanity check (check for invalid paths in the reused.list patch lists before proceeding)
  54. # in ascending filename order, apply patches from a directory
  55. apply_patches_from_directory() {
  56. patch_directory="${1}" # directory containing the patch files
  57. if [ -d "${patch_directory}" ]; then
  58. for patch in ${patch_directory}/*.patch; do
  59. if [ "${patch##*/}" = "*.patch" ]; then # oh so ugly
  60. continue # ugly ugly ugly ugly ugly
  61. fi # most hideous thing you've ever seen
  62. git am "${patch}" || return 1
  63. done
  64. fi
  65. }
  66. # files listed in the file (if found) are absolute paths, relative to the root of the libreboot src directory
  67. # the file lists patches patches that should be applied
  68. apply_patches_from_file() {
  69. patch_list="${1}" # file listing the paths to all the patches
  70. libreboot_src_root="${2}" # path to the root of the libreboot_src directory
  71. if [ -f "${patch_list}" ]; then
  72. for patchname in $(cat "${patch_list}"); do
  73. git am "${libreboot_src_root}/${patchname}" || return 1
  74. done
  75. fi
  76. }
  77. create_branch() {
  78. branchname="${1}"
  79. git branch ${branchname}
  80. git checkout ${branchname}
  81. git checkout master
  82. }
  83. # use git-init on everything
  84. # this is so that we can then apply patche
  85. # for these revisions of vboot and coreboot
  86. for i in coreboot/*; do
  87. if [ ! -d "${i}/" ]; then
  88. continue
  89. fi
  90. for revision in ${i}/*; do
  91. if [ ! -d "${revision}/" ]; then
  92. continue
  93. fi
  94. (
  95. cd "${revision}/"
  96. git init
  97. git add -A .
  98. git commit -m "coreboot revision ${revision##*/}"
  99. cd "3rdparty/vboot/"
  100. git init
  101. git add -A .
  102. git commit -m "coreboot revision ${revision##*/}"
  103. )
  104. done
  105. done
  106. for payloads in resources/libreboot/config/*; do
  107. if [ ! -d "${payloads}/" ]; then
  108. continue
  109. fi
  110. payload="${payloads##*/}"
  111. for boardconfig in resources/libreboot/config/${payload}/*; do
  112. if [ ! -d "${boardconfig}/" ]; then
  113. continue
  114. fi
  115. boardname="${boardconfig##*/}"
  116. cbrevision=$(cat "${boardconfig}/cbrevision")
  117. vbootrevision=$(cat "${boardconfig}/vbootrevision")
  118. branchname="${payload}_${boardname}"
  119. # the same vboot revision is always used for coreboot revision,
  120. # so we don't need to wworry about checking for that here
  121. # patch that version
  122. (
  123. cd "coreboot/${cbrevision}/${cbrevision}/"
  124. create_branch ${branchname}
  125. git checkout ${branchname}
  126. # apply patches (coreboot, common to all systems using this revision)
  127. apply_patches_from_directory "../../../resources/libreboot/patch/common/coreboot/${cbrevision}"
  128. # apply patches re-used from other boards, before applying main patches (common patches for similar boards)
  129. apply_patches_from_file "../../../resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}/reused.list" ../../..
  130. # apply patches (coreboot, machine-specific for this revision)
  131. apply_patches_from_directory "../../../resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}"
  132. git checkout master
  133. cd "3rdparty/vboot/"
  134. # reset to known revision (vboot)
  135. create_branch ${branchname}
  136. git checkout ${branchname}
  137. # apply patches (vboot, common to all systems using this revision)
  138. apply_patches_from_directory "../../../../../resources/libreboot/patch/common/vboot/${vbootrevision}"
  139. # apply patches re-used from other boards, before applying main patches (common patches for similar boards)
  140. apply_patches_from_file "../../../../../resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}/reused.list" ../../../../..
  141. # apply patches (vboot, machine-specific for this revision)
  142. apply_patches_from_directory "../../../../../resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}"
  143. git checkout master
  144. )
  145. done
  146. done
  147. # build coreboot utilities (in each revision) and
  148. # create symlinks to the crossgcc archive
  149. for payload in coreboot/*; do
  150. for board in "${payload}/"*; do
  151. # cbfstool, cbmem, nvramtool
  152. for util in {cbfs,nvram}tool cbmem; do
  153. make -BC "${board}/util/${util}"
  154. done
  155. # create symlink to crossgcc
  156. (
  157. cd "${board}/util/"
  158. ln -s "../../../../crossgcc/util/crossgcc/" crossgcc
  159. )
  160. done
  161. done