+# TODO
+# - ix86/x32 (php -m) prints::
+# src/mongoc/mongoc-handshake.c:478 _append_and_truncate(): precondition failed: space_for_suffix >= 0
+# Aborted
#
# Conditional build:
%bcond_without tests # build without tests
Group: Development/Languages/PHP
Source0: https://pecl.php.net/get/%{modname}-%{version}.tgz
# Source0-md5: c3b36a24b7e47e3b4148cd9bc4d163b2
+Source1: mongodb.ini
+Patch0: tests.patch
URL: https://pecl.php.net/package/mongodb
+BuildRequires: %{php_name}-cli
BuildRequires: %{php_name}-devel >= 4:5.4.0
-BuildRequires: rpmbuild(macros) >= 1.666
-%if %{with tests}
BuildRequires: %{php_name}-json
+BuildRequires: %{php_name}-pcre
BuildRequires: %{php_name}-spl
-%endif
BuildRequires: cyrus-sasl-devel
-BuildRequires: libbson-devel >= 1.5
-BuildRequires: mongo-c-driver-devel >= 1.5
+BuildRequires: libbson-devel >= 1.5.0
+BuildRequires: mongo-c-driver-devel >= 1.5.0
BuildRequires: openssl-devel
+BuildRequires: rpmbuild(macros) >= 1.666
Requires: %{php_name}-json
+Requires: %{php_name}-pcre
+Requires: %{php_name}-spl
%{?requires_php_extension}
Provides: php(%{modname}) = %{version}
+ExcludeArch: %{ix86} x32
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
%prep
%setup -qc
mv %{modname}-%{version}/* .
-
-# Create configuration file
-cat << 'EOF' > %{modname}.ini
-; Enable %{summary} extension module
-extension=%{modname}.so
-
-; Configuration
-;mongodb.debug=''
-EOF
+%patch0 -p1
%build
# Sanity check, really often broken
%configure \
--with-libbson \
--with-libmongoc \
+ --with-mongodb-sasl \
--enable-mongodb
%{__make}
-%if %{with tests}
-# simple module load test
+# simple module load test, always enabled
%{__php} -n -q \
-d extension_dir=modules \
- -d extension=%{php_extensiondir}/json.so \
+ -d extension=%{php_extensiondir}/pcre.so \
-d extension=%{php_extensiondir}/spl.so \
+ -d extension=%{php_extensiondir}/json.so \
-d extension=%{modname}.so \
-m > modules.log
grep %{modname} modules.log
+%if %{with tests}
+cat <<'EOF' > run-tests.sh
+#!/bin/sh
export NO_INTERACTION=1 REPORT_EXIT_STATUS=1 MALLOC_CHECK_=2
-%{__make} test \
+exec %{__make} test \
PHP_EXECUTABLE=%{__php} \
- PHP_TEST_SHARED_SYSTEM_EXTENSIONS="json"
+ PHP_TEST_SHARED_SYSTEM_EXTENSIONS="pcre spl json" \
+ RUN_TESTS_SETTINGS="-q $*"
+EOF
+chmod +x run-tests.sh
+
+./run-tests.sh
%endif
%install
INSTALL_ROOT=$RPM_BUILD_ROOT
install -d $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d
-cp -p %{modname}.ini $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d
+cp -p %{SOURCE1} $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d
%clean
rm -rf $RPM_BUILD_ROOT