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# make the generated file newer than the man page 149 150touch src/tool_hugehelp.c 151 152############################################################################ 153# 154# Update the IDE files 155echo "make vc-ide" 156make -s vc-ide 157 158echo "produce CHANGES" 159git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./scripts/log2changes.pl > CHANGES.dist 160 161############################################################################ 162# 163# Now run make dist to generate a tar.gz archive 164# 165 166echo "make dist" 167targz="curl-$version.tar.gz" 168make -sj dist VERSION=$version 169res=$? 170 171if test "$res" != 0; then 172 echo "make dist failed" 173 exit 2 174fi 175 176############################################################################ 177# 178# Now make a bz2 archive from the tar.gz original 179# 180 181bzip2="curl-$version.tar.bz2" 182echo "Generating $bzip2" 183gzip -dc $targz | bzip2 --best > $bzip2 184 185############################################################################ 186# 187# Now make an xz archive from the tar.gz original 188# 189 190xz="curl-$version.tar.xz" 191echo "Generating $xz" 192gzip -dc $targz | xz -6e - > $xz 193 194############################################################################ 195# 196# Now make a zip archive from the tar.gz original 197# 198makezip() { 199 rm -rf $tempdir 200 mkdir $tempdir 201 cd $tempdir 202 gzip -dc ../$targz | tar -xf - 203 find . | zip $zip -@ >/dev/null 204 mv $zip ../ 205 cd .. 206 rm -rf $tempdir 207} 208 209zip="curl-$version.zip" 210echo "Generating $zip" 211tempdir=".builddir" 212makezip 213 214echo "------------------" 215echo "maketgz report:" 216echo "" 217ls -l $targz $bzip2 $zip $xz 218 219echo "Run this:" 220echo "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip && gpg -b -a $xz" 221