summaryrefslogtreecommitdiffstats
path: root/php-doctrine-orm.spec
blob: f3fa73b23fa941d6553b89b57ac2c5e1f57cf52a (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
# remirepo spec file for php-doctrine-orm, from
#
# Fedora spec file for php-doctrine-orm
#
# Copyright (c) 2013-2016 Shawn Iwinski <shawn.iwinski@gmail.com>
#                         Remi Collet <remi@fedoraproject.org>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     doctrine
%global github_name      doctrine2
%global github_version   2.4.8
%global github_commit    5aedac1e5c5caaeac14798822c70325dc242d467

%global composer_vendor  doctrine
%global composer_project orm

# "php": ">=5.3.2"
%global php_min_ver 5.3.2
# "doctrine/collections": "~1.1"
#     NOTE: Min version not 1.1 because autoloader required
%global collections_min_ver 1.3.0
%global collections_max_ver 2.0
# "doctrine/dbal": "~2.4"
#     NOTE: Min version not 2.4 because autoloader required
%global dbal_min_ver 2.5.4
%global dbal_max_ver 3.0
# "symfony/console": "~2.0"
# "symfony/yaml": "~2.1"
#     NOTE: Min version not 2.1 because autoloader required
%global symfony_min_ver 2.7.1
%global symfony_max_ver 3.0

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

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

Name:          php-%{composer_vendor}-%{composer_project}
Version:       %{github_version}
Release:       1%{?dist}
Summary:       Doctrine Object-Relational-Mapper (ORM)

Group:         Development/Libraries
License:       MIT
URL:           http://www.doctrine-project.org/projects/orm.html

# Run "php-doctrine-orm-get-source.sh" to create source
Source0:       %{name}-%{version}-%{github_commit}.tar.gz
Source1:       %{name}-get-source.sh

# Update bin script:
# 1) Add she-bang
# 2) Auto-load using Doctrine\Common\ClassLoader
Patch0:        %{name}-bin.patch

# Fix test suite using PHPUnit 5.4
Patch1:        %{name}-phpunit54.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
%if %{with_tests}
BuildRequires: php-composer(phpunit/phpunit)
# composer.json
BuildRequires: php(language)                      >= %{php_min_ver}
BuildRequires: php-composer(doctrine/collections) <  %{collections_max_ver}
BuildRequires: php-composer(doctrine/collections) >= %{collections_min_ver}
BuildRequires: php-composer(doctrine/dbal)        <  %{dbal_max_ver}
BuildRequires: php-composer(doctrine/dbal)        >= %{dbal_min_ver}
BuildRequires: php-composer(symfony/console)      <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/console)      >= %{symfony_min_ver}
BuildRequires: php-composer(symfony/yaml)         <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/yaml)         >= %{symfony_min_ver}
BuildRequires: php-pdo
# phpcompatinfo (computed from version 2.4.8)
BuildRequires: php-ctype
BuildRequires: php-date
BuildRequires: php-dom
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-simplexml
BuildRequires: php-spl
BuildRequires: php-tokenizer
%endif

# composer.json
Requires:      php(language)                      >= %{php_min_ver}
Requires:      php-composer(doctrine/collections) <  %{collections_max_ver}
Requires:      php-composer(doctrine/collections) >= %{collections_min_ver}
Requires:      php-composer(doctrine/dbal)        <  %{dbal_max_ver}
Requires:      php-composer(doctrine/dbal)        >= %{dbal_min_ver}
Requires:      php-composer(symfony/console)      <  %{symfony_max_ver}
Requires:      php-composer(symfony/console)      >= %{symfony_min_ver}
Requires:      php-composer(symfony/yaml)         <  %{symfony_max_ver}
Requires:      php-composer(symfony/yaml)         >= %{symfony_min_ver}
Requires:      php-pdo
# phpcompatinfo (computed from version 2.4.8)
Requires:      php-ctype
Requires:      php-dom
Requires:      php-pcre
Requires:      php-reflection
Requires:      php-simplexml
Requires:      php-spl
Requires:      php-tokenizer

# Weak dependencies
%if 0%{?fedora} >= 21
## Optional caches (see Doctrine\ORM\Tools\Setup::createConfiguration())
Suggests:      php-pecl(apcu)
Suggests:      php-pecl(memcache)
Suggests:      php-pecl(redis)
Suggests:      php-xcache
%endif

# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}
# PEAR
Provides:      php-pear(pear.doctrine-project.org/DoctrineORM) = %{version}
# Rename
Obsoletes:     php-doctrine-DoctrineORM < %{version}
Provides:      php-doctrine-DoctrineORM = %{version}

%description
Object relational mapper (ORM) for PHP that sits on top of a powerful database
abstraction layer (DBAL). One of its' key features is the option to write
database queries in a proprietary object oriented SQL dialect called Doctrine
Query Language (DQL), inspired by Hibernate's HQL. This provides developers
with a powerful alternative to SQL that maintains flexibility without requiring
unnecessary code duplication.

Autoloader: %{phpdir}/Doctrine/ORM/autoload.php


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

: Patch bin script
%patch0 -p1

if %{_bindir}/phpunit --atleast-version 5.4; then
: Fix test suite using PHPUnit 5.4
%patch1 -p0
fi

: Remove empty file
rm -f lib/Doctrine/ORM/README.markdown

: Remove unnecessary executable bits
chmod a-x lib/Doctrine/ORM/Tools/Pagination/Paginator.php


%build
: Create autoloader
cat <<'AUTOLOAD' | tee lib/Doctrine/ORM/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 *
 * @return \Symfony\Component\ClassLoader\ClassLoader
 */

if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
    if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
        require_once '%{phpdir}/Symfony/Component/ClassLoader/ClassLoader.php';
    }

    $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
    $fedoraClassLoader->register();
}

$fedoraClassLoader->addPrefix('Doctrine\\ORM\\', dirname(dirname(__DIR__)));

// Dependencies (autoloader => required)
foreach(array(
    '%{phpdir}/Doctrine/Common/Collections/autoload.php' => true,
    '%{phpdir}/Doctrine/DBAL/autoload.php'               => true,
    '%{phpdir}/Symfony/Component/Console/autoload.php'   => true,
    '%{phpdir}/Symfony/Component/Yaml/autoload.php'      => true,
) as $dependencyAutoloader => $required) {
    if ($required || file_exists($dependencyAutoloader)) {
        require_once $dependencyAutoloader;
    }
}

return $fedoraClassLoader;
AUTOLOAD


%install
rm -rf %{buildroot}

: Lib
mkdir -p %{buildroot}%{phpdir}
cp -rp lib/Doctrine %{buildroot}%{phpdir}/

: Bin
mkdir -p %{buildroot}/%{_bindir}
install -pm 0755 bin/doctrine.php %{buildroot}/%{_bindir}/doctrine


%check
%if %{with_tests}
: Remove load of TestInit
mv tests/Doctrine/Tests/TestInit.php tests/Doctrine/Tests/TestInit.php.dist
grep -r --files-with-matches 'TestInit' tests \
    | xargs sed '/TestInit/d' -i

: Load annotation register file from buildroot
sed 's#__DIR__\s*\.\s*"/\(\.\./\)*lib#"%{buildroot}%{phpdir}#' \
    -i tests/Doctrine/Tests/OrmTestCase.php

: Create tests bootstrap
cat > bootstrap.php <<'BOOTSTRAP'
<?php
$fedoraClassLoader =
    require_once '%{buildroot}%{phpdir}/Doctrine/ORM/autoload.php';

$fedoraClassLoader->addPrefix('Doctrine\\Tests\\', __DIR__.'/tests');
BOOTSTRAP

# Skip test known to fail
sed -e 's/function testQueryCache_DependsOnHints/function SKIP_testQueryCache_DependsOnHints/' \
    -e 's/function testQueryCache_NoHitSaveParserResult/function SKIP_testQueryCache_NoHitSaveParserResult/' \
    -i tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php
sed 's/function testNativeQueryResultCaching/function SKIP_testNativeQueryResultCaching/' \
    -i tests/Doctrine/Tests/ORM/Functional/ResultCacheTest.php
sed 's/function testQueryCache_DependsOnFilters/function SKIP_testQueryCache_DependsOnFilters/' \
    -i tests/Doctrine/Tests/ORM/Functional/SQLFilterTest.php
%if 1
# PHP 7
sed 's/function testReusedSplObjectHashDoesNotConfuseUnitOfWork/function SKIP_testReusedSplObjectHashDoesNotConfuseUnitOfWork/' \
    -i tests/Doctrine/Tests/ORM/Functional/IdentityMapTest.php
%endif

# Weird el6 error
# TODO: Investigate and submit upstream patch
%if 0%{?el6}
sed 's#$this->_em->clear();#if (isset($this->_em)) { $this->_em->clear(); }#' \
    -i tests/Doctrine/Tests/OrmFunctionalTestCase.php
%endif
%if 0%{?el5}
# Seems to use sqlite3, not available
rm tests/Doctrine/Tests/ORM/Functional/QueryDqlFunctionTest.php
%endif

ret=0
run=0
if which php56; then
  php56 %{_bindir}/phpunit -d memory_limit="512M" --bootstrap bootstrap.php || ret=1
  run=1
fi
if which php71; then
  php71 %{_bindir}/phpunit -d memory_limit="512M" --bootstrap bootstrap.php || ret=1
  run=1
fi
if [ $run -eq 0 ]; then
  %{_bindir}/phpunit -d memory_limit="512M" --bootstrap bootstrap.php
fi
exit $ret
%else
: Tests skipped
%endif


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md *.markdown composer.json
%{_datadir}/php/Doctrine/ORM
%{_bindir}/doctrine


%changelog
* Sat Jul 09 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.8-1
- Updated to 2.4.8 (RHBZ #1347926 / CVE-2015-5723)
- Added autoloader

* Mon Jun 13 2016 Remi Collet <remi@fedoraproject.org> - 2.4.7-5
- add workaround for test suite with PHPUnit 5.4

* Sun Feb 28 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.7-4
- Skip additional tests known to fail (RHBZ #1307857)

* Sun Dec 28 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.7-1
- Updated to 2.4.7 (BZ #1175217)
- %%license usage

* Mon Nov 03 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.6-2
- Ensure 512M of memory (instead of default 128M) so mock x86_64
  builds pass (BZ #1159650)

* Tue Oct 14 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.6-1
- Updated to 2.4.6 (BZ #1108129)
- Manual git clone source instead of GitHub archive URL (to include tests)
- Removed Patch1 (%%{name}-upstream.patch)
- Added tests

* Tue Oct  7 2014 Remi Collet <remi@fedoraproject.org> 2.4.6-1
- Update to 2.4.6

* Tue Sep 23 2014 Remi Collet <remi@fedoraproject.org> 2.4.5-1
- Update to 2.4.5

* Sat Sep 13 2014 Remi Collet <remi@fedoraproject.org> 2.4.4-1
- Update to 2.4.4
- backport upstream patch to use doctrine/instantiator
- fix license handling

* Sat Jun 21 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.2-4
- Added php-composer(%%{composer_vendor}/%%{composer_project}) virtual provide
- Updated Doctrine dependencies to use php-composer virtual provides

* Fri May 30 2014 Remi Collet <remi@fedoraproject.org> 2.4.2-2
- upstream fix for latest PHP (#1103219)

* Mon Feb 17 2014 Remi Collet <rpms@famillecollet.com> 2.4.2-1
- backport 2.4.2 for remi repo

* Wed Feb 12 2014 Shawn Iwinski <shawn.iwinski@gmail.com> 2.4.2-1
- Updated to 2.4.2 (BZ #1063021)

* Sat Jan 11 2014 Remi Collet <rpms@famillecollet.com> 2.4.1-2
- backport for remi repo

* Sat Jan 04 2014 Shawn Iwinski <shawn.iwinski@gmail.com> 2.4.1-2
- Conditional %%{?dist}
- Bin script patch instead of inline update and use Doctrine Common classloader
- Updated optional cache information in %%description
- Removed empty file
- Removed unnecessary executable bit

* Sat Dec 28 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 2.4.1-1
- Initial package