u-boot-libre 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. #
  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. revision="r1"
  24. supported_uboot_versions=" \
  25. 2021.07 \
  26. "
  27. topdir="$(realpath $(dirname $(realpath $0))/../../../../)"
  28. uboot_release_topdir="${topdir}/release/u-boot-libre"
  29. release_files=""
  30. usage()
  31. {
  32. progname="resources/scripts/build/release/u-boot-libre"
  33. printf "Usage:\n"
  34. printf "\t%s # %s\n" \
  35. "${progname}" \
  36. "Release deblobbed u-boot tarballs for all supported versions"
  37. printf "\t%s [version] # %s\n" \
  38. "${progname}" \
  39. "Release deblobbed u-boot tarballs for the given versions"
  40. printf "\t%s --list-versions # %s\n" \
  41. "${progname}" \
  42. "List supported u-boot versions"
  43. printf "\t%s --help # %s\n" \
  44. "${progname}" \
  45. "Prints this help"
  46. }
  47. append_release_file()
  48. {
  49. if [ -z "${release_files}" ] ; then
  50. release_files="${release_files}$1"
  51. else
  52. release_files="${release_files} $1"
  53. fi
  54. }
  55. append_release_files()
  56. {
  57. for file in "$@" ; do
  58. append_release_file "${file}"
  59. done
  60. }
  61. print_release_files()
  62. {
  63. version="$1"
  64. printf "Source code archives for u-boot-libre-%s-%s available at:\n" \
  65. "${version}" "${revision}"
  66. for file in ${release_files} ; do
  67. printf "\t${file}\n"
  68. done
  69. }
  70. release_deblobbed_uboot()
  71. {
  72. version="$1"
  73. release_version_dir="${uboot_release_topdir}/${version}-${revision}"
  74. tmpdir="${release_version_dir}/u-boot-libre-${version}-${revision}"
  75. tarball="${tmpdir}.tar"
  76. printf "Building source code archive, version %s revision %s\n" \
  77. "${version}" "${revision}"
  78. cd "${topdir}"
  79. "${topdir}/download" u-boot "v${version}"
  80. rm -rf \
  81. "${tmpdir}/" \
  82. "${tarball}" \
  83. "${tarball}.lz" \
  84. "${tarball}.xz"
  85. mkdir -p "$(dirname ${tmpdir})"
  86. cp -R "u-boot/u-boot/" "${tmpdir}"
  87. rm -rf ${tmpdir}/.git ${tmpdir}/.gitignore
  88. make -C ${tmpdir} distclean
  89. prefix="$(dirname ${tmpdir} | sed 's#^/*##')/"
  90. tar cf "${tarball}" "${tmpdir}" \
  91. --transform="s#${prefix}##" \
  92. --format=gnu \
  93. --sort=name \
  94. --owner=0 --group=0 --numeric-owner \
  95. --mtime="1970-01-01" \
  96. lzip -9 --keep -vv "${tarball}"
  97. xz -9 --keep -vv "${tarball}"
  98. rm -rf "${tmpdir}/"
  99. append_release_files \
  100. "${tarball}" \
  101. "${tarball}.lz" \
  102. "${tarball}.xz"
  103. }
  104. release_uboot_blobs_list()
  105. {
  106. version="$1"
  107. blobs_list="$(${topdir}/download u-boot --blobs-list v${version})"
  108. release_version_dir="${uboot_release_topdir}/${version}-${revision}"
  109. destination="${release_version_dir}/blobs-${version}-${revision}.list"
  110. cd "${topdir}"
  111. rm -rf \
  112. "${destination}" \
  113. "${destination}.lz" \
  114. "${destination}.xz"
  115. install -m 755 -d "${release_version_dir}"
  116. install -m 644 -T "${blobs_list}" "${destination}"
  117. lzip -9 --keep -vv "${destination}"
  118. xz -9 --keep -vv "${destination}"
  119. append_release_files \
  120. "${destination}" \
  121. "${destination}.lz" \
  122. "${destination}.xz"
  123. }
  124. release_uboot_deblob_script()
  125. {
  126. version="$1"
  127. deblob_script="$(${topdir}/download u-boot --gen-deblob-script v${version})"
  128. release_version_dir="${uboot_release_topdir}/${version}-${revision}"
  129. destination="${release_version_dir}/deblob-${version}-${revision}.sh"
  130. cd "${topdir}"
  131. rm -rf \
  132. "${destination}" \
  133. "${destination}.lz" \
  134. "${destination}.xz"
  135. install -m 755 -d "${release_version_dir}"
  136. install -m 644 -T "${blobs_list}" "${destination}"
  137. lzip -9 --keep -vv "${destination}"
  138. xz -9 --keep -vv "${destination}"
  139. append_release_files \
  140. "${destination}" \
  141. "${destination}.lz" \
  142. "${destination}.xz"
  143. }
  144. if [ $# -eq 0 ] ; then
  145. for version in ${supported_uboot_versions} ; do
  146. release_deblobbed_uboot "${version}"
  147. release_uboot_blobs_list "${version}"
  148. release_uboot_deblob_script "${version}"
  149. print_release_files "${version}"
  150. done
  151. exit 0
  152. elif [ $# -eq 1 -a "$1" == "--help" ] ; then
  153. usage
  154. exit 0
  155. elif [ $# -eq 1 -a "$1" == "--list-versions" ] ; then
  156. for version in ${supported_uboot_versions} ; do
  157. printf "${version}\n"
  158. done
  159. exit 0
  160. elif [ $# -eq 1 ] ; then
  161. found=0
  162. for revision in ${supported_uboot_revisions} ; do
  163. if [ "${revision}" = "$1" ] ; then
  164. release_deblobbed_uboot "$1"
  165. release_uboot_blobs_list "$1"
  166. release_uboot_deblob_script "$1"
  167. print_release_files "$1"
  168. exit 0
  169. fi
  170. done
  171. printf "Error: Version '${1}' is not supported\n"
  172. exit 1
  173. fi
  174. exit 0