From d631e46ab4ad45c80ff4c177196277503533a692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20F=C3=B6rster?= Date: Thu, 20 Sep 2018 14:47:27 +0200 Subject: [PATCH] [dev-lang/php] pull multiple build fixes from fedora for 5.6 --- dev-lang/php/Manifest | 1 + dev-lang/php/files/20php5-envd | 2 + .../files/5.6-mbstring-oniguruma-6.8.patch | 12 + .../php/files/libressl-compatibility.patch | 65 + dev-lang/php/files/php-5.3.0-recode.patch | 17 + .../php/files/php-5.6-no-bison-warnings.patch | 42 + dev-lang/php/files/php-5.6.30-interbase.patch | 169 +++ dev-lang/php/files/php-5.6.31-openssl11.patch | 1198 +++++++++++++++++ dev-lang/php/files/php-5.6.37-icu62.patch | 589 ++++++++ dev-lang/php/files/php-fpm_at-simple.service | 13 + dev-lang/php/files/php-fpm_at.service | 14 + dev-lang/php/files/php-freetype-2.9.1.patch | 233 ++++ dev-lang/php/metadata.xml | 57 + dev-lang/php/php-5.6.38.ebuild | 783 +++++++++++ 14 files changed, 3195 insertions(+) create mode 100644 dev-lang/php/Manifest create mode 100644 dev-lang/php/files/20php5-envd create mode 100644 dev-lang/php/files/5.6-mbstring-oniguruma-6.8.patch create mode 100644 dev-lang/php/files/libressl-compatibility.patch create mode 100644 dev-lang/php/files/php-5.3.0-recode.patch create mode 100644 dev-lang/php/files/php-5.6-no-bison-warnings.patch create mode 100644 dev-lang/php/files/php-5.6.30-interbase.patch create mode 100644 dev-lang/php/files/php-5.6.31-openssl11.patch create mode 100644 dev-lang/php/files/php-5.6.37-icu62.patch create mode 100644 dev-lang/php/files/php-fpm_at-simple.service create mode 100644 dev-lang/php/files/php-fpm_at.service create mode 100644 dev-lang/php/files/php-freetype-2.9.1.patch create mode 100644 dev-lang/php/metadata.xml create mode 100644 dev-lang/php/php-5.6.38.ebuild diff --git a/dev-lang/php/Manifest b/dev-lang/php/Manifest new file mode 100644 index 0000000..b058b83 --- /dev/null +++ b/dev-lang/php/Manifest @@ -0,0 +1 @@ +DIST php-5.6.38.tar.xz 12467408 BLAKE2B d9ee47e193d80bce8a9ed6ffd3eb13e67ba6d1f597ece2803cd92fddc6245f46cdfe644d6cda12a6bb409b92c1fe748610cc5eb43dea0bf063fda81188ee8b3d SHA512 66c51a8e954b1496c0bad0a2864a2a1537dd1c1c573b553991d6d5bce85fc7bc340e56a21109bc5e9a03799e703204b980b569c95a5c0a1bddb01c8947e7a682 diff --git a/dev-lang/php/files/20php5-envd b/dev-lang/php/files/20php5-envd new file mode 100644 index 0000000..f6033ae --- /dev/null +++ b/dev-lang/php/files/20php5-envd @@ -0,0 +1,2 @@ +MANPATH="/usr/lib/php5/man/" +CONFIG_PROTECT_MASK="/etc/php/cli-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/apache2-php5/ext-active/" diff --git a/dev-lang/php/files/5.6-mbstring-oniguruma-6.8.patch b/dev-lang/php/files/5.6-mbstring-oniguruma-6.8.patch new file mode 100644 index 0000000..642b261 --- /dev/null +++ b/dev-lang/php/files/5.6-mbstring-oniguruma-6.8.patch @@ -0,0 +1,12 @@ +diff -aurN a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c +--- a/ext/mbstring/php_mbregex.c 2018-03-28 17:28:58.000000000 -0400 ++++ b/ext/mbstring/php_mbregex.c 2018-04-04 12:53:23.268296387 -0400 +@@ -454,7 +454,7 @@ + OnigUChar err_str[ONIG_MAX_ERROR_MESSAGE_LEN]; + + found = zend_hash_find(&MBREX(ht_rc), (char *)pattern, patlen+1, (void **) &rc); +- if (found == FAILURE || (*rc)->options != options || (*rc)->enc != enc || (*rc)->syntax != syntax) { ++ if (found == FAILURE || onig_get_options(*rc) != options || onig_get_encoding(*rc) != enc || onig_get_syntax(*rc) != syntax) { + if ((err_code = onig_new(&retval, (OnigUChar *)pattern, (OnigUChar *)(pattern + patlen), options, enc, syntax, &err_info)) != ONIG_NORMAL) { + onig_error_code_to_str(err_str, err_code, &err_info); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "mbregex compile err: %s", err_str); diff --git a/dev-lang/php/files/libressl-compatibility.patch b/dev-lang/php/files/libressl-compatibility.patch new file mode 100644 index 0000000..3b9c39d --- /dev/null +++ b/dev-lang/php/files/libressl-compatibility.patch @@ -0,0 +1,65 @@ +--- a/ext/openssl/openssl.c 2018-04-04 14:26:34.583000000 +0000 ++++ b/ext/openssl/openssl.c 2018-04-04 14:20:16.907000000 +0000 +@@ -73,7 +73,7 @@ + #ifdef HAVE_OPENSSL_MD2_H + #define OPENSSL_ALGO_MD2 4 + #endif +-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + #define OPENSSL_ALGO_DSS1 5 + #endif + #define OPENSSL_ALGO_SHA224 6 +@@ -560,7 +560,7 @@ + #endif + + /* {{{ OpenSSL compatibility functions and macros */ +-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + #define EVP_PKEY_get0_RSA(_pkey) _pkey->pkey.rsa + #define EVP_PKEY_get0_DH(_pkey) _pkey->pkey.dh + #define EVP_PKEY_get0_DSA(_pkey) _pkey->pkey.dsa +@@ -677,7 +677,7 @@ + return M_ASN1_STRING_data(asn1); + } + +-#if OPENSSL_VERSION_NUMBER < 0x10002000L || defined (LIBRESSL_VERSION_NUMBER) ++#if OPENSSL_VERSION_NUMBER < 0x10002000L || (defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + + static int X509_get_signature_nid(const X509 *x) + { +@@ -1324,7 +1324,7 @@ + mdtype = (EVP_MD *) EVP_md2(); + break; + #endif +-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + case OPENSSL_ALGO_DSS1: + mdtype = (EVP_MD *) EVP_dss1(); + break; +@@ -1450,7 +1450,7 @@ + #ifdef HAVE_OPENSSL_MD2_H + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD2", OPENSSL_ALGO_MD2, CONST_CS|CONST_PERSISTENT); + #endif +-#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || (defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_DSS1", OPENSSL_ALGO_DSS1, CONST_CS|CONST_PERSISTENT); + #endif + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA224", OPENSSL_ALGO_SHA224, CONST_CS|CONST_PERSISTENT); +@@ -3620,7 +3620,7 @@ + RETURN_FALSE; + } + +-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) ++#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !(defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + /* Due to changes in OpenSSL 1.1 related to locking when decoding CSR, + * the pub key is not changed after assigning. It means if we pass + * a private key, it will be returned including the private part. +@@ -3631,7 +3631,7 @@ + /* Retrieve the public key from the CSR */ + tpubkey = X509_REQ_get_pubkey(csr); + +-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER) ++#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !(defined (LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) + /* We need to free the CSR as it was duplicated */ + X509_REQ_free(csr); + #endif diff --git a/dev-lang/php/files/php-5.3.0-recode.patch b/dev-lang/php/files/php-5.3.0-recode.patch new file mode 100644 index 0000000..a24ee98 --- /dev/null +++ b/dev-lang/php/files/php-5.3.0-recode.patch @@ -0,0 +1,17 @@ +diff -up ext/recode/config9.m4.recode ext/recode/config9.m4 +--- ext/recode/config9.m4.recode 2008-12-02 00:30:21.000000000 +0100 ++++ ext/recode/config9.m4 2009-02-28 09:46:50.000000000 +0100 +@@ -4,13 +4,6 @@ dnl + + dnl Check for extensions with which Recode can not work + if test "$PHP_RECODE" != "no"; then +- test "$PHP_IMAP" != "no" && recode_conflict="$recode_conflict imap" +- +- if test -n "$MYSQL_LIBNAME"; then +- PHP_CHECK_LIBRARY($MYSQL_LIBNAME, hash_insert, [ +- recode_conflict="$recode_conflict mysql" +- ]) +- fi + + if test -n "$recode_conflict"; then + AC_MSG_ERROR([recode extension can not be configured together with:$recode_conflict]) diff --git a/dev-lang/php/files/php-5.6-no-bison-warnings.patch b/dev-lang/php/files/php-5.6-no-bison-warnings.patch new file mode 100644 index 0000000..1896659 --- /dev/null +++ b/dev-lang/php/files/php-5.6-no-bison-warnings.patch @@ -0,0 +1,42 @@ +From d3466a04345b31dfc62d94fe994b40321a6418ec Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky +Date: Thu, 29 Sep 2016 15:43:06 -0400 +Subject: [PATCH 1/1] Zend/acinclude.m4: don't warn about >=bison-3.0.1 + versions. + +The PHP configure script will emit a warning if it thinks your bison +version is insufficient: + + WARNING: This bison version is not supported for regeneration of + the Zend/PHP parsers (found: 3.0, min: 204, excluded: 3.0). + +However, there is an error in the test that causes it to treat all +3.0.x versions as if they were 3.0. The result is that users get +warned about a perfectly acceptable version of bison. + +This patch is meant only for Gentoo, where we can require a working +version of bison (something newer than 3.0.1). Having done so, this +patch removes the check and the WARNING. + +Gentoo-Bug: 593278 +PHP-Bug: 69055 +--- + Zend/acinclude.m4 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Zend/acinclude.m4 b/Zend/acinclude.m4 +index 7fa8c99..9d6cb1d 100644 +--- a/Zend/acinclude.m4 ++++ b/Zend/acinclude.m4 +@@ -9,7 +9,7 @@ AC_DEFUN([LIBZEND_BISON_CHECK],[ + # non-working versions, e.g. "3.0 3.2"; + # remove "none" when introducing the first incompatible bison version an + # separate any following additions by spaces +- bison_version_exclude="3.0" ++ bison_version_exclude="" + + # for standalone build of Zend Engine + test -z "$SED" && SED=sed +-- +2.7.3 + diff --git a/dev-lang/php/files/php-5.6.30-interbase.patch b/dev-lang/php/files/php-5.6.30-interbase.patch new file mode 100644 index 0000000..ea7afbd --- /dev/null +++ b/dev-lang/php/files/php-5.6.30-interbase.patch @@ -0,0 +1,169 @@ +Adapted for 5.6 from + +From 397bedcc7c3545510a22b7db8dc6444e0a05b085 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 16 Nov 2016 10:45:59 +0100 +Subject: [PATCH] Fixed bug #73512 Fails to find firebird headers + +- use fb_config output instead of relying on hardoded path + +diff -up ./ext/interbase/config.m4.fb_config ./ext/interbase/config.m4 +--- ./ext/interbase/config.m4.fb_config 2017-03-17 08:58:57.061708947 +0100 ++++ ./ext/interbase/config.m4 2017-03-17 09:04:53.389584385 +0100 +@@ -3,39 +3,54 @@ PHP_ARG_WITH(interbase,for InterBase sup + install directory [/usr/interbase]]) + + if test "$PHP_INTERBASE" != "no"; then +- if test "$PHP_INTERBASE" = "yes"; then +- IBASE_INCDIR=/usr/interbase/include +- IBASE_LIBDIR=/usr/interbase/lib ++ ++ AC_PATH_PROG(FB_CONFIG, fb_config, no) ++ ++ if test -x "$FB_CONFIG" && test "$PHP_INTERBASE" = "yes"; then ++ AC_MSG_CHECKING(for libfbconfig) ++ FB_CFLAGS=`$FB_CONFIG --cflags` ++ FB_LIBDIR=`$FB_CONFIG --libs` ++ FB_VERSION=`$FB_CONFIG --version` ++ AC_MSG_RESULT(version $FB_VERSION) ++ PHP_EVAL_LIBLINE($FB_LIBDIR, INTERBASE_SHARED_LIBADD) ++ PHP_EVAL_INCLINE($FB_CFLAGS) ++ + else +- IBASE_INCDIR=$PHP_INTERBASE/include +- IBASE_LIBDIR=$PHP_INTERBASE/$PHP_LIBDIR +- fi ++ if test "$PHP_INTERBASE" = "yes"; then ++ IBASE_INCDIR=/usr/interbase/include ++ IBASE_LIBDIR=/usr/interbase/lib ++ else ++ IBASE_INCDIR=$PHP_INTERBASE/include ++ IBASE_LIBDIR=$PHP_INTERBASE/$PHP_LIBDIR ++ fi + +- PHP_CHECK_LIBRARY(fbclient, isc_detach_database, +- [ +- IBASE_LIBNAME=fbclient +- ], [ +- PHP_CHECK_LIBRARY(gds, isc_detach_database, ++ PHP_CHECK_LIBRARY(fbclient, isc_detach_database, + [ +- IBASE_LIBNAME=gds ++ IBASE_LIBNAME=fbclient + ], [ +- PHP_CHECK_LIBRARY(ib_util, isc_detach_database, ++ PHP_CHECK_LIBRARY(gds, isc_detach_database, + [ +- IBASE_LIBNAME=ib_util ++ IBASE_LIBNAME=gds + ], [ +- AC_MSG_ERROR([libgds, libib_util or libfbclient not found! Check config.log for more information.]) ++ PHP_CHECK_LIBRARY(ib_util, isc_detach_database, ++ [ ++ IBASE_LIBNAME=ib_util ++ ], [ ++ AC_MSG_ERROR([libgds, libib_util or libfbclient not found! Check config.log for more information.]) ++ ], [ ++ -L$IBASE_LIBDIR ++ ]) + ], [ + -L$IBASE_LIBDIR + ]) + ], [ + -L$IBASE_LIBDIR + ]) +- ], [ +- -L$IBASE_LIBDIR +- ]) + +- PHP_ADD_LIBRARY_WITH_PATH($IBASE_LIBNAME, $IBASE_LIBDIR, INTERBASE_SHARED_LIBADD) +- PHP_ADD_INCLUDE($IBASE_INCDIR) ++ PHP_ADD_LIBRARY_WITH_PATH($IBASE_LIBNAME, $IBASE_LIBDIR, INTERBASE_SHARED_LIBADD) ++ PHP_ADD_INCLUDE($IBASE_INCDIR) ++ fi ++ + AC_DEFINE(HAVE_IBASE,1,[ ]) + PHP_NEW_EXTENSION(interbase, interbase.c ibase_query.c ibase_service.c ibase_events.c ibase_blobs.c, $ext_shared) + PHP_SUBST(INTERBASE_SHARED_LIBADD) +diff -up ./ext/pdo_firebird/config.m4.fb_config ./ext/pdo_firebird/config.m4 +--- ./ext/pdo_firebird/config.m4.fb_config 2017-01-19 01:17:47.000000000 +0100 ++++ ./ext/pdo_firebird/config.m4 2017-03-17 08:58:57.061708947 +0100 +@@ -8,43 +8,56 @@ if test "$PHP_PDO_FIREBIRD" != "no"; the + AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.]) + fi + +- if test "$PHP_PDO_FIREBIRD" = "yes"; then +- FIREBIRD_INCDIR= +- FIREBIRD_LIBDIR= +- FIREBIRD_LIBDIR_FLAG= ++ AC_PATH_PROG(FB_CONFIG, fb_config, no) ++ ++ if test -x "$FB_CONFIG" && test "$PHP_PDO_FIREBIRD" = "yes"; then ++ AC_MSG_CHECKING(for libfbconfig) ++ FB_CFLAGS=`$FB_CONFIG --cflags` ++ FB_LIBDIR=`$FB_CONFIG --libs` ++ FB_VERSION=`$FB_CONFIG --version` ++ AC_MSG_RESULT(version $FB_VERSION) ++ PHP_EVAL_LIBLINE($FB_LIBDIR, PDO_FIREBIRD_SHARED_LIBADD) ++ PHP_EVAL_INCLINE($FB_CFLAGS) ++ + else +- FIREBIRD_INCDIR=$PHP_PDO_FIREBIRD/include +- FIREBIRD_LIBDIR=$PHP_PDO_FIREBIRD/$PHP_LIBDIR +- FIREBIRD_LIBDIR_FLAG=-L$FIREBIRD_LIBDIR +- fi ++ if test "$PHP_PDO_FIREBIRD" = "yes"; then ++ FIREBIRD_INCDIR= ++ FIREBIRD_LIBDIR= ++ FIREBIRD_LIBDIR_FLAG= ++ else ++ FIREBIRD_INCDIR=$PHP_PDO_FIREBIRD/include ++ FIREBIRD_LIBDIR=$PHP_PDO_FIREBIRD/$PHP_LIBDIR ++ FIREBIRD_LIBDIR_FLAG=-L$FIREBIRD_LIBDIR ++ fi + +- PHP_CHECK_LIBRARY(fbclient, isc_detach_database, +- [ +- FIREBIRD_LIBNAME=fbclient +- ], [ +- PHP_CHECK_LIBRARY(gds, isc_detach_database, ++ PHP_CHECK_LIBRARY(fbclient, isc_detach_database, + [ +- FIREBIRD_LIBNAME=gds ++ FIREBIRD_LIBNAME=fbclient + ], [ +- PHP_CHECK_LIBRARY(ib_util, isc_detach_database, ++ PHP_CHECK_LIBRARY(gds, isc_detach_database, + [ +- FIREBIRD_LIBNAME=ib_util ++ FIREBIRD_LIBNAME=gds + ], [ +- AC_MSG_ERROR([libfbclient, libgds or libib_util not found! Check config.log for more information.]) ++ PHP_CHECK_LIBRARY(ib_util, isc_detach_database, ++ [ ++ FIREBIRD_LIBNAME=ib_util ++ ], [ ++ AC_MSG_ERROR([libfbclient, libgds or libib_util not found! Check config.log for more information.]) ++ ], [ ++ $FIREBIRD_LIBDIR_FLAG ++ ]) + ], [ + $FIREBIRD_LIBDIR_FLAG + ]) + ], [ + $FIREBIRD_LIBDIR_FLAG + ]) +- ], [ +- $FIREBIRD_LIBDIR_FLAG +- ]) ++ PHP_ADD_LIBRARY_WITH_PATH($FIREBIRD_LIBNAME, $FIREBIRD_LIBDIR, PDO_FIREBIRD_SHARED_LIBADD) ++ PHP_ADD_INCLUDE($FIREBIRD_INCDIR) ++ fi + + PHP_CHECK_PDO_INCLUDES + +- PHP_ADD_LIBRARY_WITH_PATH($FIREBIRD_LIBNAME, $FIREBIRD_LIBDIR, PDO_FIREBIRD_SHARED_LIBADD) +- PHP_ADD_INCLUDE($FIREBIRD_INCDIR) + AC_DEFINE(HAVE_PDO_FIREBIRD,1,[ ]) + PHP_NEW_EXTENSION(pdo_firebird, pdo_firebird.c firebird_driver.c firebird_statement.c, $ext_shared,,-I$pdo_cv_inc_path) + PHP_SUBST(PDO_FIREBIRD_SHARED_LIBADD) diff --git a/dev-lang/php/files/php-5.6.31-openssl11.patch b/dev-lang/php/files/php-5.6.31-openssl11.patch new file mode 100644 index 0000000..1cce7e3 --- /dev/null +++ b/dev-lang/php/files/php-5.6.31-openssl11.patch @@ -0,0 +1,1198 @@ +From 4ca75ff1f3c341b83932f85310595f5c0a10f57e Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Mon, 20 Mar 2017 11:45:54 +0100 +Subject: [PATCH] backport needed changes for OpenSSL 1.1 + +--- + ext/openssl/openssl.c | 528 ++++++++++++++-------- + ext/openssl/tests/001.phpt | 7 +- + ext/openssl/tests/bug41033.phpt | 4 +- + ext/openssl/tests/bug66501.phpt | 2 +- + ext/openssl/tests/openssl_error_string_basic.phpt | 6 +- + ext/openssl/tests/sni_server.phpt | 2 + + ext/openssl/xp_ssl.c | 15 - + ext/phar/util.c | 13 +- + 8 files changed, 371 insertions(+), 206 deletions(-) + +diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c +index a78a8fb..eda68f2 100644 +--- a/ext/openssl/openssl.c ++++ b/ext/openssl/openssl.c +@@ -68,7 +68,9 @@ + #ifdef HAVE_OPENSSL_MD2_H + #define OPENSSL_ALGO_MD2 4 + #endif ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) + #define OPENSSL_ALGO_DSS1 5 ++#endif + #if OPENSSL_VERSION_NUMBER >= 0x0090708fL + #define OPENSSL_ALGO_SHA224 6 + #define OPENSSL_ALGO_SHA256 7 +@@ -825,7 +827,8 @@ static int add_oid_section(struct php_x509_request * req TSRMLS_DC) /* {{{ */ + } + for (i = 0; i < sk_CONF_VALUE_num(sktmp); i++) { + cnf = sk_CONF_VALUE_value(sktmp, i); +- if (OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) { ++ if (OBJ_sn2nid(cnf->name) == NID_undef && OBJ_ln2nid(cnf->name) == NID_undef && ++ OBJ_create(cnf->value, cnf->name, cnf->name) == NID_undef) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "problem creating object %s=%s", cnf->name, cnf->value); + return FAILURE; + } +@@ -1053,9 +1056,11 @@ static EVP_MD * php_openssl_get_evp_md_from_algo(long algo) { /* {{{ */ + mdtype = (EVP_MD *) EVP_md2(); + break; + #endif ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) + case OPENSSL_ALGO_DSS1: + mdtype = (EVP_MD *) EVP_dss1(); + break; ++#endif + #if OPENSSL_VERSION_NUMBER >= 0x0090708fL + case OPENSSL_ALGO_SHA224: + mdtype = (EVP_MD *) EVP_sha224(); +@@ -1173,7 +1178,9 @@ PHP_MINIT_FUNCTION(openssl) + #ifdef HAVE_OPENSSL_MD2_H + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_MD2", OPENSSL_ALGO_MD2, CONST_CS|CONST_PERSISTENT); + #endif ++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined (LIBRESSL_VERSION_NUMBER) + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_DSS1", OPENSSL_ALGO_DSS1, CONST_CS|CONST_PERSISTENT); ++#endif + #if OPENSSL_VERSION_NUMBER >= 0x0090708fL + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA224", OPENSSL_ALGO_SHA224, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("OPENSSL_ALGO_SHA256", OPENSSL_ALGO_SHA256, CONST_CS|CONST_PERSISTENT); +@@ -1893,6 +1900,7 @@ static int openssl_x509v3_subjectAltName(BIO *bio, X509_EXTENSION *extension) + { + GENERAL_NAMES *names; + const X509V3_EXT_METHOD *method = NULL; ++ ASN1_OCTET_STRING *extension_data; + long i, length, num; + const unsigned char *p; + +@@ -1901,8 +1909,9 @@ static int openssl_x509v3_subjectAltName(BIO *bio, X509_EXTENSION *extension) + return -1; + } + +- p = extension->value->data; +- length = extension->value->length; ++ extension_data = X509_EXTENSION_get_data(extension); ++ p = extension_data->data; ++ length = extension_data->length; + if (method->it) { + names = (GENERAL_NAMES*)(ASN1_item_d2i(NULL, &p, length, + ASN1_ITEM_ptr(method->it))); +@@ -1965,6 +1974,8 @@ PHP_FUNCTION(openssl_x509_parse) + char * tmpstr; + zval * subitem; + X509_EXTENSION *extension; ++ X509_NAME *subject_name; ++ char *cert_name; + char *extname; + BIO *bio_out; + BUF_MEM *bio_buf; +@@ -1979,12 +1990,14 @@ PHP_FUNCTION(openssl_x509_parse) + } + array_init(return_value); + +- if (cert->name) { +- add_assoc_string(return_value, "name", cert->name, 1); +- } ++ subject_name = X509_get_subject_name(cert); ++ cert_name = X509_NAME_oneline(subject_name, NULL, 0); ++ add_assoc_string(return_value, "name", cert_name, 1); ++ OPENSSL_free(cert_name); ++ + /* add_assoc_bool(return_value, "valid", cert->valid); */ + +- add_assoc_name_entry(return_value, "subject", X509_get_subject_name(cert), useshortnames TSRMLS_CC); ++ add_assoc_name_entry(return_value, "subject", subject_name, useshortnames TSRMLS_CC); + /* hash as used in CA directories to lookup cert by subject name */ + { + char buf[32]; +@@ -2008,7 +2021,7 @@ PHP_FUNCTION(openssl_x509_parse) + add_assoc_string(return_value, "alias", tmpstr, 1); + } + +- sig_nid = OBJ_obj2nid((cert)->sig_alg->algorithm); ++ sig_nid = X509_get_signature_nid(cert); + add_assoc_string(return_value, "signatureTypeSN", (char*)OBJ_nid2sn(sig_nid), 1); + add_assoc_string(return_value, "signatureTypeLN", (char*)OBJ_nid2ln(sig_nid), 1); + add_assoc_long(return_value, "signatureTypeNID", sig_nid); +@@ -3482,14 +3495,21 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC) + { + assert(pkey != NULL); + +- switch (pkey->type) { ++ switch (EVP_PKEY_id(pkey)) { + #ifndef NO_RSA + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: +- assert(pkey->pkey.rsa != NULL); +- if (pkey->pkey.rsa != NULL && (NULL == pkey->pkey.rsa->p || NULL == pkey->pkey.rsa->q)) { +- return 0; +- } ++ { ++ RSA *rsa = EVP_PKEY_get0_RSA(pkey); ++ if (rsa != NULL) { ++ const BIGNUM *p, *q; ++ ++ RSA_get0_factors(rsa, &p, &q); ++ if (p == NULL || q == NULL) { ++ return 0; ++ } ++ } ++ } + break; + #endif + #ifndef NO_DSA +@@ -3498,29 +3518,50 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC) + case EVP_PKEY_DSA2: + case EVP_PKEY_DSA3: + case EVP_PKEY_DSA4: +- assert(pkey->pkey.dsa != NULL); +- +- if (NULL == pkey->pkey.dsa->p || NULL == pkey->pkey.dsa->q || NULL == pkey->pkey.dsa->priv_key){ +- return 0; +- } ++ { ++ DSA *dsa = EVP_PKEY_get0_DSA(pkey); ++ if (dsa != NULL) { ++ const BIGNUM *p, *q, *g, *pub_key, *priv_key; ++ ++ DSA_get0_pqg(dsa, &p, &q, &g); ++ if (p == NULL || q == NULL) { ++ return 0; ++ } ++ DSA_get0_key(dsa, &pub_key, &priv_key); ++ if (priv_key == NULL) { ++ return 0; ++ } ++ } ++ } + break; + #endif + #ifndef NO_DH + case EVP_PKEY_DH: +- assert(pkey->pkey.dh != NULL); +- +- if (NULL == pkey->pkey.dh->p || NULL == pkey->pkey.dh->priv_key) { +- return 0; +- } ++ { ++ DH *dh = EVP_PKEY_get0_DH(pkey); ++ if (dh != NULL) { ++ const BIGNUM *p, *q, *g, *pub_key, *priv_key; ++ ++ DH_get0_pqg(dh, &p, &q, &g); ++ if (p == NULL) { ++ return 0; ++ } ++ DH_get0_key(dh, &pub_key, &priv_key); ++ if (priv_key == NULL) { ++ return 0; ++ } ++ } ++ } + break; + #endif + #ifdef HAVE_EVP_PKEY_EC + case EVP_PKEY_EC: +- assert(pkey->pkey.ec != NULL); +- +- if ( NULL == EC_KEY_get0_private_key(pkey->pkey.ec)) { +- return 0; +- } ++ { ++ EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); ++ if (ec != NULL && NULL == EC_KEY_get0_private_key(ec)) { ++ return 0; ++ } ++ } + break; + #endif + default: +@@ -3531,42 +3572,91 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC) + } + /* }}} */ + +-#define OPENSSL_PKEY_GET_BN(_type, _name) do { \ +- if (pkey->pkey._type->_name != NULL) { \ +- int len = BN_num_bytes(pkey->pkey._type->_name); \ ++#define OPENSSL_GET_BN(_array, _bn, _name) do { \ ++ if (_bn != NULL) { \ ++ int len = BN_num_bytes(_bn); \ + char *str = emalloc(len + 1); \ +- BN_bn2bin(pkey->pkey._type->_name, (unsigned char*)str); \ ++ BN_bn2bin(_bn, (unsigned char*)str); \ + str[len] = 0; \ +- add_assoc_stringl(_type, #_name, str, len, 0); \ ++ add_assoc_stringl(_array, #_name, str, len, 0); \ + } \ + } while (0) + +-#define OPENSSL_PKEY_SET_BN(_ht, _type, _name) do { \ ++#define OPENSSL_PKEY_GET_BN(_type, _name) OPENSSL_GET_BN(_type, _name, _name) ++ ++#define OPENSSL_PKEY_SET_BN(_data, _name) do { \ + zval **bn; \ +- if (zend_hash_find(_ht, #_name, sizeof(#_name), (void**)&bn) == SUCCESS && \ ++ if (zend_hash_find(Z_ARRVAL_P(_data), #_name, sizeof(#_name), (void**)&bn) == SUCCESS && \ + Z_TYPE_PP(bn) == IS_STRING) { \ +- _type->_name = BN_bin2bn( \ ++ _name = BN_bin2bn( \ + (unsigned char*)Z_STRVAL_PP(bn), \ + Z_STRLEN_PP(bn), NULL); \ ++ } else { \ ++ _name = NULL; \ + } \ + } while (0); + +-/* {{{ php_openssl_pkey_init_dsa */ +-zend_bool php_openssl_pkey_init_dsa(DSA *dsa) ++/* {{{ php_openssl_pkey_init_rsa */ ++zend_bool php_openssl_pkey_init_and_assign_rsa(EVP_PKEY *pkey, RSA *rsa, zval *data) + { +- if (!dsa->p || !dsa->q || !dsa->g) { ++ BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; ++ ++ OPENSSL_PKEY_SET_BN(data, n); ++ OPENSSL_PKEY_SET_BN(data, e); ++ OPENSSL_PKEY_SET_BN(data, d); ++ if (!n || !d || !RSA_set0_key(rsa, n, e, d)) { + return 0; + } +- if (dsa->priv_key || dsa->pub_key) { +- return 1; ++ ++ OPENSSL_PKEY_SET_BN(data, p); ++ OPENSSL_PKEY_SET_BN(data, q); ++ if ((p || q) && !RSA_set0_factors(rsa, p, q)) { ++ return 0; ++ } ++ ++ OPENSSL_PKEY_SET_BN(data, dmp1); ++ OPENSSL_PKEY_SET_BN(data, dmq1); ++ OPENSSL_PKEY_SET_BN(data, iqmp); ++ if ((dmp1 || dmq1 || iqmp) && !RSA_set0_crt_params(rsa, dmp1, dmq1, iqmp)) { ++ return 0; ++ } ++ ++ if (!EVP_PKEY_assign_RSA(pkey, rsa)) { ++ return 0; ++ } ++ ++ return 1; ++} ++ ++/* {{{ php_openssl_pkey_init_dsa */ ++zend_bool php_openssl_pkey_init_dsa(DSA *dsa, zval *data) ++{ ++ BIGNUM *p, *q, *g, *priv_key, *pub_key; ++ const BIGNUM *priv_key_const, *pub_key_const; ++ ++ OPENSSL_PKEY_SET_BN(data, p); ++ OPENSSL_PKEY_SET_BN(data, q); ++ OPENSSL_PKEY_SET_BN(data, g); ++ if (!p || !q || !g || !DSA_set0_pqg(dsa, p, q, g)) { ++ return 0; + } ++ ++ OPENSSL_PKEY_SET_BN(data, pub_key); ++ OPENSSL_PKEY_SET_BN(data, priv_key); ++ if (pub_key) { ++ return DSA_set0_key(dsa, pub_key, priv_key); ++ } ++ ++ /* generate key */ + PHP_OPENSSL_RAND_ADD_TIME(); + if (!DSA_generate_key(dsa)) { + return 0; + } ++ + /* if BN_mod_exp return -1, then DSA_generate_key succeed for failed key + * so we need to double check that public key is created */ +- if (!dsa->pub_key || BN_is_zero(dsa->pub_key)) { ++ DSA_get0_key(dsa, &pub_key_const, &priv_key_const); ++ if (!pub_key_const || BN_is_zero(pub_key_const)) { + return 0; + } + /* all good */ +@@ -3574,15 +3664,69 @@ zend_bool php_openssl_pkey_init_dsa(DSA *dsa) + } + /* }}} */ + ++/* {{{ php_openssl_dh_pub_from_priv */ ++static BIGNUM *php_openssl_dh_pub_from_priv(BIGNUM *priv_key, BIGNUM *g, BIGNUM *p) ++{ ++ BIGNUM *pub_key, *priv_key_const_time; ++ BN_CTX *ctx; ++ ++ pub_key = BN_new(); ++ if (pub_key == NULL) { ++ return NULL; ++ } ++ ++ priv_key_const_time = BN_new(); ++ if (priv_key_const_time == NULL) { ++ BN_free(pub_key); ++ return NULL; ++ } ++ ctx = BN_CTX_new(); ++ if (ctx == NULL) { ++ BN_free(pub_key); ++ BN_free(priv_key_const_time); ++ return NULL; ++ } ++ ++ BN_with_flags(priv_key_const_time, priv_key, BN_FLG_CONSTTIME); ++ ++ if (!BN_mod_exp_mont(pub_key, g, priv_key_const_time, p, ctx, NULL)) { ++ BN_free(pub_key); ++ pub_key = NULL; ++ } ++ ++ BN_free(priv_key_const_time); ++ BN_CTX_free(ctx); ++ ++ return pub_key; ++} ++/* }}} */ ++ + /* {{{ php_openssl_pkey_init_dh */ +-zend_bool php_openssl_pkey_init_dh(DH *dh) ++zend_bool php_openssl_pkey_init_dh(DH *dh, zval *data) + { +- if (!dh->p || !dh->g) { ++ BIGNUM *p, *q, *g, *priv_key, *pub_key; ++ ++ OPENSSL_PKEY_SET_BN(data, p); ++ OPENSSL_PKEY_SET_BN(data, q); ++ OPENSSL_PKEY_SET_BN(data, g); ++ if (!p || !g || !DH_set0_pqg(dh, p, q, g)) { + return 0; + } +- if (dh->pub_key) { +- return 1; ++ ++ OPENSSL_PKEY_SET_BN(data, priv_key); ++ OPENSSL_PKEY_SET_BN(data, pub_key); ++ if (pub_key) { ++ return DH_set0_key(dh, pub_key, priv_key); + } ++ if (priv_key) { ++ pub_key = php_openssl_dh_pub_from_priv(priv_key, g, p); ++ if (pub_key == NULL) { ++ return 0; ++ } ++ return DH_set0_key(dh, pub_key, priv_key); ++ } ++ ++ /* generate key */ + PHP_OPENSSL_RAND_ADD_TIME(); + if (!DH_generate_key(dh)) { + return 0; +@@ -3614,18 +3758,8 @@ PHP_FUNCTION(openssl_pkey_new) + if (pkey) { + RSA *rsa = RSA_new(); + if (rsa) { +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, n); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, e); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, d); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, p); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, q); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, dmp1); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, dmq1); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), rsa, iqmp); +- if (rsa->n && rsa->d) { +- if (EVP_PKEY_assign_RSA(pkey, rsa)) { +- RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); +- } ++ if (php_openssl_pkey_init_and_assign_rsa(pkey, rsa, *data)) { ++ RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); + } + RSA_free(rsa); + } +@@ -3638,12 +3772,7 @@ PHP_FUNCTION(openssl_pkey_new) + if (pkey) { + DSA *dsa = DSA_new(); + if (dsa) { +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, p); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, q); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, g); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, priv_key); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dsa, pub_key); +- if (php_openssl_pkey_init_dsa(dsa)) { ++ if (php_openssl_pkey_init_dsa(dsa, *data)) { + if (EVP_PKEY_assign_DSA(pkey, dsa)) { + RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); + } +@@ -3659,11 +3788,7 @@ PHP_FUNCTION(openssl_pkey_new) + if (pkey) { + DH *dh = DH_new(); + if (dh) { +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, p); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, g); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, priv_key); +- OPENSSL_PKEY_SET_BN(Z_ARRVAL_PP(data), dh, pub_key); +- if (php_openssl_pkey_init_dh(dh)) { ++ if (php_openssl_pkey_init_dh(dh, *data)) { + if (EVP_PKEY_assign_DH(pkey, dh)) { + RETURN_RESOURCE(zend_list_insert(pkey, le_key TSRMLS_CC)); + } +@@ -3738,7 +3863,7 @@ PHP_FUNCTION(openssl_pkey_export_to_file) + cipher = NULL; + } + +- switch (EVP_PKEY_type(key->type)) { ++ switch (EVP_PKEY_base_id(key)) { + #ifdef HAVE_EVP_PKEY_EC + case EVP_PKEY_EC: + pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get1_EC_KEY(key), cipher, (unsigned char *)passphrase, passphrase_len, NULL, NULL); +@@ -3807,7 +3932,7 @@ PHP_FUNCTION(openssl_pkey_export) + cipher = NULL; + } + +- switch (EVP_PKEY_type(key->type)) { ++ switch (EVP_PKEY_base_id(key)) { + #ifdef HAVE_EVP_PKEY_EC + case EVP_PKEY_EC: + pem_write = PEM_write_bio_ECPrivateKey(bio_out, EVP_PKEY_get1_EC_KEY(key), cipher, (unsigned char *)passphrase, passphrase_len, NULL, NULL); +@@ -3928,68 +4053,88 @@ PHP_FUNCTION(openssl_pkey_get_details) + /*TODO: Use the real values once the openssl constants are used + * See the enum at the top of this file + */ +- switch (EVP_PKEY_type(pkey->type)) { ++ switch (EVP_PKEY_base_id(pkey)) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: +- ktype = OPENSSL_KEYTYPE_RSA; +- +- if (pkey->pkey.rsa != NULL) { +- zval *rsa; +- +- ALLOC_INIT_ZVAL(rsa); +- array_init(rsa); +- OPENSSL_PKEY_GET_BN(rsa, n); +- OPENSSL_PKEY_GET_BN(rsa, e); +- OPENSSL_PKEY_GET_BN(rsa, d); +- OPENSSL_PKEY_GET_BN(rsa, p); +- OPENSSL_PKEY_GET_BN(rsa, q); +- OPENSSL_PKEY_GET_BN(rsa, dmp1); +- OPENSSL_PKEY_GET_BN(rsa, dmq1); +- OPENSSL_PKEY_GET_BN(rsa, iqmp); +- add_assoc_zval(return_value, "rsa", rsa); +- } ++ { ++ RSA *rsa = EVP_PKEY_get0_RSA(pkey); ++ ktype = OPENSSL_KEYTYPE_RSA; ++ ++ if (rsa != NULL) { ++ zval *z_rsa; ++ const BIGNUM *n, *e, *d, *p, *q, *dmp1, *dmq1, *iqmp; ++ ++ RSA_get0_key(rsa, &n, &e, &d); ++ RSA_get0_factors(rsa, &p, &q); ++ RSA_get0_crt_params(rsa, &dmp1, &dmq1, &iqmp); ++ ++ ALLOC_INIT_ZVAL(z_rsa); ++ array_init(z_rsa); ++ OPENSSL_PKEY_GET_BN(z_rsa, n); ++ OPENSSL_PKEY_GET_BN(z_rsa, e); ++ OPENSSL_PKEY_GET_BN(z_rsa, d); ++ OPENSSL_PKEY_GET_BN(z_rsa, p); ++ OPENSSL_PKEY_GET_BN(z_rsa, q); ++ OPENSSL_PKEY_GET_BN(z_rsa, dmp1); ++ OPENSSL_PKEY_GET_BN(z_rsa, dmq1); ++ OPENSSL_PKEY_GET_BN(z_rsa, iqmp); ++ add_assoc_zval(return_value, "rsa", z_rsa); ++ } ++ } + + break; + case EVP_PKEY_DSA: + case EVP_PKEY_DSA2: + case EVP_PKEY_DSA3: + case EVP_PKEY_DSA4: +- ktype = OPENSSL_KEYTYPE_DSA; +- +- if (pkey->pkey.dsa != NULL) { +- zval *dsa; +- +- ALLOC_INIT_ZVAL(dsa); +- array_init(dsa); +- OPENSSL_PKEY_GET_BN(dsa, p); +- OPENSSL_PKEY_GET_BN(dsa, q); +- OPENSSL_PKEY_GET_BN(dsa, g); +- OPENSSL_PKEY_GET_BN(dsa, priv_key); +- OPENSSL_PKEY_GET_BN(dsa, pub_key); +- add_assoc_zval(return_value, "dsa", dsa); +- } ++ { ++ DSA *dsa = EVP_PKEY_get0_DSA(pkey); ++ ktype = OPENSSL_KEYTYPE_DSA; ++ ++ if (dsa != NULL) { ++ zval *z_dsa; ++ const BIGNUM *p, *q, *g, *priv_key, *pub_key; ++ ++ DSA_get0_pqg(dsa, &p, &q, &g); ++ DSA_get0_key(dsa, &pub_key, &priv_key); ++ ++ ALLOC_INIT_ZVAL(z_dsa); ++ array_init(z_dsa); ++ OPENSSL_PKEY_GET_BN(z_dsa, p); ++ OPENSSL_PKEY_GET_BN(z_dsa, q); ++ OPENSSL_PKEY_GET_BN(z_dsa, g); ++ OPENSSL_PKEY_GET_BN(z_dsa, priv_key); ++ OPENSSL_PKEY_GET_BN(z_dsa, pub_key); ++ add_assoc_zval(return_value, "dsa", z_dsa); ++ } ++ } + break; + case EVP_PKEY_DH: +- +- ktype = OPENSSL_KEYTYPE_DH; +- +- if (pkey->pkey.dh != NULL) { +- zval *dh; +- +- ALLOC_INIT_ZVAL(dh); +- array_init(dh); +- OPENSSL_PKEY_GET_BN(dh, p); +- OPENSSL_PKEY_GET_BN(dh, g); +- OPENSSL_PKEY_GET_BN(dh, priv_key); +- OPENSSL_PKEY_GET_BN(dh, pub_key); +- add_assoc_zval(return_value, "dh", dh); +- } +- ++ { ++ DH *dh = EVP_PKEY_get0_DH(pkey); ++ ktype = OPENSSL_KEYTYPE_DH; ++ ++ if (dh != NULL) { ++ zval *z_dh; ++ const BIGNUM *p, *q, *g, *priv_key, *pub_key; ++ ++ DH_get0_pqg(dh, &p, &q, &g); ++ DH_get0_key(dh, &pub_key, &priv_key); ++ ++ ALLOC_INIT_ZVAL(z_dh); ++ array_init(z_dh); ++ OPENSSL_PKEY_GET_BN(z_dh, p); ++ OPENSSL_PKEY_GET_BN(z_dh, g); ++ OPENSSL_PKEY_GET_BN(z_dh, priv_key); ++ OPENSSL_PKEY_GET_BN(z_dh, pub_key); ++ add_assoc_zval(return_value, "dh", z_dh); ++ } ++ } + break; + #ifdef HAVE_EVP_PKEY_EC + case EVP_PKEY_EC: + ktype = OPENSSL_KEYTYPE_EC; +- if (pkey->pkey.ec != NULL) { ++ if (EVP_PKEY_get0_EC_KEY(pkey) != NULL) { + zval *ec; + const EC_GROUP *ec_group; + int nid; +@@ -4546,13 +4691,13 @@ PHP_FUNCTION(openssl_private_encrypt) + cryptedlen = EVP_PKEY_size(pkey); + cryptedbuf = emalloc(cryptedlen + 1); + +- switch (pkey->type) { ++ switch (EVP_PKEY_id(pkey)) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: + successful = (RSA_private_encrypt(data_len, + (unsigned char *)data, + cryptedbuf, +- pkey->pkey.rsa, ++ EVP_PKEY_get0_RSA(pkey), + padding) == cryptedlen); + break; + default: +@@ -4604,13 +4749,13 @@ PHP_FUNCTION(openssl_private_decrypt) + cryptedlen = EVP_PKEY_size(pkey); + crypttemp = emalloc(cryptedlen + 1); + +- switch (pkey->type) { ++ switch (EVP_PKEY_id(pkey)) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: + cryptedlen = RSA_private_decrypt(data_len, + (unsigned char *)data, + crypttemp, +- pkey->pkey.rsa, ++ EVP_PKEY_get0_RSA(pkey), + padding); + if (cryptedlen != -1) { + cryptedbuf = emalloc(cryptedlen + 1); +@@ -4669,13 +4814,13 @@ PHP_FUNCTION(openssl_public_encrypt) + cryptedlen = EVP_PKEY_size(pkey); + cryptedbuf = emalloc(cryptedlen + 1); + +- switch (pkey->type) { ++ switch (EVP_PKEY_id(pkey)) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: + successful = (RSA_public_encrypt(data_len, + (unsigned char *)data, + cryptedbuf, +- pkey->pkey.rsa, ++ EVP_PKEY_get0_RSA(pkey), + padding) == cryptedlen); + break; + default: +@@ -4728,13 +4873,13 @@ PHP_FUNCTION(openssl_public_decrypt) + cryptedlen = EVP_PKEY_size(pkey); + crypttemp = emalloc(cryptedlen + 1); + +- switch (pkey->type) { ++ switch (EVP_PKEY_id(pkey)) { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: + cryptedlen = RSA_public_decrypt(data_len, + (unsigned char *)data, + crypttemp, +- pkey->pkey.rsa, ++ EVP_PKEY_get0_RSA(pkey), + padding); + if (cryptedlen != -1) { + cryptedbuf = emalloc(cryptedlen + 1); +@@ -4798,7 +4943,7 @@ PHP_FUNCTION(openssl_sign) + long keyresource = -1; + char * data; + int data_len; +- EVP_MD_CTX md_ctx; ++ EVP_MD_CTX *md_ctx; + zval *method = NULL; + long signature_algo = OPENSSL_ALGO_SHA1; + const EVP_MD *mdtype; +@@ -4831,9 +4976,11 @@ PHP_FUNCTION(openssl_sign) + siglen = EVP_PKEY_size(pkey); + sigbuf = emalloc(siglen + 1); + +- EVP_SignInit(&md_ctx, mdtype); +- EVP_SignUpdate(&md_ctx, data, data_len); +- if (EVP_SignFinal (&md_ctx, sigbuf,(unsigned int *)&siglen, pkey)) { ++ md_ctx = EVP_MD_CTX_create(); ++ if (md_ctx != NULL && ++ EVP_SignInit(md_ctx, mdtype) && ++ EVP_SignUpdate(md_ctx, data, data_len) && ++ EVP_SignFinal(md_ctx, sigbuf,(unsigned int *)&siglen, pkey)) { + zval_dtor(signature); + sigbuf[siglen] = '\0'; + ZVAL_STRINGL(signature, (char *)sigbuf, siglen, 0); +@@ -4842,7 +4989,7 @@ PHP_FUNCTION(openssl_sign) + efree(sigbuf); + RETVAL_FALSE; + } +- EVP_MD_CTX_cleanup(&md_ctx); ++ EVP_MD_CTX_destroy(md_ctx); + if (keyresource == -1) { + EVP_PKEY_free(pkey); + } +@@ -4855,8 +5002,8 @@ PHP_FUNCTION(openssl_verify) + { + zval **key; + EVP_PKEY *pkey; +- int err; +- EVP_MD_CTX md_ctx; ++ int err = 0; ++ EVP_MD_CTX *md_ctx; + const EVP_MD *mdtype; + long keyresource = -1; + char * data; int data_len; +@@ -4890,10 +5037,13 @@ PHP_FUNCTION(openssl_verify) + RETURN_FALSE; + } + +- EVP_VerifyInit (&md_ctx, mdtype); +- EVP_VerifyUpdate (&md_ctx, data, data_len); +- err = EVP_VerifyFinal (&md_ctx, (unsigned char *)signature, signature_len, pkey); +- EVP_MD_CTX_cleanup(&md_ctx); ++ md_ctx = EVP_MD_CTX_create(); ++ if (md_ctx) { ++ EVP_VerifyInit (md_ctx, mdtype); ++ EVP_VerifyUpdate (md_ctx, data, data_len); ++ err = EVP_VerifyFinal(md_ctx, (unsigned char *)signature, signature_len, pkey); ++ } ++ EVP_MD_CTX_destroy(md_ctx); + + if (keyresource == -1) { + EVP_PKEY_free(pkey); +@@ -4917,7 +5067,7 @@ PHP_FUNCTION(openssl_seal) + char *method =NULL; + int method_len = 0; + const EVP_CIPHER *cipher; +- EVP_CIPHER_CTX ctx; ++ EVP_CIPHER_CTX *ctx; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szza/|s", &data, &data_len, &sealdata, &ekeys, &pubkeys, &method, &method_len) == FAILURE) { + return; +@@ -4967,9 +5117,10 @@ PHP_FUNCTION(openssl_seal) + i++; + } + +- if (!EVP_EncryptInit(&ctx,cipher,NULL,NULL)) { ++ ctx = EVP_CIPHER_CTX_new(); ++ if (ctx == NULL || !EVP_EncryptInit(ctx,cipher,NULL,NULL)) { + RETVAL_FALSE; +- EVP_CIPHER_CTX_cleanup(&ctx); ++ EVP_CIPHER_CTX_free(ctx); + goto clean_exit; + } + +@@ -4979,15 +5130,15 @@ PHP_FUNCTION(openssl_seal) + iv = ivlen ? emalloc(ivlen + 1) : NULL; + #endif + /* allocate one byte extra to make room for \0 */ +- buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(&ctx)); +- EVP_CIPHER_CTX_cleanup(&ctx); ++ buf = emalloc(data_len + EVP_CIPHER_CTX_block_size(ctx)); ++ EVP_CIPHER_CTX_cleanup(ctx); + +- if (EVP_SealInit(&ctx, cipher, eks, eksl, NULL, pkeys, nkeys) <= 0 || +- !EVP_SealUpdate(&ctx, buf, &len1, (unsigned char *)data, data_len) || +- !EVP_SealFinal(&ctx, buf + len1, &len2)) { ++ if (EVP_SealInit(ctx, cipher, eks, eksl, NULL, pkeys, nkeys) <= 0 || ++ !EVP_SealUpdate(ctx, buf, &len1, (unsigned char *)data, data_len) || ++ !EVP_SealFinal(ctx, buf + len1, &len2)) { + RETVAL_FALSE; + efree(buf); +- EVP_CIPHER_CTX_cleanup(&ctx); ++ EVP_CIPHER_CTX_free(ctx); + goto clean_exit; + } + +@@ -5018,7 +5169,7 @@ PHP_FUNCTION(openssl_seal) + efree(buf); + } + RETVAL_LONG(len1 + len2); +- EVP_CIPHER_CTX_cleanup(&ctx); ++ EVP_CIPHER_CTX_free(ctx); + + clean_exit: + for (i=0; i password_len) { + key = emalloc(keylen); +@@ -5262,19 +5424,19 @@ PHP_FUNCTION(openssl_encrypt) + outlen = data_len + EVP_CIPHER_block_size(cipher_type); + outbuf = safe_emalloc(outlen, 1, 1); + +- EVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL); ++ EVP_EncryptInit(cipher_ctx, cipher_type, NULL, NULL); + if (password_len > keylen) { +- EVP_CIPHER_CTX_set_key_length(&cipher_ctx, password_len); ++ EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len); + } +- EVP_EncryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv); ++ EVP_EncryptInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)iv); + if (options & OPENSSL_ZERO_PADDING) { +- EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); ++ EVP_CIPHER_CTX_set_padding(cipher_ctx, 0); + } + if (data_len > 0) { +- EVP_EncryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); ++ EVP_EncryptUpdate(cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); + } + outlen = i; +- if (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) { ++ if (EVP_EncryptFinal(cipher_ctx, (unsigned char *)outbuf + i, &i)) { + outlen += i; + if (options & OPENSSL_RAW_DATA) { + outbuf[outlen] = '\0'; +@@ -5301,7 +5463,7 @@ PHP_FUNCTION(openssl_encrypt) + if (free_iv) { + efree(iv); + } +- EVP_CIPHER_CTX_cleanup(&cipher_ctx); ++ EVP_CIPHER_CTX_free(cipher_ctx); + } + /* }}} */ + +@@ -5313,7 +5475,7 @@ PHP_FUNCTION(openssl_decrypt) + char *data, *method, *password, *iv = ""; + int data_len, method_len, password_len, iv_len = 0; + const EVP_CIPHER *cipher_type; +- EVP_CIPHER_CTX cipher_ctx; ++ EVP_CIPHER_CTX *cipher_ctx; + int i, outlen, keylen; + unsigned char *outbuf, *key; + int base64_str_len; +@@ -5335,10 +5497,17 @@ PHP_FUNCTION(openssl_decrypt) + RETURN_FALSE; + } + ++ cipher_ctx = EVP_CIPHER_CTX_new(); ++ if (!cipher_ctx) { ++ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to create cipher context"); ++ RETURN_FALSE; ++ } ++ + if (!(options & OPENSSL_RAW_DATA)) { + base64_str = (char*)php_base64_decode((unsigned char*)data, data_len, &base64_str_len); + if (!base64_str) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to base64 decode the input"); ++ EVP_CIPHER_CTX_free(cipher_ctx); + RETURN_FALSE; + } + data_len = base64_str_len; +@@ -5359,17 +5528,17 @@ PHP_FUNCTION(openssl_decrypt) + outlen = data_len + EVP_CIPHER_block_size(cipher_type); + outbuf = emalloc(outlen + 1); + +- EVP_DecryptInit(&cipher_ctx, cipher_type, NULL, NULL); ++ EVP_DecryptInit(cipher_ctx, cipher_type, NULL, NULL); + if (password_len > keylen) { +- EVP_CIPHER_CTX_set_key_length(&cipher_ctx, password_len); ++ EVP_CIPHER_CTX_set_key_length(cipher_ctx, password_len); + } +- EVP_DecryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv); ++ EVP_DecryptInit_ex(cipher_ctx, NULL, NULL, key, (unsigned char *)iv); + if (options & OPENSSL_ZERO_PADDING) { +- EVP_CIPHER_CTX_set_padding(&cipher_ctx, 0); ++ EVP_CIPHER_CTX_set_padding(cipher_ctx, 0); + } +- EVP_DecryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); ++ EVP_DecryptUpdate(cipher_ctx, outbuf, &i, (unsigned char *)data, data_len); + outlen = i; +- if (EVP_DecryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) { ++ if (EVP_DecryptFinal(cipher_ctx, (unsigned char *)outbuf + i, &i)) { + outlen += i; + outbuf[outlen] = '\0'; + RETVAL_STRINGL((char *)outbuf, outlen, 0); +@@ -5386,7 +5555,7 @@ PHP_FUNCTION(openssl_decrypt) + if (base64_str) { + efree(base64_str); + } +- EVP_CIPHER_CTX_cleanup(&cipher_ctx); ++ EVP_CIPHER_CTX_free(cipher_ctx); + } + /* }}} */ + +@@ -5424,6 +5593,7 @@ PHP_FUNCTION(openssl_dh_compute_key) + zval *key; + char *pub_str; + int pub_len; ++ DH *dh; + EVP_PKEY *pkey; + BIGNUM *pub; + char *data; +@@ -5433,14 +5603,20 @@ PHP_FUNCTION(openssl_dh_compute_key) + return; + } + ZEND_FETCH_RESOURCE(pkey, EVP_PKEY *, &key, -1, "OpenSSL key", le_key); +- if (!pkey || EVP_PKEY_type(pkey->type) != EVP_PKEY_DH || !pkey->pkey.dh) { ++ if (!pkey) { + RETURN_FALSE; + } +- ++ if (EVP_PKEY_base_id(pkey) != EVP_PKEY_DH) { ++ RETURN_FALSE; ++ } ++ dh = EVP_PKEY_get0_DH(pkey); ++ if (dh == NULL) { ++ RETURN_FALSE; ++ } + pub = BN_bin2bn((unsigned char*)pub_str, pub_len, NULL); + +- data = emalloc(DH_size(pkey->pkey.dh) + 1); +- len = DH_compute_key((unsigned char*)data, pub, pkey->pkey.dh); ++ data = emalloc(DH_size(dh) + 1); ++ len = DH_compute_key((unsigned char*)data, pub, dh); + + if (len >= 0) { + data[len] = 0; +diff --git a/ext/openssl/tests/001.phpt b/ext/openssl/tests/001.phpt +index 4ca9970..2d0aa90 100644 +--- a/ext/openssl/tests/001.phpt ++++ b/ext/openssl/tests/001.phpt +@@ -18,19 +18,20 @@ for ($z = "", $i = 0; $i < 1024; $i++) { + usleep($i); + } + +-$privkey = openssl_pkey_new(); ++$conf = array('config' => dirname(__FILE__) . DIRECTORY_SEPARATOR . 'openssl.cnf'); ++$privkey = openssl_pkey_new($conf); + + if ($privkey === false) + die("failed to create private key"); + + $passphrase = "banana"; +-$key_file_name = tempnam("/tmp", "ssl"); ++$key_file_name = tempnam(sys_get_temp_dir(), "ssl"); + if ($key_file_name === false) + die("failed to get a temporary filename!"); + + echo "Export key to file\n"; + +-openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase) or die("failed to export to file $key_file_name"); ++openssl_pkey_export_to_file($privkey, $key_file_name, $passphrase, $conf) or die("failed to export to file $key_file_name"); + + echo "Load key from file - array syntax\n"; + +diff --git a/ext/openssl/tests/bug41033.phpt b/ext/openssl/tests/bug41033.phpt +index 4aeae66..4e9bea3 100644 +--- a/ext/openssl/tests/bug41033.phpt ++++ b/ext/openssl/tests/bug41033.phpt +@@ -13,11 +13,11 @@ $pub = 'file://' . dirname(__FILE__) . '/' . 'bug41033pub.pem'; + + $prkeyid = openssl_get_privatekey($prv, "1234"); + $ct = "Hello I am some text!"; +-openssl_sign($ct, $signature, $prkeyid, OPENSSL_ALGO_DSS1); ++openssl_sign($ct, $signature, $prkeyid, OPENSSL_ALGO_SHA1); + echo "Signature: ".base64_encode($signature) . "\n"; + + $pukeyid = openssl_get_publickey($pub); +-$valid = openssl_verify($ct, $signature, $pukeyid, OPENSSL_ALGO_DSS1); ++$valid = openssl_verify($ct, $signature, $pukeyid, OPENSSL_ALGO_SHA1); + echo "Signature validity: " . $valid . "\n"; + + +diff --git a/ext/openssl/tests/bug66501.phpt b/ext/openssl/tests/bug66501.phpt +index 7ad5e21..99ac4f5 100644 +--- a/ext/openssl/tests/bug66501.phpt ++++ b/ext/openssl/tests/bug66501.phpt +@@ -16,7 +16,7 @@ AwEHoUQDQgAEPq4hbIWHvB51rdWr8ejrjWo4qVNWVugYFtPg/xLQw0mHkIPZ4DvK + sqOTOnMoezkbSmVVMuwz9flvnqHGmQvmug== + -----END EC PRIVATE KEY-----'; + $key = openssl_pkey_get_private($pkey); +-$res = openssl_sign($data ='alpha', $sign, $key, 'ecdsa-with-SHA1'); ++$res = openssl_sign($data ='alpha', $sign, $key, 'SHA1'); + var_dump($res); + --EXPECTF-- + bool(true) +diff --git a/ext/openssl/tests/openssl_error_string_basic.phpt b/ext/openssl/tests/openssl_error_string_basic.phpt +index 82f3099..04cc550 100644 +--- a/ext/openssl/tests/openssl_error_string_basic.phpt ++++ b/ext/openssl/tests/openssl_error_string_basic.phpt +@@ -89,7 +89,7 @@ expect_openssl_errors('openssl_pkey_export_to_file opening', ['02001002', '2006D + expect_openssl_errors('openssl_pkey_export_to_file pem', ['0906D06C']); + // file to export cannot be written + @openssl_pkey_export_to_file($private_key_file, $invalid_file_for_write); +-expect_openssl_errors('openssl_pkey_export_to_file write', ['2006D002', '09072007']); ++expect_openssl_errors('openssl_pkey_export_to_file write', ['2006D002']); + // succesful export + @openssl_pkey_export($private_key_file_with_pass, $out, 'wrong pwd'); + expect_openssl_errors('openssl_pkey_export', ['06065064', '0906A065']); +@@ -105,7 +105,7 @@ expect_openssl_errors('openssl_private_decrypt', ['04065072']); + // public encrypt and decrypt with failed padding check and padding + @openssl_public_encrypt("data", $crypted, $public_key_file, 1000); + @openssl_public_decrypt("data", $crypted, $public_key_file); +-expect_openssl_errors('openssl_private_(en|de)crypt padding', ['0906D06C', '04068076', '0407006A', '04067072']); ++expect_openssl_errors('openssl_private_(en|de)crypt padding', ['0906D06C', '04068076', '04067072']); + + // X509 + echo "X509 errors\n"; +@@ -126,7 +126,7 @@ expect_openssl_errors('openssl_x509_checkpurpose purpose', ['0B086079']); + echo "CSR errors\n"; + // file for csr (file:///) fails when opennig (BIO_new_file) + @openssl_csr_get_subject("file://" . $invalid_file_for_read); +-expect_openssl_errors('openssl_csr_get_subject open', ['02001002', '2006D080', '20068079', '0906D06C']); ++expect_openssl_errors('openssl_csr_get_subject open', ['02001002', '2006D080']); + // file or str csr is not correct PEM - failing PEM_read_bio_X509_REQ + @openssl_csr_get_subject($crt_file); + expect_openssl_errors('openssl_csr_get_subjec pem', ['0906D06C']); +diff --git a/ext/openssl/tests/sni_server.phpt b/ext/openssl/tests/sni_server.phpt +index d44a69f..2d045df 100644 +--- a/ext/openssl/tests/sni_server.phpt ++++ b/ext/openssl/tests/sni_server.phpt +@@ -3,6 +3,8 @@ sni_server + --SKIPIF-- + enable_on_connect = 1; + sslsock->method = get_crypto_method(context, STREAM_CRYPTO_METHOD_ANY_CLIENT); + } else if (strncmp(proto, "sslv2", protolen) == 0) { +-#ifdef OPENSSL_NO_SSL2 + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv2 support is not compiled into the OpenSSL library PHP is linked against"); + return NULL; +-#else +- sslsock->enable_on_connect = 1; +- sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT; +-#endif + } else if (strncmp(proto, "sslv3", protolen) == 0) { + #ifdef OPENSSL_NO_SSL3 + php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSLv3 support is not compiled into the OpenSSL library PHP is linked against"); +diff --git a/ext/phar/util.c b/ext/phar/util.c +index 828be8f..06e4e55 100644 +--- a/ext/phar/util.c ++++ b/ext/phar/util.c +@@ -1531,7 +1531,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ + BIO *in; + EVP_PKEY *key; + EVP_MD *mdtype = (EVP_MD *) EVP_sha1(); +- EVP_MD_CTX md_ctx; ++ EVP_MD_CTX *md_ctx; + #else + int tempsig; + #endif +@@ -1608,7 +1608,8 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ + return FAILURE; + } + +- EVP_VerifyInit(&md_ctx, mdtype); ++ md_ctx = EVP_MD_CTX_create(); ++ EVP_VerifyInit(md_ctx, mdtype); + read_len = end_of_phar; + + if (read_len > sizeof(buf)) { +@@ -1620,7 +1621,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ + php_stream_seek(fp, 0, SEEK_SET); + + while (read_size && (len = php_stream_read(fp, (char*)buf, read_size)) > 0) { +- EVP_VerifyUpdate (&md_ctx, buf, len); ++ EVP_VerifyUpdate (md_ctx, buf, len); + read_len -= (off_t)len; + + if (read_len < read_size) { +@@ -1628,9 +1629,9 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ + } + } + +- if (EVP_VerifyFinal(&md_ctx, (unsigned char *)sig, sig_len, key) != 1) { ++ if (EVP_VerifyFinal(md_ctx, (unsigned char *)sig, sig_len, key) != 1) { + /* 1: signature verified, 0: signature does not match, -1: failed signature operation */ +- EVP_MD_CTX_cleanup(&md_ctx); ++ EVP_MD_CTX_destroy(md_ctx); + + if (error) { + spprintf(error, 0, "broken openssl signature"); +@@ -1639,7 +1640,7 @@ int phar_verify_signature(php_stream *fp, size_t end_of_phar, php_uint32 sig_typ + return FAILURE; + } + +- EVP_MD_CTX_cleanup(&md_ctx); ++ EVP_MD_CTX_destroy(md_ctx); + #endif + + *signature_len = phar_hex_str((const char*)sig, sig_len, signature TSRMLS_CC); +-- +2.9.4 + diff --git a/dev-lang/php/files/php-5.6.37-icu62.patch b/dev-lang/php/files/php-5.6.37-icu62.patch new file mode 100644 index 0000000..dd145bc --- /dev/null +++ b/dev-lang/php/files/php-5.6.37-icu62.patch @@ -0,0 +1,589 @@ +Backported from 7.1 for 5.6 by Remi + + +From 710284cbc4a54cac0a9ec4ea29a7486e0d99a33b Mon Sep 17 00:00:00 2001 +From: Anatol Belski +Date: Wed, 28 Mar 2018 18:00:28 +0200 +Subject: [PATCH] Fixed bug #76153 Intl compilation fails with icu4c 61.1 + +Additionally, ICU >= 59.1 requires C++11, so add the flags. Some +refactoring is needed to comply with the latest recommended build +options, such as automatic icu namespace addition. +--- + acinclude.m4 | 3 +++ + ext/intl/config.m4 | 2 +- + ext/intl/config.w32 | 2 +- + 3 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/acinclude.m4 b/acinclude.m4 +index 0e6fb5de855c..3881b2da93d6 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -2244,6 +2244,9 @@ AC_DEFUN([PHP_SETUP_ICU],[ + ICU_LIBS=`$ICU_CONFIG --ldflags --ldflags-icuio` + PHP_EVAL_INCLINE($ICU_INCS) + PHP_EVAL_LIBLINE($ICU_LIBS, $1) ++ ++ ICU_EXTRA_FLAGS=`$ICU_CONFIG --cxxflags` ++ ICU_EXTRA_FLAGS="$ICU_EXTRA_FLAGS -DU_USING_ICU_NAMESPACE=1" + fi + ]) + +diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 +index ca2cd822f483..a496d8d70c3f 100644 +--- a/ext/intl/config.m4 ++++ b/ext/intl/config.m4 +@@ -85,7 +85,7 @@ if test "$PHP_INTL" != "no"; then + breakiterator/codepointiterator_internal.cpp \ + breakiterator/codepointiterator_methods.cpp \ + idn/idn.c \ +- $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings) ++ $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings $ICU_EXTRA_FLAGS,cxx) + PHP_ADD_BUILD_DIR($ext_builddir/collator) + PHP_ADD_BUILD_DIR($ext_builddir/converter) + PHP_ADD_BUILD_DIR($ext_builddir/common) +From 398f56dbc85464c95671cbe491c951eccc1f665a Mon Sep 17 00:00:00 2001 +From: Anatol Belski +Date: Thu, 29 Mar 2018 14:12:19 +0200 +Subject: [PATCH] Adjust tests for ICU 61.1 compatibility + +--- + ext/intl/tests/formatter_format6.phpt | 3 +- + ext/intl/tests/formatter_format7.phpt | 130 ++++++++++++++++++ + .../tests/rbbiter_getBinaryRules_basic.phpt | 3 +- + .../tests/rbbiter_getBinaryRules_basic2.phpt | 57 ++++++++ + .../tests/rbbiter_getRuleStatusVec_basic.phpt | 4 +- + ext/intl/tests/rbbiter_getRules_basic.phpt | 7 +- + ext/intl/tests/rbbiter_getRules_basic2.phpt | 40 ++++++ + 7 files changed, 236 insertions(+), 8 deletions(-) + create mode 100644 ext/intl/tests/formatter_format7.phpt + create mode 100644 ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt + create mode 100644 ext/intl/tests/rbbiter_getRules_basic2.phpt + +diff --git a/ext/intl/tests/formatter_format6.phpt b/ext/intl/tests/formatter_format6.phpt +index 80894c332ba4..70703785c140 100644 +--- a/ext/intl/tests/formatter_format6.phpt ++++ b/ext/intl/tests/formatter_format6.phpt +@@ -1,7 +1,8 @@ + --TEST-- +-numfmt_format() icu >= 56.1 ++numfmt_format() icu >= 56.1 && icu < 61.1 + --SKIPIF-- + ++= 0) die('skip for ICU < 61.1'); ?> + = 56.1'); ?> + --FILE-- + = 61.1 ++--SKIPIF-- ++ ++= 61.1'); ?> ++--FILE-- ++ '##.#####################', ++ NumberFormatter::DECIMAL => '', ++ NumberFormatter::CURRENCY => '', ++ NumberFormatter::PERCENT => '', ++ NumberFormatter::SCIENTIFIC => '', ++ NumberFormatter::SPELLOUT => '@@@@@@@', ++ NumberFormatter::ORDINAL => '', ++ NumberFormatter::DURATION => '', ++ NumberFormatter::PATTERN_RULEBASED => '#####.###', ++ 1234999, // bad one ++ ); ++ ++ $integer = array( ++ NumberFormatter::ORDINAL => '', ++ NumberFormatter::DURATION => '', ++ ); ++ $locales = array( ++ 'en_US', ++ 'ru_UA', ++ 'de', ++ 'fr', ++ 'en_UK' ++ ); ++ ++ $str_res = ''; ++ $number = 1234567.891234567890000; ++ ++ foreach( $locales as $locale ) ++ { ++ $str_res .= "\nLocale is: $locale\n"; ++ foreach( $styles as $style => $pattern ) ++ { ++ $fmt = ut_nfmt_create( $locale, $style, $pattern ); ++ ++ if(!$fmt) { ++ $str_res .= "Bad formatter!\n"; ++ continue; ++ } ++ $str_res .= dump( isset($integer[$style])?ut_nfmt_format( $fmt, $number, NumberFormatter::TYPE_INT32):ut_nfmt_format( $fmt, $number ) ) . "\n"; ++ } ++ } ++ return $str_res; ++} ++ ++include_once( 'ut_common.inc' ); ++ ++// Run the test ++ut_run(); ++ ++?> ++--EXPECTREGEX-- ++Locale is: en_US ++'1234567.8912345\d+' ++'1,234,567.891' ++'\$1,234,567.89' ++'123,456,789%' ++'1.2345678912345\d+E6' ++'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five( six)? seven( nine)?' ++'1,234,567(th|ᵗʰ)' ++'342:56:07' ++'#####.###' ++'USD1,234,567.89' ++ ++Locale is: ru_UA ++'1234567.8912345\d+' ++'1 234 567,891' ++'1 234 567,89 ?(грн\.|₴)' ++'123 456 789 ?%' ++'1.2345678912345\d+E6' ++'один миллион двести тридцать четыре тысячи пятьсот шестьдесят семь целых восемьдесят девять миллионов сто двадцать три тысячи четыреста пятьдесят семь стомиллионных' ++'1 234 567.?' ++'1 234 567' ++'#####.###' ++'1 234 567,89 UAH' ++ ++Locale is: de ++'1234567.8912345\d+' ++'1.234.567,891' ++'(¤ )?1.234.567,89( ¤)?' ++'123\.456\.789 %' ++'1.2345678912345\d+E6' ++'eine Million zwei­hundert­vier­und­dreißig­tausend­fünf­hundert­sieben­und­sechzig Komma acht neun eins zwei drei vier fünf( sechs)? sieben( neun)?' ++'1.234.567.?' ++'1.234.567' ++'#####.###' ++'1.234.567,89 ¤¤' ++ ++Locale is: fr ++'1234567.8912345\d+' ++'1 234 567,891' ++'1 234 567,89 ¤' ++'123 456 789 ?%' ++'1.2345678912345\d+E6' ++'un million deux cent trente-quatre mille cinq cent soixante-sept virgule huit neuf un deux trois quatre cinq( six)? sept( neuf)?' ++'1 234 567e' ++'1 234 567' ++'#####.###' ++'1 234 567,89 ¤¤' ++ ++Locale is: en_UK ++'1234567.8912345\d+' ++'1,234,567.891' ++'¤1,234,567.89' ++'123,456,789%' ++'1.2345678912345\d+E6' ++'one million,? two hundred (and )?thirty-four thousand,? five hundred (and )?sixty-seven point eight nine one two three four five( six)? seven( nine)?' ++'1,234,567(th|ᵗʰ)' ++'342:56:07' ++'#####.###' ++'¤¤1,234,567.89' +diff --git a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt +index dce0714d4dd4..95ea31108804 100644 +--- a/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt ++++ b/ext/intl/tests/rbbiter_getBinaryRules_basic.phpt +@@ -2,6 +2,7 @@ + IntlRuleBasedBreakIterator::getBinaryRules(): basic test + --SKIPIF-- + ++= 0) die('skip for ICU < 61.1'); ?> + = 4.8 only'; ?> + --FILE-- + setText('sdfkjsdf88á.... ,;');; ++$rbbi->setText('sdfkjsdf88á.... ,;'); + + $br = $rbbi->getBinaryRules(); + +diff --git a/ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt b/ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt +new file mode 100644 +index 000000000000..f3b6c6cb34c0 +--- /dev/null ++++ b/ext/intl/tests/rbbiter_getBinaryRules_basic2.phpt +@@ -0,0 +1,57 @@ ++--TEST-- ++IntlRuleBasedBreakIterator::getBinaryRules(): basic test ++--SKIPIF-- ++ ++= 61.1 only'; ?> ++--FILE-- ++setText('sdfkjsdf88á.... ,;'); ++ ++$br = $rbbi->getBinaryRules(); ++ ++$rbbi2 = new IntlRuleBasedBreakIterator($br, true); ++ ++var_dump($rbbi->getRules(), $rbbi2->getRules()); ++var_dump($rbbi->getRules() == $rbbi2->getRules()); ++?> ++==DONE== ++--EXPECT-- ++string(137) "$LN = [[:letter:] [:number:]]; ++$S = [.;,:]; ++!!forward; ++$LN+ {1}; ++$S+ {42}; ++!!reverse; ++$LN+ {1}; ++$S+ {42}; ++!!safe_forward; ++!!safe_reverse;" ++string(137) "$LN = [[:letter:] [:number:]]; ++$S = [.;,:]; ++!!forward; ++$LN+ {1}; ++$S+ {42}; ++!!reverse; ++$LN+ {1}; ++$S+ {42}; ++!!safe_forward; ++!!safe_reverse;" ++bool(true) ++==DONE== +diff --git a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt +index a56f6bc48867..4a654508cc13 100644 +--- a/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt ++++ b/ext/intl/tests/rbbiter_getRuleStatusVec_basic.phpt +@@ -25,7 +25,7 @@ $rules = <<setText('sdfkjsdf88á.... ,;');; ++$rbbi->setText('sdfkjsdf88á.... ,;'); + + do { + var_dump($rbbi->current(), $rbbi->getRuleStatusVec()); +@@ -56,4 +56,4 @@ array(1) { + [0]=> + int(4) + } +-==DONE== +\ No newline at end of file ++==DONE== +diff --git a/ext/intl/tests/rbbiter_getRules_basic.phpt b/ext/intl/tests/rbbiter_getRules_basic.phpt +index 2f7a40eb716b..3ad1a9231151 100644 +--- a/ext/intl/tests/rbbiter_getRules_basic.phpt ++++ b/ext/intl/tests/rbbiter_getRules_basic.phpt +@@ -1,9 +1,8 @@ + --TEST-- + IntlRuleBasedBreakIterator::getRules(): basic test + --SKIPIF-- +- ++= 0) die('skip for ICU < 61.1'); ?> + --FILE-- + getRules()); + ==DONE== + --EXPECT-- + string(128) "$LN = [[:letter:] [:number:]];$S = [.;,:];!!forward;$LN+ {1};$S+ {42};!!reverse;$LN+ {1};$S+ {42};!!safe_forward;!!safe_reverse;" +-==DONE== +\ No newline at end of file ++==DONE== +diff --git a/ext/intl/tests/rbbiter_getRules_basic2.phpt b/ext/intl/tests/rbbiter_getRules_basic2.phpt +new file mode 100644 +index 000000000000..67b3831aa2f3 +--- /dev/null ++++ b/ext/intl/tests/rbbiter_getRules_basic2.phpt +@@ -0,0 +1,40 @@ ++--TEST-- ++IntlRuleBasedBreakIterator::getRules(): basic test ++--SKIPIF-- ++ ++= 61.1'); ?> ++--FILE-- ++getRules()); ++ ++?> ++==DONE== ++--EXPECT-- ++string(137) "$LN = [[:letter:] [:number:]]; ++$S = [.;,:]; ++!!forward; ++$LN+ {1}; ++$S+ {42}; ++!!reverse; ++$LN+ {1}; ++$S+ {42}; ++!!safe_forward; ++!!safe_reverse;" ++==DONE== +From 8b104d789317d96f6d3e23e635f0ca288c0a23ee Mon Sep 17 00:00:00 2001 +From: Anatol Belski +Date: Fri, 30 Mar 2018 14:14:35 +0200 +Subject: [PATCH] Fix clang build, ref buf #76153 + +Clang only allows -std=c++11 for C++ source. +--- + ext/intl/config.m4 | 27 +++++++++++++++------------ + 1 file changed, 15 insertions(+), 12 deletions(-) + +diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 +index a496d8d70c3f..aea57102f6b8 100644 +--- a/ext/intl/config.m4 ++++ b/ext/intl/config.m4 +@@ -20,7 +20,6 @@ if test "$PHP_INTL" != "no"; then + PHP_NEW_EXTENSION(intl, php_intl.c \ + intl_error.c \ + intl_convert.c \ +- intl_convertcpp.cpp \ + collator/collator.c \ + collator/collator_class.c \ + collator/collator_sort.c \ +@@ -32,8 +31,6 @@ if test "$PHP_INTL" != "no"; then + collator/collator_is_numeric.c \ + collator/collator_error.c \ + common/common_error.c \ +- common/common_enum.cpp \ +- common/common_date.cpp \ + converter/converter.c \ + formatter/formatter.c \ + formatter/formatter_main.c \ +@@ -53,17 +50,12 @@ if test "$PHP_INTL" != "no"; then + dateformat/dateformat_attr.c \ + dateformat/dateformat_data.c \ + dateformat/dateformat_format.c \ +- dateformat/dateformat_format_object.cpp \ + dateformat/dateformat_parse.c \ +- dateformat/dateformat_create.cpp \ +- dateformat/dateformat_attrcpp.cpp \ +- dateformat/dateformat_helpers.cpp \ + msgformat/msgformat.c \ + msgformat/msgformat_attr.c \ + msgformat/msgformat_class.c \ + msgformat/msgformat_data.c \ + msgformat/msgformat_format.c \ +- msgformat/msgformat_helpers.cpp \ + msgformat/msgformat_parse.c \ + grapheme/grapheme_string.c \ + grapheme/grapheme_util.c \ +@@ -73,6 +65,17 @@ if test "$PHP_INTL" != "no"; then + transliterator/transliterator.c \ + transliterator/transliterator_class.c \ + transliterator/transliterator_methods.c \ ++ idn/idn.c \ ++ $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings,cxx) ++ ++ PHP_ADD_SOURCES(PHP_EXT_DIR(intl), intl_convertcpp.cpp \ ++ common/common_enum.cpp \ ++ common/common_date.cpp \ ++ dateformat/dateformat_format_object.cpp \ ++ dateformat/dateformat_create.cpp \ ++ dateformat/dateformat_attrcpp.cpp \ ++ dateformat/dateformat_helpers.cpp \ ++ msgformat/msgformat_helpers.cpp \ + timezone/timezone_class.cpp \ + timezone/timezone_methods.cpp \ + calendar/calendar_class.cpp \ +@@ -83,9 +87,9 @@ if test "$PHP_INTL" != "no"; then + breakiterator/breakiterator_methods.cpp \ + breakiterator/rulebasedbreakiterator_methods.cpp \ + breakiterator/codepointiterator_internal.cpp \ +- breakiterator/codepointiterator_methods.cpp \ +- idn/idn.c \ +- $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings $ICU_EXTRA_FLAGS,cxx) ++ breakiterator/codepointiterator_methods.cpp, \ ++ $ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS $ICU_EXTRA_FLAGS) ++ + PHP_ADD_BUILD_DIR($ext_builddir/collator) + PHP_ADD_BUILD_DIR($ext_builddir/converter) + PHP_ADD_BUILD_DIR($ext_builddir/common) +From 2bd299f7318492fd7e5cafffa562d76ba60e69d4 Mon Sep 17 00:00:00 2001 +From: Anatol Belski +Date: Tue, 3 Apr 2018 10:42:14 +0200 +Subject: [PATCH] Fix shared ext/intl compilation + +--- + ext/intl/config.m4 | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 +index aea57102f6b8..959ecd2b26a9 100644 +--- a/ext/intl/config.m4 ++++ b/ext/intl/config.m4 +@@ -68,7 +68,7 @@ if test "$PHP_INTL" != "no"; then + idn/idn.c \ + $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings,cxx) + +- PHP_ADD_SOURCES(PHP_EXT_DIR(intl), intl_convertcpp.cpp \ ++ PHP_INTL_CPP_SOURCES="intl_convertcpp.cpp \ + common/common_enum.cpp \ + common/common_date.cpp \ + dateformat/dateformat_format_object.cpp \ +@@ -86,8 +86,13 @@ if test "$PHP_INTL" != "no"; then + breakiterator/breakiterator_methods.cpp \ + breakiterator/rulebasedbreakiterator_methods.cpp \ + breakiterator/codepointiterator_internal.cpp \ +- breakiterator/codepointiterator_methods.cpp, \ +- $ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS $ICU_EXTRA_FLAGS) ++ breakiterator/codepointiterator_methods.cpp" ++ PHP_INTL_CPP_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS $ICU_EXTRA_FLAGS" ++ if test "$ext_shared" = "no"; then ++ PHP_ADD_SOURCES(PHP_EXT_DIR(intl), $PHP_INTL_CPP_SOURCES, $PHP_INTL_CPP_FLAGS) ++ else ++ PHP_ADD_SOURCES_X(PHP_EXT_DIR(intl), $PHP_INTL_CPP_SOURCES, $PHP_INTL_CPP_FLAGS, shared_objects_intl, yes) ++ fi + + PHP_ADD_BUILD_DIR($ext_builddir/collator) + PHP_ADD_BUILD_DIR($ext_builddir/converter) +From ed5aabe8b78d8487ffc6091e0670753d59bb7f5a Mon Sep 17 00:00:00 2001 +From: Anatol Belski +Date: Thu, 5 Apr 2018 14:52:40 +0200 +Subject: [PATCH] Rename var + +--- + acinclude.m4 | 4 ++-- + ext/intl/config.m4 | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/acinclude.m4 b/acinclude.m4 +index 3881b2da93d6..c63edd309e9f 100644 +--- a/acinclude.m4 ++++ b/acinclude.m4 +@@ -2245,8 +2245,8 @@ AC_DEFUN([PHP_SETUP_ICU],[ + PHP_EVAL_INCLINE($ICU_INCS) + PHP_EVAL_LIBLINE($ICU_LIBS, $1) + +- ICU_EXTRA_FLAGS=`$ICU_CONFIG --cxxflags` +- ICU_EXTRA_FLAGS="$ICU_EXTRA_FLAGS -DU_USING_ICU_NAMESPACE=1" ++ ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags` ++ ICU_CXXFLAGS="$ICU_CXXFLAGS -DU_USING_ICU_NAMESPACE=1" + fi + ]) + +diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 +index 959ecd2b26a9..e8428e1cbbe8 100644 +--- a/ext/intl/config.m4 ++++ b/ext/intl/config.m4 +@@ -87,7 +87,7 @@ if test "$PHP_INTL" != "no"; then + breakiterator/rulebasedbreakiterator_methods.cpp \ + breakiterator/codepointiterator_internal.cpp \ + breakiterator/codepointiterator_methods.cpp" +- PHP_INTL_CPP_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS $ICU_EXTRA_FLAGS" ++ PHP_INTL_CPP_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS $ICU_CXXFLAGS" + if test "$ext_shared" = "no"; then + PHP_ADD_SOURCES(PHP_EXT_DIR(intl), $PHP_INTL_CPP_SOURCES, $PHP_INTL_CPP_FLAGS) + else +From 09d7ffabcd99fe9b99c4206f321fecc506635072 Mon Sep 17 00:00:00 2001 +From: Anatol Belski +Date: Thu, 5 Apr 2018 16:44:12 +0200 +Subject: [PATCH] Group common flags + +--- + ext/intl/config.m4 | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/ext/intl/config.m4 b/ext/intl/config.m4 +index e8428e1cbbe8..52408f8e9183 100644 +--- a/ext/intl/config.m4 ++++ b/ext/intl/config.m4 +@@ -9,6 +9,7 @@ if test "$PHP_INTL" != "no"; then + PHP_SETUP_ICU(INTL_SHARED_LIBADD) + PHP_SUBST(INTL_SHARED_LIBADD) + PHP_REQUIRE_CXX() ++ INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS" + if test "$icu_version" -ge "4002"; then + icu_spoof_src=" spoofchecker/spoofchecker_class.c \ + spoofchecker/spoofchecker.c\ +@@ -66,9 +67,9 @@ if test "$PHP_INTL" != "no"; then + transliterator/transliterator_class.c \ + transliterator/transliterator_methods.c \ + idn/idn.c \ +- $icu_spoof_src, $ext_shared,,$ICU_INCS -Wno-write-strings,cxx) ++ $icu_spoof_src, $ext_shared,,$INTL_COMMON_FLAGS,cxx) + +- PHP_INTL_CPP_SOURCES="intl_convertcpp.cpp \ ++ PHP_INTL_CXX_SOURCES="intl_convertcpp.cpp \ + common/common_enum.cpp \ + common/common_date.cpp \ + dateformat/dateformat_format_object.cpp \ +@@ -87,11 +88,11 @@ if test "$PHP_INTL" != "no"; then + breakiterator/rulebasedbreakiterator_methods.cpp \ + breakiterator/codepointiterator_internal.cpp \ + breakiterator/codepointiterator_methods.cpp" +- PHP_INTL_CPP_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS $ICU_CXXFLAGS" ++ PHP_INTL_CXX_FLAGS="$INTL_COMMON_FLAGS $ICU_CXXFLAGS" + if test "$ext_shared" = "no"; then +- PHP_ADD_SOURCES(PHP_EXT_DIR(intl), $PHP_INTL_CPP_SOURCES, $PHP_INTL_CPP_FLAGS) ++ PHP_ADD_SOURCES(PHP_EXT_DIR(intl), $PHP_INTL_CXX_SOURCES, $PHP_INTL_CXX_FLAGS) + else +- PHP_ADD_SOURCES_X(PHP_EXT_DIR(intl), $PHP_INTL_CPP_SOURCES, $PHP_INTL_CPP_FLAGS, shared_objects_intl, yes) ++ PHP_ADD_SOURCES_X(PHP_EXT_DIR(intl), $PHP_INTL_CXX_SOURCES, $PHP_INTL_CXX_FLAGS, shared_objects_intl, yes) + fi + + PHP_ADD_BUILD_DIR($ext_builddir/collator) diff --git a/dev-lang/php/files/php-fpm_at-simple.service b/dev-lang/php/files/php-fpm_at-simple.service new file mode 100644 index 0000000..5f0482e --- /dev/null +++ b/dev-lang/php/files/php-fpm_at-simple.service @@ -0,0 +1,13 @@ +[Unit] +Description=The PHP FastCGI Process Manager +After=network.target + +[Service] +Type=simple +PIDFile=/run/php-fpm/php-fpm-%I.pid +ExecStart=/usr/libexec/php-fpm-launcher php%I -y /etc/php/fpm-php%I/php-fpm.conf --nodaemonize +ExecReload=/bin/kill -USR2 $MAINPID +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/dev-lang/php/files/php-fpm_at.service b/dev-lang/php/files/php-fpm_at.service new file mode 100644 index 0000000..152c1ab --- /dev/null +++ b/dev-lang/php/files/php-fpm_at.service @@ -0,0 +1,14 @@ +[Unit] +Description=The PHP FastCGI Process Manager +After=network.target + +[Service] +Type=notify +PIDFile=/run/php-fpm/php-fpm-%I.pid +ExecStart=/usr/libexec/php-fpm-launcher php%I -y /etc/php/fpm-php%I/php-fpm.conf --nodaemonize +ExecReload=/bin/kill -USR2 $MAINPID +PrivateTmp=true + +[Install] +WantedBy=multi-user.target + diff --git a/dev-lang/php/files/php-freetype-2.9.1.patch b/dev-lang/php/files/php-freetype-2.9.1.patch new file mode 100644 index 0000000..02dfd9c --- /dev/null +++ b/dev-lang/php/files/php-freetype-2.9.1.patch @@ -0,0 +1,233 @@ +--- a/ext/gd/config.m4 2018-04-24 11:09:54.000000000 -0400 ++++ b/ext/gd/config.m4 2018-05-04 15:18:49.867283889 -0400 +@@ -186,21 +186,36 @@ + AC_DEFUN([PHP_GD_FREETYPE2],[ + if test "$PHP_FREETYPE_DIR" != "no"; then + +- for i in $PHP_FREETYPE_DIR /usr/local /usr; do +- if test -f "$i/bin/freetype-config"; then +- FREETYPE2_DIR=$i +- FREETYPE2_CONFIG="$i/bin/freetype-config" +- break ++ AC_PATH_PROG(PKG_CONFIG, pkg-config, no) ++ AC_MSG_CHECKING(for freetype2) ++ ++ if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists freetype2 ; then ++ ++ FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags freetype2` ++ FREETYPE2_LIBS=`$PKG_CONFIG --libs freetype2` ++ FREETYPE2_VERSION=`$PKG_CONFIG --modversion freetype2` ++ FREETYPE2_DIR="found" ++ ++ AC_MSG_RESULT(from pkgconfig: version $FREETYPE2_VERSION found) ++ else ++ ++ for i in $PHP_FREETYPE_DIR /usr/local /usr; do ++ if test -f "$i/bin/freetype-config"; then ++ FREETYPE2_DIR=$i ++ FREETYPE2_CONFIG="$i/bin/freetype-config" ++ break ++ fi ++ done ++ ++ if test -z "$FREETYPE2_DIR"; then ++ AC_MSG_ERROR([freetype-config not found.]) + fi +- done + +- if test -z "$FREETYPE2_DIR"; then +- AC_MSG_ERROR([freetype-config not found.]) ++ FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags` ++ FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs` ++ AC_MSG_RESULT(found via freetype-config) + fi + +- FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags` +- FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs` +- + PHP_EVAL_INCLINE($FREETYPE2_CFLAGS) + PHP_EVAL_LIBLINE($FREETYPE2_LIBS, GD_SHARED_LIBADD) + AC_DEFINE(HAVE_LIBFREETYPE,1,[ ]) +--- a/configure 2018-04-24 11:10:05.000000000 -0400 ++++ b/configure 2018-05-04 15:18:45.626367913 -0400 +@@ -34348,21 +34348,79 @@ + + if test "$PHP_FREETYPE_DIR" != "no"; then + +- for i in $PHP_FREETYPE_DIR /usr/local /usr; do +- if test -f "$i/bin/freetype-config"; then +- FREETYPE2_DIR=$i +- FREETYPE2_CONFIG="$i/bin/freetype-config" +- break ++ # Extract the first word of "pkg-config", so it can be a program name with args. ++set dummy pkg-config; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_path_PKG_CONFIG+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $PKG_CONFIG in ++ [\\/]* | ?:[\\/]*) ++ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ++ ;; ++ *) ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" ++ ;; ++esac ++fi ++PKG_CONFIG=$ac_cv_path_PKG_CONFIG ++if test -n "$PKG_CONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 ++$as_echo "$PKG_CONFIG" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype2" >&5 ++$as_echo_n "checking for freetype2... " >&6; } ++ ++ ++ if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists freetype2 ; then ++ ++ FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags freetype2` ++ FREETYPE2_LIBS=`$PKG_CONFIG --libs freetype2` ++ FREETYPE2_VERSION=`$PKG_CONFIG --modversion freetype2` ++ FREETYPE2_DIR="found" ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: from pkgconfig: version $FREETYPE2_VERSION found" >&5 ++$as_echo "from pkgconfig: version $FREETYPE2_VERSION found" >&6; } ++ else ++ ++ for i in $PHP_FREETYPE_DIR /usr/local /usr; do ++ if test -f "$i/bin/freetype-config"; then ++ FREETYPE2_DIR=$i ++ FREETYPE2_CONFIG="$i/bin/freetype-config" ++ break ++ fi ++ done ++ ++ if test -z "$FREETYPE2_DIR"; then ++ as_fn_error $? "freetype-config not found." "$LINENO" 5 + fi +- done + +- if test -z "$FREETYPE2_DIR"; then +- as_fn_error $? "freetype-config not found." "$LINENO" 5 ++ FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags` ++ FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs` ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found via freetype-config" >&5 ++$as_echo "found via freetype-config" >&6; } + fi + +- FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags` +- FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs` +- + + for ac_i in $FREETYPE2_CFLAGS; do + case $ac_i in +@@ -36019,21 +36076,78 @@ + + if test "$PHP_FREETYPE_DIR" != "no"; then + +- for i in $PHP_FREETYPE_DIR /usr/local /usr; do +- if test -f "$i/bin/freetype-config"; then +- FREETYPE2_DIR=$i +- FREETYPE2_CONFIG="$i/bin/freetype-config" +- break ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype2" >&5 ++$as_echo_n "checking for freetype2... " >&6; } ++ # Extract the first word of "pkg-config", so it can be a program name with args. ++set dummy pkg-config; ac_word=$2 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 ++$as_echo_n "checking for $ac_word... " >&6; } ++if ${ac_cv_path_PKG_CONFIG+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ case $PKG_CONFIG in ++ [\\/]* | ?:[\\/]*) ++ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ++ ;; ++ *) ++ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR ++for as_dir in $PATH ++do ++ IFS=$as_save_IFS ++ test -z "$as_dir" && as_dir=. ++ for ac_exec_ext in '' $ac_executable_extensions; do ++ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ++ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" ++ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 ++ break 2 ++ fi ++done ++ done ++IFS=$as_save_IFS ++ ++ test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" ++ ;; ++esac ++fi ++PKG_CONFIG=$ac_cv_path_PKG_CONFIG ++if test -n "$PKG_CONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 ++$as_echo "$PKG_CONFIG" >&6; } ++else ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 ++$as_echo "no" >&6; } ++fi ++ ++ ++ ++ if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists freetype2 ; then ++ ++ FREETYPE2_CFLAGS=`$PKG_CONFIG --cflags freetype2` ++ FREETYPE2_LIBS=`$PKG_CONFIG --libs freetype2` ++ FREETYPE2_VERSION=`$PKG_CONFIG --modversion freetype2` ++ ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: from pkgconfig: version $FREETYPE_VERSON found" >&5 ++$as_echo "from pkgconfig: version $FREETYPE_VERSON found" >&6; } ++ else ++ ++ for i in $PHP_FREETYPE_DIR /usr/local /usr; do ++ if test -f "$i/bin/freetype-config"; then ++ FREETYPE2_DIR=$i ++ FREETYPE2_CONFIG="$i/bin/freetype-config" ++ break ++ fi ++ done ++ ++ if test -z "$FREETYPE2_DIR"; then ++ as_fn_error $? "freetype-config not found." "$LINENO" 5 + fi +- done + +- if test -z "$FREETYPE2_DIR"; then +- as_fn_error $? "freetype-config not found." "$LINENO" 5 ++ FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags` ++ FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs` ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found via freetype-config" >&5 ++$as_echo "found via freetype-config" >&6; } + fi + +- FREETYPE2_CFLAGS=`$FREETYPE2_CONFIG --cflags` +- FREETYPE2_LIBS=`$FREETYPE2_CONFIG --libs` +- + + for ac_i in $FREETYPE2_CFLAGS; do + case $ac_i in diff --git a/dev-lang/php/metadata.xml b/dev-lang/php/metadata.xml new file mode 100644 index 0000000..cca331a --- /dev/null +++ b/dev-lang/php/metadata.xml @@ -0,0 +1,57 @@ + + + + + php-bugs@gentoo.org + PHP + + + Enable password hashing algorithm from app-crypt/argon2 + Enable CLI SAPI + + Include gcov symbols for test coverage and lcov reports. Only + useful for extension developers, and requires GCC. + + Enable embed SAPI + Add supports Enchant spelling library. + Add fileinfo extension support + Add filter extension support + Enable the FastCGI Process Manager SAPI + Adds support for gd (bundled with PHP) + Enable the hash extension + Enable JSON support + Add SASL support for the PHP LDAP extension + + Use libmyslclient driver for mysql, mysqli, PDO_Mysql (not recommended) + + Enable support for dev-db/lmdb db backend + + Enables the intl extension for extended internalization support + + + Enables built-in opcode cache, replacing pecl-apc et al. + + Enable the bundled PDO extensions + + Enables the phar extension to provide phar archive support + + + Enable the PHP Debug Command Line SAPI (like gdb for php) + + + Include dev-libs/mm support for session storage + + + Enable support for crypto through dev-libs/libsodium + + + Enable support for dev-db/tokyocabinet db backend + Enable XMLReader support + Enable XMLWriter support + Enable the XSL extension + Enable webp support for GD in php-5.x + Enable webp support for GD in php-7.x + Enable ZIP file support + Enable ZIP file encryption from dev-libs/libzip + + diff --git a/dev-lang/php/php-5.6.38.ebuild b/dev-lang/php/php-5.6.38.ebuild new file mode 100644 index 0000000..7a39c66 --- /dev/null +++ b/dev-lang/php/php-5.6.38.ebuild @@ -0,0 +1,783 @@ +# Copyright 1999-2018 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +inherit autotools flag-o-matic eapi7-ver systemd + +DESCRIPTION="The PHP language runtime engine" +HOMEPAGE="https://secure.php.net/" +SRC_URI="https://php.net/distributions/${P}.tar.xz" + +LICENSE="PHP-3.01 + BSD + Zend-2.0 + bcmath? ( LGPL-2.1+ ) + fpm? ( BSD-2 ) + gd? ( gd ) + unicode? ( BSD-2 LGPL-2.1 )" + +SLOT="$(ver_cut 1-2)" +KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ia64 ~mips ppc ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos" + +# We can build the following SAPIs in the given order +SAPIS="embed cli cgi fpm apache2" + +# SAPIs and SAPI-specific USE flags (cli SAPI is default on): +IUSE="${IUSE} + ${SAPIS/cli/+cli} + threads" + +IUSE="${IUSE} acl bcmath berkdb bzip2 calendar cdb cjk + coverage crypt +ctype curl debug + enchant exif +fileinfo +filter firebird + flatfile ftp gd gdbm gmp +hash +iconv imap inifile + intl iodbc ipv6 +json kerberos ldap ldap-sasl libedit libressl + mhash mssql mysql libmysqlclient mysqli nls + oci8-instant-client odbc +opcache pcntl pdo +phar +posix postgres qdbm + readline recode selinux +session sharedmem + +simplexml snmp soap sockets spell sqlite ssl + sybase-ct sysvipc systemd tidy +tokenizer truetype unicode vpx wddx + +xml xmlreader xmlwriter xmlrpc xpm xslt zip zlib" + +# The supported (that is, autodetected) versions of BDB are listed in +# the ./configure script. Other versions *work*, but we need to stick to +# the ones that can be detected to avoid a repeat of bug #564824. +COMMON_DEPEND=" + >=app-eselect/eselect-php-0.9.1[apache2?,fpm?] + >=dev-libs/libpcre-8.32[unicode] + fpm? ( acl? ( sys-apps/acl ) ) + apache2? ( || ( >=www-servers/apache-2.4[apache2_modules_unixd,threads=] + =dev-libs/libmcrypt-2.4 ) + curl? ( >=net-misc/curl-7.10.5 ) + enchant? ( app-text/enchant ) + exif? ( !gd? ( + virtual/jpeg:0 + media-libs/libpng:0= + sys-libs/zlib:0= + ) ) + firebird? ( dev-db/firebird ) + gd? ( virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib:0= ) + gdbm? ( >=sys-libs/gdbm-1.8.0:0= ) + gmp? ( dev-libs/gmp:0= ) + iconv? ( virtual/libiconv ) + imap? ( virtual/imap-c-client[kerberos=,ssl=] ) + intl? ( >=dev-libs/icu-62.1:= ) + iodbc? ( dev-db/libiodbc ) + kerberos? ( virtual/krb5 ) + ldap? ( >=net-nds/openldap-1.2.11 ) + ldap-sasl? ( dev-libs/cyrus-sasl >=net-nds/openldap-1.2.11 ) + libedit? ( || ( sys-freebsd/freebsd-lib dev-libs/libedit ) ) + mssql? ( dev-db/freetds[mssql] ) + libmysqlclient? ( + mysql? ( virtual/libmysqlclient:= ) + mysqli? ( virtual/libmysqlclient:= ) + ) + nls? ( sys-devel/gettext ) + oci8-instant-client? ( dev-db/oracle-instantclient-basic ) + odbc? ( >=dev-db/unixODBC-1.8.13 ) + postgres? ( dev-db/postgresql:* ) + qdbm? ( dev-db/qdbm ) + readline? ( sys-libs/readline:0= ) + recode? ( app-text/recode ) + sharedmem? ( dev-libs/mm ) + simplexml? ( >=dev-libs/libxml2-2.6.8 ) + snmp? ( >=net-analyzer/net-snmp-5.2 ) + soap? ( >=dev-libs/libxml2-2.6.8 ) + spell? ( >=app-text/aspell-0.50 ) + sqlite? ( >=dev-db/sqlite-3.7.6.3 ) + ssl? ( + !libressl? ( dev-libs/openssl:0= ) + libressl? ( dev-libs/libressl:0= ) + ) + sybase-ct? ( dev-db/freetds ) + tidy? ( app-text/htmltidy ) + truetype? ( + =media-libs/freetype-2* + >=media-libs/t1lib-5.0.0 + !gd? ( + virtual/jpeg:0 media-libs/libpng:0= sys-libs/zlib:0= ) + ) + unicode? ( dev-libs/oniguruma:= ) + vpx? ( media-libs/libvpx:0= ) + wddx? ( >=dev-libs/libxml2-2.6.8 ) + xml? ( >=dev-libs/libxml2-2.6.8 ) + xmlrpc? ( >=dev-libs/libxml2-2.6.8 virtual/libiconv ) + xmlreader? ( >=dev-libs/libxml2-2.6.8 ) + xmlwriter? ( >=dev-libs/libxml2-2.6.8 ) + xpm? ( + x11-libs/libXpm + virtual/jpeg:0 + media-libs/libpng:0= sys-libs/zlib:0= + ) + xslt? ( dev-libs/libxslt >=dev-libs/libxml2-2.6.8 ) + zip? ( sys-libs/zlib:0= ) + zlib? ( sys-libs/zlib:0= ) +" + +RDEPEND="${COMMON_DEPEND} + virtual/mta + fpm? ( + selinux? ( sec-policy/selinux-phpfpm ) + systemd? ( sys-apps/systemd ) )" + +DEPEND="${COMMON_DEPEND} + app-arch/xz-utils + >=sys-devel/bison-3.0.1 + sys-devel/flex + >=sys-devel/m4-1.4.3 + >=sys-devel/libtool-1.5.18" + +# Without USE=readline or libedit, the interactive "php -a" CLI will hang. +REQUIRED_USE=" + || ( cli cgi fpm apache2 embed ) + cli? ( ^^ ( readline libedit ) ) + truetype? ( gd zlib ) + vpx? ( gd zlib ) + cjk? ( gd zlib ) + exif? ( gd zlib ) + xpm? ( gd zlib ) + gd? ( zlib ) + simplexml? ( xml ) + soap? ( xml ) + wddx? ( xml ) + xmlrpc? ( || ( xml iconv ) ) + xmlreader? ( xml ) + xslt? ( xml ) + ldap-sasl? ( ldap ) + mhash? ( hash ) + phar? ( hash ) + recode? ( !imap !mysql !mysqli !libmysqlclient ) + libmysqlclient? ( || ( + mysql + mysqli + pdo + ) ) + + qdbm? ( !gdbm ) + readline? ( !libedit ) + sharedmem? ( !threads ) +" + +PHP_MV="$(ver_cut 1)" + +php_install_ini() { + local phpsapi="${1}" + + # work out where we are installing the ini file + php_set_ini_dir "${phpsapi}" + + # Always install the production INI file, bug 611214. + local phpinisrc="php.ini-production-${phpsapi}" + cp php.ini-production "${phpinisrc}" || die + + # default to /tmp for save_path, bug #282768 + sed -e 's|^;session.save_path .*$|session.save_path = "'"${EPREFIX}"'/tmp"|g' -i "${phpinisrc}" || die + + # Set the extension dir + sed -e "s|^extension_dir .*$|extension_dir = ${extension_dir}|g" \ + -i "${phpinisrc}" || die + + # Set the include path to point to where we want to find PEAR packages + sed -e 's|^;include_path = ".:/php/includes".*|include_path = ".:'"${EPREFIX}"'/usr/share/php'${PHP_MV}':'"${EPREFIX}"'/usr/share/php"|' -i "${phpinisrc}" || die + + dodir "${PHP_INI_DIR#${EPREFIX}}" + insinto "${PHP_INI_DIR#${EPREFIX}}" + newins "${phpinisrc}" php.ini + + elog "Installing php.ini for ${phpsapi} into ${PHP_INI_DIR#${EPREFIX}}" + elog + + dodir "${PHP_EXT_INI_DIR#${EPREFIX}}" + dodir "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}" + + if use opcache; then + elog "Adding opcache to $PHP_EXT_INI_DIR" + echo "zend_extension=${PHP_DESTDIR}/$(get_libdir)/opcache.so" >> \ + "${D}/${PHP_EXT_INI_DIR}"/opcache.ini + dosym "${PHP_EXT_INI_DIR#${EPREFIX}}/opcache.ini" \ + "${PHP_EXT_INI_DIR_ACTIVE#${EPREFIX}}/opcache.ini" + fi + + # SAPI-specific handling + if [[ "${sapi}" == "fpm" ]] ; then + einfo "Installing FPM config file php-fpm.conf" + insinto "${PHP_INI_DIR#${EPREFIX}}" + doins sapi/fpm/php-fpm.conf + fi + + dodoc php.ini-{development,production} +} + +php_set_ini_dir() { + PHP_INI_DIR="${EPREFIX}/etc/php/${1}-php${SLOT}" + PHP_EXT_INI_DIR="${PHP_INI_DIR}/ext" + PHP_EXT_INI_DIR_ACTIVE="${PHP_INI_DIR}/ext-active" +} + +src_prepare() { + eapply "${FILESDIR}/php-${SLOT}-no-bison-warnings.patch" + eapply "${FILESDIR}/5.6-mbstring-oniguruma-6.8.patch" + eapply "${FILESDIR}/php-freetype-2.9.1.patch" + + # build fixes from fedora SRPM from remi + eapply "${FILESDIR}/php-5.3.0-recode.patch" + eapply "${FILESDIR}/php-5.6.30-interbase.patch" + eapply "${FILESDIR}/php-5.6.31-openssl11.patch" + eapply "${FILESDIR}/php-5.6.37-icu62.patch" + + # Change PHP branding + # Get the alpha/beta/rc version + sed -re "s|^(PHP_EXTRA_VERSION=\").*(\")|\1-pl${PR/r/}-gentoo\2|g" \ + -i configure.in || die "Unable to change PHP branding" + + # Patch PHP to show Gentoo as the server platform + sed -e 's/PHP_UNAME=`uname -a | xargs`/PHP_UNAME=`uname -s -n -r -v | xargs`/g' \ + -i configure.in || die "Failed to fix server platform name" + + # Prevent PHP from activating the Apache config, + # as we will do that ourselves + sed -i \ + -e "s,-i -a -n php${PHP_MV},-i -n php${PHP_MV},g" \ + -e "s,-i -A -n php${PHP_MV},-i -n php${PHP_MV},g" \ + configure sapi/apache2filter/config.m4 sapi/apache2handler/config.m4 \ + || die + + # Patch PHP to support heimdal instead of mit-krb5 + if has_version "app-crypt/heimdal" ; then + sed -e 's|gssapi_krb5|gssapi|g' -i acinclude.m4 \ + || die "Failed to fix heimdal libname" + sed -e 's|PHP_ADD_LIBRARY(k5crypto, 1, $1)||g' -i acinclude.m4 \ + || die "Failed to fix heimdal crypt library reference" + fi + + eapply_user + + # Force rebuilding aclocal.m4 + rm -f aclocal.m4 || die "failed to remove aclocal.m4 in src_prepare" + eautoreconf + + if [[ ${CHOST} == *-darwin* ]] ; then + # http://bugs.php.net/bug.php?id=48795, bug #343481 + sed -i -e '/BUILD_CGI="\\$(CC)/s/CC/CXX/' configure || die + fi +} + +src_configure() { + addpredict /usr/share/snmp/mibs/.index #nowarn + addpredict /var/lib/net-snmp/mib_indexes #nowarn + + PHP_DESTDIR="${EPREFIX}/usr/$(get_libdir)/php${SLOT}" + + # The php-fpm config file wants localstatedir to be ${EPREFIX}/var + # and not the Gentoo default ${EPREFIX}/var/lib. See bug 572002. + local our_conf=( + --prefix="${PHP_DESTDIR}" + --mandir="${PHP_DESTDIR}/man" + --infodir="${PHP_DESTDIR}/info" + --libdir="${PHP_DESTDIR}/lib" + --with-libdir="$(get_libdir)" + --localstatedir="${EPREFIX}/var" + --without-pear + $(use_enable threads maintainer-zts) + ) + + our_conf+=( + $(use_enable bcmath bcmath) + $(use_with bzip2 bz2 "${EPREFIX}/usr") + $(use_enable calendar calendar) + $(use_enable coverage gcov) + $(use_enable ctype ctype) + $(use_with curl curl "${EPREFIX}/usr") + $(use_enable xml dom) + $(use_with enchant enchant "${EPREFIX}/usr") + $(use_enable exif exif) + $(use_enable fileinfo fileinfo) + $(use_enable filter filter) + $(use_enable ftp ftp) + $(use_with nls gettext "${EPREFIX}/usr") + $(use_with gmp gmp "${EPREFIX}/usr") + $(use_enable hash hash) + $(use_with mhash mhash "${EPREFIX}/usr") + $(use_with iconv iconv \ + $(use elibc_glibc || use elibc_musl || use elibc_FreeBSD || echo "${EPREFIX}/usr")) + $(use_enable intl intl) + $(use_enable ipv6 ipv6) + $(use_enable json json) + $(use_with kerberos kerberos "${EPREFIX}/usr") + $(use_enable xml libxml) + $(use_with xml libxml-dir "${EPREFIX}/usr") + $(use_enable unicode mbstring) + $(use_with crypt mcrypt "${EPREFIX}/usr") + $(use_with mssql mssql "${EPREFIX}/usr") + $(use_with unicode onig "${EPREFIX}/usr") + $(use_with ssl openssl "${EPREFIX}/usr") + $(use_with ssl openssl-dir "${EPREFIX}/usr") + $(use_enable pcntl pcntl) + $(use_enable phar phar) + $(use_enable pdo pdo) + $(use_enable opcache opcache) + $(use_with postgres pgsql "${EPREFIX}/usr") + $(use_enable posix posix) + $(use_with spell pspell "${EPREFIX}/usr") + $(use_with recode recode "${EPREFIX}/usr") + $(use_enable simplexml simplexml) + $(use_enable sharedmem shmop) + $(use_with snmp snmp "${EPREFIX}/usr") + $(use_enable soap soap) + $(use_enable sockets sockets) + $(use_with sqlite sqlite3 "${EPREFIX}/usr") + $(use_with sybase-ct sybase-ct "${EPREFIX}/usr") + $(use_enable sysvipc sysvmsg) + $(use_enable sysvipc sysvsem) + $(use_enable sysvipc sysvshm) + $(use_with tidy tidy "${EPREFIX}/usr") + $(use_enable tokenizer tokenizer) + $(use_enable wddx wddx) + $(use_enable xml xml) + $(use_enable xmlreader xmlreader) + $(use_enable xmlwriter xmlwriter) + $(use_with xmlrpc xmlrpc) + $(use_with xslt xsl "${EPREFIX}/usr") + $(use_enable zip zip) + $(use_with zlib zlib "${EPREFIX}/usr") + $(use_enable debug debug) + ) + + # DBA support + if use cdb || use berkdb || use flatfile || use gdbm || use inifile \ + || use qdbm ; then + our_conf+=( "--enable-dba${shared}" ) + fi + + # DBA drivers support + our_conf+=( + $(use_with cdb cdb) + $(use_with berkdb db4 "${EPREFIX}/usr") + $(use_enable flatfile flatfile) + $(use_with gdbm gdbm "${EPREFIX}/usr") + $(use_enable inifile inifile) + $(use_with qdbm qdbm "${EPREFIX}/usr") + ) + + # Support for the GD graphics library + our_conf+=( + $(use_with truetype freetype-dir "${EPREFIX}/usr") + $(use_with truetype t1lib "${EPREFIX}/usr") + $(use_enable cjk gd-jis-conv) + $(use_with gd jpeg-dir "${EPREFIX}/usr") + $(use_with gd png-dir "${EPREFIX}/usr") + $(use_with xpm xpm-dir "${EPREFIX}/usr") + $(use_with vpx vpx-dir "${EPREFIX}/usr") + ) + # enable gd last, so configure can pick up the previous settings + our_conf+=( $(use_with gd gd) ) + + # IMAP support + if use imap ; then + our_conf+=( + $(use_with imap imap "${EPREFIX}/usr") + $(use_with ssl imap-ssl "${EPREFIX}/usr") + ) + fi + + # Interbase/firebird support + our_conf+=( $(use_with firebird interbase "${EPREFIX}/usr") ) + + # LDAP support + if use ldap ; then + our_conf+=( + $(use_with ldap ldap "${EPREFIX}/usr") + $(use_with ldap-sasl ldap-sasl "${EPREFIX}/usr") + ) + fi + + # MySQL support + local mysqllib="mysqlnd" + local mysqlilib="mysqlnd" + use libmysqlclient && mysqllib="${EPREFIX}/usr" + use libmysqlclient && mysqlilib="${EPREFIX}/usr/bin/mysql_config" + + our_conf+=( $(use_with mysql mysql "${mysqllib}") ) + our_conf+=( $(use_with mysqli mysqli "${mysqlilib}") ) + + local mysqlsock="${EPREFIX}/var/run/mysqld/mysqld.sock" + if use mysql || use mysqli ; then + our_conf+=( $(use_with mysql mysql-sock "${mysqlsock}") ) + fi + + # ODBC support + our_conf+=( + $(use_with odbc unixODBC "${EPREFIX}/usr") + $(use_with iodbc iodbc "${EPREFIX}/usr") + ) + + # Oracle support + our_conf+=( $(use_with oci8-instant-client oci8) ) + + # PDO support + if use pdo ; then + our_conf+=( + $(use_with mssql pdo-dblib) + $(use_with mysql pdo-mysql "${mysqllib}") + $(use_with postgres pdo-pgsql) + $(use_with sqlite pdo-sqlite "${EPREFIX}/usr") + $(use_with firebird pdo-firebird "${EPREFIX}/usr") + $(use_with odbc pdo-odbc "unixODBC,${EPREFIX}/usr") + $(use_with oci8-instant-client pdo-oci) + ) + fi + + # readline/libedit support + our_conf+=( + $(use_with readline readline "${EPREFIX}/usr") + $(use_with libedit libedit "${EPREFIX}/usr") + ) + + # Session support + if use session ; then + our_conf+=( $(use_with sharedmem mm "${EPREFIX}/usr") ) + else + our_conf+=( $(use_enable session session) ) + fi + + # Use pic for shared modules such as apache2's mod_php + our_conf+=( --with-pic ) + + # we use the system copy of pcre + # --with-pcre-regex affects ext/pcre + # --with-pcre-dir affects ext/filter and ext/zip + our_conf+=( + --with-pcre-regex="${EPREFIX}/usr" + --with-pcre-dir="${EPREFIX}/usr" + ) + + # Catch CFLAGS problems + # Fixes bug #14067. + # Changed order to run it in reverse for bug #32022 and #12021. + replace-cpu-flags "k6*" "i586" + + # Cache the ./configure test results between SAPIs. + our_conf+=( --cache-file="${T}/config.cache" ) + + # Support user-passed configuration parameters + our_conf+=( ${EXTRA_ECONF:-} ) + + # Support the Apache2 extras, they must be set globally for all + # SAPIs to work correctly, especially for external PHP extensions + + mkdir -p "${WORKDIR}/sapis-build" || die + for one_sapi in $SAPIS ; do + use "${one_sapi}" || continue + php_set_ini_dir "${one_sapi}" + + # The BUILD_DIR variable is used to determine where to output + # the files that autotools creates. This was all originally + # based on the autotools-utils eclass. + BUILD_DIR="${WORKDIR}/sapis-build/${one_sapi}" + cp -a "${S}" "${BUILD_DIR}" || die + cd "${BUILD_DIR}" || die + + local sapi_conf=( + --with-config-file-path="${PHP_INI_DIR}" + --with-config-file-scan-dir="${PHP_EXT_INI_DIR_ACTIVE}" + ) + + for sapi in $SAPIS ; do + case "$sapi" in + cli|cgi|embed|fpm) + if [[ "${one_sapi}" == "${sapi}" ]] ; then + sapi_conf+=( "--enable-${sapi}" ) + if [[ "fpm" == "${sapi}" ]] ; then + sapi_conf+=( + $(use_with acl fpm-acl) + $(use_with systemd fpm-systemd) + ) + fi + else + sapi_conf+=( "--disable-${sapi}" ) + fi + ;; + + apache2) + if [[ "${one_sapi}" == "${sapi}" ]] ; then + sapi_conf+=( --with-apxs2="${EPREFIX}/usr/bin/apxs" ) + else + sapi_conf+=( --without-apxs2 ) + fi + ;; + esac + done + + # Construct the $myeconfargs array by concatenating $our_conf + # (the common args) and $sapi_conf (the SAPI-specific args). + local myeconfargs=( "${our_conf[@]}" ) + myeconfargs+=( "${sapi_conf[@]}" ) + + pushd "${BUILD_DIR}" > /dev/null || die + econf "${myeconfargs[@]}" + popd > /dev/null || die + done +} + +src_compile() { + # snmp seems to run during src_compile, too (bug #324739) + addpredict /usr/share/snmp/mibs/.index #nowarn + addpredict /var/lib/net-snmp/mib_indexes #nowarn + + for sapi in ${SAPIS} ; do + if use "${sapi}"; then + cd "${WORKDIR}/sapis-build/$sapi" || \ + die "Failed to change dir to ${WORKDIR}/sapis-build/$1" + emake + fi + done +} + +src_install() { + # see bug #324739 for what happens when we don't have that + addpredict /usr/share/snmp/mibs/.index #nowarn + + # grab the first SAPI that got built and install common files from there + local first_sapi="" + for sapi in $SAPIS ; do + if use $sapi ; then + first_sapi=$sapi + break + fi + done + + # Makefile forgets to create this before trying to write to it... + dodir "${PHP_DESTDIR#${EPREFIX}}/bin" + + # Install php environment (without any sapis) + cd "${WORKDIR}/sapis-build/$first_sapi" || die + emake INSTALL_ROOT="${D}" \ + install-build install-headers install-programs + + local extension_dir="$("${ED}/${PHP_DESTDIR#${EPREFIX}}/bin/php-config" --extension-dir)" + + # Create the directory where we'll put version-specific php scripts + keepdir "/usr/share/php${PHP_MV}" + + local sapi="", file="" + local sapi_list="" + + for sapi in ${SAPIS}; do + if use "${sapi}" ; then + einfo "Installing SAPI: ${sapi}" + cd "${WORKDIR}/sapis-build/${sapi}" || die + + if [[ "${sapi}" == "apache2" ]] ; then + # We're specifically not using emake install-sapi as libtool + # may cause unnecessary relink failures (see bug #351266) + insinto "${PHP_DESTDIR#${EPREFIX}}/apache2/" + newins ".libs/libphp5$(get_libname)" \ + "libphp${PHP_MV}$(get_libname)" + keepdir "/usr/$(get_libdir)/apache2/modules" + else + # needed each time, php_install_ini would reset it + local dest="${PHP_DESTDIR#${EPREFIX}}" + into "${dest}" + case "$sapi" in + cli) + source="sapi/cli/php" + ;; + cgi) + source="sapi/cgi/php-cgi" + ;; + fpm) + source="sapi/fpm/php-fpm" + ;; + embed) + source="libs/libphp${PHP_MV}$(get_libname)" + ;; + *) + die "unhandled sapi in src_install" + ;; + esac + + if [[ "${source}" == *"$(get_libname)" ]]; then + dolib.so "${source}" + else + dobin "${source}" + local name="$(basename ${source})" + dosym "${dest}/bin/${name}" "/usr/bin/${name}${SLOT}" + fi + fi + + php_install_ini "${sapi}" + + # construct correct SAPI string for php-config + # thanks to ferringb for the bash voodoo + if [[ "${sapi}" == "apache2" ]]; then + sapi_list="${sapi_list:+${sapi_list} }apache2handler" + else + sapi_list="${sapi_list:+${sapi_list} }${sapi}" + fi + fi + done + + # Installing opcache module + if use opcache ; then + into "${PHP_DESTDIR#${EPREFIX}}" + dolib.so "modules/opcache$(get_libname)" + fi + + # Install env.d files + newenvd "${FILESDIR}/20php5-envd" "20php${SLOT}" + sed -e "s|/lib/|/$(get_libdir)/|g" -i "${ED}/etc/env.d/20php${SLOT}" || die + sed -e "s|php5|php${SLOT}|g" -i "${ED}/etc/env.d/20php${SLOT}" || die + + # set php-config variable correctly (bug #278439) + sed -e "s:^\(php_sapis=\)\".*\"$:\1\"${sapi_list}\":" -i \ + "${ED}/usr/$(get_libdir)/php${SLOT}/bin/php-config" || die + + if use fpm ; then + if use systemd; then + systemd_newunit "${FILESDIR}/php-fpm_at.service" \ + "php-fpm@${SLOT}.service" + else + systemd_newunit "${FILESDIR}/php-fpm_at-simple.service" \ + "php-fpm@${SLOT}.service" + fi + fi +} + +src_test() { + echo ">>> Test phase [test]: ${CATEGORY}/${PF}" + PHP_BIN="${WORKDIR}/sapis-build/cli/sapi/cli/php" + if [[ ! -x "${PHP_BIN}" ]] ; then + ewarn "Test phase requires USE=cli, skipping" + return + else + export TEST_PHP_EXECUTABLE="${PHP_BIN}" + fi + + if [[ -x "${WORKDIR}/sapis/cgi/php-cgi" ]] ; then + export TEST_PHP_CGI_EXECUTABLE="${WORKDIR}/sapis/cgi/php-cgi" + fi + + REPORT_EXIT_STATUS=1 "${TEST_PHP_EXECUTABLE}" -n -d \ + "session.save_path=${T}" \ + "${WORKDIR}/sapis-build/cli/run-tests.php" -n -q -d \ + "session.save_path=${T}" + + for name in ${EXPECTED_TEST_FAILURES}; do + mv "${name}.out" "${name}.out.orig" 2>/dev/null || die + done + + local failed="$(find -name '*.out')" + if [[ ${failed} != "" ]] ; then + ewarn "The following test cases failed unexpectedly:" + for name in ${failed}; do + ewarn " ${name/.out/}" + done + else + einfo "No unexpected test failures, all fine" + fi + + if [[ ${PHP_SHOW_UNEXPECTED_TEST_PASS} == "1" ]] ; then + local passed="" + for name in ${EXPECTED_TEST_FAILURES}; do + [[ -f "${name}.diff" ]] && continue + passed="${passed} ${name}" + done + if [[ ${passed} != "" ]] ; then + einfo "The following test cases passed unexpectedly:" + for name in ${passed}; do + ewarn " ${passed}" + done + else + einfo "None of the known-to-fail tests passed, all fine" + fi + fi +} + +pkg_postinst() { + # Output some general info to the user + if use apache2 ; then + elog + elog "To enable PHP in apache, you will need to add \"-D PHP\" to" + elog "your apache2 command. OpenRC users can append that string to" + elog "APACHE2_OPTS in /etc/conf.d/apache2." + elog + elog "The apache module configuration file 70_mod_php.conf is" + elog "provided (and maintained) by eselect-php." + elog + fi + + # Create the symlinks for php + for m in ${SAPIS}; do + [[ ${m} == 'embed' ]] && continue; + if use $m ; then + local ci=$(eselect php show $m) + if [[ -z $ci ]]; then + eselect php set $m php${SLOT} || die + einfo "Switched ${m} to use php:${SLOT}" + einfo + elif [[ $ci != "php${SLOT}" ]] ; then + elog "To switch $m to use php:${SLOT}, run" + elog " eselect php set $m php${SLOT}" + elog + fi + fi + done + + # Remove dead symlinks for SAPIs that were just disabled. For + # example, if the user has the cgi SAPI enabled, then he has an + # eselect-php symlink for it. If he later reinstalls PHP with + # USE="-cgi", that symlink will break. This call to eselect is + # supposed to remove that dead link per bug 572436. + eselect php cleanup || die + + if ! has "php${SLOT/./-}" ${PHP_TARGETS}; then + elog "To build extensions for this version of PHP, you will need to" + elog "add php${SLOT/./-} to your PHP_TARGETS USE_EXPAND variable." + elog + fi + + # Warn about the removal of PHP_INI_VERSION if the user has it set. + if [[ -n "${PHP_INI_VERSION}" ]]; then + ewarn 'The PHP_INI_VERSION variable has been phased out. You may' + ewarn 'remove it from your configuration at your convenience. See' + ewarn + ewarn ' https://bugs.gentoo.org/611214' + ewarn + ewarn 'for more information.' + fi + + elog "For details on how version slotting works, please see" + elog "the wiki:" + elog + elog " https://wiki.gentoo.org/wiki/PHP" + elog +} + +pkg_postrm() { + # This serves two purposes. First, if we have just removed the last + # installed version of PHP, then this will remove any dead symlinks + # belonging to eselect-php. Second, if a user upgrades slots from + # (say) 5.6 to 7.0 and depcleans the old slot, then this will update + # his existing symlinks to point to the new 7.0 installation. The + # latter is bug 432962. + # + # Note: the eselect-php package may not be installed at this point, + # so we can't die() if this command fails. + eselect php cleanup +}