summaryrefslogtreecommitdiffstats
path: root/php-jms-serializer.spec
blob: 72dcb87a46629df8bfa638f99066073976a803a9 (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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
# remirepo spec file for php-jms-serializer, from
#
# Fedora spec file for php-jms-serializer
#
# Copyright (c) 2017-2020 Shawn Iwinski <shawn@iwin.ski>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     schmittjoh
%global github_name      serializer
%global github_version   1.14.1
%global github_commit    ba908d278fff27ec01fb4349f372634ffcd697c0

%global composer_vendor  jms
%global composer_project serializer

# Deprecate Symfony 2 on Fedora 32+ and EPEL 8+
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 8
%global with_symfony2 0
%else
%global with_symfony2 1
%endif

# "php": "^5.5|^7.0"
%global php_min_ver 5.5.0
# "doctrine/annotations": "^1.0"
#     NOTE: Min version not 1.0 because autoloader required
%global doctrine_annotations_min_ver 1.2.6
%global doctrine_annotations_max_ver 2.0
# "doctrine/instantiator": "^1.0.3"
%global doctrine_instantiator_min_ver 1.0.3
%global doctrine_instantiator_max_ver 2.0
# "doctrine/orm": "~2.1"
#     NOTE: Min version not 2.1 because autoloader required
%global doctrine_orm_min_ver 2.4.8
%global doctrine_orm_max_ver 3.0
# "jms/metadata": "^1.3"
#     NOTE: Min version not 1.3 because autoloader required
%global jms_metadata_min_ver 1.6.0
%global jms_metadata_max_ver 2.0
# "jms/parser-lib": "1.*"
#     NOTE: Min version not 1.0 because autoloader required
%global jms_parser_lib_min_ver 1.0.0-7
%global jms_parser_lib_max_ver 2.0
# "phpcollection/phpcollection": "~0.1"
#     NOTE: Min version not 0.1 because autoloader required
%global phpcollection_min_ver 0.5.0
%global phpcollection_max_ver 1.0
# "phpoption/phpoption": "^1.1"
#     NOTE: Min version not 1.1 because autoloader required
%global phpoption_min_ver 1.5.0
%global phpoption_max_ver 2.0
# "psr/container": "^1.0"
%global psr_container_min_ver 1.0
%global psr_container_max_ver 2.0
# "symfony/dependency-injection": "^2.7|^3.3|^4.0"
# "symfony/expression-language": "^2.6|^3.0"
# "symfony/filesystem": "^2.1"
# "symfony/form": "~2.1|^3.0"
# "symfony/translation": "^2.1|^3.0"
# "symfony/validator": "^2.2|^3.0"
# "symfony/yaml": "^2.1|^3.0"
%if %{with_symfony2}
#     NOTE: Min version not 2.6 because autoloader required
%global symfony_min_ver 2.7.1
%else
%global symfony_min_ver 3.3
%endif
%global symfony_max_ver 4.0

# "twig/twig": "~1.12|~2.0"
#     NOTE: Min version not 1.12 because autoloader required
%global twig_min_ver 1.18.2
%if 0%{?fedora} >= 25 || 0%{?rhel} >= 8
%global twig_max_ver 3.0
%else
%global twig_max_ver 2.0
%endif

# Build using "--without tests" to disable tests
%global with_tests 0%{!?_without_tests:1}

# Range dependencies supported?
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
%global with_range_dependencies 1
%else
%global with_range_dependencies 0
%endif

# Weak dependencies supported?
%if 0%{?fedora} >= 21 || 0%{?rhel} >= 8
%global with_weak_dependencies 1
%else
%global with_weak_dependencies 0
%endif

%{!?phpdir:  %global phpdir  %{_datadir}/php}

Name:          php-%{composer_vendor}-%{composer_project}
Version:       %{github_version}
Release:       3%{?github_release}%{?dist}
Summary:       Library for (de-)serializing data of any complexity

License:       MIT
URL:           http://jmsyst.com/libs/serializer

# GitHub export contains non-allowable licened documentation.
# Run php-jms-serializer-get-source.sh to create allowable source.
Source0:       %{name}-%{github_version}-%{github_commit}.tar.gz
Source1:       %{name}-get-source.sh

BuildArch:     noarch
# Tests
%if %{with_tests}
BuildRequires: php-cli
## composer.json
BuildRequires: php(language) >= %{php_min_ver}
BuildRequires: php-composer(phpunit/phpunit)
%if %{with_range_dependencies}
BuildRequires: (php-composer(doctrine/annotations) >= %{doctrine_annotations_min_ver} with php-composer(doctrine/annotations) < %{doctrine_annotations_max_ver})
BuildRequires: (php-composer(doctrine/instantiator) >= %{doctrine_instantiator_min_ver} with php-composer(doctrine/instantiator) < %{doctrine_instantiator_max_ver})
BuildRequires: (php-composer(doctrine/orm) >= %{doctrine_orm_min_ver} with php-composer(doctrine/orm) < %{doctrine_orm_max_ver})
BuildRequires: (php-composer(jms/metadata) >= %{jms_metadata_min_ver} with php-composer(jms/metadata) < %{jms_metadata_max_ver})
BuildRequires: (php-JMSParser >= %{jms_parser_lib_min_ver} with php-composer(jms/parser-lib) < %{jms_parser_lib_max_ver})
BuildRequires: (php-composer(phpcollection/phpcollection) >= %{phpcollection_min_ver} with php-composer(phpcollection/phpcollection) < %{phpcollection_max_ver})
BuildRequires: (php-composer(phpoption/phpoption) >= %{phpoption_min_ver} with php-composer(phpoption/phpoption) < %{phpoption_max_ver})
BuildRequires: (php-composer(psr/container) >= %{psr_container_min_ver} with php-composer(psr/container) < %{psr_container_max_ver})
BuildRequires: (php-composer(symfony/dependency-injection) >= %{symfony_min_ver} with php-composer(symfony/dependency-injection) < %{symfony_max_ver})
BuildRequires: (php-composer(symfony/expression-language) >= %{symfony_min_ver} with php-composer(symfony/expression-language) < %{symfony_max_ver})
BuildRequires: (php-composer(symfony/filesystem) >= %{symfony_min_ver} with php-composer(symfony/filesystem) < %{symfony_max_ver})
BuildRequires: (php-composer(symfony/form) >= %{symfony_min_ver} with php-composer(symfony/form) < %{symfony_max_ver})
BuildRequires: (php-composer(symfony/translation) >= %{symfony_min_ver} with php-composer(symfony/translation) < %{symfony_max_ver})
BuildRequires: (php-composer(symfony/validator) >= %{symfony_min_ver} with php-composer(symfony/validator) < %{symfony_max_ver})
BuildRequires: (php-composer(symfony/yaml) >= %{symfony_min_ver} with php-composer(symfony/yaml) < %{symfony_max_ver})
BuildRequires: (php-composer(twig/twig) >= %{twig_min_ver} with php-composer(twig/twig) < %{twig_max_ver})
%else
BuildRequires: php-composer(doctrine/annotations) <  %{doctrine_annotations_max_ver}
BuildRequires: php-composer(doctrine/annotations) >= %{doctrine_annotations_min_ver}
BuildRequires: php-composer(doctrine/instantiator) <  %{doctrine_instantiator_max_ver}
BuildRequires: php-composer(doctrine/instantiator) >= %{doctrine_instantiator_min_ver}
BuildRequires: php-composer(doctrine/orm) <  %{doctrine_orm_max_ver}
BuildRequires: php-composer(doctrine/orm) >= %{doctrine_orm_min_ver}
BuildRequires: php-composer(jms/metadata) <  %{jms_metadata_max_ver}
BuildRequires: php-composer(jms/metadata) >= %{jms_metadata_min_ver}
BuildRequires: php-composer(jms/parser-lib) <  %{jms_parser_lib_max_ver}
#BuildRequires: php-composer(jms/parser-lib) >= %%{jms_parser_lib_min_ver}
BuildRequires: php-JMSParser                >= %{jms_parser_lib_min_ver}
BuildRequires: php-composer(phpcollection/phpcollection) <  %{phpcollection_max_ver}
BuildRequires: php-composer(phpcollection/phpcollection) >= %{phpcollection_min_ver}
BuildRequires: php-composer(phpoption/phpoption) <  %{phpoption_max_ver}
BuildRequires: php-composer(phpoption/phpoption) >= %{phpoption_min_ver}
BuildRequires: php-composer(psr/container) <  %{psr_container_max_ver}
BuildRequires: php-composer(psr/container) >= %{psr_container_min_ver}
BuildRequires: php-composer(symfony/dependency-injection) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/expression-language) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/filesystem) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/form) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/translation) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/validator) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/yaml) <  %{symfony_max_ver}
BuildRequires: php-composer(twig/twig) <  %{twig_max_ver}
BuildRequires: php-composer(twig/twig) >= %{twig_min_ver}
%endif
## phpcompatinfo (computed from version 1.14.1)
BuildRequires: php-composer(doctrine/cache) < 2
BuildRequires: php-composer(doctrine/common) < 3
BuildRequires: php-date
BuildRequires: php-dom
BuildRequires: php-json
BuildRequires: php-libxml
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-simplexml
BuildRequires: php-spl
## Autoloader
BuildRequires: php-composer(fedora/autoloader)
%endif

# composer.json
Requires:      php(language) >= %{php_min_ver}
%if %{with_range_dependencies}
Requires:      (php-composer(doctrine/annotations) >= %{doctrine_annotations_min_ver} with php-composer(doctrine/annotations) < %{doctrine_annotations_max_ver})
Requires:      (php-composer(doctrine/instantiator) >= %{doctrine_instantiator_min_ver} with php-composer(doctrine/instantiator) < %{doctrine_instantiator_max_ver})
Requires:      (php-composer(jms/metadata) >= %{jms_metadata_min_ver} with php-composer(jms/metadata) < %{jms_metadata_max_ver})
Requires:      (php-JMSParser >= %{jms_parser_lib_min_ver} with php-composer(jms/parser-lib) < %{jms_parser_lib_max_ver})
Requires:      (php-composer(phpcollection/phpcollection) >= %{phpcollection_min_ver} with php-composer(phpcollection/phpcollection) < %{phpcollection_max_ver})
Requires:      (php-composer(phpoption/phpoption) >= %{phpoption_min_ver} with php-composer(phpoption/phpoption) < %{phpoption_max_ver})
%else
Requires:      php-composer(doctrine/annotations) <  %{doctrine_annotations_max_ver}
Requires:      php-composer(doctrine/annotations) >= %{doctrine_annotations_min_ver}
Requires:      php-composer(doctrine/instantiator) <  %{doctrine_instantiator_max_ver}
Requires:      php-composer(doctrine/instantiator) >= %{doctrine_instantiator_min_ver}
Requires:      php-composer(jms/metadata) <  %{jms_metadata_max_ver}
Requires:      php-composer(jms/metadata) >= %{jms_metadata_min_ver}
Requires:      php-composer(jms/parser-lib) <  %{jms_parser_lib_max_ver}
#Requires:      php-composer(jms/parser-lib) >= %%{jms_parser_lib_min_ver}
Requires:      php-JMSParser                >= %{jms_parser_lib_min_ver}
Requires:      php-composer(phpcollection/phpcollection) <  %{phpcollection_max_ver}
Requires:      php-composer(phpcollection/phpcollection) >= %{phpcollection_min_ver}
Requires:      php-composer(phpoption/phpoption) <  %{phpoption_max_ver}
Requires:      php-composer(phpoption/phpoption) >= %{phpoption_min_ver}
%endif
# phpcompatinfo (computed from version 1.14.1)
Requires:      php-composer(doctrine/common) < 3
Requires:      php-date
Requires:      php-dom
Requires:      php-json
Requires:      php-libxml
Requires:      php-pcre
Requires:      php-simplexml
Requires:      php-spl
# Autoloader
Requires:      php-composer(fedora/autoloader)

%if %{with_weak_dependencies}
# Weak dependencies
Suggests:      php-composer(symfony/yaml)
Suggests:      php-composer(doctrine/collections)
Suggests:      php-composer(doctrine/cache)
%endif

# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}

%description
This library allows you to (de-)serialize data of any complexity. Currently, it
supports XML, JSON, and YAML.

It also provides you with a rich tool-set to adapt the output to your specific
needs.

Built-in features include:
* (De-)serialize data of any complexity; circular references are handled
  gracefully.
* Supports many built-in PHP types (such as dates)
* Integrates with Doctrine ORM, et. al.
* Supports versioning, e.g. for APIs
* Configurable via PHP, XML, YAML, or Doctrine Annotations

Autoloader: %{phpdir}/JMS/Serializer/autoload.php


%prep
%setup -qn %{github_name}-%{github_commit}

: Remove Propel
find . -type f -name '*Propel*' -delete -print
sed '/Propel/d' -i src/JMS/Serializer/SerializerBuilder.php

: Remove Doctrine PHPCR
find . -type f -name '*PHPCR*' -delete -print


%build
: Create autoloader
cat <<'AUTOLOAD' | tee src/JMS/Serializer/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 */
require_once '%{phpdir}/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('JMS\\Serializer\\', __DIR__);

\Fedora\Autoloader\Dependencies::required([
    '%{phpdir}/Doctrine/Common/Annotations/autoload.php',
    [
        '%{phpdir}/Doctrine/Common/Persistence/autoload.php',
        '%{phpdir}/Doctrine/Common/autoload.php',
    ],
    '%{phpdir}/Doctrine/Instantiator/autoload.php',
    '%{phpdir}/JMS/Parser/autoload.php',
    '%{phpdir}/Metadata/autoload.php',
    '%{phpdir}/PhpCollection/autoload.php',
    '%{phpdir}/PhpOption/autoload.php',
]);

\Fedora\Autoloader\Dependencies::optional([
    '%{phpdir}/Doctrine/Common/Cache/autoload.php',
    '%{phpdir}/Doctrine/Common/Collections/autoload.php',
%if %{with_symfony2}
    [
        '%{phpdir}/Symfony3/Component/Yaml/autoload.php',
        '%{phpdir}/Symfony/Component/Yaml/autoload.php',
    ],
%else
    '%{phpdir}/Symfony3/Component/Yaml/autoload.php',
%endif
]);
AUTOLOAD


%install
mkdir -p %{buildroot}%{phpdir}
cp -rp src/JMS %{buildroot}%{phpdir}/


%check
%if %{with_tests}
: Create tests bootstrap
cat <<'BOOTSTRAP' | tee bootstrap.php
<?php
require '%{buildroot}%{phpdir}/JMS/Serializer/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('JMS\\Serializer\\Tests\\', __DIR__.'/tests');

\Fedora\Autoloader\Dependencies::required([
    '%{phpdir}/Doctrine/ORM/autoload.php',
    '%{phpdir}/Psr/Container/autoload.php',
%if %{with_symfony2}
    [
        '%{phpdir}/Symfony3/Component/DependencyInjection/autoload.php',
        '%{phpdir}/Symfony/Component/DependencyInjection/autoload.php',
    ],
    [
        '%{phpdir}/Symfony3/Component/ExpressionLanguage/autoload.php',
        '%{phpdir}/Symfony/Component/ExpressionLanguage/autoload.php',
    ],
    [
        '%{phpdir}/Symfony3/Component/Filesystem/autoload.php',
        '%{phpdir}/Symfony/Component/Filesystem/autoload.php',
    ],
    [
        '%{phpdir}/Symfony3/Component/Form/autoload.php',
        '%{phpdir}/Symfony/Component/Form/autoload.php',
    ],
    [
        '%{phpdir}/Symfony3/Component/Translation/autoload.php',
        '%{phpdir}/Symfony/Component/Translation/autoload.php',
    ],
    [
        '%{phpdir}/Symfony3/Component/Validator/autoload.php',
        '%{phpdir}/Symfony/Component/Validator/autoload.php',
    ],
%else
    '%{phpdir}/Symfony3/Component/DependencyInjection/autoload.php',
    '%{phpdir}/Symfony3/Component/ExpressionLanguage/autoload.php',
    '%{phpdir}/Symfony3/Component/Filesystem/autoload.php',
    '%{phpdir}/Symfony3/Component/Form/autoload.php',
    '%{phpdir}/Symfony3/Component/Translation/autoload.php',
    '%{phpdir}/Symfony3/Component/Validator/autoload.php',
%endif
    (PHP_VERSION_ID < 70000)
        ? '%{phpdir}/Twig/autoload.php'
        : [
            '%{phpdir}/Twig2/autoload.php',
            '%{phpdir}/Twig/autoload.php',
        ],
]);

use Doctrine\Common\Annotations\AnnotationRegistry;
AnnotationRegistry::registerLoader('class_exists');
BOOTSTRAP

: Skip test known to fail
sed 's/function testInlineArray/function SKIP_testInlineArray/' \
    -i tests/Serializer/JsonSerializationTest.php

: Upstream tests
RETURN_CODE=0
PHPUNIT=$(which phpunit)
for PHP_EXEC in php php72 php73 php74; do
    if [ "php" = "$PHP_EXEC" ] || which $PHP_EXEC; then
        if [ $($PHP_EXEC -r 'echo PHP_VERSION_ID;') -lt 70200 ]; then
            sed \
                -e 's/function testArrayFloats/function SKIP_testArrayFloats/' \
                -e 's/function testCurrencyAwarePrice/function SKIP_testCurrencyAwarePrice/' \
                -i tests/Serializer/BaseSerializationTest.php
        fi

        $PHP_EXEC $PHPUNIT --bootstrap bootstrap.php || RETURN_CODE=1
    fi
done
exit $RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc composer.json
%{phpdir}/JMS/Serializer


%changelog
* Tue Aug 18 2020 Shawn Iwinski <shawn@iwin.ski> - 1.14.1-3
- Bumping release to ensure all changes are built

* Tue Aug 18 2020 Remi Collet <remi@remirepo.net> - 1.14.1-2
- Update to 1.14.1 (previous update failed to change commit hash so 1.10.0 was built)
- Change license from ASL 2.0 to MIT

* Tue Aug 18 2020 Shawn Iwinski <shawn@iwin.ski> - 1.14.1-1
- Update to 1.14.1
- Fix FTBFS (RHBZ #1865219)
- Conditionally use range dependencies
- Conditionally drop Symfony 2 interoperability

* Tue Feb 26 2019 Remi Collet <remi@remirepo.net> - 1.10.0-5
- cleanup for EL-8

* Thu Dec 14 2017 Shawn Iwinski <shawn@iwin.ski> - 1.10.0-1
- Update to 1.10.0 (RHBZ #1508429)
- Allow Symfony 3

* Sat Oct 07 2017 Shawn Iwinski <shawn@iwin.ski> - 1.9.0-1
- Update to 1.9.0
- Copy some remirepo modifications to make backporting easier:
  https://git.remirepo.net/cgit/rpms/php/jms/php-jms-serializer.git/commit/?id=a33673e63e7e85740df0b340eafb96c8682a084a

* Sat Aug 12 2017 Shawn Iwinski <shawn@iwin.ski> - 1.8.1-1
- Update to 1.8.1

* Wed Jul 12 2017 Shawn Iwinski <shawn@iwin.ski> - 1.7.1-1
- Initial package