util 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. #!/bin/bash
  2. #
  3. # helper script: generate the release archives
  4. #
  5. # Copyright (C) 2014, 2015 Leah Rowe <info@minifree.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 current working directory when running
  21. # it is the root directory of the libreboot git repository clone.
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. arch="unknown"
  25. if [ "$(uname -i)" = "i686" ] || [ "$(uname -m)" = "i686" ]
  26. then
  27. arch="i686"
  28. echo "Running on i686. ok."
  29. sleep 2
  30. elif [ "$(uname -i)" = "x86_64" ] || [ "$(uname -m)" = "x86_64" ]
  31. then
  32. arch="x86_64"
  33. echo "Running on x86_64. ok."
  34. sleep 2
  35. else
  36. echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
  37. exit 1
  38. fi
  39. if [ -f "version" ]; then
  40. # _src release archive is being used
  41. version="$(cat version)"
  42. else
  43. # git repo is being used
  44. version="$(git describe --tags HEAD)"
  45. fi
  46. versiondir="release/${version}"
  47. distname="libreboot_${version}_util"
  48. distdir="${versiondir}/${distname}"
  49. printf "Creating utility archive (static executables)\n"
  50. # delete the old data
  51. rm -Rf "${distdir:?}/"
  52. rm -f "${distdir}.tar.xz"
  53. # this is where they will go
  54. mkdir -p "${distdir}/"
  55. # include version information
  56. printf '%s\n' "${version}" >"${distdir}/version"
  57. # --------------
  58. # BUC.TS related
  59. # --------------
  60. # X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
  61. # Include it statically compiled
  62. cp -R "bucts" "bucts_/"
  63. # make it statically compile
  64. ./build module bucts static
  65. mkdir -p "${distdir}/bucts/${arch}/"
  66. mv "bucts/bucts" "${distdir}/bucts/${arch}/"
  67. rm -Rf "bucts/"
  68. mv "bucts_/" "bucts/"
  69. # ----------------
  70. # Flashrom related
  71. # ----------------
  72. # Flashrom is used to install libreboot on supported targets
  73. # Include it statically compiled
  74. cp -R "flashrom/" "flashrom_/"
  75. # make it statically compile
  76. ./build module flashrom static
  77. mkdir -p "${distdir}/flashrom/${arch}/"
  78. mv "flashrom/flashrom" "${distdir}/flashrom/${arch}/"
  79. mv "flashrom/flashrom_lenovobios_sst" "${distdir}/flashrom/${arch}/"
  80. mv "flashrom/flashrom_lenovobios_macronix" "${distdir}/flashrom/${arch}/"
  81. rm -Rf "flashrom/"
  82. mv "flashrom_/" "flashrom/"
  83. # ----------------
  84. # cbfstool related
  85. # ----------------
  86. # build cbfstool, compiled (statically linked) and include the binary
  87. mkdir -p "${distdir}/cbfstool/${arch}/"
  88. cd "coreboot/util/"
  89. cp -R "cbfstool" "cbfstool_/"
  90. cd "cbfstool/"
  91. make clean
  92. make SHARED=0 CC='gcc -static'
  93. mv "cbfstool" "../../../${distdir}/cbfstool/${arch}/"
  94. if [ "${arch}" = "x86_64" ]
  95. then
  96. # Now build 32-bit binaries
  97. make clean
  98. make SHARED=0 CC='gcc -static -m32'
  99. mkdir "../../../${distdir}/cbfstool/i686"
  100. mv "cbfstool" "../../../${distdir}/cbfstool/i686/"
  101. fi
  102. # cross-compile for ARM
  103. make clean
  104. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  105. mkdir "../../../${distdir}/cbfstool/armv7l/"
  106. mv "cbfstool" "../../../${distdir}/cbfstool/armv7l/"
  107. cd ../
  108. rm -Rf "cbfstool/"
  109. mv "cbfstool_/" "cbfstool/"
  110. cd ../../
  111. # ----------------
  112. # ich9deblob related
  113. # ----------------
  114. # build ich9deblob, compiled (statically linked) and include the binary
  115. mkdir -p "${distdir}/ich9deblob/${arch}"
  116. cd "resources/utilities/"
  117. cp -R "ich9deblob" "ich9deblob_/"
  118. cd "ich9deblob/"
  119. make clean
  120. make SHARED=0 CC='gcc -static'
  121. mv "ich9deblob" "../../../${distdir}/ich9deblob/${arch}/"
  122. mv "ich9gen" "../../../${distdir}/ich9deblob/${arch}/"
  123. mv "demefactory" "../../../${distdir}/ich9deblob/${arch}/"
  124. if [ "${arch}" = "x86_64" ]
  125. then
  126. # Now build 32-bit binaries
  127. make clean
  128. make SHARED=0 CC='gcc -static -m32'
  129. mkdir "../../../${distdir}/ich9deblob/i686/"
  130. mv "ich9deblob" "../../../${distdir}/ich9deblob/i686/"
  131. mv "ich9gen" "../../../${distdir}/ich9deblob/i686/"
  132. mv "demefactory" "../../../${distdir}/ich9deblob/i686/"
  133. fi
  134. # cross-compile for ARM
  135. make clean
  136. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  137. mkdir "../../../${distdir}/ich9deblob/armv7l"
  138. mv "ich9deblob" "../../../${distdir}/ich9deblob/armv7l/"
  139. mv "ich9gen" "../../../${distdir}/ich9deblob/armv7l/"
  140. mv "demefactory" "../../../${distdir}/ich9deblob/armv7l/"
  141. cd "../"
  142. rm -Rf "ich9deblob/"
  143. mv "ich9deblob_/" "ich9deblob/"
  144. cd "../../"
  145. # -----------------
  146. # nvramtool related
  147. # -----------------
  148. # build nvramtool, compiled (statically linked) and include the binary
  149. cd "coreboot/util/"
  150. cp -R "nvramtool/" "nvramtool_/"
  151. cd "nvramtool/"
  152. make clean
  153. make SHARED=0 CC='gcc -static'
  154. mkdir -p "../../../${distdir}/nvramtool/${arch}/"
  155. mv "nvramtool" "../../../${distdir}/nvramtool/${arch}/"
  156. if [ "${arch}" = "x86_64" ]
  157. then
  158. # Now build 32-bit binaries
  159. make clean
  160. make SHARED=0 CC='gcc -static -m32'
  161. mkdir "../../../${distdir}/nvramtool/i686/"
  162. mv "nvramtool" "../../../${distdir}/nvramtool/i686/"
  163. fi
  164. cd "../"
  165. rm -Rf "nvramtool/"
  166. mv "nvramtool_/" "nvramtool/"
  167. cd "../../"
  168. # -------------
  169. # Miscellaneous
  170. # -------------
  171. # Flashing script
  172. cp "flash" "${distdir}/"
  173. # powertop script
  174. cp "resources/scripts/misc/powertop.trisquel7" "${distdir}/"
  175. printf "\n\n"
  176. # ### Create the release tarballs
  177. # ----------------------------------------------------------------------------------------------------------------------------
  178. printf "Compressing %s/ into %s.tar.xz\n" "${distdir}" "${distdir}.tar.xz"
  179. # create lzma compressed util archive
  180. (cd "${versiondir}/" && tar -c "${distname}/" | xz -9e >"${distname}.tar.xz")
  181. printf "done\n\n"
  182. # ### Delete the uncompressed release directories
  183. # ----------------------------------------------------------------------------------------------------------------------------
  184. # The uncompressed archives are no longer needed
  185. rm -Rf "${distdir:?}/"