From 879ad5bb32ab9182afce0db96a5a76702abfb50d Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 1 Dec 2022 16:14:03 +0100 Subject: initial package open https://github.com/TysonAndre/immutable_cache-pecl/pull/16 - use TEST_PHP_ARGS open https://github.com/TysonAndre/immutable_cache-pecl/pull/17 - mark igbinary as required --- .gitignore | 9 ++ 16.patch | 23 ++++ 17.patch | 34 ++++++ Makefile | 4 + PHPINFO | 22 ++++ REFLECTION | 193 +++++++++++++++++++++++++++++++++ php-pecl-immutable-cache.spec | 245 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 530 insertions(+) create mode 100644 .gitignore create mode 100644 16.patch create mode 100644 17.patch create mode 100644 Makefile create mode 100644 PHPINFO create mode 100644 REFLECTION create mode 100644 php-pecl-immutable-cache.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01f0400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +clog +package-*.xml +*.tgz +*.tar.bz2 +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/16.patch b/16.patch new file mode 100644 index 0000000..a122569 --- /dev/null +++ b/16.patch @@ -0,0 +1,23 @@ +From 17dee351417758f8d30c49e26e3212e888100c4e Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 1 Dec 2022 15:21:51 +0100 +Subject: [PATCH] Use TEST_PHP_ARGS (from run-tests.php) instead of trying to + build it + +--- + tests/server_test.inc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/server_test.inc b/tests/server_test.inc +index a47c45c..1738f2a 100644 +--- a/tests/server_test.inc ++++ b/tests/server_test.inc +@@ -32,7 +32,7 @@ function server_start_one($host, $port, $code = 'echo "Hello world";', $php_opts + } else { + $php_args = "-d extension_dir=$doc_root/../modules"; + } +- $php_args = "$php_args -d extension=$ext"; ++ $php_args = (getenv('TEST_PHP_ARGS') ?: "$php_args -d extension=$ext"); + + if ($php_opts) { + $php_args = "$php_args -d " . implode(' -d ', $php_opts);; diff --git a/17.patch b/17.patch new file mode 100644 index 0000000..4fb2c94 --- /dev/null +++ b/17.patch @@ -0,0 +1,34 @@ +From 40b4d9d4e7be19fd54ab9796f5548848ece0fc57 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Thu, 1 Dec 2022 15:45:10 +0100 +Subject: [PATCH] mark igbinary as required + +--- + php_immutable_cache.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/php_immutable_cache.c b/php_immutable_cache.c +index 3d93868..3eb6ec9 100644 +--- a/php_immutable_cache.c ++++ b/php_immutable_cache.c +@@ -625,10 +625,19 @@ PHP_FUNCTION(immutable_cache_exists) { + } + /* }}} */ + ++static const zend_module_dep immutable_cache_deps[] = { ++#ifdef IMMUTABLE_CACHE_IGBINARY ++ ZEND_MOD_REQUIRED("igbinary") ++#endif ++ ZEND_MOD_END ++}; ++ + /* {{{ module definition structure */ + + zend_module_entry immutable_cache_module_entry = { +- STANDARD_MODULE_HEADER, ++ STANDARD_MODULE_HEADER_EX, ++ NULL, ++ immutable_cache_deps, + PHP_IMMUTABLE_CACHE_EXTNAME, + ext_functions, + PHP_MINIT(immutable_cache), diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13af741 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile + diff --git a/PHPINFO b/PHPINFO new file mode 100644 index 0000000..8f55ec3 --- /dev/null +++ b/PHPINFO @@ -0,0 +1,22 @@ + +immutable_cache + +immutable_cache Support => Disabled +Version => 6.1.0 +immutable_cache Debugging => Disabled +MMAP Support => Enabled +MMAP File Mask => +Serialization Support => Disabled +Build Date => Dec 1 2022 00:00:00 + +Directive => Local Value => Master Value +immutable_cache.enabled => On => On +immutable_cache.shm_segments => 1 => 1 +immutable_cache.shm_size => 256M => 256M +immutable_cache.entries_hint => 4096 => 4096 +immutable_cache.mmap_file_mask => no value => no value +immutable_cache.enable_cli => Off => Off +immutable_cache.protect_memory => Off => Off +immutable_cache.preload_path => no value => no value +immutable_cache.coredump_unmap => Off => Off +immutable_cache.serializer => default => default diff --git a/REFLECTION b/REFLECTION new file mode 100644 index 0000000..56653d6 --- /dev/null +++ b/REFLECTION @@ -0,0 +1,193 @@ +Extension [ extension #112 immutable_cache version 6.1.0 ] { + + - Dependencies { + Dependency [ igbinary (Required) ] + } + + - INI { + Entry [ immutable_cache.enabled ] + Current = '1' + } + Entry [ immutable_cache.shm_segments ] + Current = '1' + } + Entry [ immutable_cache.shm_size ] + Current = '256M' + } + Entry [ immutable_cache.entries_hint ] + Current = '4096' + } + Entry [ immutable_cache.mmap_file_mask ] + Current = '' + } + Entry [ immutable_cache.enable_cli ] + Current = '0' + } + Entry [ immutable_cache.protect_memory ] + Current = '0' + } + Entry [ immutable_cache.preload_path ] + Current = '' + } + Entry [ immutable_cache.coredump_unmap ] + Current = '0' + } + Entry [ immutable_cache.serializer ] + Current = 'default' + } + } + + - Constants [12] { + Constant [ int IMMUTABLE_CACHE_LIST_ACTIVE ] { 1 } + Constant [ int IMMUTABLE_CACHE_LIST_DELETED ] { 2 } + Constant [ int IMMUTABLE_CACHE_ITER_TYPE ] { 1 } + Constant [ int IMMUTABLE_CACHE_ITER_KEY ] { 2 } + Constant [ int IMMUTABLE_CACHE_ITER_VALUE ] { 4 } + Constant [ int IMMUTABLE_CACHE_ITER_NUM_HITS ] { 8 } + Constant [ int IMMUTABLE_CACHE_ITER_CTIME ] { 32 } + Constant [ int IMMUTABLE_CACHE_ITER_ATIME ] { 128 } + Constant [ int IMMUTABLE_CACHE_ITER_REFCOUNT ] { 256 } + Constant [ int IMMUTABLE_CACHE_ITER_MEM_SIZE ] { 512 } + Constant [ int IMMUTABLE_CACHE_ITER_NONE ] { 0 } + Constant [ int IMMUTABLE_CACHE_ITER_ALL ] { 4294967295 } + } + + - Functions { + Function [ function immutable_cache_enabled ] { + + - Parameters [0] { + } + - Return [ bool ] + } + Function [ function immutable_cache_add ] { + + - Parameters [2] { + Parameter #0 [ $key ] + Parameter #1 [ mixed $value = ] + } + - Return [ array|bool ] + } + Function [ function immutable_cache_fetch ] { + + - Parameters [2] { + Parameter #0 [ $key ] + Parameter #1 [ &$success = null ] + } + - Return [ mixed ] + } + Function [ function immutable_cache_exists ] { + + - Parameters [1] { + Parameter #0 [ $key ] + } + - Return [ array|bool ] + } + Function [ function immutable_cache_cache_info ] { + + - Parameters [1] { + Parameter #0 [ bool $limited = false ] + } + - Return [ array|false ] + } + Function [ function immutable_cache_key_info ] { + + - Parameters [1] { + Parameter #0 [ string $key ] + } + - Return [ ?array ] + } + Function [ function immutable_cache_sma_info ] { + + - Parameters [1] { + Parameter #0 [ bool $limited = false ] + } + - Return [ array|false ] + } + } + + - Classes [1] { + Class [ final class ImmutableCacheIterator implements Iterator, Traversable ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [9] { + Method [ public method __construct ] { + + - Parameters [4] { + Parameter #0 [ $search = null ] + Parameter #1 [ int $format = IMMUTABLE_CACHE_ITER_ALL ] + Parameter #2 [ int $chunk_size = 0 ] + Parameter #3 [ int $list = IMMUTABLE_CACHE_LIST_ACTIVE ] + } + } + + Method [ public method rewind ] { + + - Parameters [0] { + } + - Return [ void ] + } + + Method [ public method next ] { + + - Parameters [0] { + } + - Return [ void ] + } + + Method [ public method valid ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ public method key ] { + + - Parameters [0] { + } + - Return [ string|int ] + } + + Method [ public method current ] { + + - Parameters [0] { + } + - Return [ mixed ] + } + + Method [ public method getTotalHits ] { + + - Parameters [0] { + } + - Return [ int ] + } + + Method [ public method getTotalSize ] { + + - Parameters [0] { + } + - Return [ int ] + } + + Method [ public method getTotalCount ] { + + - Parameters [0] { + } + - Return [ int ] + } + } + } + } +} + diff --git a/php-pecl-immutable-cache.spec b/php-pecl-immutable-cache.spec new file mode 100644 index 0000000..19d6f74 --- /dev/null +++ b/php-pecl-immutable-cache.spec @@ -0,0 +1,245 @@ +# remirepo spec file for php-pecl-immutable-cache +# +# Copyright (c) 2022 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# + +# we don't want -z defs linker flag +%undefine _strict_symbol_defs_build + +%if 0%{?scl:1} +%scl_package php-pecl-immutable-cache +%endif + +%bcond_without tests +%bcond_without igbinary + +%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} +%global pecl_name immutable_cache +# After 40-igbinary +%global ini_name 50-%{pecl_name}.ini + +%global upstream_version 6.1.0 +#global upstream_prever RC1 + +Summary: An shared memory cache of immutable values +Name: %{?scl_prefix}php-pecl-immutable-cache +Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} +Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} + +License: PHP-3.01 +URL: https://pecl.php.net/package/%{pecl_name} +Source0: https://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz + +Patch0: https://patch-diff.githubusercontent.com/raw/TysonAndre/immutable_cache-pecl/pull/16.patch +Patch1: https://patch-diff.githubusercontent.com/raw/TysonAndre/immutable_cache-pecl/pull/17.patch + +BuildRequires: make +BuildRequires: %{?dtsprefix}gcc +BuildRequires: %{?scl_prefix}php-devel >= 7.2 +BuildRequires: %{?scl_prefix}php-pear +%if %{with igbinary} +BuildRequires: %{?scl_prefix}php-pecl-igbinary-devel +%endif + +Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} +Requires: %{?scl_prefix}php(api) = %{php_core_api} +%{?_sclreq:Requires: %{?scl_prefix}runtime%{?_sclreq}%{?_isa}} +%if %{with igbinary} +Requires: %{?scl_prefix}php-igbinary%{?_isa} +%endif + +Provides: %{?scl_prefix}php-%{pecl_name} = %{version} +Provides: %{?scl_prefix}php-%{pecl_name}%{?_isa} = %{version} +Provides: %{?scl_prefix}php-pecl(%{pecl_name}) = %{version} +Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version} +# Notice pecl_name != name +Provides: %{?scl_prefix}php-pecl-%{pecl_name} = %{version}-%{release} +Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release} + + +%description +%{pecl_name} - an shared memory cache of immutable values. Based on APCu. + +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection (%{scl} by %{?scl_vendor}%{!?scl_vendor:rh})}. + + +%package devel +Summary: %{pecl_name} developer files (headers) +Requires: %{name}%{?_isa} = %{version}-%{release} +Requires: %{?scl_prefix}php-devel%{?_isa} + +%description devel +These are the files needed to compile programs using %{pecl_name}. + + +%prep +%setup -qc +mv %{pecl_name}-%{upstream_version}%{?upstream_prever} NTS + +%{?_licensedir:sed -e '/LICENSE/s/role="doc"/role="src"/' -i package.xml} + +cd NTS +%patch0 -p1 -b .pr16 +%patch1 -p1 -b .pr17 + +# Check version as upstream often forget to update this +extver=$(sed -n '/define PHP_IMMUTABLE_CACHE_VERSION/{s/.* "//;s/".*$//;p}' php_immutable_cache.h) +if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}%{?gh_date:-dev}"; then + : Error: Upstream version is ${extver}, expecting %{upstream_version}%{?upstream_prever}%{?gh_date:-dev}. + exit 1 +fi +cd .. + + +%if %{with_zts} +# duplicate for ZTS build +cp -pr NTS ZTS +%endif + +# Create configuration file +cat > %{ini_name} << 'EOF' +; Enable %{pecl_name} extension module +extension=%{pecl_name}.so + +; Configuration +;immutable_cache.enabled = On +;immutable_cache.shm_segments =1 +;immutable_cache.shm_size = 256M +;immutable_cache.entries_hint =4096 +;immutable_cache.mmap_file_mask = +;immutable_cache.enable_cli = On +;immutable_cache.protect_memory = Off +;immutable_cache.preload_path = +;immutable_cache.coredump_unmap = Off +;immutable_cache.serializer = default +EOF + + +%build +%{?dtsenable} + +peclconf() { +%configure \ + --enable-immutable-cache \ +%if %{with igbinary} + --enable-immutable-cache-igbinary \ +%endif + --with-php-config=$1 +} + +cd NTS +%{_bindir}/phpize +peclconf %{_bindir}/php-config +make %{?_smp_mflags} + +%if %{with_zts} +cd ../ZTS +%{_bindir}/zts-phpize +peclconf %{_bindir}/zts-php-config +make %{?_smp_mflags} +%endif + + +%install +%{?dtsenable} + +# Install the NTS stuff +make -C NTS install INSTALL_ROOT=%{buildroot} +install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} + +# Install XML package description +install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml + +# Install the ZTS stuff +%if %{with_zts} +make -C ZTS install INSTALL_ROOT=%{buildroot} +install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name} +%endif + +# Tests and Documentation +for i in $(grep 'role="test"' package.xml | sed -e 's/^.*name="//;s/".*$//') +do [ -f NTS/$i ] && install -Dpm 644 NTS/$i %{buildroot}%{pecl_testdir}/%{pecl_name}/tests/$i +done +for i in $(grep 'role="doc"' package.xml | sed -e 's/^.*name="//;s/".*$//') +do [ -f NTS/$i ] && install -Dpm 644 NTS/$i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i +done + + +%check +OPT="-n" +[ -f %{php_extdir}/igbinary.so ] && OPT="$OPT -d extension=igbinary.so" + +: Minimal load test for NTS extension +%{_bindir}/php $OPT \ + --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ + --modules | grep '^%{pecl_name}$' + +%if %{with_zts} +: Minimal load test for ZTS extension +%{__ztsphp} $OPT \ + --define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \ + --modules | grep '^%{pecl_name}$' + +%endif + +%if %{with tests} +cd NTS +: Run upstream test suite +TEST_PHP_EXECUTABLE=%{__php} \ +TEST_PHP_ARGS="-n $OPT -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" \ +REPORT_EXIT_STATUS=1 \ +%{__php} -n run-tests.php -P -q --show-diff +%endif + + +%if 0%{?fedora} < 24 && 0%{?rhel} < 8 +# 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 -a -x %{__pecl} ] ; then + %{pecl_uninstall} %{pecl_name} >/dev/null || : +fi +%endif + + +%files +%{?_licensedir:%license NTS/LICENSE} +%doc %{pecl_docdir}/%{pecl_name} +%{pecl_xmldir}/%{name}.xml + +%config(noreplace) %{php_inidir}/%{ini_name} +%{php_extdir}/%{pecl_name}.so + +%if %{with_zts} +%{php_ztsextdir}/%{pecl_name}.so +%config(noreplace) %{php_ztsinidir}/%{ini_name} +%endif + +%files devel +%doc %{pecl_testdir}/%{pecl_name} +%{php_incldir}/ext/%{pecl_name} + +%if %{with_zts} +%{php_ztsincldir}/ext/%{pecl_name} +%endif + + +%changelog +* Thu Dec 1 2022 Remi Collet - 6.1.0-1 +- initial package +- open https://github.com/TysonAndre/immutable_cache-pecl/pull/16 - use TEST_PHP_ARGS +- open https://github.com/TysonAndre/immutable_cache-pecl/pull/17 - mark igbinary as required -- cgit