From f82f69429f780596b4eaeb025dd424a184ba20c8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 9 Oct 2018 09:04:30 +0200 Subject: New package, version 3.0.2 --- .gitignore | 7 + 0001-fix-ZTS-build-on-PHP-7.patch | 142 ++++++++ Makefile | 4 + PHPINFO | 4 + REFLECTION | 658 ++++++++++++++++++++++++++++++++++++++ php-pecl-luasandbox.spec | 241 ++++++++++++++ 6 files changed, 1056 insertions(+) create mode 100644 .gitignore create mode 100644 0001-fix-ZTS-build-on-PHP-7.patch create mode 100644 Makefile create mode 100644 PHPINFO create mode 100644 REFLECTION create mode 100644 php-pecl-luasandbox.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ab5c4f --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +package-*.xml +*.tgz +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/0001-fix-ZTS-build-on-PHP-7.patch b/0001-fix-ZTS-build-on-PHP-7.patch new file mode 100644 index 0000000..69b1abf --- /dev/null +++ b/0001-fix-ZTS-build-on-PHP-7.patch @@ -0,0 +1,142 @@ +From cea90a7fe86db551234f02c4046258ffbf696e59 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 9 Oct 2018 08:28:10 +0200 +Subject: [PATCH] fix ZTS build on PHP 7+ + +--- + luasandbox.c | 28 ++++++++++++++-------------- + 1 file changed, 14 insertions(+), 14 deletions(-) + +diff --git a/luasandbox.c b/luasandbox.c +index ab9eabe..6a4d561 100644 +--- a/luasandbox.c ++++ b/luasandbox.c +@@ -606,7 +606,7 @@ struct luasandbox_load_helper_params { + php_luasandbox_obj * sandbox; + zval *zthis; + zval *return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls; + #endif + char *code; +@@ -618,7 +618,7 @@ static int luasandbox_load_helper_protected(lua_State* L) { + struct luasandbox_load_helper_params *p = (struct luasandbox_load_helper_params *)lua_touserdata(L, 1); + int status; + zval *return_value = p->return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls = p->tsrm_ls; + #endif + +@@ -695,7 +695,7 @@ static void luasandbox_load_helper(int binary, INTERNAL_FUNCTION_PARAMETERS) + luasandbox_timer_unpause(&p.sandbox->timer); + + p.zthis = getThis(); +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + p.tsrm_ls = tsrm_ls; + #endif + p.return_value = return_value; +@@ -768,7 +768,7 @@ PHP_METHOD(LuaSandbox, loadBinary) + static int luasandbox_safe_trace_to_zval(lua_State* L) { + zval *zsandbox = (zval *)lua_touserdata(L, 2); + zval *ztrace = (zval *)lua_touserdata(L, 3); +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls = (void ***)lua_touserdata(L, 4); + #endif + +@@ -847,7 +847,7 @@ static void luasandbox_handle_error(php_luasandbox_obj * sandbox, int status TSR + lua_pushlightuserdata(L, LUASANDBOX_GET_CURRENT_ZVAL_PTR(sandbox)); + lua_pushlightuserdata(L, ztrace); + lua_pushlightuserdata(L, +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + tsrm_ls + #else + NULL +@@ -1272,7 +1272,7 @@ struct LuaSandbox_callFunction_params { + php_luasandbox_obj * sandbox; + zval *zthis; + zval *return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls; + #endif + char *name; +@@ -1284,7 +1284,7 @@ struct LuaSandbox_callFunction_params { + static int LuaSandbox_callFunction_protected(lua_State* L) { + struct LuaSandbox_callFunction_params *p = (struct LuaSandbox_callFunction_params *)lua_touserdata(L, 1); + zval *return_value = p->return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls = p->tsrm_ls; + #endif + +@@ -1322,7 +1322,7 @@ PHP_METHOD(LuaSandbox, callFunction) + + p.zthis = getThis(); + p.return_value = return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + p.tsrm_ls = tsrm_ls; + #endif + status = lua_cpcall(L, LuaSandbox_callFunction_protected, &p); +@@ -1357,7 +1357,7 @@ PHP_METHOD(LuaSandbox, callFunction) + struct LuaSandbox_wrapPhpFunction_params { + zval *zthis; + zval *return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls; + #endif + zval *z; +@@ -1366,7 +1366,7 @@ struct LuaSandbox_wrapPhpFunction_params { + static int LuaSandbox_wrapPhpFunction_protected(lua_State* L) { + struct LuaSandbox_wrapPhpFunction_params *p = (struct LuaSandbox_wrapPhpFunction_params *)lua_touserdata(L, 1); + zval *return_value = p->return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls = p->tsrm_ls; + #endif + +@@ -1404,7 +1404,7 @@ PHP_METHOD(LuaSandbox, wrapPhpFunction) + } + + p.return_value = return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + p.tsrm_ls = tsrm_ls; + #endif + status = lua_cpcall(L, LuaSandbox_wrapPhpFunction_protected, &p); +@@ -1494,7 +1494,7 @@ PHP_METHOD(LuaSandboxFunction, __construct) + struct LuaSandboxFunction_call_params { + php_luasandbox_obj * sandbox; + zval *return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls; + #endif + php_luasandboxfunction_obj *func; +@@ -1505,7 +1505,7 @@ struct LuaSandboxFunction_call_params { + static int LuaSandboxFunction_call_protected(lua_State* L) { + struct LuaSandboxFunction_call_params *p = (struct LuaSandboxFunction_call_params *)lua_touserdata(L, 1); + zval *return_value = p->return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + void ***tsrm_ls = p->tsrm_ls; + #endif + +@@ -1523,7 +1523,7 @@ PHP_METHOD(LuaSandboxFunction, call) + int status; + + p.return_value = return_value; +-#ifdef ZTS ++#if defined(ZTS) && PHP_VERSION_ID < 70000 + p.tsrm_ls = tsrm_ls; + #endif + p.numArgs = 0; +-- +2.14.4 + 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..a9f3d1a --- /dev/null +++ b/PHPINFO @@ -0,0 +1,4 @@ + +luasandbox + +luasandbox support => enabled diff --git a/REFLECTION b/REFLECTION new file mode 100644 index 0000000..e8c9b82 --- /dev/null +++ b/REFLECTION @@ -0,0 +1,658 @@ +Extension [ extension #15 luasandbox version 3.0.2 ] { + + - Classes [10] { + Class [ class LuaSandbox ] { + + - Constants [3] { + Constant [ public integer SAMPLES ] { 0 } + Constant [ public integer SECONDS ] { 1 } + Constant [ public integer PERCENT ] { 2 } + } + + - Static properties [0] { + } + + - Static methods [1] { + Method [ static public method getVersionInfo ] { + + - Parameters [0] { + } + } + } + + - Properties [0] { + } + + - Methods [15] { + Method [ public method loadString ] { + + - Parameters [2] { + Parameter #0 [ $code ] + Parameter #1 [ $chunkName ] + } + } + + Method [ public method loadBinary ] { + + - Parameters [2] { + Parameter #0 [ $code ] + Parameter #1 [ $chunkName ] + } + } + + Method [ public method setMemoryLimit ] { + + - Parameters [1] { + Parameter #0 [ $limit ] + } + } + + Method [ public method getMemoryUsage ] { + + - Parameters [0] { + } + } + + Method [ public method getPeakMemoryUsage ] { + + - Parameters [0] { + } + } + + Method [ public method setCPULimit ] { + + - Parameters [1] { + Parameter #0 [ $limit ] + } + } + + Method [ public method getCPUUsage ] { + + - Parameters [0] { + } + } + + Method [ public method pauseUsageTimer ] { + + - Parameters [0] { + } + } + + Method [ public method unpauseUsageTimer ] { + + - Parameters [0] { + } + } + + Method [ public method enableProfiler ] { + + - Parameters [1] { + Parameter #0 [ $period ] + } + } + + Method [ public method disableProfiler ] { + + - Parameters [0] { + } + } + + Method [ public method getProfilerFunctionReport ] { + + - Parameters [1] { + Parameter #0 [ $units ] + } + } + + Method [ public method callFunction ] { + + - Parameters [2] { + Parameter #0 [ $name ] + Parameter #1 [ $... ] + } + } + + Method [ public method wrapPhpFunction ] { + + - Parameters [2] { + Parameter #0 [ $name ] + Parameter #1 [ $function ] + } + } + + Method [ public method registerLibrary ] { + + - Parameters [2] { + Parameter #0 [ $libname ] + Parameter #1 [ $functions ] + } + } + } + } + + Class [ class LuaSandboxError extends Exception implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxRuntimeError extends LuaSandboxError implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxFatalError extends LuaSandboxError implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxSyntaxError extends LuaSandboxFatalError implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxMemoryError extends LuaSandboxFatalError implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxErrorError extends LuaSandboxFatalError implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxTimeoutError extends LuaSandboxFatalError implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxEmergencyTimeoutError extends LuaSandboxFatalError implements Throwable ] { + + - Constants [4] { + Constant [ public integer RUN ] { 2 } + Constant [ public integer SYNTAX ] { 3 } + Constant [ public integer MEM ] { 4 } + Constant [ public integer ERR ] { 5 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [4] { + Property [ protected $message ] + Property [ protected $code ] + Property [ protected $file ] + Property [ protected $line ] + } + + - Methods [10] { + Method [ public method __construct ] { + + - Parameters [3] { + Parameter #0 [ $message ] + Parameter #1 [ $code ] + Parameter #2 [ $previous ] + } + } + + Method [ public method __wakeup ] { + } + + Method [ final public method getMessage ] { + } + + Method [ final public method getCode ] { + } + + Method [ final public method getFile ] { + } + + Method [ final public method getLine ] { + } + + Method [ final public method getTrace ] { + } + + Method [ final public method getPrevious ] { + } + + Method [ final public method getTraceAsString ] { + } + + Method [ public method __toString ] { + } + } + } + + Class [ class LuaSandboxFunction ] { + + - Constants [0] { + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [3] { + Method [ final private method __construct ] { + + - Parameters [0] { + } + } + + Method [ public method call ] { + + - Parameters [1] { + Parameter #0 [ $... ] + } + } + + Method [ public method dump ] { + + - Parameters [0] { + } + } + } + } + } +} + diff --git a/php-pecl-luasandbox.spec b/php-pecl-luasandbox.spec new file mode 100644 index 0000000..f64eacc --- /dev/null +++ b/php-pecl-luasandbox.spec @@ -0,0 +1,241 @@ +# remirepo spec file for php-pecl-luasandbox +# +# Copyright (c) 2015-2018 Remi Collet +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/4.0/ +# +# Please, preserve the changelog entries +# +%if 0%{?scl:1} +%global sub_prefix %{scl_prefix} +%scl_package php-pecl-luasandbox +%else +%global _root_libdir %{_libdir} +%endif + +%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} +%global proj_name LuaSandbox +%global pecl_name luasandbox +%global with_tests 0%{!?_without_tests:1} +%if "%{php_version}" < "5.6" +%global ini_name %{pecl_name}.ini +%else +%global ini_name 40-%{pecl_name}.ini +%endif + +Summary: Lua interpreter with limits and safe environment +Name: %{?sub_prefix}php-pecl-%{pecl_name} +Version: 3.0.2 +Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +License: MIT +URL: http://pecl.php.net/package/%{proj_name} +Source0: http://pecl.php.net/get/%{proj_name}-%{version}.tgz + +Patch1: 0001-fix-ZTS-build-on-PHP-7.patch + +BuildRequires: %{?dtsprefix}gcc +BuildRequires: %{?scl_prefix}php-devel +BuildRequires: %{?scl_prefix}php-pear +# version 5.1 required +%if 0%{?fedora} >=20 || 0%{?rhel} >= 8 +BuildRequires: compat-lua-devel +%else +BuildRequires: lua-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}} + +Provides: %{?scl_prefix}php-%{pecl_name} = %{version} +Provides: %{?scl_prefix}php-%{pecl_name}%{?_isa} = %{version} +Provides: %{?scl_prefix}php-pecl(%{proj_name}) = %{version} +Provides: %{?scl_prefix}php-pecl(%{proj_name})%{?_isa} = %{version} +%if "%{?scl_prefix}" != "%{?sub_prefix}" +Provides: %{?scl_prefix}php-pecl-%{pecl_name} = %{version}-%{release} +Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release} +%endif + +%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} +# Other third party repo stuff +%if "%{php_version}" > "5.6" +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 +%if "%{php_version}" > "7.1" +Obsoletes: php71u-pecl-%{pecl_name} <= %{version} +Obsoletes: php71w-pecl-%{pecl_name} <= %{version} +%endif +%if "%{php_version}" > "7.2" +Obsoletes: php72u-pecl-%{pecl_name} <= %{version} +Obsoletes: php72w-pecl-%{pecl_name} <= %{version} +%endif +%if "%{php_version}" > "7.3" +Obsoletes: php73u-pecl-%{pecl_name} <= %{version} +Obsoletes: php73w-pecl-%{pecl_name} <= %{version} +%endif +%endif + +%if 0%{?fedora} < 20 && 0%{?rhel} < 7 +# Filter shared private +%{?filter_provides_in: %filter_provides_in %{_libdir}/.*\.so$} +%{?filter_setup} +%endif + + +%description +LuaSandbox is an extension for running untrusted Lua code within a +PHP web request. Code is run in a stripped-down, safe environment. +Time and memory limits can be set. + + +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection (%{scl} by %{?scl_vendor}%{!?scl_vendor:rh})}. + + +%prep +%setup -q -c +mv %{proj_name}-%{version} NTS + +# Don't install tests +sed -e 's/role="test"/role="src"/' \ + %{?_licensedir:-e '/COPYING/s/role="doc"/role="src"/' } \ + -i package.xml + +cd NTS +%patch1 -p1 -b.zts + +: Sanity check, really often broken +extver=$(sed -n '/#define LUASANDBOX_VERSION /{s/.* "//;s/".*$//;p}' luasandbox_version.h) +if test "x${extver}" != "x%{version}"; then + : Error: Upstream extension version is ${extver}, expecting %{version}. + exit 1 +fi +cd .. + +%if %{with_zts} +# Duplicate source tree for NTS / ZTS build +cp -pr NTS ZTS +%endif + +# Create configuration file +cat << 'EOF' | tee %{ini_name} +; Enable %{pecl_name} extension module +extension=%{pecl_name}.so +EOF + + +%build +%{?dtsenable} + +cd NTS +%{_bindir}/phpize +%configure \ + --with-luasandbox \ + --with-php-config=%{_bindir}/php-config +make %{?_smp_mflags} + +%if %{with_zts} +cd ../ZTS +%{_bindir}/zts-phpize +%configure \ + --with-luasandbox \ + --with-php-config=%{_bindir}/zts-php-config +make %{?_smp_mflags} +%endif + + +%install +%{?dtsenable} + +make -C NTS install INSTALL_ROOT=%{buildroot} + +# install config file +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 + +%if %{with_zts} +make -C ZTS install INSTALL_ROOT=%{buildroot} + +install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name} +%endif + +# 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 +done + + +%check +cd NTS +: Minimal load test for NTS extension +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ + --modules | grep -i %{pecl_name} + +: Upstream test suite for NTS extension +TEST_PHP_EXECUTABLE=%{_bindir}/php \ +TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=1 \ +%{_bindir}/php -n run-tests.php + +%if %{with_zts} +cd ../ZTS +: Minimal load test for ZTS extension +%{__ztsphp} --no-php-ini \ + --define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \ + --modules | grep -i %{pecl_name} + +: Upstream test suite for ZTS extension +TEST_PHP_EXECUTABLE=%{__ztsphp} \ +TEST_PHP_ARGS="-n -d extension=$PWD/modules/%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=1 \ +%{__ztsphp} -n run-tests.php +%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} %{proj_name} >/dev/null || : +fi +%endif + + +%files +%doc %{pecl_docdir}/%{pecl_name} +%{?_licensedir:%license NTS/COPYING} + +%{pecl_xmldir}/%{name}.xml +%config(noreplace) %{php_inidir}/%{ini_name} +%{php_extdir}/%{pecl_name}.so + +%if %{with_zts} +%config(noreplace) %{php_ztsinidir}/%{ini_name} +%{php_ztsextdir}/%{pecl_name}.so +%endif + + +%changelog +* Tue Oct 9 2018 Remi Collet - 3.0.2-1 +- initial package, version 3.0.2 (stable) +- add patch to fix ZTS build with PHP 7+ -- cgit