xref: /PHP-7.3/makedist (revision 096f148c)
1#!/bin/sh
2#
3# Distribution generator for git
4#
5# Usage: makedist version
6# Example: makedist 5.4.1
7# Example: makedist 5.3.5RC1
8#
9# To work, this script needs a consistent tagging of all releases.
10# Each release of a package should have a tag of the form
11#
12#  php-X.Y.Z[sub]
13#
14# The distribution ends up in a .tar.gz file that contains the distribution
15# in a directory called php-<version>.
16# A .tar.bz2 file is also created.
17#
18# Written by Stig Bakken <ssb@guardian.no> 1997-05-28.
19# Adapted to git by Stanislav Malyshev <stas@php.net>
20
21
22if test "$#" != "1"; then
23    echo "Usage: makedist <version>" >&2
24    exit 1
25fi
26
27VER=$1 ; shift
28
29old_IFS="$IFS"
30IFS=.
31eval set `bison --version| grep 'GNU Bison' | cut -d ' ' -f 4 | sed -e 's/\./ /g'`
32if test "${1}" -lt "3" -o "${1}" = "3" -a "${2}" -eq "0" -a "${3}" -lt "2"; then
33  echo "You will need bison >= 3.0.2 if you want to regenerate the Zend parser (found ${1}.${2}.${3})."
34  exit 2
35fi
36eval set `re2c --version| grep 're2c' | cut -d ' ' -f 2 | sed -e 's/\./ /g'`
37if test "${2}" -lt "13" -o "${2}" -eq "13" -a "${3}" -lt "5"; then
38  echo "You will need re2c >= 0.13.5 if you want to regenerate the Zend scanner (found ${1}.${2}.${3})."
39  exit 2
40fi
41IFS="$old_IFS"
42
43if test "x$PHPROOT" != "x"; then
44    remote_option=--remote=$PHPROOT
45else
46    remote_option=
47fi
48
49LT_TARGETS='ltconfig ltmain.sh config.guess config.sub'
50
51if echo '\c' | grep -s c >/dev/null 2>&1
52then
53    ECHO_N="echo -n"
54    ECHO_C=""
55else
56    ECHO_N="echo"
57    ECHO_C='\c'
58fi
59
60MY_OLDPWD=`pwd`
61
62# the destination .tar.gz file
63ARCHIVE=$MY_OLDPWD/php-$VER.tar
64
65# temporary directory used to check out files from SVN
66DIR=php-$VER
67DIRPATH=$MY_OLDPWD/$DIR
68
69if test -d "$DIRPATH"; then
70    echo "The directory $DIR" >&2
71    echo "already exists, rename or remove it and run makedist again." >&2
72    exit 1
73fi
74
75# Export PHP
76$ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
77git archive --format=tar $remote_option refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
78echo ""
79
80cd $DIR || exit 5
81
82# hide away our own versions of libtool-generated files
83for i in $LT_TARGETS; do
84  if test -f "$i"; then
85    mv $i $i.bak
86    cp $i.bak $i
87  fi
88done
89
90# generate some files so people don't need bison, re2c and autoconf
91# to install
92set -x
93./buildconf --copy --force
94
95# remove buildmk.stamp. Otherwise, buildcheck.sh might not be run,
96# when a user runs buildconf in the distribution.
97rm -f buildmk.stamp
98
99./genfiles
100
101# now restore our versions of libtool-generated files
102for i in $LT_TARGETS; do
103  test -f "$i" && mv $i.bak $i
104done
105
106# removing junk files
107find . -name \*.orig -print0 | xargs -0 rm
108rm -fr autom4te.cache/
109
110# touching everything to be packaged
111find $MY_OLDPWD/php-$VER -exec touch -c {} \;
112
113# tweak zendparse to be exported through ZEND_API
114# NOTE this has to be revisited once bison supports foreign skeletons
115#      and that bison version is used. Read /usr/share/bison/README for more
116sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.c
117sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
118sed -i 's,^#ifndef YYTOKENTYPE,#include "zend.h"\n#ifndef YYTOKENTYPE,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
119
120# download pear
121$ECHO_N "makedist: Attempting to download PEAR's phar archive"
122if test ! -x wget; then
123	wget https://pear.php.net/install-pear-nozlib.phar -nd -P pear/
124	if [ "x$?" != "x0" ]
125	then
126		$ECHO_N "Pear download failed";
127		exit 7
128	fi
129else
130	$ECHO_N "Missing wget binary needed for pear download";
131	exit 7
132fi
133
134cd $MY_OLDPWD
135$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
136rm -f $ARCHIVE.gz
137tar cf $ARCHIVE php-$VER || exit 8
138gzip -9 $ARCHIVE || exit 9
139echo ""
140
141$ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
142rm -f $ARCHIVE.bz2
143tar cf $ARCHIVE php-$VER || exit 10
144bzip2 -9 $ARCHIVE || exit 11
145echo ""
146
147$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
148rm -f $ARCHIVE.xz
149tar cf $ARCHIVE php-$VER || exit 10
150xz -9 $ARCHIVE || exit 12
151echo ""
152
153$ECHO_N "makedist: cleaning up...$ECHO_C"
154rm -rf $DIRPATH || exit 13
155echo ""
156
157exit 0
158