src 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/bin/env bash
  2. #
  3. # helper script: generate release archive (source code)
  4. #
  5. # Copyright (C) 2020,2021 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 working directory is the root
  21. # of git or release archive
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. projectname="$(cat projectname)"
  25. version="version-unknown"
  26. if [ -f version ]; then
  27. version="$(cat version)"
  28. fi
  29. versiondate="version-date-unknown"
  30. if [ -f versiondate ]; then
  31. versiondate="$(cat versiondate)"
  32. fi
  33. reldir="release/${version}"
  34. dirname="${projectname}-${version}_src"
  35. srcdir="${reldir}/${dirname}"
  36. printf "Building source code archive, version %s\n" "${version}"
  37. [ ! -d "release/" ] && mkdir -p release/
  38. [ ! -d "${reldir}/" ] && mkdir -p "${reldir}/"
  39. [ -d "${srcdir}/" ] && \
  40. rm -Rf "${srcdir}/"
  41. [ -f "${srcdir}.tar.xz" ] && \
  42. rm -f "${srcdir}.tar.xz/"
  43. mkdir -p "${srcdir}/"
  44. printf "%s" "${version}" > "${srcdir}"/version
  45. modlist="coreboot flashrom grub memtest86plus seabios ich9utils me_cleaner"
  46. dirlist="resources" # do not add blobs directory here. it is handled below
  47. filelist="blobutil modify download build README.md COPYING Makefile update version versiondate projectname .gitcheck"
  48. for modname in ${modlist}; do
  49. if [ ! -d "${modname}/" ]; then
  50. ./download ${modname}
  51. fi
  52. done
  53. for dir in ${modlist} ${dirlist}; do
  54. cp -R "${dir}/" "${srcdir}/"
  55. done
  56. mkdir -p "${srcdir}"/blobs
  57. # do not copy intel ME etc, but do copy ifd/gbe files
  58. for i in t440p w541 xx20 xx30; do
  59. for j in ifd gbe 16_ifd; do
  60. if [ -f "blobs/${i}/${j}.bin"]; then
  61. if [ ! -e "${srcdir}/blobs/${i}" ]; then
  62. mkdir -p "${srcdir}/blobs/${i}"
  63. fi
  64. cp blobs/${i}/${j}.bin "${srcdir}/blobs/${i}"
  65. fi
  66. done
  67. done
  68. for i in ${filelist}; do
  69. if [ ! -f "${i}" ]; then
  70. printf "build/release/src: ERROR: file '%s' does not exist.\n" "${i}"
  71. rm -Rf "${srcdir}"
  72. exit 1
  73. fi
  74. cp ${i} "${srcdir}/"
  75. done
  76. (
  77. cd "${srcdir}/coreboot/"
  78. for i in *; do
  79. [ ! -d "${i}" ] && continue
  80. (
  81. cd "${i}/"
  82. make distclean
  83. )
  84. done
  85. )
  86. (
  87. cd "${srcdir}/"
  88. ./build clean all
  89. rm -Rf coreboot/coreboot/
  90. rm -Rf .git* */.git* coreboot/*/.git* coreboot/*/3rdparty/*/.git*
  91. rm -Rf coreboot/*/util/nvidia/cbootimage/.git*
  92. )
  93. (
  94. cd "${reldir}/"
  95. printf "%s\n" "${version}" > "${dirname}/version"
  96. printf "%s\n" "${versiondate}" > "${dirname}/versiondate"
  97. printf "%s\n" "${projectname}" > "${dirname}/projectname"
  98. tar -c "${dirname}/" | xz -9e >"${dirname}.tar.xz"
  99. rm -Rf "${dirname}/"
  100. )
  101. printf "Source code archive available at %s.tar.xz\n\n" "${srcdir}"