xref: /PHP-5.5/makedist (revision 512f9bfe)
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/\./ /'`
32if test "${1}" = "1" -a "${2}" -lt "28"; then
33  echo "You will need bison 1.28 if you want to regenerate the Zend parser (found ${1}.${2}).)"
34  exit 2
35fi
36IFS="$old_IFS"
37
38if test "x$PHPROOT" == "x"; then
39    PHPROOT=git@git.php.net:php-src.git;
40fi
41
42LT_TARGETS='ltconfig ltmain.sh config.guess config.sub'
43
44if echo '\c' | grep -s c >/dev/null 2>&1
45then
46    ECHO_N="echo -n"
47    ECHO_C=""
48else
49    ECHO_N="echo"
50    ECHO_C='\c'
51fi
52
53MY_OLDPWD=`pwd`
54
55# the destination .tar.gz file
56ARCHIVE=$MY_OLDPWD/php-$VER.tar
57
58# temporary directory used to check out files from SVN
59DIR=php-$VER
60DIRPATH=$MY_OLDPWD/$DIR
61
62if test -d "$DIRPATH"; then
63    echo "The directory $DIR"
64    echo "already exists, rename or remove it and run makedist again."
65    exit 1
66fi
67
68# Export PHP
69$ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
70git archive --format=tar --remote=$PHPROOT refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
71echo ""
72
73cd $DIR || exit 5
74
75# hide away our own versions of libtool-generated files
76for i in $LT_TARGETS; do
77  if test -f "$i"; then
78    mv $i $i.bak
79    cp $i.bak $i
80  fi
81done
82
83# generate some files so people don't need bison, flex and autoconf
84# to install
85set -x
86./buildconf --copy --force
87
88# remove buildmk.stamp. Otherwise, buildcheck.sh might not be run,
89# when a user runs buildconf in the distribution.
90rm -f buildmk.stamp
91
92./genfiles
93
94# now restore our versions of libtool-generated files
95for i in $LT_TARGETS; do
96  test -f "$i" && mv $i.bak $i
97done
98
99# removing junk files
100find . -name \*.orig -print0 | xargs -0 rm
101rm -fr autom4te.cache/
102
103# download pear
104$ECHO_N "makedist: Attempting to download PEAR's phar archive"
105if test ! -x wget; then
106	wget http://pear.php.net/install-pear-nozlib.phar -nd -P pear/
107else
108	$ECHO_N "Missing wget binary needed for pear download";
109	exit 7
110fi
111
112cd $MY_OLDPWD
113$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
114rm -f $ARCHIVE.gz
115tar cf $ARCHIVE php-$VER || exit 8
116gzip -9 $ARCHIVE || exit 9
117echo ""
118
119$ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
120rm -f $ARCHIVE.bz2
121tar cf $ARCHIVE php-$VER || exit 10
122bzip2 -9 $ARCHIVE || exit 11
123echo ""
124
125$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
126rm -f $ARCHIVE.xz
127tar cf $ARCHIVE php-$VER || exit 10
128xz -9 $ARCHIVE || exit 12
129echo ""
130
131$ECHO_N "makedist: cleaning up...$ECHO_C"
132rm -rf $DIRPATH || exit 13
133echo ""
134
135exit 0
136