maketgz 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #!/bin/sh
  2. # Script to build release-archives with. Note that this requires a checkout
  3. # from git and you should first run ./buildconf and build curl once.
  4. #
  5. #***************************************************************************
  6. # _ _ ____ _
  7. # Project ___| | | | _ \| |
  8. # / __| | | | |_) | |
  9. # | (__| |_| | _ <| |___
  10. # \___|\___/|_| \_\_____|
  11. #
  12. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  13. #
  14. # This software is licensed as described in the file COPYING, which
  15. # you should have received as part of this distribution. The terms
  16. # are also available at https://curl.se/docs/copyright.html.
  17. #
  18. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  19. # copies of the Software, and permit persons to whom the Software is
  20. # furnished to do so, under the terms of the COPYING file.
  21. #
  22. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  23. # KIND, either express or implied.
  24. #
  25. # SPDX-License-Identifier: curl
  26. #
  27. ###########################################################################
  28. set -eu
  29. export LC_ALL=C
  30. export TZ=UTC
  31. version="${1:-}"
  32. if [ -z "$version" ]; then
  33. echo "Specify a version number!"
  34. exit
  35. fi
  36. if [ "only" = "${2:-}" ]; then
  37. echo "Setup version number only!"
  38. only=1
  39. else
  40. only=
  41. fi
  42. libversion="$version"
  43. # we make curl the same version as libcurl
  44. curlversion="$libversion"
  45. major=$(echo "$libversion" | cut -d. -f1 | sed -e "s/[^0-9]//g")
  46. minor=$(echo "$libversion" | cut -d. -f2 | sed -e "s/[^0-9]//g")
  47. patch=$(echo "$libversion" | cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g")
  48. if test -z "$patch"; then
  49. echo "invalid version number? needs to be z.y.z"
  50. exit
  51. fi
  52. #
  53. # As a precaution, remove all *.dist files that may be lying around, to reduce
  54. # the risk of old leftovers getting shipped. The root 'Makefile.dist' is the
  55. # exception.
  56. echo "removing all old *.dist files"
  57. find . -name "*.dist" -a ! -name Makefile.dist -exec rm {} \;
  58. numeric="$(printf "%02x%02x%02x\n" "$major" "$minor" "$patch")"
  59. HEADER=include/curl/curlver.h
  60. CHEADER=src/tool_version.h
  61. if test -z "$only"; then
  62. ext=".dist"
  63. # when not setting up version numbers locally
  64. for a in $HEADER $CHEADER; do
  65. cp "$a" "$a$ext"
  66. done
  67. HEADER="$HEADER$ext"
  68. CHEADER="$CHEADER$ext"
  69. fi
  70. # requires a date command that knows + for format and -d for date input
  71. timestamp=${SOURCE_DATE_EPOCH:-$(date +"%s")}
  72. datestamp=$(date -d "@$timestamp" +"%F")
  73. filestamp=$(date -d "@$timestamp" +"%Y%m%d%H%M.%S")
  74. # Replace version number in header file:
  75. sed -i.bak \
  76. -e "s/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION \"$libversion\"/g" \
  77. -e "s/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x$numeric/g" \
  78. -e "s/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR $major/g" \
  79. -e "s/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR $minor/g" \
  80. -e "s/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH $patch/g" \
  81. -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
  82. "$HEADER"
  83. rm -f "$HEADER.bak"
  84. # Replace version number in header file:
  85. sed -i.bak "s/#define CURL_VERSION .*/#define CURL_VERSION \"$curlversion\"/g" "$CHEADER"
  86. rm -f "$CHEADER.bak"
  87. if test -n "$only"; then
  88. # done!
  89. exit
  90. fi
  91. echo "curl version $curlversion"
  92. echo "libcurl version $libversion"
  93. echo "libcurl numerical $numeric"
  94. echo "datestamp $datestamp"
  95. findprog() {
  96. file="$1"
  97. for part in $(echo "$PATH" | tr ':' ' '); do
  98. path="$part/$file"
  99. if [ -x "$path" ]; then
  100. # there it is!
  101. return 1
  102. fi
  103. done
  104. # no such executable
  105. return 0
  106. }
  107. ############################################################################
  108. #
  109. # Enforce a rerun of configure (updates the VERSION)
  110. #
  111. echo "Re-running config.status"
  112. ./config.status --recheck >/dev/null
  113. ############################################################################
  114. #
  115. # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
  116. # been modified.
  117. #
  118. if { findprog automake >/dev/null 2>/dev/null; } then
  119. echo "- Could not find or run automake, I hope you know what you are doing!"
  120. else
  121. echo "Runs automake --include-deps"
  122. automake --include-deps Makefile >/dev/null
  123. fi
  124. echo "produce CHANGES"
  125. git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./scripts/log2changes.pl > CHANGES.dist
  126. echo "produce RELEASE-TOOLS.md"
  127. ./scripts/release-tools.sh "$timestamp" "$version" > docs/RELEASE-TOOLS.md.dist
  128. ############################################################################
  129. #
  130. # Now run make dist to generate a tar.gz archive
  131. #
  132. echo "make dist"
  133. targz="curl-$version.tar.gz"
  134. make -sj dist "VERSION=$version"
  135. res=$?
  136. if test "$res" != 0; then
  137. echo "make dist failed"
  138. exit 2
  139. fi
  140. retar() {
  141. tempdir=$1
  142. rm -rf "$tempdir"
  143. mkdir "$tempdir"
  144. cd "$tempdir"
  145. gzip -dc "../$targz" | tar -xf -
  146. find curl-* -depth -exec touch -c -t "$filestamp" '{}' +
  147. tar --create --format=ustar --owner=0 --group=0 --numeric-owner --sort=name curl-* | gzip --best --no-name > out.tar.gz
  148. mv out.tar.gz ../
  149. cd ..
  150. rm -rf "$tempdir"
  151. }
  152. retar ".tarbuild"
  153. echo "replace $targz with out.tar.gz"
  154. mv out.tar.gz "$targz"
  155. ############################################################################
  156. #
  157. # Now make a bz2 archive from the tar.gz original
  158. #
  159. bzip2="curl-$version.tar.bz2"
  160. echo "Generating $bzip2"
  161. gzip -dc "$targz" | bzip2 --best > "$bzip2"
  162. ############################################################################
  163. #
  164. # Now make an xz archive from the tar.gz original
  165. #
  166. xz="curl-$version.tar.xz"
  167. echo "Generating $xz"
  168. gzip -dc "$targz" | xz -6e - > "$xz"
  169. ############################################################################
  170. #
  171. # Now make a zip archive from the tar.gz original
  172. #
  173. makezip() {
  174. rm -rf "$tempdir"
  175. mkdir "$tempdir"
  176. cd "$tempdir"
  177. gzip -dc "../$targz" | tar -xf -
  178. find . | sort | zip -9 -X "$zip" -@ >/dev/null
  179. mv "$zip" ../
  180. cd ..
  181. rm -rf "$tempdir"
  182. }
  183. zip="curl-$version.zip"
  184. echo "Generating $zip"
  185. tempdir=".builddir"
  186. makezip
  187. # Set deterministic timestamp
  188. touch -c -t "$filestamp" "$targz" "$bzip2" "$xz" "$zip"
  189. echo "------------------"
  190. echo "maketgz report:"
  191. echo ""
  192. ls -l "$targz" "$bzip2" "$xz" "$zip"
  193. sha256sum "$targz" "$bzip2" "$xz" "$zip"
  194. echo "Run this:"
  195. echo "gpg -b -a '$targz' && gpg -b -a '$bzip2' && gpg -b -a '$xz' && gpg -b -a '$zip'"