util 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #!/bin/bash
  2. #
  3. # helper script: generate the release archives
  4. #
  5. # Copyright (C) 2014, 2015, 2016 Leah Woods <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/${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. # include version information
  70. printf '%s\n' "${version}" >"${distdir}/version"
  71. # include version date information
  72. printf '%s\n' "${versiondate}" >"${distdir}/versiondate"
  73. # --------------
  74. # BUC.TS related
  75. # --------------
  76. # X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
  77. # Include it statically compiled
  78. cp -R "bucts" "bucts_/"
  79. # make it statically compile
  80. ./build module bucts static
  81. mkdir -p "${distdir}/bucts/${arch}/"
  82. mv "bucts/bucts" "${distdir}/bucts/${arch}/"
  83. rm -Rf "bucts/"
  84. mv "bucts_/" "bucts/"
  85. # ----------------
  86. # Flashrom related
  87. # ----------------
  88. # Flashrom is used to install libreboot on supported targets
  89. # Include it statically compiled
  90. cp -R "flashrom/" "flashrom_/"
  91. # make it statically compile
  92. ./build module flashrom static
  93. mkdir -p "${distdir}/flashrom/${arch}/"
  94. mv "flashrom/flashrom" "${distdir}/flashrom/${arch}/"
  95. mv "flashrom/flashrom_lenovobios_sst" "${distdir}/flashrom/${arch}/"
  96. mv "flashrom/flashrom_lenovobios_macronix" "${distdir}/flashrom/${arch}/"
  97. rm -Rf "flashrom/"
  98. mv "flashrom_/" "flashrom/"
  99. # ----------------
  100. # ich9deblob related
  101. # ----------------
  102. # build ich9deblob, compiled (statically linked) and include the binary
  103. mkdir -p "${distdir}/ich9deblob/${arch}"
  104. cd "resources/utilities/"
  105. cp -R "ich9deblob" "ich9deblob_/"
  106. cd "ich9deblob/"
  107. make clean
  108. make SHARED=0 CC='gcc -static'
  109. mv "ich9deblob" "../../../${distdir}/ich9deblob/${arch}/"
  110. mv "ich9gen" "../../../${distdir}/ich9deblob/${arch}/"
  111. mv "demefactory" "../../../${distdir}/ich9deblob/${arch}/"
  112. if [ "${arch}" = "x86_64" ]
  113. then
  114. # Now build 32-bit binaries
  115. make clean
  116. make SHARED=0 CC='gcc -static -m32'
  117. mkdir "../../../${distdir}/ich9deblob/i686/"
  118. mv "ich9deblob" "../../../${distdir}/ich9deblob/i686/"
  119. mv "ich9gen" "../../../${distdir}/ich9deblob/i686/"
  120. mv "demefactory" "../../../${distdir}/ich9deblob/i686/"
  121. fi
  122. # cross-compile for ARM
  123. make clean
  124. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  125. mkdir "../../../${distdir}/ich9deblob/armv7l"
  126. mv "ich9deblob" "../../../${distdir}/ich9deblob/armv7l/"
  127. mv "ich9gen" "../../../${distdir}/ich9deblob/armv7l/"
  128. mv "demefactory" "../../../${distdir}/ich9deblob/armv7l/"
  129. cd "../"
  130. rm -Rf "ich9deblob/"
  131. mv "ich9deblob_/" "ich9deblob/"
  132. cd "../../"
  133. # -------------
  134. # Miscellaneous
  135. # -------------
  136. # Flashing script
  137. cp "flash" "${distdir}/"
  138. # powertop script
  139. cp "resources/scripts/misc/powertop.trisquel7" "${distdir}/"
  140. printf "\n\n"
  141. # ### Create the release tarballs
  142. # ----------------------------------------------------------------------------------------------------------------------------
  143. printf "Compressing %s/ into %s.tar.xz\n" "${distdir}" "${distdir}.tar.xz"
  144. # create lzma compressed util archive
  145. (cd "${versiondir}/" && tar -c "${distname}/" | xz -9e >"${distname}.tar.xz")
  146. printf "done\n\n"
  147. # ### Delete the uncompressed release directories
  148. # ----------------------------------------------------------------------------------------------------------------------------
  149. # The uncompressed archives are no longer needed
  150. rm -Rf "${distdir:?}/"