[php-pecl-memcache] - Update to 3.0.8 - enable conditional ZTS extension build

Remi Collet remi at fedoraproject.org
Mon Apr 8 09:08:51 UTC 2013


commit 7643fb06091940910a89b3e85686c6664ae9a19e
Author: Remi Collet <remi at fedoraproject.org>
Date:   Mon Apr 8 11:08:36 2013 +0200

    - Update to 3.0.8
    - enable conditional ZTS extension build

 .gitignore                                    |    2 +
 LICENSE                                       |   68 ---------------
 connect.inc                                   |   97 ++++++++++++++++++++++
 php-pecl-memcache-3.0.5-get-mem-corrupt.patch |   89 --------------------
 php-pecl-memcache-3.0.7-bug59602.patch        |   13 ---
 php-pecl-memcache.spec                        |  110 +++++++++++++++++++------
 sources                                       |    2 +-
 7 files changed, 184 insertions(+), 197 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 671f4f1..cb0db0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+clog
 *spec~
 /memcache-3.0.6.tgz
 /memcache-3.0.7.tgz
+/memcache-3.0.8.tgz
diff --git a/connect.inc b/connect.inc
new file mode 100644
index 0000000..96d2875
--- /dev/null
+++ b/connect.inc
@@ -0,0 +1,97 @@
+<?php
+
+if (!extension_loaded("memcache")) {
+	die("skip");
+}
+
+error_reporting(E_ALL);
+
+/*
+* Please change host & port to match your configuration 
+*/
+
+$host = "localhost";
+$port = 11211;
+$udpPort = 11211;
+
+$host2 = "localhost";
+$port2 = 11212;
+$udpPort2 = 11212;
+
+//ini_set('memcache.hash_strategy', 'standard');
+//ini_set('memcache.hash_function', 'fnv');
+//ini_set('memcache.protocol', 'binary');
+
+if (ini_get('memcache.protocol') == 'binary') {
+	$udpPort = 0;
+	$udpPort2 = 0;
+}
+
+/* Start a server listening to a unix domain socket
+ *
+ * mkdir /var/run/memcached
+ * chown memcached:memcached /var/run/memcached
+ * memcached -d -u memcached -s /var/run/memcached/memcached.sock
+ * chmod a+w /var/run/memcached/memcached.sock
+ */
+$domainsocket = 'unix:///var/run/memcached/memcached.sock';
+
+// A server which is guaranteed to fail immediatly
+$nonExistingHost = "localhost";
+$nonExistingPort = 11213;
+
+// A server which times out when attempting to connect to
+$unreachableHost = '10.254.254.254';
+$unreachablePort = 11211;
+
+$udpPacketSize = 1400;
+
+$balanceKeys = array(
+	'consistent'	=> array(
+			'crc32'		=> array('key1_abc', 'key2_abcde'),
+			'fnv'		=> array('key1_a', 'key2_2534534'),
+			),
+	'standard'		=> array(
+			'crc32'		=> array('load_test_key1', 'load_test_key2'),
+			'fnv'		=> array('key1_ab', 'key2_a'),
+			),
+	);
+
+$strat = strtolower(ini_get('memcache.hash_strategy'));
+$func = strtolower(ini_get('memcache.hash_function'));
+list ($balanceKey1, $balanceKey2) = $balanceKeys[$strat][$func];
+
+if (!isset($udpPort))
+	$udpPort = 0;
+if (!isset($udpPort2))
+	$udpPort2 = 0;
+
+$memcache = memcache_connect($host, $port);
+
+function test_connect1() {
+	global $host, $port, $udpPort;
+	$memcache = new MemcachePool();
+	$memcache->connect($host, $port, isset($udpPort) ? $udpPort : 0);
+	return $memcache;
+}
+
+function test_connect2() {
+	global $host2, $port2, $udpPort2;
+	$memcache = new MemcachePool();
+	$memcache->connect($host2, $port2, isset($udpPort2) ? $udpPort2 : 0);
+	return $memcache;
+}
+
+function test_connect_pool() {
+	global $host, $port, $udpPort, $host2, $port2, $udpPort2;
+	$memcache = new MemcachePool();
+	$memcache->addServer($host, $port, isset($udpPort) ? $udpPort : 0);
+	$memcache->addServer($host2, $port2, isset($udpPort2) ? $udpPort2 : 0);
+	return $memcache;
+}
+
+if (!$memcache) {
+	die('skip Connection to memcached failed');
+}
+
+?>
diff --git a/php-pecl-memcache.spec b/php-pecl-memcache.spec
index ffdad3b..abf6377 100644
--- a/php-pecl-memcache.spec
+++ b/php-pecl-memcache.spec
@@ -1,31 +1,32 @@
+%{!?php_inidir: %{expand: %%global php_inidir %{_sysconfdir}/php.d}}
+%{!?__php:      %{expand: %%global __php      %{_bindir}/php}}
 %{!?__pecl:     %{expand: %%global __pecl     %{_bindir}/pecl}}
 
+%global with_zts  0%{?__ztsphp:1}
 %global pecl_name memcache
+# Not ready, some failed UDP tests. Neded investigation.
+%global with_tests %{?_with_tests:1}%{!?_with_tests:0}
 
 Summary:      Extension to work with the Memcached caching daemon
 Name:         php-pecl-memcache
-Version:      3.0.7
-Release:      7%{?dist}
+Version:      3.0.8
+Release:      1%{?dist}
 License:      PHP
 Group:        Development/Languages
 URL:          http://pecl.php.net/package/%{pecl_name}
 
 Source:       http://pecl.php.net/get/%{pecl_name}-%{version}.tgz
 Source2:      xml2changelog
-# https://bugs.php.net/63141
-Source3:      LICENSE
-
-# https://bugs.php.net/63142
-# http://svn.php.net/viewvc?view=revision&revision=327754
-Patch1:       %{name}-3.0.5-get-mem-corrupt.patch
-
-# https://bugs.php.net/59602
-# http://svn.php.net/viewvc?view=revision&revision=328202
-Patch2:       %{name}-3.0.7-bug59602.patch
+# Missing in official archive
+# http://svn.php.net/viewvc/pecl/memcache/branches/NON_BLOCKING_IO/tests/connect.inc?view=co
+Source3:      connect.inc
 
 BuildRequires: php-devel
 BuildRequires: php-pear
 BuildRequires: zlib-devel
+%if %{with_tests}
+BuildRequires: memcached
+%endif
 
 Requires(post): %{__pecl}
 Requires(postun): %{__pecl}
@@ -57,8 +58,6 @@ Memcache can be used as a PHP session handler.
 %setup -c -q
 
 pushd %{pecl_name}-%{version}
-%patch1 -p1 -b .get-mem-corrupt.patch
-%patch2 -p4 -b .bug54602
 
 # Chech version as upstream often forget to update this
 extver=$(sed -n '/#define PHP_MEMCACHE_VERSION/{s/.* "//;s/".*$//;p}' php_memcache.h)
@@ -69,9 +68,7 @@ if test "x${extver}" != "x%{version}"; then
 fi
 popd
 
-%{_bindir}/php %{SOURCE2} package.xml | tee CHANGELOG | head -n 5
-
-cp -p %{SOURCE3} .
+%{__php} %{SOURCE2} package.xml | tee CHANGELOG | head -n 8
 
 cat >%{pecl_name}.ini << 'EOF'
 ; ----- Enable %{pecl_name} extension module
@@ -115,12 +112,23 @@ extension=%{pecl_name}.so
 ;session.save_path="tcp://localhost:11211?persistent=1&weight=1&timeout=1&retry_interval=15"
 EOF
 
+%if %{with_zts}
+cp -r %{pecl_name}-%{version} %{pecl_name}-%{version}-zts
+%endif
+
 
 %build
 cd %{pecl_name}-%{version}
-phpize
-%configure
+%{_bindir}/phpize
+%configure --with-php-config=%{_bindir}/php-config
+make %{?_smp_mflags}
+
+%if %{with_zts}
+cd ../%{pecl_name}-%{version}-zts
+%{_bindir}/zts-phpize
+%configure --with-php-config=%{_bindir}/zts-php-config
 make %{?_smp_mflags}
+%endif
 
 
 %install
@@ -128,19 +136,59 @@ make -C %{pecl_name}-%{version} \
      install INSTALL_ROOT=%{buildroot}
 
 # Drop in the bit of configuration
-install -D -m 644 %{pecl_name}.ini %{buildroot}%{_sysconfdir}/php.d/%{pecl_name}.ini
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_inidir}/%{pecl_name}.ini
+
+%if %{with_zts}
+make -C %{pecl_name}-%{version}-zts \
+     install INSTALL_ROOT=%{buildroot}
+
+install -D -m 644 %{pecl_name}.ini %{buildroot}%{php_ztsinidir}/%{pecl_name}.ini
+%endif
 
 # Install XML package description
 install -Dpm 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml
 
 
 %check
-cd %{pecl_name}-%{version}
 # simple module load test
-%{_bindir}/php --no-php-ini \
-    --define extension_dir=%{buildroot}%{php_extdir} \
+%{__php} --no-php-ini \
+    --define extension_dir=%{pecl_name}-%{version}/modules \
+    --define extension=%{pecl_name}.so \
+    --modules | grep %{pecl_name}
+
+%if %{with_zts}
+%{__ztsphp} --no-php-ini \
+    --define extension_dir=%{pecl_name}-%{version}-zts/modules \
     --define extension=%{pecl_name}.so \
     --modules | grep %{pecl_name}
+%endif
+
+%if %{with_tests}
+cd %{pecl_name}-%{version}
+cp %{SOURCE3} tests
+sed -e "s:/var/run/memcached/memcached.sock:$PWD/memcached.sock:" \
+    -i tests/connect.inc
+
+# Launch the daemons
+memcached -p 11211 -U 11211      -d -P $PWD/memcached1.pid
+memcached -p 11212 -U 11212      -d -P $PWD/memcached2.pid
+memcached -s $PWD/memcached.sock -d -P $PWD/memcached3.pid
+
+# Run the test Suite
+ret=0
+TEST_PHP_EXECUTABLE=%{_bindir}/php \
+TEST_PHP_ARGS="-n -d extension_dir=$PWD/modules -d extension=%{pecl_name}.so" \
+NO_INTERACTION=1 \
+REPORT_EXIT_STATUS=1 \
+%{_bindir}/php -n run-tests.php || ret=1
+
+# Cleanup
+if [ -f memcached2.pid ]; then
+   kill $(cat memcached?.pid)
+fi
+
+exit $ret
+%endif
 
 
 %post
@@ -154,14 +202,24 @@ fi
 
 
 %files
-%doc CHANGELOG %{pecl_name}-%{version}/CREDITS %{pecl_name}-%{version}/README LICENSE
+%doc CHANGELOG %{pecl_name}-%{version}/{CREDITS,README,LICENSE}
 %doc %{pecl_name}-%{version}/example.php %{pecl_name}-%{version}/memcache.php
-%config(noreplace) %{_sysconfdir}/php.d/%{pecl_name}.ini
-%{php_extdir}/%{pecl_name}.so
 %{pecl_xmldir}/%{name}.xml
+%config(noreplace) %{php_inidir}/%{pecl_name}.ini
+%{php_extdir}/%{pecl_name}.so
+
+%if %{with_zts}
+%config(noreplace) %{php_ztsinidir}/%{pecl_name}.ini
+%{php_ztsextdir}/%{pecl_name}.so
+%endif
+
 
 
 %changelog
+* Mon Apr 08 2013 Remi Collet <remi at fedoraproject.org> - 3.0.8-1
+- Update to 3.0.8
+- enable conditional ZTS extension build
+
 * Fri Mar 22 2013 Remi Collet <rcollet at redhat.com> - 3.0.7-7
 - rebuild for http://fedoraproject.org/wiki/Features/Php55
 
diff --git a/sources b/sources
index 1be676e..13725c2 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-5cc9f2ef11f5c931794ece1a148416df  memcache-3.0.7.tgz
+24505e9b263d2c77f8ae5e9b4725e7d1  memcache-3.0.8.tgz


More information about the scm-commits mailing list