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 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 67PLISTO=$PLIST 68 69if test -z "$only"; then 70 ext=".dist" 71 # when not setting up version numbers locally 72 for a in $HEADER $CHEADER $PLIST; do 73 cp $a "$a$ext" 74 done 75 HEADER="$HEADER$ext" 76 CHEADER="$CHEADER$ext" 77 PLIST="$PLIST$ext" 78fi 79 80# requires a date command that knows + for format 81datestamp=`date +"%F"` 82 83# Replace version number in header file: 84sed -i.bak \ 85 -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \ 86 -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \ 87 -e 's/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR '$major'/g' \ 88 -e 's/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR '$minor'/g' \ 89 -e 's/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH '$patch'/g' \ 90 -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \ 91 $HEADER 92rm -f "$HEADER.bak" 93 94# Replace version number in header file: 95sed -i.bak 's/#define CURL_VERSION .*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER 96rm -f "$CHEADER.bak" 97 98# Replace version number in plist file: 99sed "s/@CURL_PLIST_VERSION@/$curlversion/g" < $PLISTO.in >$PLIST 100 101if test -n "$only"; then 102 # done! 103 exit; 104fi 105 106echo "curl version $curlversion" 107echo "libcurl version $libversion" 108echo "libcurl numerical $numeric" 109echo "datestamp $datestamp" 110 111findprog() { 112 file="$1" 113 for part in `echo $PATH| tr ':' ' '`; do 114 path="$part/$file" 115 if [ -x "$path" ]; then 116 # there it is! 117 return 1 118 fi 119 done 120 121 # no such executable 122 return 0 123} 124 125############################################################################ 126# 127# Enforce a rerun of configure (updates the VERSION) 128# 129 130echo "Re-running config.status" 131./config.status --recheck >/dev/null 132 133############################################################################ 134# 135# automake is needed to run to make a non-GNU Makefile.in if Makefile.am has 136# been modified. 137# 138 139if { findprog automake >/dev/null 2>/dev/null; } then 140 echo "- Could not find or run automake, I hope you know what you're doing!" 141else 142 echo "Runs automake --include-deps" 143 automake --include-deps Makefile >/dev/null 144fi 145 146############################################################################ 147# 148# Modify the man pages to display the version number and date. 149# 150 151echo "update man pages" 152./scripts/updatemanpages.pl $version >/dev/null 153 154# make the generated file newer than the man page 155touch src/tool_hugehelp.c 156 157############################################################################ 158# 159# Update the IDE files 160echo "make vc-ide" 161make -s vc-ide 162 163echo "produce CHANGES" 164git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./scripts/log2changes.pl > CHANGES.dist 165 166############################################################################ 167# 168# Now run make dist to generate a tar.gz archive 169# 170 171echo "make dist" 172targz="curl-$version.tar.gz" 173make -sj dist VERSION=$version 174res=$? 175 176if test "$res" != 0; then 177 echo "make dist failed" 178 exit 2 179fi 180 181############################################################################ 182# 183# Now make a bz2 archive from the tar.gz original 184# 185 186bzip2="curl-$version.tar.bz2" 187echo "Generating $bzip2" 188gzip -dc $targz | bzip2 --best > $bzip2 189 190############################################################################ 191# 192# Now make an xz archive from the tar.gz original 193# 194 195xz="curl-$version.tar.xz" 196echo "Generating $xz" 197gzip -dc $targz | xz -6e - > $xz 198 199############################################################################ 200# 201# Now make a zip archive from the tar.gz original 202# 203makezip() { 204 rm -rf $tempdir 205 mkdir $tempdir 206 cd $tempdir 207 gzip -dc ../$targz | tar -xf - 208 find . | zip $zip -@ >/dev/null 209 mv $zip ../ 210 cd .. 211 rm -rf $tempdir 212} 213 214zip="curl-$version.zip" 215echo "Generating $zip" 216tempdir=".builddir" 217makezip 218 219echo "------------------" 220echo "maketgz report:" 221echo "" 222ls -l $targz $bzip2 $zip $xz 223 224echo "Run this:" 225echo "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip && gpg -b -a $xz" 226