summaryrefslogtreecommitdiff
path: root/scripts/dev/makedist
blob: 2bea7c5e802fcae5658fc48a95c77cbbeff27410 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/sh
#
# Distribution generator for git
#
# Usage: makedist version
# Example: makedist 5.4.1
# Example: makedist 5.3.5RC1
#
# To work, this script needs a consistent tagging of all releases.
# Each release of a package should have a tag of the form
#
#  php-X.Y.Z[sub]
#
# The distribution ends up in a .tar.gz file that contains the distribution
# in a directory called php-<version>.
# A .tar.bz2 file is also created.
#
# Written by Stig Bakken <ssb@guardian.no> 1997-05-28.
# Adapted to git by Stanislav Malyshev <stas@php.net>

# Go to project root directory.
cd $(CDPATH= cd -- "$(dirname -- "$0")/../../" && pwd -P)

if test "$#" != "1"; then
  echo "Usage: makedist <version>" >&2
  exit 1
fi

VER=$1 ; shift

if test "x$PHPROOT" = "x"; then
  PHPROOT=git@git.php.net:php-src.git;
fi

LT_TARGETS='build/ltmain.sh build/config.guess build/config.sub'

if echo '\c' | grep -s c >/dev/null 2>&1
then
  ECHO_N="echo -n"
  ECHO_C=""
else
  ECHO_N="echo"
  ECHO_C='\c'
fi

MY_OLDPWD=`pwd`

# the destination .tar.gz file
ARCHIVE=$MY_OLDPWD/php-$VER.tar

# temporary directory used to check out files from SVN
DIR=php-$VER
DIRPATH=$MY_OLDPWD/$DIR

if test -d "$DIRPATH"; then
  echo "The directory $DIR" >&2
  echo "already exists, rename or remove it and run makedist again." >&2
  exit 1
fi

# Export PHP
$ECHO_N "makedist: exporting tag 'php-$VER' from '$PHPROOT'...$ECHO_C"
git archive --format=tar --remote=$PHPROOT refs/tags/php-$VER --prefix=php-$VER/ | (cd $MY_OLDPWD; tar xvf -) || exit 4
echo ""

cd $DIR || exit 5

# hide away our own versions of libtool-generated files
for i in $LT_TARGETS; do
  if test -f "$i"; then
    mv $i $i.bak
    cp $i.bak $i
  fi
done

# generate some files so people don't need bison, re2c and autoconf
# to install
set -x
./buildconf --force

# Generate lexer and parser files
./scripts/dev/genfiles
exit_code=$?
if test "$exit_code" != "0"; then
  exit $exit_code
fi

# now restore our versions of libtool-generated files
for i in $LT_TARGETS; do
  test -f "$i" && mv $i.bak $i
done

# removing junk files
rm -fr autom4te.cache/

# touching everything to be packaged
find $MY_OLDPWD/php-$VER -exec touch -c {} \;

# tweak zendparse to be exported through ZEND_API
# NOTE this has to be revisited once bison supports foreign skeletons
#      and that bison version is used. Read /usr/share/bison/README for more
sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.c
sed -i 's,^int zendparse\(.*\),ZEND_API int zendparse\1,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h
sed -i 's,^#ifndef YYTOKENTYPE,#include "zend.h"\n#ifndef YYTOKENTYPE,g' $MY_OLDPWD/php-$VER/Zend/zend_language_parser.h

# download pear
$ECHO_N "makedist: Attempting to download PEAR's phar archive"
if test ! -x wget; then
  wget https://pear.php.net/install-pear-nozlib.phar -nd -P pear/
  if [ "x$?" != "x0" ]
  then
    $ECHO_N "Pear download failed";
      exit 7
  fi
else
  $ECHO_N "Missing wget binary needed for pear download";
  exit 7
fi

cd $MY_OLDPWD
$ECHO_N "makedist: making gzipped tar archive...$ECHO_C"
rm -f $ARCHIVE.gz
tar cf $ARCHIVE php-$VER || exit 8
gzip -9 $ARCHIVE || exit 9
echo ""

$ECHO_N "makedist: making bz2zipped tar archive...$ECHO_C"
rm -f $ARCHIVE.bz2
tar cf $ARCHIVE php-$VER || exit 10
bzip2 -9 $ARCHIVE || exit 11
echo ""

$ECHO_N "makedist: making xz2zipped tar archive...$ECHO_C"
rm -f $ARCHIVE.xz
tar cf $ARCHIVE php-$VER || exit 10
xz -9 $ARCHIVE || exit 12
echo ""

$ECHO_N "makedist: cleaning up...$ECHO_C"
rm -rf $DIRPATH || exit 13
echo ""

exit 0