summaryrefslogtreecommitdiffstats
path: root/php-pimple.spec
blob: e7eb33c8aa8ee720fdb4734b3e3e7d73784b1d9f (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
# remirepo spec file for php-pimple, from:
#
# Fedora spec file for php-pimple
#
# Copyright (c) 2015-2018 Shawn Iwinski <shawn.iwinski@gmail.com>
#                         Christian Glombek <christian.glombek@rwth-aachen.de>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     silexphp
%global github_name      Pimple
%global github_version   3.5.0
%global github_commit    a94b3a4db7fb774b3d78dad2315ddc07629e1bed

%global composer_vendor  pimple
%global composer_project pimple

# "php": ">=5.3.0"
%global php_min_ver 7.2.5
# "psr/container": "^1.1|^2.0"
%global psr_container_min_ver 1.1
%global psr_container_max_ver 3.0
# "symfony/phpunit-bridge": "^5.4@dev"
# symfony5 isn't in the repos, but 4.4 works as well
%global phpunit_bridge_min_ver 4.4
%global phpunit_bridge_max_ver 6.0

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

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

Name:          php-%{composer_project}
Version:       %{github_version}
Release:       1%{?dist}
Summary:       A simple dependency injection container for PHP

Group:         Development/Libraries
License:       MIT
URL:           http://pimple.sensiolabs.org
Source0:       https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz

BuildArch:     noarch
# Tests
%if %{with_tests}
BuildRequires: phpunit8
## composer.json
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires:(php-composer(psr/container) >= %{psr_container_min_ver}           with php-composer(psr/container) <  %{psr_container_max_ver})
BuildRequires:(php-composer(symfony/phpunit-bridge) >= %{phpunit_bridge_min_ver} with php-composer(symfony/phpunit-bridge) < %{phpunit_bridge_max_ver})
%else
BuildRequires: php-psr-container2
BuildRequires: php-symfony4-phpunit-bridge
%endif

## phpcompatinfo (computed from version 3.5.0)
BuildRequires: php-reflection
BuildRequires: php-spl
## Autoloader
BuildRequires: php-composer(fedora/autoloader)
%endif

# composer.json
Requires:  php(language) >= %{php_min_ver}
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires: (php-composer(psr/container) >= %{psr_container_min_ver}           with php-composer(psr/container) <  %{psr_container_max_ver})
%else
Requires:  php-psr-container2
%endif
# phpcompatinfo (computed from version 3.2.3)
Requires:  php-spl
## Autoloader
Requires:  php-composer(fedora/autoloader)

# Composer
Provides:  php-composer(%{composer_vendor}/%{composer_project}) = %{version}
# Rename
Obsoletes: php-Pimple < %{version}-%{release}
Provides:  php-Pimple = %{version}-%{release}
# Drop extension
Obsoletes: php-pimple-lib < %{version}-%{release}
Provides:  php-pimple-lib = %{version}-%{release}

%description
%{summary}.

Autoloader: %{phpdir}/Pimple/autoload.php


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


%build
: Create autoloader
cat <<'AUTOLOAD' | tee src/Pimple/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('Pimple\\', __DIR__);

\Fedora\Autoloader\Dependencies::required(array(
    array(
        '%{phpdir}/Psr/Container2/autoload.php', // v2 preferred
        '%{phpdir}/Psr/Container/autoload.php', // v1 as fallback
)));
AUTOLOAD


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


%check
: Check the autoloader
%{_bindir}/php -r "
    require_once '%{buildroot}/%{phpdir}/Pimple/autoload.php';
    exit(
        class_exists('\Pimple\Container')
        ? 0 : 1
    );
"

%if %{with_tests}
: Create a autoloader for tests
mkdir vendor
cat << 'EOF' | tee vendor/autoload.php
<?php
require_once '%{buildroot}/%{phpdir}/Pimple/autoload.php';
require_once '%{phpdir}/Symfony4/Bridge/PhpUnit/autoload.php';
EOF

: Upstream tests
: Run phpunit tests
RETURN_CODE=0
PHPUNIT=$(which phpunit8)
for PHP_EXEC in php php74 php80 php81; do
    if which $PHP_EXEC; then
        $PHP_EXEC $PHPUNIT --verbose \
            || RETURN_CODE=1
    fi
done
exit $RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc CHANGELOG
%doc README.rst
%doc composer.json
%{phpdir}/Pimple
%exclude %{phpdir}/Pimple/Tests


%changelog
* Thu Aug 11 2022 Remi Collet <remi@remirepo.net> - 3.5.0-1
- update to 3.5.0, from Fedora
- switch to phpunit8
- use range dependencies

* Thu Feb 22 2018 Remi Collet <remi@remirepo.net> - 3.2.3-1
- sync with rawhide spec

* Fri Feb 09 2018 Christian Glombek <christian.glombek@rwth-aachen.de> - 3.2.3-1
- Update to 3.2.3 (RHBZ #1467881)

* Sat Aug 05 2017 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.2.2-1
- Update to 3.2.2 (RHBZ #1467881)
- Drop extension completely
- Switch autoloader to php-composer(fedora/autoloader)
- Test with SCLs if available

* Wed Aug  5 2015 Remi Collet <remi@remirepo.net> - 3.0.1-1
- backport for #remirepo
- adapt for SCL
- drop library subpackage in SCL

* Sun Aug 02 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.0.1-1
- Updated to 3.0.1

* Mon Jul 20 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.0.0-5
- Autoloader changed to Symfony ClassLoader

* Thu May 21 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.0.0-4
- Add library autoloader
- Spec cleanup

* Wed Sep 03 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.0.0-3
- Separate extension and library (i.e. sub-package library)

* Mon Aug 25 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.0.0-2
- Fixed compat file location in description
- Included real class in compat file
- Always run extension minimal load test
- Fixed test suite with previous installed version
- "make test NO_INTERACTION=1 REPORT_EXIT_STATUS=1" instead of "echo "n" | make test"

* Thu Jul 31 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.0.0-1
- Updated to 3.0.0
- Added custom compat file for obsoleted php-Pimple

* Tue Jul 29 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.1.1-1
- Initial package