summaryrefslogtreecommitdiffstats
path: root/php-mongodb.spec
blob: 261a05479d29669995482f09a09bbd0113daf848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# remirepo/fedora spec file for php-mongodb
#
# Copyright (c) 2015-2021 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#
# disabled for https://fedoraproject.org/wiki/Changes/MongoDB_Removal
%bcond_with          tests

%global gh_commit    8123216f21d31a2a5b845aa91fba7a182d060509
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     mongodb
#global gh_date      20151102
%global gh_project   mongo-php-library
%global psr0         MongoDB

%global upstream_version 1.9.0
%global upstream_prever  alpha1
%global upstream_lower   alpha1

%global ext_version      1.10

Name:           php-%{gh_owner}
Version:        %{upstream_version}%{?upstream_prever:~%{upstream_lower}}
%if 0%{?gh_date}
Release:        1%{gh_date}git%{gh_short}%{?dist}
%else
Release:        1%{?dist}
%endif
Summary:        MongoDB driver library

License:        ASL 2.0
URL:            https://github.com/%{gh_owner}/%{gh_project}
Source0:        https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{name}-%{upstream_version}%{?upstream_prever}-%{gh_short}.tar.gz

# Get rid of jean85/pretty-package-versions
Patch0:         %{name}-rpm.patch

BuildArch:      noarch
BuildRequires:  php(language) >= 7.0
BuildRequires:  php-cli
BuildRequires:  php-reflection
BuildRequires:  php-date
BuildRequires:  php-dom
BuildRequires:  php-hash
BuildRequires:  php-json
BuildRequires:  php-spl
# remirepo:1
%if 0%{?fedora} >= 31 || 0%{?rhel} >= 8
BuildRequires: (php-composer(symfony/polyfill-php80) >= 1.19 with php-composer(symfony/polyfill-php80) < 2)
# remirepo:4
%else
BuildRequires:  php-symfony-polyfill                 <  2
BuildRequires:  php-symfony-polyfill                 >= 1.19
%endif
%if %{with tests}
BuildRequires:  mongodb-server >= 2.4
BuildRequires:  php-pecl(mongodb) >= %{ext_version}
# From composer.json, "require-dev": {
#        "phpunit/phpunit": "^6.4 || ^8.3",
#        "sebastian/comparator": "^2.0 || ^3.0",
#        "squizlabs/php_codesniffer": "^3.5, <3.5.5",
#        "symfony/phpunit-bridge": "^5.x@dev"
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
%global phpunit %{_bindir}/phpunit9
%else
%global phpunit %{_bindir}/phpunit8
%endif
BuildRequires:  %{phpunit}
%endif
# For autoloader
BuildRequires:  php-composer(fedora/autoloader)

# From composer.json, "require": {
#        "php": "^7.0 || ^8.0"
#        "ext-hash": "*",
#        "ext-json": "*",
#        "ext-mongodb": "^1.8.1"
#        "jean85/pretty-package-versions": "^1.2 || ^2.0.1"
#        "symfony/polyfill-php80": "^1.19"
Requires:       php(language) >= 7.0
Requires:       php-hash
Requires:       php-json
Requires:       php-pecl(mongodb) >= %{ext_version}
# remirepo:1
%if 0%{?fedora} >= 31 || 0%{?rhel} >= 8
Requires:      (php-composer(symfony/polyfill-php80) >= 1.19 with php-composer(symfony/polyfill-php80) < 2)
# remirepo:4
%else
Requires:       php-symfony-polyfill                 <  2
Requires:       php-symfony-polyfill                 >= 1.19
%endif
# From phpcompatinfo report for 1.8.0
Requires:       php-reflection
Requires:       php-date
Requires:       php-spl
# For autoloader
Requires:       php-composer(fedora/autoloader)

# Composer
Provides:       php-composer(%{gh_owner}/%{gh_owner}) = %{version}%{?prever}


%description
This library provides a high-level abstraction around the lower-level drivers
for PHP and HHVM (i.e. the mongodb extension).

While the extension provides a limited API for executing commands, queries,
and write operations, this library implements an API similar to that of the
legacy PHP driver. It contains abstractions for client, database, and
collection objects, and provides methods for CRUD operations and common
commands (e.g. index and collection management).

Autoloader: %{_datadir}/php/%{psr0}/autoload.php


%prep
%setup -q -n %{gh_project}-%{gh_commit}

cat << 'EOF'  | tee src/autoload.php
<?php
/* Autoloader for mongodb/mongodb and its dependencies */

require_once '%{_datadir}/php/Fedora/Autoloader/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('MongoDB\\', __DIR__);
require_once __DIR__. '/functions.php';
\Fedora\Autoloader\Dependencies::required([
    '%{_datadir}/php/Symfony/Polyfill/autoload.php',
]);
EOF

# Get rid of jean85/pretty-package-versions
%patch0 -p1 -b .rpm
sed -e 's/@VERSION@/%{upstream_version}%{?upstream_prever:-%{upstream_lower}}/' -i src/Client.php
find src -name \*.rpm -delete
grep -F '%{upstream_version}' src/Client.php


%build
# Nothing


%install
mkdir -p   %{buildroot}%{_datadir}/php
cp -pr src %{buildroot}%{_datadir}/php/%{psr0}


%check
: Check autoloader
php -r '
require_once "%{buildroot}%{_datadir}/php/%{psr0}/autoload.php";
exit (class_exists("%{psr0}\\Client") ? 0 : 1);
'

%if %{with tests}
: Run a server
mkdir dbtest

: Choose a port to allow parallel build
port=$(php -r 'echo (27010+PHP_INT_SIZE+%{?fedora}%{?rhel});')

mongod \
  --journal \
  --logpath     $PWD/server.log \
  --pidfilepath $PWD/server.pid \
  --dbpath      $PWD/dbtest \
  --port        $port \
  --smallfiles \
  --fork

sed -e "s/27017/$port/" phpunit.xml.dist >phpunit.xml
cat << 'EOF' | tee tests/bootstrap.php
<?php
// Library
require_once '%{buildroot}%{_datadir}/php/%{psr0}/autoload.php';
// Test suite
\Fedora\Autoloader\Autoload::addPsr4('MongoDB\\Tests\\', __DIR__);
require_once __DIR__ . '/PHPUnit/Functions.php
EOF

: Run the test suite
ret=0
for cmdarg in "php %{phpunit}" "php72 %{_bindir}/phpunit8" php73 php74 php80; do
  if which $cmdarg; then
    set $cmdarg
    $1 ${2:-%{_bindir}/phpunit9} --verbose || ret=1
  fi
done

: Cleanup
[ -s server.pid ] && kill $(cat server.pid)

exit $ret
%else
: Test suite disabled
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc composer.json
%doc *.md
%doc docs
%{_datadir}/php/%{psr0}


%changelog
* Fri Apr  9 2021 Remi Collet <remi@remirepo.net> - 1.9.0~alpha1-1
- update to 1.9.0
- raise dependency on mongodb extension version 1.10

* Wed Nov 25 2020 Remi Collet <remi@remirepo.net> - 1.8.0-1
- update to 1.8.0
- raise dependency on mongodb extension 1.8.1
- add dependency on symfony/polyfill-php80

* Fri Nov  6 2020 Remi Collet <remi@remirepo.net> - 1.7.2-1
- update to 1.7.2

* Mon Oct 12 2020 Remi Collet <remi@remirepo.net> - 1.7.1-1
- update to 1.7.1

* Mon Aug 10 2020 Remi Collet <remi@remirepo.net> - 1.7.0-1
- update to 1.7.0
- raise dependency on PHP 7.0
- raise dependency on mongodb extension 1.8

* Wed Feb  5 2020 Remi Collet <remi@remirepo.net> - 1.6.0-1
- update to 1.6.0
- raise dependency on mongodb extension 1.7

* Tue Jan 14 2020 Remi Collet <remi@remirepo.net> - 1.5.2-1
- update to 1.5.2

* Thu Nov 14 2019 Remi Collet <remi@remirepo.net> - 1.5.1-1
- update to 1.5.1

* Mon Sep  9 2019 Remi Collet <remi@remirepo.net> - 1.5.0-1
- update to 1.5.0
- raise dependency on PHP 5.6
- raise dependency on mongodb extension 1.6

* Mon Aug 19 2019 Remi Collet <remi@remirepo.net> - 1.4.3-1
- update to 1.4.3

* Tue Feb  5 2019 Remi Collet <remi@remirepo.net> - 1.4.2-3
- disable test suite and so mongodb-server build dependency
  for https://fedoraproject.org/wiki/Changes/MongoDB_Removal

* Fri Aug 24 2018 Remi Collet <remi@remirepo.net> - 1.4.2-1
- update to 1.4.2

* Wed Jul 11 2018 Remi Collet <remi@remirepo.net> - 1.4.1-1
- update to 1.4.1

* Thu Jun 28 2018 Remi Collet <remi@remirepo.net> - 1.4.0-1
- update to 1.4.0
- raise dependency on mongodb extension 1.5.0

* Fri Apr 20 2018 Remi Collet <remi@remirepo.net> - 1.3.2-1
- update to 1.3.2

* Wed Apr  4 2018 Remi Collet <remi@remirepo.net> - 1.3.1-1
- update to 1.3.1

* Fri Feb  9 2018 Remi Collet <remi@remirepo.net> - 1.3.0-1
- Update to 1.3.0
- raise dependency on mongodb extension 1.4.0

* Tue Nov 14 2017 Remi Collet <remi@remirepo.net> - 1.2.0-1
- Update to 1.2.0
- raise dependency on PHP 5.5
- raise dependency on mongodb extension 1.3.0

* Sun May 14 2017 Remi Collet <remi@remirepo.net> - 1.1.2-2
- ensure fedora/autoloader is used

* Fri Feb 17 2017 Remi Collet <remi@remirepo.net> - 1.1.2-1
- update to 1.1.2

* Thu Jan 19 2017 Remi Collet <remi@fedoraproject.org> - 1.1.1-1
- update to 1.1.1

* Wed Dec  7 2016 Remi Collet <remi@fedoraproject.org> - 1.1.0-1
- update to 1.1.0
- raise dependency on php-pecl-mongodb 1.2.0
- switch to fedora/autoloader

* Tue Dec  6 2016 Remi Collet <remi@fedoraproject.org> - 1.0.4-1
- update to 1.0.4

* Tue Sep 27 2016 Remi Collet <remi@fedoraproject.org> - 1.0.3-1
- update to 1.0.3

* Thu Jul 28 2016 Remi Collet <remi@fedoraproject.org> - 1.0.2-2
- only run upstream test suite when build --with tests

* Thu Mar 31 2016 Remi Collet <remi@fedoraproject.org> - 1.0.2-1
- update to 1.0.2

* Sat Mar  5 2016 Remi Collet <remi@fedoraproject.org> - 1.0.1-1
- update to 1.0.1

* Fri Jan 22 2016 Remi Collet <remi@fedoraproject.org> - 1.0.0-1
- update to 1.0.0

* Mon Jan  4 2016 Remi Collet <remi@fedoraproject.org> - 1.0.0-0.4.beta2
- update to 1.0.0beta2
- raise dependency on pecl/mongodb ^1.1.1
- run test suite with both PHP 5 and 7 when available

* Tue Nov  3 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-0.3.beta1
- update to 1.0.0beta1

* Mon Nov  2 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-0.2.20151102gita3c0b97
- git snapshot

* Sat Oct 31 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-0.1.alpha1
- initial package