blob: 92ea871af2dd6679ef80c15558dd325e8e419f75 [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001#!/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) 1998 - 2022, 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
29version=$1
30
31if [ -z "$version" ]; then
32 echo "Specify a version number!"
33 exit
34fi
35
36if [ "xonly" = "x$2" ]; then
37 echo "Setup version number only!"
38 only=1
39fi
40
41libversion="$version"
42
43# we make curl the same version as libcurl
44curlversion=$libversion
45
46major=`echo $libversion | cut -d. -f1 | sed -e "s/[^0-9]//g"`
47minor=`echo $libversion | cut -d. -f2 | sed -e "s/[^0-9]//g"`
48patch=`echo $libversion | cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
49
50if test -z "$patch"; then
51 echo "invalid version number? needs to be z.y.z"
52 exit
53fi
54
55#
56# As a precaution, remove all *.dist files that may be lying around, to reduce
57# the risk of old leftovers getting shipped. The root 'Makefile.dist' is the
58# exception.
59echo "removing all old *.dist files"
60find . -name "*.dist" -a ! -name Makefile.dist -exec rm {} \;
61
62numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
63
64HEADER=include/curl/curlver.h
65CHEADER=src/tool_version.h
66PLIST=lib/libcurl.plist
67
68if test -z "$only"; then
69 ext=".dist"
70 # when not setting up version numbers locally
71 for a in $HEADER $CHEADER $PLIST; do
72 cp $a "$a$ext"
73 done
74 HEADER="$HEADER$ext"
75 CHEADER="$CHEADER$ext"
76 PLIST="$PLIST$ext"
77fi
78
79# requires a date command that knows + for format
80datestamp=`date +"%F"`
81
82# Replace version number in header file:
83sed -i.bak \
84 -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \
85 -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \
86 -e 's/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR '$major'/g' \
87 -e 's/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR '$minor'/g' \
88 -e 's/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH '$patch'/g' \
89 -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
90 $HEADER
91rm -f "$HEADER.bak"
92
93# Replace version number in header file:
94sed -i.bak 's/#define CURL_VERSION .*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER
95rm -f "$CHEADER.bak"
96
97if test -n "$only"; then
98 # done!
99 exit;
100fi
101
102echo "curl version $curlversion"
103echo "libcurl version $libversion"
104echo "libcurl numerical $numeric"
105echo "datestamp $datestamp"
106
107findprog() {
108 file="$1"
109 for part in `echo $PATH| tr ':' ' '`; do
110 path="$part/$file"
111 if [ -x "$path" ]; then
112 # there it is!
113 return 1
114 fi
115 done
116
117 # no such executable
118 return 0
119}
120
121############################################################################
122#
123# Enforce a rerun of configure (updates the VERSION)
124#
125
126echo "Re-running config.status"
127./config.status --recheck >/dev/null
128
129############################################################################
130#
131# automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
132# been modified.
133#
134
135if { findprog automake >/dev/null 2>/dev/null; } then
136 echo "- Could not find or run automake, I hope you know what you're doing!"
137else
138 echo "Runs automake --include-deps"
139 automake --include-deps Makefile >/dev/null
140fi
141
142############################################################################
143#
144# Modify the man pages to display the version number and date.
145#
146
147echo "update man pages"
148./scripts/updatemanpages.pl $version >/dev/null
149
150# make the generated file newer than the man page
151touch src/tool_hugehelp.c
152
153############################################################################
154#
155# Update the IDE files
156echo "make vc-ide"
157make -s vc-ide
158
159echo "produce CHANGES"
160git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./scripts/log2changes.pl > CHANGES.dist
161
162############################################################################
163#
164# Now run make dist to generate a tar.gz archive
165#
166
167echo "make dist"
168targz="curl-$version.tar.gz"
169make -sj dist VERSION=$version
170res=$?
171
172if test "$res" != 0; then
173 echo "make dist failed"
174 exit 2
175fi
176
177############################################################################
178#
179# Now make a bz2 archive from the tar.gz original
180#
181
182bzip2="curl-$version.tar.bz2"
183echo "Generating $bzip2"
184gzip -dc $targz | bzip2 --best > $bzip2
185
186############################################################################
187#
188# Now make an xz archive from the tar.gz original
189#
190
191xz="curl-$version.tar.xz"
192echo "Generating $xz"
193gzip -dc $targz | xz -6e - > $xz
194
195############################################################################
196#
197# Now make a zip archive from the tar.gz original
198#
199makezip() {
200 rm -rf $tempdir
201 mkdir $tempdir
202 cd $tempdir
203 gzip -dc ../$targz | tar -xf -
204 find . | zip $zip -@ >/dev/null
205 mv $zip ../
206 cd ..
207 rm -rf $tempdir
208}
209
210zip="curl-$version.zip"
211echo "Generating $zip"
212tempdir=".builddir"
213makezip
214
215echo "------------------"
216echo "maketgz report:"
217echo ""
218ls -l $targz $bzip2 $zip $xz
219
220echo "Run this:"
221echo "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip && gpg -b -a $xz"