diff options
author | Remi Collet <remi@remirepo.net> | 2020-03-04 09:01:16 +0100 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2020-03-04 09:01:16 +0100 |
commit | a20e85a081b257a9b3a8bc90c6aa6c08ec3d18d7 (patch) | |
tree | c69c4081c4efd105d0c1f0b22e6e479e8d3bc554 |
New package
-rw-r--r-- | .gitignore | 8 | ||||
-rw-r--r-- | 0001-fix-c89.patch | 33 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | PHPINFO | 7 | ||||
-rw-r--r-- | REFLECTION | 46 | ||||
-rw-r--r-- | php-pecl-csv.spec | 223 |
6 files changed, 321 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fc9aa8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +clog +package-*.xml +*.tgz +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/0001-fix-c89.patch b/0001-fix-c89.patch new file mode 100644 index 0000000..d5ba611 --- /dev/null +++ b/0001-fix-c89.patch @@ -0,0 +1,33 @@ +From 9085a7d766983a4d3aa9172a64b0e79c9cb01ae5 Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@remirepo.net> +Date: Wed, 4 Mar 2020 08:49:20 +0100 +Subject: [PATCH] fix c89 + +--- + csv.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/csv.c b/csv.c +index 0ed90d3..77263b6 100644 +--- a/csv.c ++++ b/csv.c +@@ -226,6 +226,7 @@ static HashTable* rfc4180_string_to_hashtable( + char **buffer, const size_t length, const zend_string *delimiter, + const zend_string *enclosure, const zend_string *eol_sequence) + { ++ size_t index; + HashTable *return_value = zend_new_array(8); + + bool in_escaped_field = false; +@@ -237,7 +238,7 @@ static HashTable* rfc4180_string_to_hashtable( + size_t field_value_length = 0; + + /* Main loop to "tokenize" the row */ +- for (size_t index = 0; index < length; ++index) { ++ for (index = 0; index < length; ++index) { + /* Check for field escape sequence (i.e. enclosure) */ + if (php_memnstr(row, ZSTR_VAL(enclosure), ZSTR_LEN(enclosure), row + ZSTR_LEN(enclosure))) { + row += ZSTR_LEN(enclosure); +-- +2.24.1 + 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 + @@ -0,0 +1,7 @@ + +csv + +CSV support => enabled +Version => 0.3.0 +Author => George Peter Banyard +Bug reports => https://gitlab.com/Girgias/csv-php-extension/issues diff --git a/REFLECTION b/REFLECTION new file mode 100644 index 0000000..441c0a2 --- /dev/null +++ b/REFLECTION @@ -0,0 +1,46 @@ +Extension [ <persistent> extension #73 csv version 0.3.0 ] { + + - Functions { + Function [ <internal:csv> function csv_array_to_row ] { + + - Parameters [4] { + Parameter #0 [ <required> array $fields ] + Parameter #1 [ <optional> string $delimiter ] + Parameter #2 [ <optional> string $enclosure ] + Parameter #3 [ <optional> string $eolSequence ] + } + - Return [ string ] + } + Function [ <internal:csv> function csv_collection_to_file ] { + + - Parameters [4] { + Parameter #0 [ <required> array $collection ] + Parameter #1 [ <optional> string $delimiter ] + Parameter #2 [ <optional> string $enclosure ] + Parameter #3 [ <optional> string $eolSequence ] + } + - Return [ string ] + } + Function [ <internal:csv> function csv_file_to_collection ] { + + - Parameters [4] { + Parameter #0 [ <required> string $file ] + Parameter #1 [ <optional> string $delimiter ] + Parameter #2 [ <optional> string $enclosure ] + Parameter #3 [ <optional> string $eolSequence ] + } + - Return [ array ] + } + Function [ <internal:csv> function csv_row_to_array ] { + + - Parameters [4] { + Parameter #0 [ <required> string $row ] + Parameter #1 [ <optional> string $delimiter ] + Parameter #2 [ <optional> string $enclosure ] + Parameter #3 [ <optional> string $eolSequence ] + } + - Return [ array ] + } + } +} + diff --git a/php-pecl-csv.spec b/php-pecl-csv.spec new file mode 100644 index 0000000..54c4f1f --- /dev/null +++ b/php-pecl-csv.spec @@ -0,0 +1,223 @@ +# remirepo spec file for php-pecl-csv +# +# Copyright (c) 2020 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-csv +%else +%global _root_libdir %{_libdir} +%endif + +%global with_zts 0%{!?_without_zts:%{?__ztsphp:1}} +%global proj_name CSV +%global pecl_name csv +%global with_tests 0%{!?_without_tests:1} +%global ini_name 40-%{pecl_name}.ini + +Summary: CSV PHP extension +Name: %{?sub_prefix}php-pecl-%{pecl_name} +Version: 0.3.0 +Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +License: PHP +URL: https://pecl.php.net/package/%{proj_name} +Source0: https://pecl.php.net/get/%{proj_name}-%{version}.tgz + +Patch0: 0001-fix-c89.patch + +BuildRequires: %{?dtsprefix}gcc +BuildRequires: %{?scl_prefix}php-devel > 7.3 +BuildRequires: %{?scl_prefix}php-pear + +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 +Obsoletes: php73-pecl-%{pecl_name} <= %{version} +Obsoletes: php73w-pecl-%{pecl_name} <= %{version} +%if "%{php_version}" > "7.4" +Obsoletes: php74-pecl-%{pecl_name} <= %{version} +Obsoletes: php74w-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 +A new and improved CSV file PHP extension which follows RFC 4180 instead of +using a custom escape mechanism. + +Supports multi-bytes delimiters, enclosures, and providing a custom EOL +sequence. + +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 '/LICENSE/s/role="doc"/role="src"/' } \ + -i package.xml + +cd NTS +chmod -x * +%patch0 -p1 -b .pr2 + +: Sanity check, really often broken +extver=$(sed -n '/# define PHP_CSV_VERSION /{s/.* "//;s/".*$//;p}' php_csv.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 \ + --enable-csv \ + --with-php-config=%{_bindir}/php-config +make %{?_smp_mflags} + +%if %{with_zts} +cd ../ZTS +%{_bindir}/zts-phpize +%configure \ + --enable-csv \ + --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 --show-diff + +%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 --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} %{proj_name} >/dev/null || : +fi +%endif + + +%files +%doc %{pecl_docdir}/%{pecl_name} +%{?_licensedir:%license NTS/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 + + +%changelog +* Wed Mar 4 2020 Remi Collet <remi@remirepo.net> - 0.3.0-1 +- initial package, version 0.3.0 (stable) +- open https://gitlab.com/Girgias/csv-php-extension/issues/1 bad perms +- open https://gitlab.com/Girgias/csv-php-extension/issues/2 tests +- open https://gitlab.com/Girgias/csv-php-extension/-/merge_requests/3 CR/LF +- add patch for old GCC from + https://gitlab.com/Girgias/csv-php-extension/-/merge_requests/4 |