build-release 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. #!/bin/bash
  2. #
  3. # build-release script: generates libreboot_bin and libreboot_src release archives
  4. #
  5. # Copyright (C) 2014, 2015 Francis Rowe <info@gluglug.org.uk>
  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. set -u -e -v
  21. arch="unknown"
  22. if [ $(uname -i) = "i686" ] || [ $(uname -m) = "i686" ]
  23. then
  24. arch="i686"
  25. echo "Running on i686. ok."
  26. sleep 2
  27. elif [ $(uname -i) = "x86_64" ] || [ $(uname -m) = "x86_64" ]
  28. then
  29. arch="x86_64"
  30. echo "Running on x86_64. ok."
  31. sleep 2
  32. else
  33. echo "This script must be run on an i686 or x86_64 host. x86_64 is recommended."
  34. exit 1
  35. fi
  36. # MAKE SURE THAT YOU RAN "buildall" OR "builddeps" *AT LEAST ONCE*
  37. # You should also run the 'build' script before running this
  38. # ### Delete old archives before continuing
  39. # ----------------------------------------------------------------------------------------------------------------------------
  40. echo "Deleting old release archives"
  41. rm -f libreboot_src.tar.xz
  42. rm -f libreboot_bin.tar.xz
  43. # Get manifest which will be used to copy everything
  44. find -maxdepth 1 > releasefilelist
  45. # ### Prepare libreboot_src archive ready for release
  46. # ----------------------------------------------------------------------------------------------------------------------------
  47. echo "Preparing libreboot_src release archive"
  48. mkdir libreboot_src
  49. for resource in $(cat releasefilelist)
  50. do
  51. if [ "$resource" != "." ]
  52. then
  53. cp -r $resource libreboot_src
  54. fi
  55. done
  56. cd libreboot_src/
  57. # clean everything
  58. ./cleandeps
  59. # back to main checkout directory
  60. cd ../
  61. # ### Further work in libreboot_src: delete *.git and *.svn
  62. # ### To save space since they are not useful in the release archives
  63. # ### Changes to these projects should be submitted upstream
  64. # ----------------------------------------------------------------------------------------------------------------------------
  65. cd libreboot_src/
  66. # These instructions will also work even if .git or .svn are already deleted
  67. # because "rm -rf" won't complain if they are missing. It is still useful on
  68. # the release archives (non-git), for example if the user re-downloads these programmes.
  69. # remove .git for libreboot project itself
  70. rm -rf .git*
  71. # # bucts needs .git to stay, otherwise it won't compile
  72. # # We don't need .git* (please submit all upstreamable changes directly to bucts upstream)
  73. # # removing them, to reduce the size of the archive
  74. # cd bucts
  75. # rm -rf .git
  76. # rm -rf .gitignore
  77. # cd ../
  78. # # it was found to cause issues when deleting:
  79. # # GIT_DISCOVERY_ACROSS_FILESYSTEM not set
  80. # coreboot:
  81. # the instructions for coreboot remain in getgb script
  82. # they need to stay there, because otherwise "git diff"
  83. # will show the blobs that were deleted (which means,
  84. # that libreboot would be distributing blobs)
  85. # Flashrom:
  86. cd flashrom/
  87. rm -rf .svn
  88. cd ../
  89. # GRUB:
  90. cd grub/
  91. rm -rf .git
  92. rm -f .gitignore
  93. cd ../
  94. # SeaBIOS:
  95. cd seabios/
  96. rm -rf .git
  97. rm -f .gitignore
  98. cd ../
  99. cd ../
  100. # ### Prepare libreboot_bin archive ready for release
  101. # ----------------------------------------------------------------------------------------------------------------------------
  102. echo "Preparing libreboot_bin release archive"
  103. mkdir libreboot_bin
  104. # ---------------------------------------
  105. # Include the ROM's in the binary archive
  106. # ---------------------------------------
  107. cp -r bin libreboot_bin/
  108. # ---------------
  109. # SeaBIOS related
  110. # ---------------
  111. # Include SeaBIOS and SeaVGABIOS option ROM in the binary archive
  112. cp seabios/out/vgabios.bin libreboot_bin/
  113. cp seabios/out/bios.bin.elf libreboot_bin/
  114. # Add the script for it
  115. cp addseabios libreboot_bin/
  116. # Menu entry to be added to grub configs
  117. cp resources/grub/config/seabios.cfg libreboot_bin/
  118. # --------------
  119. # BUC.TS related
  120. # --------------
  121. # X60/T60: BUC.TS utility is needed to flash libreboot while Lenovo BIOS is running
  122. # Include it statically compiled
  123. cp -r bucts bucts_
  124. # make it statically compile
  125. ./builddeps-bucts static
  126. mkdir libreboot_bin/bucts
  127. mkdir libreboot_bin/bucts/"$arch"
  128. mv bucts/bucts libreboot_bin/bucts/"$arch"
  129. rm -rf bucts
  130. mv bucts_ bucts
  131. # ----------------
  132. # Flashrom related
  133. # ----------------
  134. # Flashrom is used to install libreboot on supported targets
  135. # Include it statically compiled
  136. cp -r flashrom flashrom_
  137. # make it statically compile
  138. ./builddeps-flashrom static
  139. mkdir libreboot_bin/flashrom
  140. cd flashrom/
  141. mkdir ../libreboot_bin/flashrom/"$arch"
  142. mv flashrom ../libreboot_bin/flashrom/"$arch"
  143. mv flashrom_lenovobios_sst ../libreboot_bin/flashrom/"$arch"
  144. mv flashrom_lenovobios_macronix ../libreboot_bin/flashrom/"$arch"
  145. cd ../
  146. rm -rf flashrom
  147. mv flashrom_ flashrom
  148. # ----------------
  149. # cbfstool related
  150. # ----------------
  151. # build cbfstool, compiled (statically linked) and include the binary
  152. cd coreboot/util/
  153. cp -r cbfstool cbfstool_
  154. cd cbfstool/
  155. make clean
  156. make SHARED=0 CC='gcc -static'
  157. mkdir ../../../libreboot_bin/cbfstool
  158. mkdir ../../../libreboot_bin/cbfstool/"$arch"
  159. mv cbfstool ../../../libreboot_bin/cbfstool/"$arch"/
  160. mv rmodtool ../../../libreboot_bin/cbfstool/"$arch"/
  161. if [ "$arch" = "x86_64" ]
  162. then
  163. # Now build 32-bit binaries
  164. make clean
  165. make SHARED=0 CC='gcc -static -m32'
  166. mkdir ../../../libreboot_bin/cbfstool/i686
  167. mv cbfstool ../../../libreboot_bin/cbfstool/i686/
  168. mv rmodtool ../../../libreboot_bin/cbfstool/i686/
  169. fi
  170. # cross-compile for ARM
  171. make clean
  172. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  173. mkdir ../../../libreboot_bin/cbfstool/armv7l
  174. mv cbfstool ../../../libreboot_bin/cbfstool/armv7l/
  175. mv rmodtool ../../../libreboot_bin/cbfstool/armv7l/
  176. cd ../
  177. rm -rf cbfstool
  178. mv cbfstool_ cbfstool
  179. cd ../../
  180. # ----------------
  181. # ich9deblob related
  182. # ----------------
  183. # build ich9deblob, compiled (statically linked) and include the binary
  184. cd resources/utilities/
  185. cp -r ich9deblob ich9deblob_
  186. cd ich9deblob/
  187. make clean
  188. make SHARED=0 CC='gcc -static'
  189. mkdir ../../../libreboot_bin/ich9deblob
  190. mkdir ../../../libreboot_bin/ich9deblob/"$arch"
  191. mv ich9deblob ../../../libreboot_bin/ich9deblob/"$arch"/
  192. mv ich9gen ../../../libreboot_bin/ich9deblob/"$arch"/
  193. if [ "$arch" = "x86_64" ]
  194. then
  195. # Now build 32-bit binaries
  196. make clean
  197. make SHARED=0 CC='gcc -static -m32'
  198. mkdir ../../../libreboot_bin/ich9deblob/i686
  199. mv ich9deblob ../../../libreboot_bin/ich9deblob/i686/
  200. mv ich9gen ../../../libreboot_bin/ich9deblob/i686/
  201. fi
  202. # cross-compile for ARM
  203. make clean
  204. make SHARED=0 CC='arm-linux-gnueabi-gcc -static'
  205. mkdir ../../../libreboot_bin/ich9deblob/armv7l
  206. mv ich9deblob ../../../libreboot_bin/ich9deblob/armv7l/
  207. mv ich9gen ../../../libreboot_bin/ich9deblob/armv7l/
  208. cd ../
  209. rm -rf ich9deblob
  210. mv ich9deblob_ ich9deblob
  211. cd ../../
  212. # -----------------
  213. # nvramtool related
  214. # -----------------
  215. # build nvramtool, compiled (statically linked) and include the binary
  216. cd coreboot/util/
  217. cp -r nvramtool nvramtool_
  218. cd nvramtool/
  219. make clean
  220. make SHARED=0 CC='gcc -static'
  221. mkdir ../../../libreboot_bin/nvramtool
  222. mkdir ../../../libreboot_bin/nvramtool/"$arch"
  223. mv nvramtool ../../../libreboot_bin/nvramtool/"$arch"/
  224. if [ "$arch" = "x86_64" ]
  225. then
  226. # Now build 32-bit binaries
  227. make clean
  228. make SHARED=0 CC='gcc -static -m32'
  229. mkdir ../../../libreboot_bin/nvramtool/i686
  230. mv nvramtool ../../../libreboot_bin/nvramtool/i686/
  231. fi
  232. cd ../
  233. rm -rf nvramtool
  234. mv nvramtool_ nvramtool
  235. cd ../../
  236. # -----------------
  237. # cbmem related
  238. # -----------------
  239. # build cbmem, compiled (statically linked) and include the binary
  240. cd coreboot/util/
  241. cp -r cbmem cbmem_
  242. cd cbmem/
  243. make clean
  244. make SHARED=0 CC='gcc -static'
  245. mkdir ../../../libreboot_bin/cbmem
  246. mkdir ../../../libreboot_bin/cbmem/"$arch"
  247. mv cbmem ../../../libreboot_bin/cbmem/"$arch"/
  248. if [ "$arch" = "x86_64" ]
  249. then
  250. # Now build 32-bit binaries
  251. make clean
  252. make SHARED=0 CC='gcc -static -m32'
  253. mkdir ../../../libreboot_bin/cbmem/i686
  254. mv cbmem ../../../libreboot_bin/cbmem/i686/
  255. fi
  256. cd ../
  257. rm -rf cbmem
  258. mv cbmem_ cbmem
  259. cd ../../
  260. # ---------------------
  261. # Include documentation
  262. # ---------------------
  263. cp -r docs libreboot_bin/
  264. # -----------------------------------------------------------------------
  265. # X60/X60T/T60: Script for setting up powertop (kills high pitched noise)
  266. # -----------------------------------------------------------------------
  267. cp powertop.trisquel6 libreboot_bin/
  268. cp powertop.trisquel6.init libreboot_bin/
  269. cp powertop.trisquel7 libreboot_bin/
  270. cp powertop.trisquel7.init libreboot_bin/
  271. # -------------
  272. # Miscellaneous
  273. # -------------
  274. # include X60 cmos.layout file
  275. cp coreboot/src/mainboard/lenovo/x60/cmos.layout libreboot_bin/x60cmos.layout
  276. cp coreboot/src/mainboard/lenovo/t60/cmos.layout libreboot_bin/t60cmos.layout
  277. cp coreboot/src/mainboard/apple/macbook21/cmos.layout libreboot_bin/macbook21cmos.layout
  278. # FLASHING SCRIPTS
  279. # Flashrom script (makes flashing easier: ./flash path/to/libreboot.rom)
  280. cp flash libreboot_bin/
  281. # Brick-prone flashing script (for mismatching board names, when they change)
  282. cp forceflash libreboot_bin/
  283. # X60/T60: so that the user can use libreboot_bin to overwrite lenovo bios with libreboot
  284. cp lenovobios_firstflash libreboot_bin/
  285. cp lenovobios_secondflash libreboot_bin/
  286. # For initial flashing on macbook21/11
  287. cp macbook21_firstflash libreboot_bin/
  288. # ich9macchange script (change MAC address on X200 ROMs, using ich9gen)
  289. cp ich9macchange libreboot_bin/
  290. # for changing the GRUB background
  291. cp grub-background libreboot_bin/
  292. # ### Create the release tarballs
  293. # ----------------------------------------------------------------------------------------------------------------------------
  294. # Also delete the manifest
  295. rm -f libreboot_src/releasefilelist
  296. rm -f libreboot_bin/releasefilelist
  297. rm -f releasefilelist
  298. # We don't want to encourage development
  299. # to happen on the release archives.
  300. # Development goes in git.
  301. rm -f libreboot_src/build-release
  302. rm -f libreboot_src/getall
  303. rm -f libreboot_src/getbucts
  304. rm -f libreboot_src/getcb
  305. rm -f libreboot_src/getflashrom
  306. rm -f libreboot_src/getgrub
  307. rm -f libreboot_src/getgrubinvaders
  308. rm -f libreboot_src/getmt86
  309. rm -f libreboot_src/getseabios
  310. # ich9deblob: there are certain files in there
  311. # that the user most likely does not want to share
  312. rm -f libreboot_src/resources/utilities/ich9deblob/deblobbed_descriptor.bin
  313. rm -f libreboot_src/resources/utilities/ich9deblob/factory.rom
  314. rm -f libreboot_src/resources/utilities/ich9deblob/libreboot.rom
  315. rm -f libreboot_src/resources/utilities/ich9deblob/mkdescriptor.c
  316. rm -f libreboot_src/resources/utilities/ich9deblob/mkdescriptor.h
  317. rm -f libreboot_src/resources/utilities/ich9deblob/mkgbe.c
  318. rm -f libreboot_src/resources/utilities/ich9deblob/mkgbe.h
  319. rm -f libreboot_src/resources/utilities/ich9deblob/ich9fdgbe_4m.bin
  320. rm -f libreboot_src/resources/utilities/ich9deblob/ich9fdgbe_8m.bin
  321. rm -f libreboot_src/mkgbe.c
  322. rm -f libreboot_src/mkgbe.h
  323. rm -f libreboot_src/ich9fdgbe_8m.bin
  324. rm -f libreboot_src/ich9fdgbe_4m.bin
  325. # delete the "tobuild"
  326. rm -rf libreboot_src/tobuild/
  327. rm -f libreboot_src/tobuild.tar.xz
  328. # delete the old commitid file
  329. rm -f commitid
  330. rm -f libreboot_src/commitid
  331. # create file showing the commit ID from git for this archive.
  332. cat .git/refs/heads/master > commitid
  333. # include it in the release archives
  334. cp commitid libreboot_src/
  335. cp commitid libreboot_bin/
  336. echo "Creating compressed libreboot_src release archive"
  337. # create lzma compressed src archive
  338. tar cfJ libreboot_src.tar.xz libreboot_src
  339. echo "Creating compressed libreboot_bin release archive"
  340. # create lzma compressed bin archive
  341. tar cfJ libreboot_bin.tar.xz libreboot_bin
  342. # ### Delete the uncompressed release directories
  343. # ----------------------------------------------------------------------------------------------------------------------------
  344. echo "Deleted the uncompressed release archives"
  345. rm -rf libreboot_src
  346. rm -rf libreboot_bin
  347. # For those utilities that have to be built on the target
  348. ./mkextbuild
  349. # DONE. See libreboot_src.tar.xz and libreboot_bin.tar.xz
  350. # NOTE FOR FCHMMR: don't forget to add ARM binaries for flashrom
  351. # NOTE FOR FCHMMR: don't forget to add i386 binaries for flashrom/bucts
  352. # The tarball tobuild.tar.xz has been created with everything needed to build these utilities
  353. # ------------------- DONE ----------------------