u-boot-libre 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #!/usr/bin/env bash
  2. #
  3. # helper script: generate deblobbed stable u-boot source code releases
  4. #
  5. # Copyright (C) 2020,2021 Leah Rowe <info@minifree.org>
  6. # Copyright (C) 2022 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
  7. # Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
  8. #
  9. # This program is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. #
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. revision="r2"
  25. supported_uboot_versions=" \
  26. 2021.07 \
  27. 2022.07 \
  28. "
  29. topdir="$(realpath $(dirname $(realpath $0))/../../../../)"
  30. uboot_release_topdir="${topdir}/release/u-boot-libre"
  31. release_files=""
  32. usage()
  33. {
  34. progname="resources/scripts/build/release/u-boot-libre"
  35. printf "Usage:\n"
  36. printf "\t%s # %s\n" \
  37. "${progname}" \
  38. "Release deblobbed u-boot tarballs for all supported versions"
  39. printf "\t%s [version] # %s\n" \
  40. "${progname}" \
  41. "Release deblobbed u-boot tarballs for the given versions"
  42. printf "\t%s --list-versions # %s\n" \
  43. "${progname}" \
  44. "List supported u-boot versions"
  45. printf "\t%s --help # %s\n" \
  46. "${progname}" \
  47. "Prints this help"
  48. }
  49. append_release_file()
  50. {
  51. if [ -z "${release_files}" ] ; then
  52. release_files="${release_files}$1"
  53. else
  54. release_files="${release_files} $1"
  55. fi
  56. }
  57. append_release_files()
  58. {
  59. for file in "$@" ; do
  60. append_release_file "${file}"
  61. done
  62. }
  63. print_release_files()
  64. {
  65. version="$1"
  66. printf "Source code archives for u-boot-libre-%s-%s available at:\n" \
  67. "${version}" "${revision}"
  68. for file in ${release_files} ; do
  69. printf "\t${file}\n"
  70. done
  71. }
  72. release_deblobbed_uboot()
  73. {
  74. version="$1"
  75. release_version_dir="${uboot_release_topdir}/${version}-${revision}"
  76. tmpdir="${release_version_dir}/u-boot-libre-${version}-${revision}"
  77. tarball="${tmpdir}.tar"
  78. printf "Building source code archive, version %s revision %s\n" \
  79. "${version}" "${revision}"
  80. cd "${topdir}"
  81. "${topdir}/download" u-boot "v${version}"
  82. rm -rf \
  83. "${tmpdir}/" \
  84. "${tarball}" \
  85. "${tarball}.lz" \
  86. "${tarball}.xz"
  87. mkdir -p "$(dirname ${tmpdir})"
  88. cp -R "u-boot/v${version}/" "${tmpdir}"
  89. rm -rf ${tmpdir}/.git ${tmpdir}/.gitignore
  90. make -C ${tmpdir} distclean
  91. prefix="$(dirname ${tmpdir} | sed 's#^/*##')/"
  92. tar cf "${tarball}" "${tmpdir}" \
  93. --transform="s#${prefix}##" \
  94. --format=gnu \
  95. --sort=name \
  96. --owner=0 --group=0 --numeric-owner \
  97. --mtime="@${SOURCE_DATE_EPOCH:-0}" \
  98. lzip -9 --keep -vv "${tarball}"
  99. xz -9 --keep -vv "${tarball}"
  100. rm -rf "${tmpdir}/"
  101. append_release_files \
  102. "${tarball}" \
  103. "${tarball}.lz" \
  104. "${tarball}.xz"
  105. }
  106. release_uboot_blobs_list()
  107. {
  108. version="$1"
  109. blobs_list="$(${topdir}/download u-boot --blobs-list v${version})"
  110. release_version_dir="${uboot_release_topdir}/${version}-${revision}"
  111. destination="${release_version_dir}/blobs-${version}-${revision}.list"
  112. cd "${topdir}"
  113. rm -rf \
  114. "${destination}" \
  115. "${destination}.lz" \
  116. "${destination}.xz"
  117. install -m 755 -d "${release_version_dir}"
  118. install -m 644 -T "${blobs_list}" "${destination}"
  119. lzip -9 --keep -vv "${destination}"
  120. xz -9 --keep -vv "${destination}"
  121. append_release_files \
  122. "${destination}" \
  123. "${destination}.lz" \
  124. "${destination}.xz"
  125. }
  126. release_uboot_deblob_script()
  127. {
  128. version="$1"
  129. deblob_script="$(${topdir}/download u-boot --gen-deblob-script v${version})"
  130. release_version_dir="${uboot_release_topdir}/${version}-${revision}"
  131. destination="${release_version_dir}/deblob-${version}-${revision}.sh"
  132. cd "${topdir}"
  133. rm -rf \
  134. "${destination}" \
  135. "${destination}.lz" \
  136. "${destination}.xz"
  137. install -m 755 -d "${release_version_dir}"
  138. install -m 644 -T "${deblob_script}" "${destination}"
  139. lzip -9 --keep -vv "${destination}"
  140. xz -9 --keep -vv "${destination}"
  141. append_release_files \
  142. "${destination}" \
  143. "${destination}.lz" \
  144. "${destination}.xz"
  145. }
  146. if [ $# -eq 0 ] ; then
  147. for version in ${supported_uboot_versions} ; do
  148. release_deblobbed_uboot "${version}"
  149. release_uboot_blobs_list "${version}"
  150. release_uboot_deblob_script "${version}"
  151. print_release_files "${version}"
  152. done
  153. exit 0
  154. elif [ $# -eq 1 -a "$1" == "--help" ] ; then
  155. usage
  156. exit 0
  157. elif [ $# -eq 1 -a "$1" == "--list-versions" ] ; then
  158. for version in ${supported_uboot_versions} ; do
  159. printf "${version}\n"
  160. done
  161. exit 0
  162. elif [ $# -eq 1 ] ; then
  163. found=0
  164. for revision in ${supported_uboot_revisions} ; do
  165. if [ "${revision}" = "$1" ] ; then
  166. release_deblobbed_uboot "$1"
  167. release_uboot_blobs_list "$1"
  168. release_uboot_deblob_script "$1"
  169. print_release_files "$1"
  170. exit 0
  171. fi
  172. done
  173. printf "Error: Version '${1}' is not supported\n"
  174. exit 1
  175. fi
  176. exit 0