Browse Source

initial package creation

Signed-off-by: Toshaan Bharvani <toshaan@powerel.org>
master
Toshaan Bharvani 3 weeks ago
commit
3f0fa002dc
  1. 78
      SOURCES/174.patch
  2. 214
      SPECS/php-pecl-msgpack.spec

78
SOURCES/174.patch

@ -0,0 +1,78 @@
From da2e275aff642de43b94260ac1715379de9572ba Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Fri, 5 Jul 2024 11:47:33 +0200
Subject: [PATCH] fix tests for 8.4

---
tests/015.phpt | 2 +-
tests/015b.phpt | 2 +-
tests/015e.phpt | 2 +-
tests/027.phpt | 2 +-
tests/028.phpt | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/015.phpt b/tests/015.phpt
index 4bd0f52..9e053aa 100644
--- a/tests/015.phpt
+++ b/tests/015.phpt
@@ -46,7 +46,7 @@ function gc($time) {
ini_set('session.serialize_handler', 'msgpack');
-session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
+@session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
diff --git a/tests/015b.phpt b/tests/015b.phpt
index de383ee..b736fb5 100644
--- a/tests/015b.phpt
+++ b/tests/015b.phpt
@@ -45,7 +45,7 @@ function gc($time) {
return true;
}
-session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
+@session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
diff --git a/tests/015e.phpt b/tests/015e.phpt
index b18a34a..0598d42 100644
--- a/tests/015e.phpt
+++ b/tests/015e.phpt
@@ -48,7 +48,7 @@ function gc($time) {
ini_set('session.serialize_handler', 'msgpack');
-session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
+@session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();
diff --git a/tests/027.phpt b/tests/027.phpt
index c8f89ab..49cf193 100644
--- a/tests/027.phpt
+++ b/tests/027.phpt
@@ -53,7 +53,7 @@ class Bar {
ini_set('session.serialize_handler', 'msgpack');
-session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
+@session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
$db_object = new Foo();
diff --git a/tests/028.phpt b/tests/028.phpt
index a55b90b..a5f7637 100644
--- a/tests/028.phpt
+++ b/tests/028.phpt
@@ -88,7 +88,7 @@ function gc($time) {
ini_set('session.serialize_handler', 'msgpack');
-session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
+@session_set_save_handler('open', 'close', 'read', 'write', 'destroy', 'gc');
session_start();

214
SPECS/php-pecl-msgpack.spec

@ -0,0 +1,214 @@
%global gh_commit 943d27267fbf6da6b4d225f344f4731aec0c671b
%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner msgpack
%global gh_project msgpack-php
%global pecl_name msgpack
%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}}
%global ini_name 40-%{pecl_name}.ini

%global upstream_version 2.2.0
%global sources %{pecl_name}-%{upstream_version}%{?upstream_prever}
%global _configure ../%{sources}/configure

%bcond_with msgpack
%bcond_without tests


Name: php-pecl-msgpack
License: BSD-3-Clause
Version: 2.2.0
Release: 1%{?dist}
URL: https://pecl.php.net/package/msgpack
Summary: API for communicating with MessagePack serialization
Source: https://pecl.php.net/get/%{pecl_name}-%{upstream_version}%{?upstream_prever}.tgz
Patch0: 174.patch
BuildRequires: make
BuildRequires: gcc
BuildRequires: php-devel >= 7.0
BuildRequires: php-pear
%if %{with msgpack}
BuildRequires: msgpack-devel
%else
Provides: bundled(msgpack) = 3.2.0
%endif

Requires: php(zend-abi) = %{php_zend_api}
Requires: php(api) = %{php_core_api}

Provides: php-%{pecl_name} = %{version}
Provides: php-%{pecl_name}%{?_isa} = %{version}
Provides: php-pecl(%{pecl_name}) = %{version}
Provides: php-pecl(%{pecl_name})%{?_isa} = %{version}


%description
This extension provide API for communicating with MessagePack serialization.

MessagePack is an efficient binary serialization format. It lets you exchange
data among multiple languages like JSON but it's faster and smaller.
For example, small integers (like flags or error code) are encoded into a
single byte, and typical short strings only require an extra byte in addition
to the strings themselves.

If you ever wished to use JSON for convenience (storing an image with metadata)
but could not for technical reasons (encoding, size, speed...), MessagePack is
a perfect replacement.

This extension is still EXPERIMENTAL.


%package devel
Summary: MessagePack developer files (header)
Group: Development/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{?scl_prefix}php-devel%{?_isa}
These are the files needed to compile programs using MessagePack serializer.


%prep
%setup -qc

sed -e '/LICENSE/s/role="doc"/role="src"/' -i package.xml

cd %{sources}
%patch -P0 -p1

%if %{with msgpack}
# use system library
rm -rf msgpack
%endif

# Sanity check, really often broken
extver=$(sed -n '/#define PHP_MSGPACK_VERSION/{s/.* "//;s/".*$//;p}' php_msgpack.h)
if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}%{?gh_date:-dev}"; then
: Error: Upstream extension version is ${extver}, expecting %{upstream_version}%{?upstream_prever}%{?gh_date:-dev}.
exit 1
fi
cd ..

mkdir NTS
%if %{with_zts}
mkdir ZTS
%endif

# Drop in the bit of configuration
cat > %{ini_name} << 'EOF'
; Enable MessagePack extension module
extension = %{pecl_name}.so

; Configuration options

;msgpack.error_display = On
;msgpack.illegal_key_insert = Off
;msgpack.php_only = On
EOF


%build
cd %{sources}
%{__phpize}

cd ../NTS
%configure --with-php-config=%{__phpconfig}
make %{?_smp_mflags}

%if %{with_zts}
cd ../ZTS
%configure --with-php-config=%{__ztsphpconfig}
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}

%if %{with_zts}
# Install the ZTS stuff
make -C ZTS install INSTALL_ROOT=%{buildroot}
install -D -m 644 %{ini_name} %{buildroot}%{php_ztsinidir}/%{ini_name}
%endif

# Install the package XML file
install -D -m 644 package.xml %{buildroot}%{pecl_xmldir}/%{name}.xml

# Test & Documentation
cd %{sources}
for i in $(grep 'role="test"' ../package.xml | sed -e 's/^.*name="//;s/".*$//')
do [ -f tests/$i ] && install -Dpm 644 tests/$i %{buildroot}%{pecl_testdir}/%{pecl_name}/tests/$i
[ -f $i ] && install -Dpm 644 $i %{buildroot}%{pecl_testdir}/%{pecl_name}/$i
done
for i in $(grep 'role="doc"' ../package.xml | sed -e 's/^.*name="//;s/".*$//')
do install -Dpm 644 $i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i
done


%check
# Erratic results, segfauilt and mark as XFAIL
rm */tests/034.phpt
%ifarch aarch64
# too slow
rm */tests/035.phpt
%endif

%if "%{php_version}" > "7.4"
OPT="-q --show-diff %{?_smp_mflags}"
%else
OPT="-q --show-diff"
%endif

cd %{sources}
: Minimal load test for NTS extension
%{__php} --no-php-ini \
--define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \
--modules | grep %{pecl_name}

%if %{with tests}
: Upstream test suite for NTS extension
TEST_PHP_EXECUTABLE=%{__php} \
TEST_PHP_ARGS="-n -d extension_dir=$PWD/../NTS/modules -d extension=%{pecl_name}.so" \
REPORT_EXIT_STATUS=1 \
%{__php} -n run-tests.php $OPT
%endif

%if %{with_zts}
: Minimal load test for ZTS extension
%{__ztsphp} --no-php-ini \
--define extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \
--modules | grep %{pecl_name}

%if %{with tests}
: Upstream test suite for ZTS extension
TEST_PHP_EXECUTABLE=%{__ztsphp} \
TEST_PHP_ARGS="-n -d extension_dir=$PWD/../ZTS/modules -d extension=%{pecl_name}.so" \
REPORT_EXIT_STATUS=1 \
%{__ztsphp} -n run-tests.php $OPT
%endif
%endif


%files
%license %{sources}/LICENSE
%{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


%files devel
%{php_incldir}/ext/%{pecl_name}

%if %{with_zts}
%{php_ztsincldir}/ext/%{pecl_name}
%endif


%changelog
Loading…
Cancel
Save