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