xref: /third_party/curl/maketgz (revision 13498266)
113498266Sopenharmony_ci#!/bin/sh
213498266Sopenharmony_ci# Script to build release-archives with. Note that this requires a checkout
313498266Sopenharmony_ci# from git and you should first run ./buildconf and build curl once.
413498266Sopenharmony_ci#
513498266Sopenharmony_ci#***************************************************************************
613498266Sopenharmony_ci#                                  _   _ ____  _
713498266Sopenharmony_ci#  Project                     ___| | | |  _ \| |
813498266Sopenharmony_ci#                             / __| | | | |_) | |
913498266Sopenharmony_ci#                            | (__| |_| |  _ <| |___
1013498266Sopenharmony_ci#                             \___|\___/|_| \_\_____|
1113498266Sopenharmony_ci#
1213498266Sopenharmony_ci# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
1313498266Sopenharmony_ci#
1413498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which
1513498266Sopenharmony_ci# you should have received as part of this distribution. The terms
1613498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html.
1713498266Sopenharmony_ci#
1813498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell
1913498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is
2013498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file.
2113498266Sopenharmony_ci#
2213498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
2313498266Sopenharmony_ci# KIND, either express or implied.
2413498266Sopenharmony_ci#
2513498266Sopenharmony_ci# SPDX-License-Identifier: curl
2613498266Sopenharmony_ci#
2713498266Sopenharmony_ci###########################################################################
2813498266Sopenharmony_ci
2913498266Sopenharmony_civersion=$1
3013498266Sopenharmony_ci
3113498266Sopenharmony_ciif [ -z "$version" ]; then
3213498266Sopenharmony_ci  echo "Specify a version number!"
3313498266Sopenharmony_ci  exit
3413498266Sopenharmony_cifi
3513498266Sopenharmony_ci
3613498266Sopenharmony_ciif [ "xonly" = "x$2" ]; then
3713498266Sopenharmony_ci  echo "Setup version number only!"
3813498266Sopenharmony_ci  only=1
3913498266Sopenharmony_cifi
4013498266Sopenharmony_ci
4113498266Sopenharmony_cilibversion="$version"
4213498266Sopenharmony_ci
4313498266Sopenharmony_ci# we make curl the same version as libcurl
4413498266Sopenharmony_cicurlversion=$libversion
4513498266Sopenharmony_ci
4613498266Sopenharmony_cimajor=`echo $libversion | cut -d. -f1 | sed -e "s/[^0-9]//g"`
4713498266Sopenharmony_ciminor=`echo $libversion | cut -d. -f2 | sed -e "s/[^0-9]//g"`
4813498266Sopenharmony_cipatch=`echo $libversion | cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"`
4913498266Sopenharmony_ci
5013498266Sopenharmony_ciif test -z "$patch"; then
5113498266Sopenharmony_ci  echo "invalid version number? needs to be z.y.z"
5213498266Sopenharmony_ci  exit
5313498266Sopenharmony_cifi
5413498266Sopenharmony_ci
5513498266Sopenharmony_ci#
5613498266Sopenharmony_ci# As a precaution, remove all *.dist files that may be lying around, to reduce
5713498266Sopenharmony_ci# the risk of old leftovers getting shipped. The root 'Makefile.dist' is the
5813498266Sopenharmony_ci# exception.
5913498266Sopenharmony_ciecho "removing all old *.dist files"
6013498266Sopenharmony_cifind . -name "*.dist" -a ! -name Makefile.dist -exec rm {} \;
6113498266Sopenharmony_ci
6213498266Sopenharmony_cinumeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"`
6313498266Sopenharmony_ci
6413498266Sopenharmony_ciHEADER=include/curl/curlver.h
6513498266Sopenharmony_ciCHEADER=src/tool_version.h
6613498266Sopenharmony_ciPLIST=lib/libcurl.plist
6713498266Sopenharmony_ciPLISTO=$PLIST
6813498266Sopenharmony_ci
6913498266Sopenharmony_ciif test -z "$only"; then
7013498266Sopenharmony_ci  ext=".dist"
7113498266Sopenharmony_ci  # when not setting up version numbers locally
7213498266Sopenharmony_ci  for a in $HEADER $CHEADER $PLIST; do
7313498266Sopenharmony_ci    cp $a "$a$ext"
7413498266Sopenharmony_ci  done
7513498266Sopenharmony_ci  HEADER="$HEADER$ext"
7613498266Sopenharmony_ci  CHEADER="$CHEADER$ext"
7713498266Sopenharmony_ci  PLIST="$PLIST$ext"
7813498266Sopenharmony_cifi
7913498266Sopenharmony_ci
8013498266Sopenharmony_ci# requires a date command that knows + for format
8113498266Sopenharmony_cidatestamp=`date +"%F"`
8213498266Sopenharmony_ci
8313498266Sopenharmony_ci# Replace version number in header file:
8413498266Sopenharmony_cised -i.bak \
8513498266Sopenharmony_ci    -e 's/^#define LIBCURL_VERSION .*/#define LIBCURL_VERSION "'$libversion'"/g' \
8613498266Sopenharmony_ci    -e 's/^#define LIBCURL_VERSION_NUM .*/#define LIBCURL_VERSION_NUM 0x'$numeric'/g' \
8713498266Sopenharmony_ci    -e 's/^#define LIBCURL_VERSION_MAJOR .*/#define LIBCURL_VERSION_MAJOR '$major'/g' \
8813498266Sopenharmony_ci    -e 's/^#define LIBCURL_VERSION_MINOR .*/#define LIBCURL_VERSION_MINOR '$minor'/g' \
8913498266Sopenharmony_ci    -e 's/^#define LIBCURL_VERSION_PATCH .*/#define LIBCURL_VERSION_PATCH '$patch'/g' \
9013498266Sopenharmony_ci    -e "s/^#define LIBCURL_TIMESTAMP .*/#define LIBCURL_TIMESTAMP \"$datestamp\"/g" \
9113498266Sopenharmony_ci    $HEADER
9213498266Sopenharmony_cirm -f "$HEADER.bak"
9313498266Sopenharmony_ci
9413498266Sopenharmony_ci# Replace version number in header file:
9513498266Sopenharmony_cised -i.bak 's/#define CURL_VERSION .*/#define CURL_VERSION "'$curlversion'"/g' $CHEADER
9613498266Sopenharmony_cirm -f "$CHEADER.bak"
9713498266Sopenharmony_ci
9813498266Sopenharmony_ci# Replace version number in plist file:
9913498266Sopenharmony_cised "s/@CURL_PLIST_VERSION@/$curlversion/g" < $PLISTO.in >$PLIST
10013498266Sopenharmony_ci
10113498266Sopenharmony_ciif test -n "$only"; then
10213498266Sopenharmony_ci  # done!
10313498266Sopenharmony_ci  exit;
10413498266Sopenharmony_cifi
10513498266Sopenharmony_ci
10613498266Sopenharmony_ciecho "curl version $curlversion"
10713498266Sopenharmony_ciecho "libcurl version $libversion"
10813498266Sopenharmony_ciecho "libcurl numerical $numeric"
10913498266Sopenharmony_ciecho "datestamp $datestamp"
11013498266Sopenharmony_ci
11113498266Sopenharmony_cifindprog() {
11213498266Sopenharmony_ci  file="$1"
11313498266Sopenharmony_ci  for part in `echo $PATH| tr ':' ' '`; do
11413498266Sopenharmony_ci    path="$part/$file"
11513498266Sopenharmony_ci    if [ -x "$path" ]; then
11613498266Sopenharmony_ci      # there it is!
11713498266Sopenharmony_ci      return 1
11813498266Sopenharmony_ci    fi
11913498266Sopenharmony_ci  done
12013498266Sopenharmony_ci
12113498266Sopenharmony_ci  # no such executable
12213498266Sopenharmony_ci  return 0
12313498266Sopenharmony_ci}
12413498266Sopenharmony_ci
12513498266Sopenharmony_ci############################################################################
12613498266Sopenharmony_ci#
12713498266Sopenharmony_ci# Enforce a rerun of configure (updates the VERSION)
12813498266Sopenharmony_ci#
12913498266Sopenharmony_ci
13013498266Sopenharmony_ciecho "Re-running config.status"
13113498266Sopenharmony_ci./config.status --recheck >/dev/null
13213498266Sopenharmony_ci
13313498266Sopenharmony_ci############################################################################
13413498266Sopenharmony_ci#
13513498266Sopenharmony_ci# automake is needed to run to make a non-GNU Makefile.in if Makefile.am has
13613498266Sopenharmony_ci# been modified.
13713498266Sopenharmony_ci#
13813498266Sopenharmony_ci
13913498266Sopenharmony_ciif { findprog automake >/dev/null 2>/dev/null; } then
14013498266Sopenharmony_ci  echo "- Could not find or run automake, I hope you know what you're doing!"
14113498266Sopenharmony_cielse
14213498266Sopenharmony_ci  echo "Runs automake --include-deps"
14313498266Sopenharmony_ci  automake --include-deps Makefile >/dev/null
14413498266Sopenharmony_cifi
14513498266Sopenharmony_ci
14613498266Sopenharmony_ci############################################################################
14713498266Sopenharmony_ci#
14813498266Sopenharmony_ci# make the generated file newer than the man page
14913498266Sopenharmony_ci
15013498266Sopenharmony_citouch src/tool_hugehelp.c
15113498266Sopenharmony_ci
15213498266Sopenharmony_ci############################################################################
15313498266Sopenharmony_ci#
15413498266Sopenharmony_ci# Update the IDE files
15513498266Sopenharmony_ciecho "make vc-ide"
15613498266Sopenharmony_cimake -s vc-ide
15713498266Sopenharmony_ci
15813498266Sopenharmony_ciecho "produce CHANGES"
15913498266Sopenharmony_cigit log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./scripts/log2changes.pl > CHANGES.dist
16013498266Sopenharmony_ci
16113498266Sopenharmony_ci############################################################################
16213498266Sopenharmony_ci#
16313498266Sopenharmony_ci# Now run make dist to generate a tar.gz archive
16413498266Sopenharmony_ci#
16513498266Sopenharmony_ci
16613498266Sopenharmony_ciecho "make dist"
16713498266Sopenharmony_citargz="curl-$version.tar.gz"
16813498266Sopenharmony_cimake -sj dist VERSION=$version
16913498266Sopenharmony_cires=$?
17013498266Sopenharmony_ci
17113498266Sopenharmony_ciif test "$res" != 0; then
17213498266Sopenharmony_ci    echo "make dist failed"
17313498266Sopenharmony_ci    exit 2
17413498266Sopenharmony_cifi
17513498266Sopenharmony_ci
17613498266Sopenharmony_ci############################################################################
17713498266Sopenharmony_ci#
17813498266Sopenharmony_ci# Now make a bz2 archive from the tar.gz original
17913498266Sopenharmony_ci#
18013498266Sopenharmony_ci
18113498266Sopenharmony_cibzip2="curl-$version.tar.bz2"
18213498266Sopenharmony_ciecho "Generating $bzip2"
18313498266Sopenharmony_cigzip -dc $targz | bzip2 --best > $bzip2
18413498266Sopenharmony_ci
18513498266Sopenharmony_ci############################################################################
18613498266Sopenharmony_ci#
18713498266Sopenharmony_ci# Now make an xz archive from the tar.gz original
18813498266Sopenharmony_ci#
18913498266Sopenharmony_ci
19013498266Sopenharmony_cixz="curl-$version.tar.xz"
19113498266Sopenharmony_ciecho "Generating $xz"
19213498266Sopenharmony_cigzip -dc $targz | xz -6e - > $xz
19313498266Sopenharmony_ci
19413498266Sopenharmony_ci############################################################################
19513498266Sopenharmony_ci#
19613498266Sopenharmony_ci# Now make a zip archive from the tar.gz original
19713498266Sopenharmony_ci#
19813498266Sopenharmony_cimakezip() {
19913498266Sopenharmony_ci  rm -rf $tempdir
20013498266Sopenharmony_ci  mkdir $tempdir
20113498266Sopenharmony_ci  cd $tempdir
20213498266Sopenharmony_ci  gzip -dc ../$targz | tar -xf -
20313498266Sopenharmony_ci  find . | zip $zip -@ >/dev/null
20413498266Sopenharmony_ci  mv $zip ../
20513498266Sopenharmony_ci  cd ..
20613498266Sopenharmony_ci  rm -rf $tempdir
20713498266Sopenharmony_ci}
20813498266Sopenharmony_ci
20913498266Sopenharmony_cizip="curl-$version.zip"
21013498266Sopenharmony_ciecho "Generating $zip"
21113498266Sopenharmony_citempdir=".builddir"
21213498266Sopenharmony_cimakezip
21313498266Sopenharmony_ci
21413498266Sopenharmony_ciecho "------------------"
21513498266Sopenharmony_ciecho "maketgz report:"
21613498266Sopenharmony_ciecho ""
21713498266Sopenharmony_cils -l $targz $bzip2 $zip $xz
21813498266Sopenharmony_ci
21913498266Sopenharmony_ciecho "Run this:"
22013498266Sopenharmony_ciecho "gpg -b -a $targz && gpg -b -a $bzip2 && gpg -b -a $zip && gpg -b -a $xz"
221