summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--php-pecl-ssdeep.spec69
-rw-r--r--ssdeep-php7.patch100
2 files changed, 149 insertions, 20 deletions
diff --git a/php-pecl-ssdeep.spec b/php-pecl-ssdeep.spec
index 57eb46d..9704947 100644
--- a/php-pecl-ssdeep.spec
+++ b/php-pecl-ssdeep.spec
@@ -23,19 +23,19 @@
Summary: Wrapper for libfuzzy library
Name: %{?scl_prefix}php-pecl-%{pecl_name}
Version: 1.0.4
-Release: 3%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}.1
+Release: 4%{?dist}%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}
License: BSD
Group: Development/Languages
URL: http://pecl.php.net/package/%{pecl_name}
Source0: http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
+Patch0: %{pecl_name}-php7.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: %{?scl_prefix}php-devel > 5.2
BuildRequires: %{?scl_prefix}php-pear
BuildRequires: ssdeep-devel > 2.5
-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}}
@@ -47,17 +47,21 @@ Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version}
%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1}
# Other third party repo stuff
-Obsoletes: php53-pecl-%{pecl_name}
-Obsoletes: php53u-pecl-%{pecl_name}
-Obsoletes: php54-pecl-%{pecl_name}
-Obsoletes: php54w-pecl-%{pecl_name}
+Obsoletes: php53-pecl-%{pecl_name} <= %{version}
+Obsoletes: php53u-pecl-%{pecl_name} <= %{version}
+Obsoletes: php54-pecl-%{pecl_name} <= %{version}
+Obsoletes: php54w-pecl-%{pecl_name} <= %{version}
%if "%{php_version}" > "5.5"
-Obsoletes: php55u-pecl-%{pecl_name}
-Obsoletes: php55w-pecl-%{pecl_name}
+Obsoletes: php55u-pecl-%{pecl_name} <= %{version}
+Obsoletes: php55w-pecl-%{pecl_name} <= %{version}
%endif
%if "%{php_version}" > "5.6"
-Obsoletes: php56u-pecl-%{pecl_name}
-Obsoletes: php56w-pecl-%{pecl_name}
+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
@@ -84,11 +88,27 @@ This extensions wraps the ssdeep fuzzy hashing API created by Jesse Kornblum.
Documentation: http://php.net/ssdeep
+Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection}.
+
%prep
%setup -q -c
mv %{pecl_name}-%{version} NTS
+# Don't install/register tests
+sed -e 's/role="test"/role="src"/' -i package.xml
+
+pushd NTS
+%patch0 -p1 -b .php7
+
+# Sanity check, really often broken
+extver=$(sed -n '/# *define PHP_SSDEEP_VERSION/{s/.* "//;s/".*$//;p}' php_ssdeep.h)
+if test "x${extver}" != "x%{version}%{?versuf}"; then
+ : Error: Upstream extension version is ${extver}, expecting %{version}%{?versuf}.
+ exit 1
+fi
+popd
+
%if %{with_zts}
# Duplicate source tree for NTS / ZTS build
cp -pr NTS ZTS
@@ -138,23 +158,27 @@ make -C ZTS install INSTALL_ROOT=%{buildroot}
install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name}
%endif
-# Test & Documentation
-for i in $(grep 'role="test"' package.xml | sed -e 's/^.*name="//;s/".*$//')
-do install -Dpm 644 NTS/$i %{buildroot}%{pecl_testdir}/%{pecl_name}/$i
- sed -e 's/\r//' -i %{buildroot}%{pecl_testdir}/%{pecl_name}/$i
-done
+# Documentation
for i in $(grep 'role="doc"' package.xml | sed -e 's/^.*name="//;s/".*$//')
do install -Dpm 644 NTS/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i
sed -e 's/\r//' -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
@@ -195,8 +219,8 @@ 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
@@ -208,6 +232,11 @@ rm -rf %{buildroot}
%changelog
+* Mon Apr 6 2015 Remi Collet <remi@fedoraproject.org> - 1.0.4-4
+- add fix for PHP 7
+- drop runtime dependency on pear, new scriptlets
+- don't install/register tests
+
* Wed Dec 24 2014 Remi Collet <remi@fedoraproject.org> - 1.0.4-3.1
- Fedora 21 SCL mass rebuild
diff --git a/ssdeep-php7.patch b/ssdeep-php7.patch
new file mode 100644
index 0000000..05dbd4e
--- /dev/null
+++ b/ssdeep-php7.patch
@@ -0,0 +1,100 @@
+From c62cadc78de1ee69ca3643441477b779d0a817e4 Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@php.net>
+Date: Mon, 6 Apr 2015 10:30:12 +0200
+Subject: [PATCH] PHP 7 compatibility
+
+---
+ php_ssdeep.h | 9 +++++++++
+ ssdeep.c | 22 +++++++++++++---------
+ 2 files changed, 22 insertions(+), 9 deletions(-)
+
+diff --git a/php_ssdeep.h b/php_ssdeep.h
+index 5deaa40..9a88de0 100644
+--- a/php_ssdeep.h
++++ b/php_ssdeep.h
+@@ -47,4 +47,13 @@
+
+ extern zend_module_entry php_ssdeep_module_entry;
+ # define phpext_php_ssdeep_ptr &php_ssdeep_module_entry
++
++#if PHP_MAJOR_VERSION < 7
++typedef int strsize_t;
++#define _RETURN_STRING(s) RETURN_STRING(s, 0);
++#else
++typedef size_t strsize_t;
++#define _RETURN_STRING(s) { RETVAL_STRING(s); efree(s); return; }
++#endif
++
+ #endif
+diff --git a/ssdeep.c b/ssdeep.c
+index 3cae212..81f4e07 100644
+--- a/ssdeep.c
++++ b/ssdeep.c
+@@ -67,8 +67,12 @@ ZEND_END_ARG_INFO()
+ const zend_function_entry ssdeep_functions[] = {
+ PHP_FE(ssdeep_fuzzy_hash, arginfo_ssdeep_fuzzy_hash)
+ PHP_FE(ssdeep_fuzzy_hash_filename, arginfo_ssdeep_fuzzy_hash_filename)
+- PHP_FE(ssdeep_fuzzy_compare, arginfo_ssdeep_fuzzy_compare) {
+- NULL, NULL, NULL} /* Must be the last line in ssdeep_functions[] */
++ PHP_FE(ssdeep_fuzzy_compare, arginfo_ssdeep_fuzzy_compare)
++#ifdef PHP_FE_END
++ PHP_FE_END
++#else
++ { NULL, NULL, NULL } /* Must be the last line in ssdeep_functions[] */
++#endif
+ };
+ /* }}} */
+
+@@ -101,16 +105,16 @@ PHP_MINFO_FUNCTION(ssdeep) {
+ PHP_FUNCTION(ssdeep_fuzzy_hash) {
+ char *hash = (char *) emalloc(FUZZY_MAX_RESULT);
+ char *to_hash;
+- int to_hash_len;
++ strsize_t to_hash_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &to_hash, &to_hash_len) == FAILURE) {
+ RETURN_NULL();
+ }
+
+- if (0 != fuzzy_hash_buf((unsigned char *) to_hash, to_hash_len, hash)) {
++ if (0 != fuzzy_hash_buf((unsigned char *) to_hash, (uint32_t)to_hash_len, hash)) {
+ RETURN_FALSE;
+ } else {
+- RETURN_STRING(hash, 0);
++ _RETURN_STRING(hash);
+ }
+ }
+ /* }}} */
+@@ -120,7 +124,7 @@ PHP_FUNCTION(ssdeep_fuzzy_hash) {
+ PHP_FUNCTION(ssdeep_fuzzy_hash_filename) {
+ char *hash = (char *) emalloc(FUZZY_MAX_RESULT);
+ char *file_name;
+- int file_name_len;
++ strsize_t file_name_len;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &file_name, &file_name_len) == FAILURE) {
+ RETURN_NULL();
+@@ -129,7 +133,7 @@ PHP_FUNCTION(ssdeep_fuzzy_hash_filename) {
+ if (0 != fuzzy_hash_filename(file_name, hash)) {
+ RETURN_FALSE;
+ } else {
+- RETURN_STRING(hash, 0);
++ _RETURN_STRING(hash);
+ }
+ }
+ /* }}} */
+@@ -138,9 +142,9 @@ PHP_FUNCTION(ssdeep_fuzzy_hash_filename) {
+ */
+ PHP_FUNCTION(ssdeep_fuzzy_compare) {
+ char *signature1 = NULL;
+- int signature1_len;
++ strsize_t signature1_len;
+ char *signature2 = NULL;
+- int signature2_len;
++ strsize_t signature2_len;
+ int match;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &signature1, &signature1_len, &signature2, &signature2_len) == FAILURE) {
+--
+2.1.0
+