tobuild 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/usr/bin/env bash
  2. # helper: prepare a small source archive for those utils
  3. # that don't easily cross-compile. Then the tarball can be extracted
  4. # on those systems with the target architecture, and compiled.
  5. #
  6. # Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. [ "x${DEBUG+set}" = 'xset' ] && set -v
  22. set -u -e
  23. if [ -f "version" ]; then
  24. # _src release archive is being used
  25. version="$(cat version)"
  26. versiondate="$(cat versiondate)"
  27. else
  28. # git repo is being used
  29. version="$(git describe --tags HEAD)"
  30. versiondate="$(git show -s --format=%ct)"
  31. fi
  32. versiondir="release/oldbuildsystem/${version}"
  33. distname="libreboot_${version}_tobuild"
  34. distdir="${versiondir}/${distname}"
  35. printf "Creating source archive for flashrom and bucts\n"
  36. # delete the old data
  37. rm -Rf "${distdir:?}/"
  38. rm -f "${distdir}.tar.xz"
  39. # this is where they will go
  40. mkdir -p "${distdir}/"
  41. # flashrom
  42. cp -R "flashrom/" "${distdir}/"
  43. rm -f "${distdir}/flashrom/flashrom_lenovobios_sst"
  44. rm -f "${distdir}/flashrom/flashrom_lenovobios_macronix"
  45. (cd "${distdir}/flashrom/" && make clean)
  46. mkdir -p "${distdir}/resources/flashrom/"
  47. cp -R "resources/flashrom/patch/" "${distdir}/resources/flashrom/"
  48. # bucts
  49. cp -R "bucts/" "${distdir}/"
  50. (cd "${distdir}/bucts/" && make clean)
  51. mkdir -p "${distdir}/resources/bucts/"
  52. cp -R "resources/bucts/patch/" "${distdir}/resources/bucts/"
  53. # the build script will be needed
  54. cp build "${distdir}/"
  55. # needed build scripts (helpers)
  56. mkdir -p "${distdir}/resources/scripts/helpers/build/"
  57. mkdir -p "${distdir}/resources/scripts/helpers/build/module/"
  58. mkdir -p "${distdir}/resources/scripts/helpers/build/clean/"
  59. cp "resources/scripts/helpers/build/clean/bucts" "${distdir}/resources/scripts/helpers/build/clean/"
  60. cp "resources/scripts/helpers/build/clean/flashrom" "${distdir}/resources/scripts/helpers/build/clean/"
  61. cp "resources/scripts/helpers/build/module/bucts" "${distdir}/resources/scripts/helpers/build/module/"
  62. cp "resources/scripts/helpers/build/module/flashrom" "${distdir}/resources/scripts/helpers/build/module/"
  63. cp "resources/scripts/misc/powertop.trisquel7" "${distdir}/"
  64. # this has to be done before generating
  65. # the "version" file
  66. if [ ! -f "version" ]; then
  67. # generate ChangeLog and NEWS files
  68. rm -f "ChangeLog" "NEWS"
  69. git log > "${distdir}/ChangeLog"
  70. cp "${distdir}/ChangeLog" "${distdir}/NEWS"
  71. else
  72. # building from release archive
  73. cp "ChangeLog" "${distdir}/"
  74. cp "NEWS" "${distdir}/"
  75. fi
  76. if [ -f "RELEASE" ]; then
  77. rm -f "${distdir}/ChangeLog"
  78. rm -f "${distdir}/NEWS"
  79. cp "RELEASE" "${distdir}/ChangeLog"
  80. cp "RELEASE" "${distdir}/NEWS"
  81. fi
  82. # include version information
  83. printf '%s\n' "${version}" >"${distdir}/version"
  84. # include version date information
  85. printf '%s\n' "${versiondate}" >"${distdir}/versiondate"
  86. # that is all. now tar it up
  87. (cd "${versiondir}/" && tar -c "${distname}/" | xz -9e >"${distname}.tar.xz")
  88. # and delete the directory
  89. rm -Rf "${distdir:?}/"
  90. printf "\n"
  91. printf "Tar archive created: %s\n" "${distdir}.tar.xz"
  92. printf "NOTE: don't forget to add ARM binaries for flashrom.\n"
  93. printf "NOTE: don't forget to add i386 binaries for flashrom/bucts.\n"
  94. printf "The archive %s.tar.xz has been created with everything needed to build these utilities.\n\n" "${distname}"