-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install PHP5.2/5.3 on trusty #2049
Changes from 50 commits
e4003ff
c8d6e2d
d8260ad
b1b226f
1b13149
0c7a85a
66dee1d
1897cab
c8e13f7
8aefb15
342d101
46cfe03
f3941b5
3860847
c2305df
23ebced
065d4f0
cc7bcb7
b437869
6027806
bf5b34c
26af1ec
bf8a10e
37ac2fc
efcbd66
bb4cab3
0497eeb
773b772
484ca3a
dd54882
d87839d
bccc478
658f352
2cfb5a5
6d64fa5
5ebf52f
455e4b0
a516690
7b1346c
32c7533
75d7f9f
a4f8ce9
e7667c3
0abeba6
7ebc7d0
c2712d0
1c9948c
d41b45b
4447192
10ff765
9309a3a
b973a38
d021c5d
5913b80
6541cdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/bin/bash | ||
|
||
# Uses phpbrew to install older php versions on modern(ish) distros. | ||
# Installs a shim that selects the correct phpunit version to run | ||
# if using an older version of php. | ||
|
||
# we have to save and restore the original working directory, because | ||
# phpbrew can mess up if we don't run it from the home directory | ||
ORIG_DIR=`pwd`; | ||
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]] || [[ ${SWITCH_TO_PHP:0:3} == "5.3" ]]; then | ||
PHPBREW_BUILT_CHECK=$HOME/.phpbrew/bashrc | ||
|
||
# directory to store phpbrew and old phpunit in | ||
mkdir -p $HOME/php-utils-bin | ||
|
||
# install the phpunit shim to run the right phpunit version for these old php versions | ||
cp ${THIS_DIR}/phpunit-shim.sh $HOME/php-utils-bin/phpunit | ||
chmod +x $HOME/php-utils-bin/phpunit | ||
|
||
# install phpbrew | ||
curl -L -o $HOME/php-utils-bin/phpbrew https://github.com/phpbrew/phpbrew/raw/f6a422e1ba49293ee73bc4c317795c021bc57020/phpbrew | ||
chmod +x $HOME/php-utils-bin/phpbrew | ||
|
||
# symlink to phpunit3.6 in the ph5.2 installation | ||
PHP52_PATH=$HOME/.phpbrew/php/php-5.2.17 | ||
ln -s ${PHP52_PATH}/lib/php/phpunit/phpunit.php $HOME/php-utils-bin/phpunit-3.6 | ||
|
||
# install phpunit4.8 | ||
curl -L -o $HOME/php-utils-bin/phpunit-4.8 https://phar.phpunit.de/phpunit-4.8.9.phar | ||
chmod +x $HOME/php-utils-bin/phpunit-4.8 | ||
|
||
# got to check our php-utils-bin first, as we're overriding travis' phpunit shim | ||
export PATH=$HOME/php-utils-bin:$PATH | ||
|
||
# php and phpunit installs should be cached, only build if they're not there. | ||
if [ ! -f $PHPBREW_BUILT_CHECK ]; then | ||
|
||
# init with known --old to get 5.2 and 5.3 | ||
$HOME/php-utils-bin/phpbrew init | ||
$HOME/php-utils-bin/phpbrew known --old | ||
|
||
# build PHP5.2 | ||
tail -F $HOME/.phpbrew/build/php-5.2.17/build.log & | ||
TAIL_PID=$! | ||
$HOME/php-utils-bin/phpbrew install --patch ${THIS_DIR}/patches/node.patch --patch ${THIS_DIR}/patches/openssl.patch 5.2 +default +mysql +pdo \ | ||
+gettext +phar +openssl -- --with-openssl-dir=/usr/include/openssl --enable-spl --with-mysql --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr | ||
kill -TERM $TAIL_PID | ||
|
||
# build PHP5.3 | ||
tail -F $HOME/.phpbrew/build/php-5.3.29/build.log & | ||
TAIL_PID=$! | ||
$HOME/php-utils-bin/phpbrew install --patch ${THIS_DIR}/patches/node.patch --patch ${THIS_DIR}/patches/openssl.patch 5.3 +default +mysql +pdo \ | ||
+gettext +phar +openssl -- --with-openssl-dir=/usr/include/openssl --enable-spl --with-mysql --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr | ||
kill -TERM $TAIL_PID | ||
|
||
# install PHPUnit 3.6. The only install method available is from source, using git branches old | ||
# enough that they don't rely on any PHP5.3+ features. This clones each needed dependency | ||
# and then we add the paths to the include_path by setting up an extra .ini file | ||
cd ${PHP52_PATH}/lib/php | ||
|
||
# dependencies | ||
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/dbunit.git | ||
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/php-code-coverage.git | ||
git clone --depth=1 --branch=1.3.2 git://github.com/sebastianbergmann/php-file-iterator.git | ||
git clone --depth=1 --branch=1.1.1 git://github.com/sebastianbergmann/php-invoker.git | ||
git clone --depth=1 --branch=1.1.2 git://github.com/sebastianbergmann/php-text-template.git | ||
git clone --depth=1 --branch=1.0.3 git://github.com/sebastianbergmann/php-timer.git | ||
git clone --depth=1 --branch=1.1.4 git://github.com/sebastianbergmann/php-token-stream.git | ||
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/phpunit-mock-objects.git | ||
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/phpunit-selenium.git | ||
git clone --depth=1 --branch=1.0.0 git://github.com/sebastianbergmann/phpunit-story.git | ||
|
||
# and the version of phpunit that we expect to run with php 5.2 | ||
git clone --depth=1 --branch=3.6 git://github.com/sebastianbergmann/phpunit.git | ||
|
||
# fix up the version number of phpunit | ||
sed -i 's/@package_version@/3.6-git/g' phpunit/PHPUnit/Runner/Version.php | ||
|
||
# now set up an ini file that adds all of the above to include_path for the PHP5.2 install | ||
mkdir -p $HOME/.phpbrew/php/php-5.2.17/var/db | ||
echo "include_path=.:${PHP52_PATH}/lib/php:${PHP52_PATH}/lib/php/dbunit:${PHP52_PATH}/lib/php/php-code-coverage:${PHP52_PATH}/lib/php/php-file-iterator:${PHP52_PATH}/lib/php/php-invoker:${PHP52_PATH}/lib/php/php-text-template:${PHP52_PATH}/lib/php/php-timer:${PHP52_PATH}/lib/php/php-token-stream:${PHP52_PATH}/lib/php/phpunit-mock-objects:${PHP52_PATH}/lib/php/phpunit-selenium:${PHP52_PATH}/lib/php/phpunit-story:${PHP52_PATH}/lib/php/phpunit" > ${PHP52_PATH}/var/db/path.ini | ||
|
||
# one more PHPUnit dependency that we need to install using pear under PHP5.2 | ||
cd $HOME | ||
export PHPBREW_RC_ENABLE=1 | ||
source $HOME/.phpbrew/bashrc | ||
phpbrew use 5.2.17 | ||
pear channel-discover pear.symfony-project.com | ||
pear install pear.symfony-project.com/YAML-1.0.2 | ||
|
||
# manually go back to the system php, we can't use `phpbrew switch-off` | ||
# because we're running a version of php that phpbrew doesn't work with at this point | ||
unset PHPBREW_PHP | ||
unset PHPBREW_PATH | ||
__phpbrew_set_path | ||
__phpbrew_reinit | ||
eval `$BIN env` | ||
|
||
# clean up build directory | ||
rm -rf $HOME/.phpbrew/build/* | ||
fi | ||
|
||
# all needed php versions and phpunit versions are installed, either from the above | ||
# install script, or from travis cache, so switch to using them | ||
cd $HOME | ||
export PATH=$HOME/php-utils-bin:$PATH | ||
export PHPBREW_RC_ENABLE=1 | ||
source $HOME/.phpbrew/bashrc | ||
|
||
if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]]; then | ||
phpbrew use 5.2.17 | ||
else | ||
phpbrew use 5.3.29 | ||
fi | ||
|
||
elif [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then | ||
# all other PHP 5.x versions | ||
mkdir -p $HOME/phpunit-bin | ||
wget -O $HOME/phpunit-bin/phpunit https://phar.phpunit.de/phpunit-4.8.phar | ||
chmod +x $HOME/phpunit-bin/phpunit | ||
export PATH=$HOME/phpunit-bin/:$PATH | ||
else | ||
composer global require "phpunit/phpunit=5.7.*" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
fi | ||
|
||
cd $ORIG_DIR |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800 | ||
+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800 | ||
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA | ||
RETVAL_FALSE; | ||
} else { | ||
if (mode == 0) { | ||
+#ifdef LIBXML2_NEW_BUFFER | ||
+ ret = xmlOutputBufferGetSize(buf); | ||
+#else | ||
ret = buf->buffer->use; | ||
+#endif | ||
if (ret > 0) { | ||
+#ifdef LIBXML2_NEW_BUFFER | ||
+ RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1); | ||
+#else | ||
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1); | ||
+#endif | ||
} else { | ||
RETVAL_EMPTY_STRING(); | ||
} | ||
--- ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800 | ||
+++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800 | ||
@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea | ||
if (buff != NULL) { | ||
xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL); | ||
xmlOutputBufferFlush(buff); | ||
+ | ||
+#ifdef LIBXML2_NEW_BUFFER | ||
+ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff), | ||
+ xmlOutputBufferGetSize(buff), 1); | ||
+#else | ||
ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1); | ||
+#endif | ||
(void)xmlOutputBufferClose(buff); | ||
return SUCCESS; | ||
} | ||
--- ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800 | ||
+++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800 | ||
@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML) | ||
|
||
xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding); | ||
xmlOutputBufferFlush(outbuf); | ||
+#ifdef LIBXML2_NEW_BUFFER | ||
+ RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf), | ||
+ xmlOutputBufferGetSize(outbuf), 1); | ||
+#else | ||
RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1); | ||
+#endif | ||
xmlOutputBufferClose(outbuf); | ||
} | ||
} else { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- ext/openssl/xp_ssl.c | ||
+++ ext/openssl/xp_ssl.c | ||
@@ -328,10 +328,12 @@ static inline int php_openssl_setup_cryp | ||
sslsock->is_client = 1; | ||
method = SSLv23_client_method(); | ||
break; | ||
+#ifndef OPENSSL_NO_SSL2 | ||
case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: | ||
sslsock->is_client = 1; | ||
method = SSLv2_client_method(); | ||
break; | ||
+#endif | ||
case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: | ||
sslsock->is_client = 1; | ||
method = SSLv3_client_method(); | ||
@@ -348,10 +350,12 @@ static inline int php_openssl_setup_cryp | ||
sslsock->is_client = 0; | ||
method = SSLv3_server_method(); | ||
break; | ||
+#ifndef OPENSSL_NO_SSL2 | ||
case STREAM_CRYPTO_METHOD_SSLv2_SERVER: | ||
sslsock->is_client = 0; | ||
method = SSLv2_server_method(); | ||
break; | ||
+#endif | ||
case STREAM_CRYPTO_METHOD_TLS_SERVER: | ||
sslsock->is_client = 0; | ||
method = TLSv1_server_method(); | ||
@@ -629,9 +633,11 @@ static inline int php_openssl_tcp_sockop | ||
case STREAM_CRYPTO_METHOD_SSLv23_CLIENT: | ||
sock->method = STREAM_CRYPTO_METHOD_SSLv23_SERVER; | ||
break; | ||
+#ifndef OPENSSL_NO_SSL2 | ||
case STREAM_CRYPTO_METHOD_SSLv2_CLIENT: | ||
sock->method = STREAM_CRYPTO_METHOD_SSLv2_SERVER; | ||
break; | ||
+#endif | ||
case STREAM_CRYPTO_METHOD_SSLv3_CLIENT: | ||
sock->method = STREAM_CRYPTO_METHOD_SSLv3_SERVER; | ||
break; | ||
@@ -911,9 +917,11 @@ php_stream *php_openssl_ssl_socket_facto | ||
if (strncmp(proto, "ssl", protolen) == 0) { | ||
sslsock->enable_on_connect = 1; | ||
sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT; | ||
+#ifndef OPENSSL_NO_SSL2 | ||
} else if (strncmp(proto, "sslv2", protolen) == 0) { | ||
sslsock->enable_on_connect = 1; | ||
sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT; | ||
+#endif | ||
} else if (strncmp(proto, "sslv3", protolen) == 0) { | ||
sslsock->enable_on_connect = 1; | ||
sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
PHP_VERSION=`php -v` | ||
|
||
if [[ ${PHP_VERSION:0:7} == "PHP 5.2" ]]; then | ||
phpunit-3.6 "$@" | ||
elif [[ ${PHP_VERSION:0:7} == "PHP 5.3" ]]; then | ||
phpunit-4.8 "$@" | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't this need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it does. Will add :) |
||
|
||
exit $? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Via https://github.com/WordPress/gutenberg/pull/2049/files#diff-7143235e98877ad64ec9f5c2fe1ad4feR16
Should
$HOME/php-utils-bin
also be added to the cache?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel too strongly about this, but because there are already phpunit shims injected by Travis, I'd rather only have this around when we actually need it, so that anyone who needs to debug this in the future has a slightly easier time figuring out what phpunit is actually getting run.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'm simplifying this so it works as before, with a phpunit-bin directory and a single
phpunit
executable file in there. Makes things much easier to follow, and we don't need our shim.