]> git.pld-linux.org Git - packages/php-pecl-mongodb.git/blame - php-pecl-mongodb.spec
Handle static ext-json on php 8
[packages/php-pecl-mongodb.git] / php-pecl-mongodb.spec
CommitLineData
72c237bb 1# TODO
3513b6f0 2# - libmongocrypt
72c237bb
ER
3# - ix86/x32 (php -m) prints::
4# src/mongoc/mongoc-handshake.c:478 _append_and_truncate(): precondition failed: space_for_suffix >= 0
5# Aborted
e6a2fe32
ER
6#
7# Conditional build:
8%bcond_without tests # build without tests
3cfe18c3 9%bcond_with sasl # Include Cyrus SASL support (for bundled only)
3bff6cd8 10%bcond_without ssl # Enable TLS connections and SCRAM-SHA-1 authentication (for bundled only)
efb59f9a 11%bcond_with bundled # Use bundled libmongoc
e6a2fe32
ER
12
13%define php_name php%{?php_suffix}
14%define modname mongodb
15Summary: MongoDB driver for PHP
78f25fe6 16Name: %{php_name}-pecl-%{modname}
8fff2a60 17Version: 1.12.0
512f9152 18Release: 1
e6a2fe32
ER
19License: Apache v2.0
20Group: Development/Languages/PHP
78f25fe6 21Source0: https://pecl.php.net/get/%{modname}-%{version}.tgz
8fff2a60 22# Source0-md5: f88bb3ab2ec98fb60108bac5fa20a681
29b44cd3 23Source1: mongodb.ini
e6a2fe32 24URL: https://pecl.php.net/package/mongodb
2782ab30 25BuildRequires: %{php_name}-cli
3513b6f0 26BuildRequires: %{php_name}-devel >= 4:7.0
e6a2fe32 27BuildRequires: %{php_name}-json
7ac97c34 28BuildRequires: %{php_name}-pcre
4b7a708c 29BuildRequires: %{php_name}-spl
bc94cadc 30%{?with_sasl:BuildRequires: cyrus-sasl-devel}
3cfe18c3 31%if %{without bundled}
8fff2a60
ER
32BuildRequires: libbson-devel >= 1.20.0
33BuildRequires: mongo-c-driver-devel >= 1.20.0
3cfe18c3 34%endif
e6a2fe32 35BuildRequires: openssl-devel
a88e3999 36BuildRequires: rpmbuild(macros) >= 1.666
e6a2fe32 37Requires: %{php_name}-json
8808cfb4 38%if %{without bundled}
8fff2a60 39Requires: mongo-c-driver-libs >= 1.20.0
8808cfb4 40%endif
9d61e514
ER
41Requires: %{php_name}-pcre
42Requires: %{php_name}-spl
e6a2fe32
ER
43%{?requires_php_extension}
44Provides: php(%{modname}) = %{version}
72c237bb 45ExcludeArch: %{ix86} x32
e6a2fe32
ER
46BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
47
48%description
49The purpose of this driver is to provide exceptionally thin glue
50between MongoDB and PHP, implementing only fundemental and
51performance-critical components necessary to build a fully-functional
52MongoDB driver.
53
54%prep
55%setup -qc
56mv %{modname}-%{version}/* .
57
3cfe18c3 58%if %{without bundled}
8cb30902
ER
59# Ensure we use system library
60# remove only C sources, m4 resources needed for phpize via m4_include
61find \
8cb30902 62 src/libmongoc \
efb59f9a 63 -name '*.[ch]' -delete
3cfe18c3 64%endif
8cb30902 65
279c36ad
ER
66xfail() {
67 local t=$1
68 test -f $t
69 cat >> $t <<-EOF
70
71 --XFAIL--
72 Skip
73 EOF
74}
75
76# failed tests. investigate later
77while read line; do
78 t=${line##*\[}; t=${t%\]}
79 xfail $t
80done << 'EOF'
81MongoDB\BSON\Javascript::__set_state() [tests/bson/bson-javascript-set_state-001.phpt]
279c36ad 82MongoDB\Driver\ReadPreference: var_export() [tests/readPreference/readpreference-var_export-001.phpt]
279c36ad
ER
83EOF
84
e6a2fe32 85%build
512f9152
ER
86get_version() {
87 local define="$1" filename="$2"
88 awk -vdefine="$define" '/#define/ && $2 == define {print $3}' "$filename" | xargs
89}
e6a2fe32 90# Sanity check, really often broken
512f9152 91extver=$(get_version PHP_MONGODB_VERSION phongo_version.h)
e6a2fe32
ER
92if test "x${extver}" != "x%{version}"; then
93 : Error: Upstream extension version is ${extver}, expecting %{version}.
94 exit 1
95fi
96
97phpize
e6a2fe32
ER
98
99%configure \
8808cfb4 100 --with-mongodb-system-libs=%{?with_bundled:no}%{!?with_bundled:yes} \
3cfe18c3 101 --with-mongodb-ssl=%{!?with_ssl:no}%{?with_ssl:openssl} \
bc94cadc 102 --with-mongodb-sasl=%{!?with_sasl:no}%{?with_sasl:yes} \
e6a2fe32
ER
103 --enable-mongodb
104
105%{__make}
106
c485d9ea 107# simple module load test, always enabled
7d8f1158 108%{__php} -n -q -d display_errors=off \
e6a2fe32 109 -d extension_dir=modules \
e6527bb6 110%if "%php_major_version.%php_minor_version" < "7.4"
7ac97c34 111 -d extension=%{php_extensiondir}/pcre.so \
4b7a708c 112 -d extension=%{php_extensiondir}/spl.so \
e6527bb6 113%endif
7d8f1158 114%if "%php_major_version.%php_minor_version" < "8.0"
7ac97c34 115 -d extension=%{php_extensiondir}/json.so \
7d8f1158 116%endif
e6a2fe32
ER
117 -d extension=%{modname}.so \
118 -m > modules.log
7d8f1158 119grep "^%{modname}$" modules.log
e6a2fe32 120
c485d9ea
ER
121%if %{with tests}
122cat <<'EOF' > run-tests.sh
123#!/bin/sh
e6a2fe32 124export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2
c485d9ea 125exec %{__make} test \
e6a2fe32 126 PHP_EXECUTABLE=%{__php} \
7d8f1158 127 PHP_TEST_SHARED_SYSTEM_EXTENSIONS="\
e6527bb6 128%if "%php_major_version.%php_minor_version" < "7.4"
7d8f1158
ER
129 pcre spl \
130%endif
131%if "%php_major_version.%php_minor_version" < "8.0"
132 json \
e6527bb6 133%endif
7d8f1158 134 " \
c485d9ea
ER
135 RUN_TESTS_SETTINGS="-q $*"
136EOF
137chmod +x run-tests.sh
138
139./run-tests.sh
e6a2fe32
ER
140%endif
141
142%install
143rm -rf $RPM_BUILD_ROOT
144%{__make} install \
145 EXTENSION_DIR=%{php_extensiondir} \
146 INSTALL_ROOT=$RPM_BUILD_ROOT
147
78f25fe6 148install -d $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d
b3161ed1 149cp -p %{SOURCE1} $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d
e6a2fe32
ER
150
151%clean
152rm -rf $RPM_BUILD_ROOT
153
154%files
155%defattr(644,root,root,755)
b3161ed1 156%config(noreplace) %verify(not md5 mtime size) %{php_sysconfdir}/conf.d/%{modname}.ini
e6a2fe32 157%attr(755,root,root) %{php_extensiondir}/%{modname}.so
This page took 0.076058 seconds and 4 git commands to generate.