xref: /PHP-7.2/makedist (revision 9f5cb626)
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    PHPROOT=git@git.php.net:php-src.git;
45fi
46
47LT_TARGETS='ltconfig ltmain.sh config.guess config.sub'
48
49if echo '\c' | grep -s c >/dev/null 2>&1
50then
51    ECHO_N="echo -n"
52    ECHO_C=""
53else
54    ECHO_N="echo"
55    ECHO_C='\c'
56fi
57
58MY_OLDPWD=`pwd`
59
60# the destination .tar.gz file
61ARCHIVE=$MY_OLDPWD/php-$VER.tar
62
63# temporary directory used to check out files from SVN
64DIR=php-$VER
65DIRPATH=$MY_OLDPWD/$DIR
66
67if test -d "$DIRPATH"; then
68    echo "The directory $DIR" >&2
69    echo "already exists, rename or remove it and run makedist again." >&2
70    exit 1
71fi
72
73# Export PHP
74$ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
75git archive --format=tar --remote=$PHPROOT refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
76echo ""
77
78cd $DIR || exit 5
79
80# hide away our own versions of libtool-generated files
81for i in $LT_TARGETS; do
82  if test -f "$i"; then
83    mv $i $i.bak
84    cp $i.bak $i
85  fi
86done
87
88# generate some files so people don't need bison, flex and autoconf
89# to install
90set -x
91./buildconf --copy --force
92
93# remove buildmk.stamp. Otherwise, buildcheck.sh might not be run,
94# when a user runs buildconf in the distribution.
95rm -f buildmk.stamp
96
97./genfiles
98
99# now restore our versions of libtool-generated files
100for i in $LT_TARGETS; do
101  test -f "$i" && mv $i.bak $i
102done
103
104# removing junk files
105find . -name \*.orig -print0 | xargs -0 rm
106rm -fr autom4te.cache/
107
108# touching everything to be packaged
109find $MY_OLDPWD/php-$VER -exec touch -c {} \;
110
111# tweak zendparse to be exported through ZEND_API
112# NOTE this has to be revisited once bison supports foreign skeletons
113#      and that bison version is used. Read /usr/share/bison/README for more
114sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.c
115sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
116sed -i 's,^#ifndef YYTOKENTYPE,#include "zend.h"\n#ifndef YYTOKENTYPE,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
117
118# download pear
119$ECHO_N "makedist: Attempting to download PEAR's phar archive"
120if test ! -x wget; then
121	wget https://pear.php.net/install-pear-nozlib.phar -nd -P pear/
122	if [ "x$?" != "x0" ]
123	then
124		$ECHO_N "Pear download failed";
125		exit 7
126	fi
127else
128	$ECHO_N "Missing wget binary needed for pear download";
129	exit 7
130fi
131
132cd $MY_OLDPWD
133$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
134rm -f $ARCHIVE.gz
135tar cf $ARCHIVE php-$VER || exit 8
136gzip -9 $ARCHIVE || exit 9
137echo ""
138
139$ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
140rm -f $ARCHIVE.bz2
141tar cf $ARCHIVE php-$VER || exit 10
142bzip2 -9 $ARCHIVE || exit 11
143echo ""
144
145$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
146rm -f $ARCHIVE.xz
147tar cf $ARCHIVE php-$VER || exit 10
148xz -9 $ARCHIVE || exit 12
149echo ""
150
151$ECHO_N "makedist: cleaning up...$ECHO_C"
152rm -rf $DIRPATH || exit 13
153echo ""
154
155exit 0
156