blob: 55a57c1b3a5af9acb81b641ff39ca0ace818f436 [file] [log] [blame]
Elliott Hughes72d948d2018-08-03 14:37:21 -07001#!/bin/sh
Lucas Eckels9bd90e62012-08-06 15:07:02 -07002# 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#
Elliott Hughes72d948d2018-08-03 14:37:21 -070012# Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070013#
14# This software is licensed as described in the file COPYING, which
15# you should have received as part of this distribution. The terms
Alex Deymo8f1a2142016-06-28 14:49:26 -070016# are also available at https://curl.haxx.se/docs/copyright.html.
Lucas Eckels9bd90e62012-08-06 15:07:02 -070017#
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###########################################################################
26
27version=$1
28
29if [ -z "$version" ]; then
30 echo "Specify a version number!"
31 exit
32fi
33
Elliott Hughescee03382017-06-23 12:17:18 -070034if [ "xonly" = "x$2" ]; then
Elliott Hughes72d948d2018-08-03 14:37:21 -070035 echo "Setup version number only!"
36 only=1
Elliott Hughescee03382017-06-23 12:17:18 -070037fi
38
Lucas Eckels9bd90e62012-08-06 15:07:02 -070039libversion="$version"
40
41# we make curl the same version as libcurl
42curlversion=$libversion
43
Elliott Hughes72d948d2018-08-03 14:37:21 -070044major=`echo $libversion | cut -d. -f1 | sed -e "s/[^0-9]//g"`
45minor=`echo $libversion | cut -d. -f2 | sed -e "s/[^0-9]//g"`
46patch=`echo $libversion | cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
Lucas Eckels9bd90e62012-08-06 15:07:02 -070047
Elliott Hughescee03382017-06-23 12:17:18 -070048if test -z "$patch"; then
Elliott Hughes72d948d2018-08-03 14:37:21 -070049 echo "invalid version number? needs to be z.y.z"
50 exit
Elliott Hughescee03382017-06-23 12:17:18 -070051fi
52
Elliott Hughes82be86d2017-09-20 17:00:17 -070053#
54# As a precaution, remove all *.dist files that may be lying around, to reduce
55# the risk of old leftovers getting shipped. The root 'Makefile.dist' is the
56# exception.
57echo "removing all old *.dist files"
58find . -name "*.dist" -a ! -name Makefile.dist -exec rm {} \;
59
Lucas Eckels9bd90e62012-08-06 15:07:02 -070060numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
61
62HEADER=include/curl/curlver.h
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070063CHEADER=src/tool_version.h
Elliott Hughescee03382017-06-23 12:17:18 -070064PLIST=lib/libcurl.plist
65
66if test -z "$only"; then
Elliott Hughes72d948d2018-08-03 14:37:21 -070067 ext=".dist"
68 # when not setting up version numbers locally
69 for a in $HEADER $CHEADER $PLIST; do
70 cp $a "$a$ext"
71 done
72 HEADER="$HEADER$ext"
73 CHEADER="$CHEADER$ext"
74 PLIST="$PLIST$ext"
Elliott Hughescee03382017-06-23 12:17:18 -070075fi
Lucas Eckels9bd90e62012-08-06 15:07:02 -070076
Elliott Hughes82be86d2017-09-20 17:00:17 -070077# requires a date command that knows + for format
78datestamp=`date +"%F"`
Lucas Eckels9bd90e62012-08-06 15:07:02 -070079
80# Replace version number in header file:
Elliott Hughes72d948d2018-08-03 14:37:21 -070081sed -i.bak \
82 -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \
Lucas Eckels9bd90e62012-08-06 15:07:02 -070083 -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \
84 -e 's/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR '$major'/g' \
85 -e 's/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR '$minor'/g' \
86 -e 's/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH '$patch'/g' \
87 -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
Elliott Hughes72d948d2018-08-03 14:37:21 -070088 $HEADER
89rm -f "$HEADER.bak"
Lucas Eckels9bd90e62012-08-06 15:07:02 -070090
91# Replace version number in header file:
Elliott Hughes72d948d2018-08-03 14:37:21 -070092sed -i.bak 's/#define CURL_VERSION .*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER
93rm -f "$CHEADER.bak"
Elliott Hughescee03382017-06-23 12:17:18 -070094
95# Replace version number in plist file:
Elliott Hughes72d948d2018-08-03 14:37:21 -070096sed -i.bak "s/7\.12\.3/$libversion/g" $PLIST
97rm -f "$PLIST.bak"
Elliott Hughescee03382017-06-23 12:17:18 -070098
99if test -n "$only"; then
Elliott Hughes72d948d2018-08-03 14:37:21 -0700100 # done!
101 exit;
Elliott Hughescee03382017-06-23 12:17:18 -0700102fi
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700103
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700104echo "curl version $curlversion"
105echo "libcurl version $libversion"
106echo "libcurl numerical $numeric"
107echo "datestamp $datestamp"
108
Elliott Hughes72d948d2018-08-03 14:37:21 -0700109findprog() {
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700110 file="$1"
111 for part in `echo $PATH| tr ':' ' '`; do
112 path="$part/$file"
113 if [ -x "$path" ]; then
114 # there it is!
115 return 1
116 fi
117 done
118
119 # no such executable
120 return 0
121}
122
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700123############################################################################
124#
125# Enforce a rerun of configure (updates the VERSION)
126#
127
128echo "Re-running config.status"
129./config.status --recheck >/dev/null
130
131############################################################################
132#
133# automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
134# been modified.
135#
136
137if { findprog automake >/dev/null 2>/dev/null; } then
138 echo "- Could not find or run automake, I hope you know what you're doing!"
139else
140 echo "Runs automake --include-deps"
141 automake --include-deps Makefile >/dev/null
142fi
143
144############################################################################
145#
Elliott Hughes82be86d2017-09-20 17:00:17 -0700146# Modify the man pages to display the version number and date.
147#
148
149echo "update man pages"
150./scripts/updatemanpages.pl $version
151
152# make the generated file newer than the man page
153touch src/tool_hugehelp.c
154
155############################################################################
156#
Elliott Hughescee03382017-06-23 12:17:18 -0700157# Update the IDE files
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700158echo "make vc-ide"
159make -s vc-ide
160
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700161echo "produce CHANGES"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700162git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./scripts/log2changes.pl > CHANGES.dist
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700163
164############################################################################
165#
166# Now run make dist to generate a tar.gz archive
167#
168
169echo "make dist"
170targz="curl-$version.tar.gz"
Alex Deymo8f1a2142016-06-28 14:49:26 -0700171make -sj dist VERSION=$version
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700172
173############################################################################
174#
175# Now make a bz2 archive from the tar.gz original
176#
177
178bzip2="curl-$version.tar.bz2"
179echo "Generating $bzip2"
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700180gzip -dc $targz | bzip2 --best > $bzip2
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700181
182############################################################################
183#
Elliott Hughes82be86d2017-09-20 17:00:17 -0700184# Now make an xz archive from the tar.gz original
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700185#
186
Elliott Hughes82be86d2017-09-20 17:00:17 -0700187xz="curl-$version.tar.xz"
188echo "Generating $xz"
189gzip -dc $targz | xz -6e - > $xz
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700190
191############################################################################
192#
193# Now make a zip archive from the tar.gz original
194#
Elliott Hughes72d948d2018-08-03 14:37:21 -0700195makezip() {
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700196 rm -rf $tempdir
197 mkdir $tempdir
198 cd $tempdir
199 gzip -dc ../$targz | tar -xf -
200 find . | zip $zip -@ >/dev/null
201 mv $zip ../
202 cd ..
203 rm -rf $tempdir
204}
205
206zip="curl-$version.zip"
207echo "Generating $zip"
208tempdir=".builddir"
209makezip
210
211echo "------------------"
212echo "maketgz report:"
213echo ""
Elliott Hughes82be86d2017-09-20 17:00:17 -0700214ls -l $targz $bzip2 $zip $xz
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700215
216echo "Run this:"
Elliott Hughes82be86d2017-09-20 17:00:17 -0700217echo "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip && gpg -b -a $xz"