From 774a7c3b2c7a5940a3ef389fa9b23f4974ec13d9 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 4 Apr 2015 10:41:20 +0200 Subject: php-pecl-lzf: add fix for PHP 7 --- php-lzf-php7.patch | 127 ++++++++++++++++++++++++++++++++++++++++++ php-lzf-rm-bundled-libs.patch | 2 +- php-pecl-lzf.spec | 68 ++++++++++++++-------- 3 files changed, 174 insertions(+), 23 deletions(-) create mode 100644 php-lzf-php7.patch diff --git a/php-lzf-php7.patch b/php-lzf-php7.patch new file mode 100644 index 0000000..1352983 --- /dev/null +++ b/php-lzf-php7.patch @@ -0,0 +1,127 @@ +--- pecl/lzf/trunk/filter.c 2015/04/04 06:53:08 336356 ++++ pecl/lzf/trunk/filter.c 2015/04/04 08:08:12 336357 +@@ -1,5 +1,6 @@ + #include "php.h" + #include "lzf.h" ++#include "php_lzf.h" + + #define LZF_BLOCKSIZE (1024 * 64 - 1) + +@@ -160,7 +161,7 @@ + int flags TSRMLS_DC) + { + size_t consumed = 0; +- php_lzf_filter_state *inst = (php_lzf_filter_state *) thisfilter->abstract; ++ php_lzf_filter_state *inst = (php_lzf_filter_state *) Z_PTR(thisfilter->abstract); + php_stream_filter_status_t exit_status = PSFS_FEED_ME; + php_stream_bucket *bucket = NULL; + +@@ -208,8 +209,8 @@ + { + assert(thisfilter->abstract != NULL); + +- php_lzf_filter_state_dtor((php_lzf_filter_state *) thisfilter->abstract TSRMLS_CC); +- pefree(thisfilter->abstract, ((php_lzf_filter_state *) thisfilter->abstract)->persistent); ++ php_lzf_filter_state_dtor((php_lzf_filter_state *) Z_PTR(thisfilter->abstract) TSRMLS_CC); ++ pefree(Z_PTR(thisfilter->abstract), ((php_lzf_filter_state *) Z_PTR(thisfilter->abstract))->persistent); + } + + static php_stream_filter_ops lzf_compress_ops = { +--- pecl/lzf/trunk/lzf.c 2015/04/04 06:53:08 336356 ++++ pecl/lzf/trunk/lzf.c 2015/04/04 08:08:12 336357 +@@ -41,7 +41,11 @@ + PHP_FE(lzf_compress, NULL) + PHP_FE(lzf_decompress, NULL) + PHP_FE(lzf_optimized_for, NULL) ++#ifdef PHP_FE_END ++ PHP_FE_END ++#else + {NULL, NULL, NULL} /* Must be the last line in lzf_functions[] */ ++#endif + }; + /* }}} */ + +@@ -75,6 +79,8 @@ + { + php_stream_filter_register_factory("lzf.compress", &php_lzf_compress_filter_factory TSRMLS_CC); + php_stream_filter_register_factory("lzf.decompress", &php_lzf_decompress_filter_factory TSRMLS_CC); ++ ++ return SUCCESS; + } + /* }}} */ + +@@ -84,6 +90,8 @@ + { + php_stream_filter_unregister_factory("lzf.compress" TSRMLS_CC); + php_stream_filter_unregister_factory("lzf.decompress" TSRMLS_CC); ++ ++ return SUCCESS; + } + /* }}} */ + +@@ -110,7 +118,7 @@ + PHP_FUNCTION(lzf_compress) + { + char *retval, *arg = NULL; +- int arg_len, result; ++ strsize_t arg_len, result; + + if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { + WRONG_PARAM_COUNT; +@@ -127,10 +135,10 @@ + RETURN_FALSE; + } + +- retval = erealloc(retval, result + 1); + retval[result] = 0; + +- RETURN_STRINGL(retval, result, 0); ++ _RETVAL_STRINGL(retval, result); ++ efree(retval); + } + /* }}} */ + +@@ -139,7 +147,7 @@ + PHP_FUNCTION(lzf_decompress) + { + char *arg = NULL; +- int arg_len, result, i = 1; ++ strsize_t arg_len, result, i = 1; + char *buffer; + size_t buffer_size = 1024; + +@@ -168,10 +176,10 @@ + RETURN_FALSE; + } + +- buffer = erealloc(buffer, result + 1); + buffer[result] = 0; + +- RETURN_STRINGL(buffer, result, 0); ++ _RETVAL_STRINGL(buffer, result); ++ efree(buffer); + } + /* }}} */ + +--- pecl/lzf/trunk/php_lzf.h 2015/04/04 06:53:08 336356 ++++ pecl/lzf/trunk/php_lzf.h 2015/04/04 08:08:12 336357 +@@ -49,6 +49,19 @@ + PHP_FUNCTION(lzf_decompress); + PHP_FUNCTION(lzf_optimized_for); + ++#if PHP_MAJOR_VERSION < 7 ++typedef long zend_long; ++typedef int strsize_t; ++#define _RETVAL_STRINGL(a,l) RETVAL_STRINGL(a,l,1) ++#define Z_PTR(p) (p) ++#else ++typedef size_t strsize_t; ++#define TSRMLS_C ++#define TSRMLS_CC ++#define TSRMLS_DC ++#define _RETVAL_STRINGL(a,l) RETVAL_STRINGL(a,l) ++#endif ++ + #endif /* PHP_LZF_H */ + + diff --git a/php-lzf-rm-bundled-libs.patch b/php-lzf-rm-bundled-libs.patch index 9c8cacc..36a2ef6 100644 --- a/php-lzf-rm-bundled-libs.patch +++ b/php-lzf-rm-bundled-libs.patch @@ -24,7 +24,7 @@ diff -ruN LZF-1.6.2.orig/config.m4 LZF-1.6.2/config.m4 + dnl + LIBNAME=lzf + LIBSYMBOL=lzf_decompress -+ PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, [PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LZF_DIR/lib, LZF_SHARED_LIBADD) AC_DEFINE(HAVE_LZFLIB,1,[ ])],[AC_MSG_ERROR([lzf libs not found])], []) ++ PHP_CHECK_LIBRARY($LIBNAME, $LIBSYMBOL, [PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LZF_DIR/$PHP_LIBDIR, LZF_SHARED_LIBADD) AC_DEFINE(HAVE_LZFLIB,1,[ ])],[AC_MSG_ERROR([lzf libs not found])], []) + PHP_SUBST(LZF_SHARED_LIBADD) + PHP_NEW_EXTENSION(lzf, lzf.c filter.c, $ext_shared) fi diff --git a/php-pecl-lzf.spec b/php-pecl-lzf.spec index 5c59dc8..9853eea 100644 --- a/php-pecl-lzf.spec +++ b/php-pecl-lzf.spec @@ -14,7 +14,7 @@ Name: %{?scl_prefix}php-pecl-lzf Version: 1.6.2 -Release: 10%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}.1 +Release: 11%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} Summary: Extension to handle LZF de/compression Group: Development/Languages License: PHP @@ -28,6 +28,9 @@ Source1: http://www.php.net/license/2_02.txt # remove bundled lzf libs Patch0: php-lzf-rm-bundled-libs.patch +# PHP 7 compatibility +# http://svn.php.net/viewvc?view=revision&revision=336357 +Patch1: php-lzf-php7.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: %{?scl_prefix}php-devel @@ -36,8 +39,6 @@ BuildRequires: liblzf-devel Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} Requires: %{?scl_prefix}php(api) = %{php_core_api} -Requires(post): %{__pecl} -Requires(postun): %{__pecl} %{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}} Provides: %{?scl_prefix}php-%{ext_name} = %{version} @@ -47,17 +48,17 @@ Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version} %if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} # Other third party repo stuff -Obsoletes: php53-pecl-%{ext_name} -Obsoletes: php53u-pecl-%{ext_name} -Obsoletes: php54-pecl-%{ext_name} -Obsoletes: php54w-pecl-%{ext_name} +Obsoletes: php53-pecl-%{ext_name} <= %{version} +Obsoletes: php53u-pecl-%{ext_name} <= %{version} +Obsoletes: php54-pecl-%{ext_name} <= %{version} +Obsoletes: php54w-pecl-%{ext_name} <= %{version} %if "%{php_version}" > "5.5" -Obsoletes: php55u-pecl-%{ext_name} -Obsoletes: php55w-pecl-%{ext_name} +Obsoletes: php55u-pecl-%{ext_name} <= %{version} +Obsoletes: php55w-pecl-%{ext_name} <= %{version} %endif %if "%{php_version}" > "5.6" -Obsoletes: php56u-pecl-%{ext_name} -Obsoletes: php56w-pecl-%{ext_name} +Obsoletes: php56u-pecl-%{ext_name} <= %{version} +Obsoletes: php56w-pecl-%{ext_name} <= %{version} %endif %endif @@ -75,13 +76,19 @@ library LZF is a very fast compression algorithm, ideal for saving space with a slight speed cost. +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection}. + %prep %setup -c -q +# Don't install/register tests +sed -e 's/role="test"/role="src"/' -i package.xml + mv %{pecl_name}-%{version} NTS cd NTS %patch0 -p1 -b liblzf +%patch1 -p3 -b .php7 rm -f lzf_c.c lzf_d.c lzf.h cp %{SOURCE1} LICENSE @@ -134,12 +141,9 @@ make install -C ZTS INSTALL_ROOT=%{buildroot} install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name} %endif -# Test & Documentation +# Documentation cd NTS -for i in $(grep 'role="test"' ../package.xml | sed -e 's/^.*name="//;s/".*$//') -do install -Dpm 644 $i %{buildroot}%{pecl_testdir}/%{pecl_name}/$i -done -for i in LICENSE $(grep 'role="doc"' ../package.xml | sed -e 's/^.*name="//;s/".*$//') +for i in $(grep 'role="doc"' ../package.xml | sed -e 's/^.*name="//;s/".*$//') do install -Dpm 644 $i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i done @@ -178,23 +182,37 @@ NO_INTERACTION=1 \ rm -rf %{buildroot} -%post -%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : +# Don't install/register tests +sed -e 's/role="test"/role="src"/' -i package.xml +# when pear installed alone, after us +%triggerin -- %{?scl_prefix}php-pear +if [ -x %{__pecl} ] ; then + %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : +fi + +# posttrans as pear can be installed after us +%posttrans +if [ -x %{__pecl} ] ; then + %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : +fi %postun -if [ $1 -eq 0 ] ; then - %{pecl_uninstall} %{pecl_name} >/dev/null || : +if [ $1 -eq 0 -a -x %{__pecl} ] ; then + %{pecl_uninstall} %{pecl_name} >/dev/null || : fi %files %defattr(-,root,root,-) +%{!?_licensedir:%global license %%doc} +%license NTS/LICENSE %doc %{pecl_docdir}/%{pecl_name} -%doc %{pecl_testdir}/%{pecl_name} +%{pecl_xmldir}/%{name}.xml + %config(noreplace) %{php_inidir}/%{ini_name} %{php_extdir}/%{ext_name}.so -%{pecl_xmldir}/%{name}.xml + %if %{with_zts} %config(noreplace) %{php_ztsinidir}/%{ini_name} %{php_ztsextdir}/%{ext_name}.so @@ -202,6 +220,12 @@ fi %changelog +* Sat Apr 4 2015 Remi Collet - 1.6.2-11 +- add upstream fix for PHP 7 +- fix license handling +- don't install/register tests +- drop runtime dependency on pear, new scriptlets + * Wed Dec 24 2014 Remi Collet - 1.6.2-10.1 - Fedora 21 SCL mass rebuild -- cgit