maketgz (6574B)
1 #!/bin/sh 2 # Script to build release-archives with. Note that this requires a checkout 3 # from git and you should first run autoreconf -fi 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 29 set -eu 30 31 export LC_ALL=C 32 export TZ=UTC 33 34 version="${1:-}" 35 cmd="${2:-}" 36 37 if [ -z "$version" ]; then 38 echo "Specify a version number!" 39 exit 40 fi 41 42 echo "$cmd" 43 44 only="" 45 if [ "only" = "$cmd" ]; then 46 echo "Setup version number only!" 47 only=1 48 fi 49 50 commit="" 51 if [ "commit" = "$cmd" ]; then 52 commit=1 53 fi 54 55 libversion="$version" 56 57 # we make curl the same version as libcurl 58 curlversion="$libversion" 59 60 major=$(echo "$libversion" | cut -d. -f1 | sed -e "s/[^0-9]//g") 61 minor=$(echo "$libversion" | cut -d. -f2 | sed -e "s/[^0-9]//g") 62 patch=$(echo "$libversion" | cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g") 63 64 if test -z "$patch"; then 65 echo "invalid version number? needs to be z.y.z" 66 exit 67 fi 68 69 # 70 # As a precaution, remove all *.dist files that may be lying around, to reduce 71 # the risk of old leftovers getting shipped. 72 echo "removing all old *.dist files" 73 find . -name "*.dist" -exec rm {} \; 74 75 numeric="$(printf "%02x%02x%02x\n" "$major" "$minor" "$patch")" 76 77 HEADER=include/curl/curlver.h 78 CHEADER=src/tool_version.h 79 80 if test -z "$only"; then 81 ext=".dist" 82 # when not setting up version numbers locally 83 for a in $HEADER $CHEADER; do 84 cp "$a" "$a$ext" 85 done 86 HEADER="$HEADER$ext" 87 CHEADER="$CHEADER$ext" 88 fi 89 90 # requires a date command that knows + for format and -d for date input 91 timestamp=${SOURCE_DATE_EPOCH:-$(date +"%s")} 92 datestamp=$(date -d "@$timestamp" +"%F") 93 filestamp=$(date -d "@$timestamp" +"%Y%m%d%H%M.%S") 94 95 # Replace version number in header file: 96 sed -i \ 97 -e "s/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION \"$libversion\"/g" \ 98 -e "s/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x$numeric/g" \ 99 -e "s/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR $major/g" \ 100 -e "s/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR $minor/g" \ 101 -e "s/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH $patch/g" \ 102 -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \ 103 "$HEADER" 104 105 # Replace version number in header file: 106 sed -i "s/#define CURL_VERSION .*/#define CURL_VERSION \"$curlversion\"/g" "$CHEADER" 107 108 if test -n "$only"; then 109 # done! 110 exit 111 fi 112 113 echo "curl version $curlversion" 114 echo "libcurl version $libversion" 115 echo "libcurl numerical $numeric" 116 echo "datestamp $datestamp" 117 118 findprog() { 119 file="$1" 120 for part in $(echo "$PATH" | tr ':' ' '); do 121 path="$part/$file" 122 if [ -x "$path" ]; then 123 # there it is! 124 return 1 125 fi 126 done 127 128 # no such executable 129 return 0 130 } 131 132 ############################################################################ 133 # 134 # Enforce a rerun of configure (updates the VERSION) 135 # 136 137 echo "Re-running config.status" 138 ./config.status --recheck >/dev/null 139 140 echo "Recreate the built-in manual (with correct version)" 141 export CURL_MAKETGZ_VERSION="$version" 142 rm -f docs/cmdline-opts/curl.txt 143 make -C src 144 145 ############################################################################ 146 # 147 # automake is needed to run to make a non-GNU Makefile.in if Makefile.am has 148 # been modified. 149 # 150 151 if { findprog automake >/dev/null 2>/dev/null; } then 152 echo "- Could not find or run automake, I hope you know what you are doing!" 153 else 154 echo "Runs automake --include-deps" 155 automake --include-deps Makefile >/dev/null 156 fi 157 158 if test -n "$commit"; then 159 echo "produce docs/tarball-commit.txt" 160 git rev-parse HEAD >docs/tarball-commit.txt.dist 161 fi 162 163 echo "produce RELEASE-TOOLS.md" 164 ./scripts/release-tools.sh "$timestamp" "$version" "$commit" > docs/RELEASE-TOOLS.md.dist 165 166 ############################################################################ 167 # 168 # Now run make dist to generate a tar.gz archive 169 # 170 171 echo "make dist" 172 targz="curl-$version.tar.gz" 173 make -sj dist "VERSION=$version" 174 res=$? 175 176 if test "$res" != 0; then 177 echo "make dist failed" 178 exit 2 179 fi 180 181 retar() { 182 tempdir=$1 183 rm -rf "$tempdir" 184 mkdir "$tempdir" 185 cd "$tempdir" 186 gzip -dc "../$targz" | tar -xf - 187 find curl-* -depth -exec touch -c -t "$filestamp" '{}' + 188 tar --create --format=ustar --owner=0 --group=0 --numeric-owner --sort=name curl-* | gzip --best --no-name > out.tar.gz 189 mv out.tar.gz ../ 190 cd .. 191 rm -rf "$tempdir" 192 } 193 194 retar ".tarbuild" 195 echo "replace $targz with out.tar.gz" 196 mv out.tar.gz "$targz" 197 198 ############################################################################ 199 # 200 # Now make a bz2 archive from the tar.gz original 201 # 202 203 bzip2="curl-$version.tar.bz2" 204 echo "Generating $bzip2" 205 gzip -dc "$targz" | bzip2 --best > "$bzip2" 206 207 ############################################################################ 208 # 209 # Now make an xz archive from the tar.gz original 210 # 211 212 xz="curl-$version.tar.xz" 213 echo "Generating $xz" 214 gzip -dc "$targz" | xz -6e - > "$xz" 215 216 ############################################################################ 217 # 218 # Now make a zip archive from the tar.gz original 219 # 220 makezip() { 221 rm -rf "$tempdir" 222 mkdir "$tempdir" 223 cd "$tempdir" 224 gzip -dc "../$targz" | tar -xf - 225 find . | sort | zip -9 -X "$zip" -@ >/dev/null 226 mv "$zip" ../ 227 cd .. 228 rm -rf "$tempdir" 229 } 230 231 zip="curl-$version.zip" 232 echo "Generating $zip" 233 tempdir=".builddir" 234 makezip 235 236 # Set deterministic timestamp 237 touch -c -t "$filestamp" "$targz" "$bzip2" "$xz" "$zip" 238 239 echo "------------------" 240 echo "maketgz report:" 241 echo "" 242 ls -l "$targz" "$bzip2" "$xz" "$zip" 243 sha256sum "$targz" "$bzip2" "$xz" "$zip" 244 245 echo "Run this:" 246 echo "gpg -b -a '$targz' && gpg -b -a '$bzip2' && gpg -b -a '$xz' && gpg -b -a '$zip'"