util 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. #!/usr/bin/env bash
  2. #
  3. # helper script: generate the release archives
  4. #
  5. # Copyright (C) 2014, 2015, 2016 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. versiondate="$(cat versiondate)"
  43. else
  44. # git repo is being used
  45. version="$(git describe --tags HEAD)"
  46. versiondate="$(git show -s --format=%ct)"
  47. fi
  48. versiondir="release/oldbuildsystem/${version}"
  49. distname="libreboot_${version}_util"
  50. distdir="${versiondir}/${distname}"
  51. printf "Creating utility archive (static executables)\n"
  52. # delete the old data
  53. rm -Rf "${distdir:?}/"
  54. rm -f "${distdir}.tar.xz"
  55. # this is where they will go
  56. mkdir -p "${distdir}/"
  57. # this has to be done before generating
  58. # the "version" file
  59. if [ ! -f "version" ]; then
  60. # generate ChangeLog and NEWS files
  61. rm -f "ChangeLog" "NEWS"
  62. git log > "${distdir}/ChangeLog"
  63. cp "${distdir}/ChangeLog" "${distdir}/NEWS"
  64. else
  65. # building from release archive
  66. cp "ChangeLog" "${distdir}/"
  67. cp "NEWS" "${distdir}/"
  68. fi
  69. if [ -f "RELEASE" ]; then
  70. rm -f "${distdir}/ChangeLog"
  71. rm -f "${distdir}/NEWS"
  72. cp "RELEASE" "${distdir}/ChangeLog"
  73. cp "RELEASE" "${distdir}/NEWS"
  74. fi
  75. # include version information
  76. printf '%s\n' "${version}" >"${distdir}/version"
  77. # include version date information
  78. printf '%s\n' "${versiondate}" >"${distdir}/versiondate"
  79. # --------------
  80. # BUC.TS related
  81. # --------------
  82. # X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
  83. # Include it statically compiled
  84. cp -R "bucts" "bucts_/"
  85. # make it statically compile
  86. ./oldbuild module bucts static
  87. mkdir -p "${distdir}/bucts/${arch}/"
  88. mv "bucts/bucts" "${distdir}/bucts/${arch}/"
  89. rm -Rf "bucts/"
  90. mv "bucts_/" "bucts/"
  91. # ----------------
  92. # Flashrom related
  93. # ----------------
  94. # Flashrom is used to install libreboot on supported targets
  95. # Include it statically compiled
  96. cp -R "flashrom/" "flashrom_/"
  97. # make it statically compile
  98. ./oldbuild module flashrom static
  99. mkdir -p "${distdir}/flashrom/${arch}/"
  100. mv "flashrom/flashrom" "${distdir}/flashrom/${arch}/"
  101. mv "flashrom/flashrom_lenovobios_sst" "${distdir}/flashrom/${arch}/"
  102. mv "flashrom/flashrom_lenovobios_macronix" "${distdir}/flashrom/${arch}/"
  103. rm -Rf "flashrom/"
  104. mv "flashrom_/" "flashrom/"
  105. # ----------------
  106. # cbfstool related
  107. # ----------------
  108. # build cbfstool, compiled (statically linked) and include the binary
  109. mkdir -p "${distdir}/cbfstool/${arch}/"
  110. cd "crossgcc/util/"
  111. cp -R "cbfstool" "cbfstool_/"
  112. cd "cbfstool/"
  113. sed -i '/.*fmd_scanner.o.*-Wno-unused-function$/ s/$/ -Wno-sign-compare/' Makefile.inc # build fix for latest flex version
  114. make clean
  115. make SHARED=0 CC='gcc -static'
  116. mv "cbfstool" "../../../${distdir}/cbfstool/${arch}/"
  117. if [ "${arch}" = "x86_64" ]
  118. then
  119. # Now build 32-bit binaries
  120. make clean
  121. make SHARED=0 CC='gcc -static -m32'
  122. mkdir "../../../${distdir}/cbfstool/i686"
  123. mv "cbfstool" "../../../${distdir}/cbfstool/i686/"
  124. fi
  125. # cross-compile for ARM
  126. make clean
  127. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  128. mkdir "../../../${distdir}/cbfstool/armv7l/"
  129. mv "cbfstool" "../../../${distdir}/cbfstool/armv7l/"
  130. cd ../
  131. rm -Rf "cbfstool/"
  132. mv "cbfstool_/" "cbfstool/"
  133. cd ../../
  134. # ----------------
  135. # ich9deblob related
  136. # ----------------
  137. # build ich9deblob, compiled (statically linked) and include the binary
  138. mkdir -p "${distdir}/ich9utils/${arch}"
  139. cd "resources/utilities/"
  140. cp -R "ich9utils" "ich9utils_/"
  141. cd "ich9utils/"
  142. make clean
  143. make SHARED=0 CC='gcc -static'
  144. mv "ich9deblob" "../../../${distdir}/ich9utils/${arch}/"
  145. mv "ich9gen" "../../../${distdir}/ich9utils/${arch}/"
  146. mv "demefactory" "../../../${distdir}/ich9utils/${arch}/"
  147. mv "ich9show" "../../../${distdir}/ich9utils/${arch}/"
  148. if [ "${arch}" = "x86_64" ]
  149. then
  150. # Now build 32-bit binaries
  151. make clean
  152. make SHARED=0 CC='gcc -static -m32'
  153. mkdir "../../../${distdir}/ich9utils/i686/"
  154. mv "ich9deblob" "../../../${distdir}/ich9utils/i686/"
  155. mv "ich9gen" "../../../${distdir}/ich9utils/i686/"
  156. mv "demefactory" "../../../${distdir}/ich9utils/i686/"
  157. mv "ich9show" "../../../${distdir}/ich9utils/i686/"
  158. fi
  159. # cross-compile for ARM
  160. make clean
  161. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  162. mkdir "../../../${distdir}/ich9utils/armv7l"
  163. mv "ich9deblob" "../../../${distdir}/ich9utils/armv7l/"
  164. mv "ich9gen" "../../../${distdir}/ich9utils/armv7l/"
  165. mv "demefactory" "../../../${distdir}/ich9utils/armv7l/"
  166. mv "ich9show" "../../../${distdir}/ich9utils/armv7l/"
  167. cd "../"
  168. rm -Rf "ich9deblob/"
  169. mv "ich9deblob_/" "ich9deblob/"
  170. cd "../../"
  171. # -----------------
  172. # nvramtool related
  173. # -----------------
  174. # build nvramtool, compiled (statically linked) and include the binary
  175. cd "crossgcc/util/"
  176. cp -R "nvramtool/" "nvramtool_/"
  177. cd "nvramtool/"
  178. make clean
  179. make SHARED=0 CC='gcc -static'
  180. mkdir -p "../../../${distdir}/nvramtool/${arch}/"
  181. mv "nvramtool" "../../../${distdir}/nvramtool/${arch}/"
  182. if [ "${arch}" = "x86_64" ]
  183. then
  184. # Now build 32-bit binaries
  185. make clean
  186. make SHARED=0 CC='gcc -static -m32'
  187. mkdir "../../../${distdir}/nvramtool/i686/"
  188. mv "nvramtool" "../../../${distdir}/nvramtool/i686/"
  189. fi
  190. cd "../"
  191. rm -Rf "nvramtool/"
  192. mv "nvramtool_/" "nvramtool/"
  193. cd "../../"
  194. # -------------
  195. # Miscellaneous
  196. # -------------
  197. # Flashing script
  198. cp "flash" "${distdir}/"
  199. # powertop script
  200. cp "resources/scripts/misc/powertop.trisquel7" "${distdir}/"
  201. # grubeditor.sh script
  202. cp "resources/scripts/misc/grubeditor.sh" "${distdir}/"
  203. printf "\n\n"
  204. # ### Create the release tarballs
  205. # ----------------------------------------------------------------------------------------------------------------------------
  206. printf "Compressing %s/ into %s.tar.xz\n" "${distdir}" "${distdir}.tar.xz"
  207. # create lzma compressed util archive
  208. (cd "${versiondir}/" && tar -c "${distname}/" | xz -9e >"${distname}.tar.xz")
  209. printf "done\n\n"
  210. # ### Delete the uncompressed release directories
  211. # ----------------------------------------------------------------------------------------------------------------------------
  212. # The uncompressed archives are no longer needed
  213. rm -Rf "${distdir:?}/"