util 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. #!/bin/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}/ich9deblob/${arch}"
  139. cd "resources/utilities/"
  140. cp -R "ich9deblob" "ich9deblob_/"
  141. cd "ich9deblob/"
  142. make clean
  143. make SHARED=0 CC='gcc -static'
  144. mv "ich9deblob" "../../../${distdir}/ich9deblob/${arch}/"
  145. mv "ich9gen" "../../../${distdir}/ich9deblob/${arch}/"
  146. mv "demefactory" "../../../${distdir}/ich9deblob/${arch}/"
  147. if [ "${arch}" = "x86_64" ]
  148. then
  149. # Now build 32-bit binaries
  150. make clean
  151. make SHARED=0 CC='gcc -static -m32'
  152. mkdir "../../../${distdir}/ich9deblob/i686/"
  153. mv "ich9deblob" "../../../${distdir}/ich9deblob/i686/"
  154. mv "ich9gen" "../../../${distdir}/ich9deblob/i686/"
  155. mv "demefactory" "../../../${distdir}/ich9deblob/i686/"
  156. fi
  157. # cross-compile for ARM
  158. make clean
  159. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  160. mkdir "../../../${distdir}/ich9deblob/armv7l"
  161. mv "ich9deblob" "../../../${distdir}/ich9deblob/armv7l/"
  162. mv "ich9gen" "../../../${distdir}/ich9deblob/armv7l/"
  163. mv "demefactory" "../../../${distdir}/ich9deblob/armv7l/"
  164. cd "../"
  165. rm -Rf "ich9deblob/"
  166. mv "ich9deblob_/" "ich9deblob/"
  167. cd "../../"
  168. # -----------------
  169. # nvramtool related
  170. # -----------------
  171. # build nvramtool, compiled (statically linked) and include the binary
  172. cd "crossgcc/util/"
  173. cp -R "nvramtool/" "nvramtool_/"
  174. cd "nvramtool/"
  175. make clean
  176. make SHARED=0 CC='gcc -static'
  177. mkdir -p "../../../${distdir}/nvramtool/${arch}/"
  178. mv "nvramtool" "../../../${distdir}/nvramtool/${arch}/"
  179. if [ "${arch}" = "x86_64" ]
  180. then
  181. # Now build 32-bit binaries
  182. make clean
  183. make SHARED=0 CC='gcc -static -m32'
  184. mkdir "../../../${distdir}/nvramtool/i686/"
  185. mv "nvramtool" "../../../${distdir}/nvramtool/i686/"
  186. fi
  187. cd "../"
  188. rm -Rf "nvramtool/"
  189. mv "nvramtool_/" "nvramtool/"
  190. cd "../../"
  191. # -------------
  192. # Miscellaneous
  193. # -------------
  194. # Flashing script
  195. cp "flash" "${distdir}/"
  196. # powertop script
  197. cp "resources/scripts/misc/powertop.trisquel7" "${distdir}/"
  198. printf "\n\n"
  199. # ### Create the release tarballs
  200. # ----------------------------------------------------------------------------------------------------------------------------
  201. printf "Compressing %s/ into %s.tar.xz\n" "${distdir}" "${distdir}.tar.xz"
  202. # create lzma compressed util archive
  203. (cd "${versiondir}/" && tar -c "${distname}/" | xz -9e >"${distname}.tar.xz")
  204. printf "done\n\n"
  205. # ### Delete the uncompressed release directories
  206. # ----------------------------------------------------------------------------------------------------------------------------
  207. # The uncompressed archives are no longer needed
  208. rm -Rf "${distdir:?}/"