From ce0cf2d1cc78c1793209add4bc5104844df6cdf5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 6 Apr 2015 19:15:00 +0200 Subject: php-pecl-xattr: add fix for PHP 7 --- 3_0.txt | 68 ---------------- 3_01.txt | 68 ++++++++++++++++ REFLECTION | 31 +++++++- php-pecl-xattr.spec | 47 ++++++++--- xattr-php7.patch | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 355 insertions(+), 81 deletions(-) delete mode 100644 3_0.txt create mode 100644 3_01.txt create mode 100644 xattr-php7.patch diff --git a/3_0.txt b/3_0.txt deleted file mode 100644 index 6c1c170..0000000 --- a/3_0.txt +++ /dev/null @@ -1,68 +0,0 @@ --------------------------------------------------------------------- - The PHP License, version 3.0 -Copyright (c) 1999 - 2006 The PHP Group. All rights reserved. --------------------------------------------------------------------- - -Redistribution and use in source and binary forms, with or without -modification, is permitted provided that the following conditions -are met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. The name "PHP" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact group@php.net. - - 4. Products derived from this software may not be called "PHP", nor - may "PHP" appear in their name, without prior written permission - from group@php.net. You may indicate that your software works in - conjunction with PHP by saying "Foo for PHP" instead of calling - it "PHP Foo" or "phpfoo" - - 5. The PHP Group may publish revised and/or new versions of the - license from time to time. Each version will be given a - distinguishing version number. - Once covered code has been published under a particular version - of the license, you may always continue to use it under the terms - of that version. You may also choose to use such covered code - under the terms of any subsequent version of the license - published by the PHP Group. No one other than the PHP Group has - the right to modify the terms applicable to covered code created - under this License. - - 6. Redistributions of any form whatsoever must retain the following - acknowledgment: - "This product includes PHP, freely available from - ". - -THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND -ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP -DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------- - -This software consists of voluntary contributions made by many -individuals on behalf of the PHP Group. - -The PHP Group can be contacted via Email at group@php.net. - -For more information on the PHP Group and the PHP project, -please see . - -This product includes the Zend Engine, freely available at -. diff --git a/3_01.txt b/3_01.txt new file mode 100644 index 0000000..6059c80 --- /dev/null +++ b/3_01.txt @@ -0,0 +1,68 @@ +-------------------------------------------------------------------- + The PHP License, version 3.01 +Copyright (c) 1999 - 2014 The PHP Group. All rights reserved. +-------------------------------------------------------------------- + +Redistribution and use in source and binary forms, with or without +modification, is permitted provided that the following conditions +are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. The name "PHP" must not be used to endorse or promote products + derived from this software without prior written permission. For + written permission, please contact group@php.net. + + 4. Products derived from this software may not be called "PHP", nor + may "PHP" appear in their name, without prior written permission + from group@php.net. You may indicate that your software works in + conjunction with PHP by saying "Foo for PHP" instead of calling + it "PHP Foo" or "phpfoo" + + 5. The PHP Group may publish revised and/or new versions of the + license from time to time. Each version will be given a + distinguishing version number. + Once covered code has been published under a particular version + of the license, you may always continue to use it under the terms + of that version. You may also choose to use such covered code + under the terms of any subsequent version of the license + published by the PHP Group. No one other than the PHP Group has + the right to modify the terms applicable to covered code created + under this License. + + 6. Redistributions of any form whatsoever must retain the following + acknowledgment: + "This product includes PHP software, freely available from + ". + +THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND +ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP +DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +-------------------------------------------------------------------- + +This software consists of voluntary contributions made by many +individuals on behalf of the PHP Group. + +The PHP Group can be contacted via Email at group@php.net. + +For more information on the PHP Group and the PHP project, +please see . + +PHP includes the Zend Engine, freely available at +. diff --git a/REFLECTION b/REFLECTION index d8bfcf5..04043af 100644 --- a/REFLECTION +++ b/REFLECTION @@ -1,4 +1,4 @@ -Extension [ extension #142 xattr version 1.2.0 ] { +Extension [ extension #86 xattr version 1.2.0 ] { - Constants [4] { Constant [ integer XATTR_ROOT ] { 2 } @@ -9,14 +9,43 @@ Extension [ extension #142 xattr version 1.2.0 ] { - Functions { Function [ function xattr_set ] { + + - Parameters [4] { + Parameter #0 [ $path ] + Parameter #1 [ $name ] + Parameter #2 [ $value ] + Parameter #3 [ $flags ] + } } Function [ function xattr_get ] { + + - Parameters [3] { + Parameter #0 [ $path ] + Parameter #1 [ $name ] + Parameter #2 [ $flags ] + } } Function [ function xattr_remove ] { + + - Parameters [3] { + Parameter #0 [ $path ] + Parameter #1 [ $name ] + Parameter #2 [ $flags ] + } } Function [ function xattr_list ] { + + - Parameters [2] { + Parameter #0 [ $path ] + Parameter #1 [ $flags ] + } } Function [ function xattr_supported ] { + + - Parameters [2] { + Parameter #0 [ $path ] + Parameter #1 [ $flags ] + } } } } diff --git a/php-pecl-xattr.spec b/php-pecl-xattr.spec index a99eedf..8e30313 100644 --- a/php-pecl-xattr.spec +++ b/php-pecl-xattr.spec @@ -22,7 +22,7 @@ Summary: Extended attributes Name: %{?scl_prefix}php-pecl-%{pecl_name} Version: 1.2.0 -Release: 5%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}.1 +Release: 6%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')} License: PHP Group: Development/Languages URL: http://pecl.php.net/package/%{pecl_name} @@ -30,15 +30,15 @@ Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz # https://bugs.php.net/65842 Please Provides LICENSE file # URL from xattr.c headers -Source1: http://www.php.net/license/3_0.txt +Source1: http://www.php.net/license/3_01.txt + +Patch0: %{pecl_name}-php7.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: %{?scl_prefix}php-devel BuildRequires: %{?scl_prefix}php-pear BuildRequires: libattr-devel -Requires(post): %{__pecl} -Requires(postun): %{__pecl} Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} Requires: %{?scl_prefix}php(api) = %{php_core_api} %{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}} @@ -62,6 +62,10 @@ Obsoletes: php55w-pecl-%{pecl_name} <= %{version} Obsoletes: php56u-pecl-%{pecl_name} <= %{version} Obsoletes: php56w-pecl-%{pecl_name} <= %{version} %endif +%if "%{php_version}" > "7.0" +Obsoletes: php70u-pecl-%{pecl_name} <= %{version} +Obsoletes: php70w-pecl-%{pecl_name} <= %{version} +%endif %endif %if 0%{?fedora} < 20 && 0%{?rhel} < 7 @@ -75,13 +79,21 @@ Obsoletes: php56w-pecl-%{pecl_name} <= %{version} This package allows to manipulate extended attributes on filesystems that support them. Requires libattr from Linux XFS project. +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection}. + %prep %setup -q -c + +# Don't install/register tests +sed -e 's/role="test"/role="src"/' -i package.xml + + mv %{pecl_name}-%{version} NTS cd NTS cp %{SOURCE1} LICENSE +%patch0 -p3 -b .php7 # http://svn.php.net/viewvc?view=revision&revision=331704 sed -e 's:/lib:/$PHP_LIBDIR:' -i config.m4 @@ -142,22 +154,27 @@ make -C ZTS install 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/".*$//') do install -Dpm 644 $i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i done -%post -%{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : +# 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 +if [ $1 -eq 0 -a -x %{__pecl} ] ; then %{pecl_uninstall} %{pecl_name} >/dev/null || : fi @@ -182,9 +199,10 @@ rm -rf %{buildroot} %files %defattr(-,root,root,-) +%{?_licensedir:%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}/%{pecl_name}.so @@ -195,6 +213,11 @@ rm -rf %{buildroot} %changelog +* Mon Apr 6 2015 Remi Collet - 1.2.0-6 +- add fix for PHP-7 +- drop runtime dependency on pear, new scriptlets +- don't install/register tests + * Wed Dec 24 2014 Remi Collet - 1.2.0-5.1 - Fedora 21 SCL mass rebuild diff --git a/xattr-php7.patch b/xattr-php7.patch new file mode 100644 index 0000000..fbd2285 --- /dev/null +++ b/xattr-php7.patch @@ -0,0 +1,222 @@ +--- pecl/xattr/trunk/php_xattr.h 2015/04/06 16:58:20 336402 ++++ pecl/xattr/trunk/php_xattr.h 2015/04/06 17:01:25 336403 +@@ -1,13 +1,13 @@ + /* + +----------------------------------------------------------------------+ +- | PHP Version 5 | ++ | PHP Version 5, 7 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2004 The PHP Group | ++ | Copyright (c) 1997-2015 The PHP Group | + +----------------------------------------------------------------------+ +- | This source file is subject to version 3.0 of the PHP license, | ++ | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | +- | http://www.php.net/license/3_0.txt. | ++ | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | +@@ -45,6 +45,17 @@ + PHP_FUNCTION(xattr_list); + PHP_FUNCTION(xattr_supported); + ++#if PHP_MAJOR_VERSION < 7 ++typedef long zend_long; ++typedef int strsize_t; ++#define _RETVAL_STRINGL(s,l,d) RETVAL_STRINGL(s,l,d) ++#define _RETURN_STRINGL(s,l,d) RETURN_STRINGL(s,l,d) ++#else ++typedef size_t strsize_t; ++#define _RETVAL_STRINGL(s,l,d) { RETVAL_STRINGL(s,l); if (!d) efree(s); } ++#define _RETURN_STRINGL(s,l,d) { _RETVAL_STRINGL(s,l,d); return; } ++#endif ++ + #endif /* PHP_XATTR_H */ + + +--- pecl/xattr/trunk/xattr.c 2015/04/06 16:58:20 336402 ++++ pecl/xattr/trunk/xattr.c 2015/04/06 17:01:25 336403 +@@ -1,13 +1,13 @@ + /* + +----------------------------------------------------------------------+ +- | PHP Version 5 | ++ | PHP Version 5, 7 | + +----------------------------------------------------------------------+ +- | Copyright (c) 1997-2004 The PHP Group | ++ | Copyright (c) 1997-2015 The PHP Group | + +----------------------------------------------------------------------+ +- | This source file is subject to version 3.0 of the PHP license, | ++ | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | +- | http://www.php.net/license/3_0.txt. | ++ | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | +@@ -43,17 +43,39 @@ + #include + #include + ++ZEND_BEGIN_ARG_INFO_EX(xattr_set_arginfo, 0, 0, 3) ++ ZEND_ARG_INFO(0, path) ++ ZEND_ARG_INFO(0, name) ++ ZEND_ARG_INFO(0, value) ++ ZEND_ARG_INFO(0, flags) ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_INFO_EX(xattr_get_arginfo, 0, 0, 2) ++ ZEND_ARG_INFO(0, path) ++ ZEND_ARG_INFO(0, name) ++ ZEND_ARG_INFO(0, flags) ++ZEND_END_ARG_INFO() ++ ++ZEND_BEGIN_ARG_INFO_EX(xattr_list_arginfo, 0, 0, 1) ++ ZEND_ARG_INFO(0, path) ++ ZEND_ARG_INFO(0, flags) ++ZEND_END_ARG_INFO() ++ + /* {{{ xattr_functions[] + * + * Every user visible function must have an entry in xattr_functions[]. + */ + zend_function_entry xattr_functions[] = { +- PHP_FE(xattr_set, NULL) +- PHP_FE(xattr_get, NULL) +- PHP_FE(xattr_remove, NULL) +- PHP_FE(xattr_list, NULL) +- PHP_FE(xattr_supported, NULL) +- {NULL, NULL, NULL} /* Must be the last line in xattr_functions[] */ ++ PHP_FE(xattr_set, xattr_set_arginfo) ++ PHP_FE(xattr_get, xattr_get_arginfo) ++ PHP_FE(xattr_remove, xattr_get_arginfo) ++ PHP_FE(xattr_list, xattr_list_arginfo) ++ PHP_FE(xattr_supported, xattr_list_arginfo) ++#ifdef PHP_FE_END ++ PHP_FE_END ++#else ++ { NULL, NULL, NULL } ++#endif + }; + /* }}} */ + +@@ -112,7 +134,9 @@ + char *attr_name = NULL; + char *attr_value = NULL; + char *path = NULL; +- int error, tmp, value_len, flags = 0; ++ int error; ++ zend_long flags = 0; ++ strsize_t tmp, value_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|l", &path, &tmp, &attr_name, &tmp, &attr_value, &value_len, &flags) == FAILURE) { + return; +@@ -131,7 +155,7 @@ + flags &= ATTR_ROOT | ATTR_DONTFOLLOW | ATTR_CREATE | ATTR_REPLACE; + + /* Attempt to set an attribute, warn if failed. */ +- error = attr_set(path, attr_name, attr_value, value_len, flags); ++ error = attr_set(path, attr_name, attr_value, (int)value_len, (int)flags); + if (error == -1) { + switch (errno) { + case E2BIG: +@@ -164,8 +188,10 @@ + char *attr_name = NULL; + char *attr_value = NULL; + char *path = NULL; +- int error, tmp, flags = 0; +- size_t buffer_size = XATTR_BUFFER_SIZE; ++ int error; ++ strsize_t tmp; ++ zend_long flags = 0; ++ int buffer_size = XATTR_BUFFER_SIZE; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) { + return; +@@ -192,7 +218,7 @@ + * If buffer is too small then attr_get sets errno to E2BIG and tells us + * how many bytes are required by setting buffer_size variable. + */ +- error = attr_get(path, attr_name, attr_value, &buffer_size, flags); ++ error = attr_get(path, attr_name, attr_value, &buffer_size, (int)flags); + + /* + * Loop is necessary in case that someone edited extended attributes +@@ -203,13 +229,14 @@ + if (!attr_value) + RETURN_FALSE; + +- error = attr_get(path, attr_name, attr_value, &buffer_size, flags); ++ error = attr_get(path, attr_name, attr_value, &buffer_size, (int)flags); + } + + /* Return a string if everything is ok */ + if (!error) { +- attr_value = erealloc(attr_value, buffer_size); +- RETURN_STRINGL(attr_value, buffer_size, 0); ++ _RETVAL_STRINGL(attr_value, buffer_size, 1); /* copy + free instead of realloc */ ++ efree(attr_value); ++ return; + } + + /* Error handling part */ +@@ -240,8 +267,10 @@ + Checks if filesystem supports extended attributes */ + PHP_FUNCTION(xattr_supported) + { +- char *buffer, *path = NULL; +- int error, tmp, flags = 0; ++ char *buffer="", *path = NULL; ++ int error; ++ strsize_t tmp; ++ zend_long flags = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &tmp, &flags) == FAILURE) { + return; +@@ -290,7 +319,9 @@ + { + char *attr_name = NULL; + char *path = NULL; +- int error, tmp, flags = 0; ++ int error; ++ strsize_t tmp; ++ zend_long flags = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|l", &path, &tmp, &attr_name, &tmp, &flags) == FAILURE) { + return; +@@ -309,7 +340,7 @@ + flags &= ATTR_ROOT | ATTR_DONTFOLLOW; + + /* Attempt to remove an attribute, warn if failed. */ +- error = attr_remove(path, attr_name, flags); ++ error = attr_remove(path, attr_name, (int)flags); + if (error == -1) { + switch (errno) { + case E2BIG: +@@ -341,8 +372,10 @@ + { + char *buffer, *path = NULL; + char *p, *prefix; +- int error, tmp, flags = 0; +- ssize_t i = 0, buffer_size = XATTR_BUFFER_SIZE; ++ int error; ++ strsize_t tmp; ++ zend_long flags = 0; ++ size_t i = 0, buffer_size = XATTR_BUFFER_SIZE; + size_t len, prefix_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &path, &tmp, &flags) == FAILURE) { +@@ -442,7 +475,11 @@ + while (i != buffer_size) { + len = strlen(p) + 1; /* +1 for NULL */ + if (strstr(p, prefix) == p) { ++#if PHP_MAJOR_VERSION < 7 + add_next_index_stringl(return_value, p + prefix_len, len - 1 - prefix_len, 1); ++#else ++ add_next_index_stringl(return_value, p + prefix_len, len - 1 - prefix_len); ++#endif + } + + p += len; -- cgit