roms 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/usr/bin/env sh
  2. #
  3. # helper script: generate release archive (ROM images)
  4. #
  5. # Copyright (C) 2020,2021,2022 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. if [ ! -d "bin/" ]; then
  34. printf "build/release/roms: no ROMs built yet. Exiting.\n"
  35. exit 1
  36. fi
  37. [ ! -d "release/" ] && \
  38. mkdir -p release/
  39. [ ! -d "release/${version}/" ] && \
  40. mkdir -p "release/${version}/"
  41. [ -d "release/${version}/roms/" ] && \
  42. rm -Rf "release/${version}/roms/"
  43. [ ! -d "release/${version}/roms/" ] && \
  44. mkdir -p "release/${version}/roms/"
  45. printf "Building ROM image archives for version %s\n" "${version}"
  46. for romdir in bin/*; do
  47. target="${romdir##*/}"
  48. echo ${target}
  49. if [ ! -d "${romdir}/" ]; then
  50. continue
  51. fi
  52. CONFIG_HAVE_MRC="y"
  53. CONFIG_HAVE_ME_BIN="y"
  54. grep "CONFIG_HAVE_ME_BIN=y" "resources/coreboot/${target}/config/"* || CONFIG_HAVE_ME_BIN="n"
  55. grep "CONFIG_HAVE_MRC=y" "resources/coreboot/${target}/config/"* || CONFIG_HAVE_MRC="n"
  56. # remove ME/MRC from ROM images
  57. if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
  58. if [ ! -d coreboot/default ]; then
  59. ./download coreboot default || exit 1
  60. fi
  61. ifdtooldir="coreboot/default/util/ifdtool"
  62. ifdtool="${ifdtooldir}/ifdtool"
  63. if [ ! -f "${ifdtool}" ]; then
  64. ./build module cbutils default || exit 1
  65. fi
  66. cbfstooldir="coreboot/default/util/cbfstool"
  67. cbfstool="${cbfstooldir}/cbfstool"
  68. if [ ! -f "${cbfstool}" ]; then
  69. ./build module cbutils default || exit 1
  70. fi
  71. rm -Rf "${romdir}_tmp" # dirty hack, to reduce disk io later
  72. # rather than using /tmp, which might not be tmpfs
  73. mkdir "${romdir}_tmp"
  74. for romfile in "${romdir}"/*.rom
  75. do
  76. if [ ! -f "${romfile}" ]
  77. then
  78. continue
  79. fi
  80. ${ifdtool} --nuke me "${romfile}" || exit 1
  81. mv "${romfile}" "${romdir}_tmp"/
  82. mv "${romfile}.new" "${romfile}"
  83. if [ "${CONFIG_HAVE_MRC}" = "y" ]
  84. then
  85. ${cbfstool} "${romfile}" remove -n mrc.bin || exit 1
  86. ${cbfstool} "${romfile}" print
  87. fi
  88. done
  89. fi
  90. printf "Generating release/%s/roms/%s-%s_%s.tar.xz\n" "${version}" "${projectname}" "${version}" "${target##*/}"
  91. printf "%s\n" "${version}" > "${romdir}/version"
  92. printf "%s\n" "${versiondate}" > "${romdir}/versiondate"
  93. printf "%s\n" "${projectname}" > "${romdir}/projectname"
  94. tar -c "${romdir}/" | xz -9e >"release/${version}/roms/${projectname}-${version}_${target##*/}.tar.xz"
  95. if [ -d "${romdir}_tmp" ]
  96. then
  97. rm -Rf "${romdir}"
  98. mv "${romdir}_tmp" "${romdir}"
  99. fi
  100. done
  101. printf "\nROM image release archives available at release/%s/roms/\n\n" "${version}"