summaryrefslogtreecommitdiffstats
path: root/php-friendsofphp-proxy-manager-lts.spec
blob: 6bb11faa51c297c95038087061a1bc7ed24cd365 (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
# remirepo/fedora spec file for php-friendsofphp-proxy-manager-lts
#
# Copyright (c) 2021-2022 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#

%global github_owner     FriendsOfPHP
%global github_name      proxy-manager-lts
%global github_version   1.0.7
%global github_commit    c828ced1f932094ab79e4120a106a666565e4d9c
%global github_short     %(c=%{github_commit}; echo ${c:0:7})
%global major            %nil

%global ns_project       ProxyManager

%global composer_vendor  friendsofphp
%global composer_project proxy-manager-lts

# Build using "--without tests" to disable tests
%bcond_without tests

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

Name:          php-%{composer_vendor}-%{composer_project}%{major}
Version:       %{github_version}
Release:       1%{?github_release}%{?dist}
Summary:       OOP proxy wrappers utilities

License:       MIT
URL:           https://github.com/%{github_owner}/%{github_name}
Source0:       %{name}-%{github_version}-%{github_short}.tgz
Source1:       makesrc.sh

BuildArch:     noarch
# As we use phpunit9
BuildRequires: php(language) >= 7.3
%if %{with tests}
BuildRequires: php-reflection
BuildRequires: php-pcre
BuildRequires: php-spl
# remirepo:1
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
BuildRequires:(php-composer(laminas/laminas-code) >= 4       with php-composer(laminas/laminas-code) <  5)
BuildRequires:(php-composer(symfony/filesystem)   >= 4.4.17  with php-composer(symfony/filesystem)   <  7)
## composer.json (require-dev)
#        "ext-phar":                     "*",
#        "symfony/phpunit-bridge":       "^5.4|^6.0"
# remirepo:4
%else
BuildRequires: php-laminas-code                   >= 3.4.1
BuildRequires: php-symfony4-filesystem            >= 4.4.17
%endif
%global phpunit %{_bindir}/phpunit9
BuildRequires:  %{phpunit}
%endif
## Autoloader
BuildRequires: php-fedora-autoloader-devel

# composer.json
#        "php":                       ">=7.1",
#        "laminas/laminas-code":      "~3.4.1|^4.0",
#        "symfony/filesystem":        "^4.4.17|^5.0|^6.0"
Requires:      php(language) >= 7.1
# remirepo:1
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
# prefer v4 required for PHP 8, better with PHP 7.4
Requires:     (php-composer(laminas/laminas-code) >= 4.0     with php-composer(laminas/laminas-code) <  5)
Requires:     (php-composer(symfony/filesystem)   >= 4.4.17  with php-composer(symfony/filesystem)   <  7)
# remirepo:4
%else
Requires:      php-laminas-code                   >= 3.4.1
Requires:      php-symfony4-filesystem            >= 4.4.17
%endif
# phpcompatinfo (computed from version 1.0.3)
Requires:      php-reflection
Requires:      php-pcre
Requires:      php-spl
# Autoloader
Requires:      php-composer(fedora/autoloader)

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

%description
This package is a fork of the excellent ocramius/proxy-manager library
that adds long term support for a wider range of PHP versions.

Unless they're caused by this very fork, please report issues and submit
new features to the origin library.

This fork:

* maintains compatibility with PHP >=7.1;
  supporting new versions of PHP is considered as a bugfix;
* won't bump the minimum supported version of PHP in a minor release;
* does not depend on Composer 2, thus can be used with Composer 1 if
  you need more time to migrate;
* uses a versioning policy that is friendly to progressive migrations
  while providing the latest improvements from the origin lib.

Autoloader: %{phpdir}/%{github_owner}/%{ns_project}%{major}/autoload.php


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


%build
: Create autoloader
phpab --template fedora \
      --output src/autoload.php \
      src

cat <<'AUTOLOAD' | tee -a src/autoload.php

if (PHP_VERSION_ID < 70400) {
    $code = '%{phpdir}/Laminas/Code/autoload.php';
} else if (PHP_VERSION_ID < 80000) {
    $code = [
        '%{phpdir}/Laminas/Code4/autoload.php',
        '%{phpdir}/Laminas/Code/autoload.php',
    ];
} else {
    $code = '%{phpdir}/Laminas/Code4/autoload.php';
}
\Fedora\Autoloader\Dependencies::required([
    $code,
    [
        '%{phpdir}/Symfony6/Component/Filesystem/autoload.php',
        '%{phpdir}/Symfony5/Component/Filesystem/autoload.php',
        '%{phpdir}/Symfony4/Component/Filesystem/autoload.php',
    ],
]);
AUTOLOAD


%install
# fake "vendor" directory to avoid conflict with real ocramius library
mkdir -p %{buildroot}%{phpdir}/%{github_owner}/
cp -rp src %{buildroot}%{phpdir}/%{github_owner}/%{ns_project}%{major}


%check
%if %{with tests}
mkdir vendor
cat << 'EOF' | tee vendor/autoload.php
<?php
require_once "%{buildroot}%{phpdir}/%{github_owner}/%{ns_project}%{major}/autoload.php";
\Fedora\Autoloader\Autoload::addPsr4('ProxyManagerTest\\',      dirname(__DIR__) . "/tests/ProxyManagerTest");
\Fedora\Autoloader\Autoload::addPsr4('ProxyManagerTestAsset\\', dirname(__DIR__) . "/tests/ProxyManagerTestAsset");
\Fedora\Autoloader\Autoload::addPsr4('Laminas\\Server\\',       dirname(__DIR__) . "/tests/Stubbed/Laminas/Server");
EOF


: Upstream tests
ret=0
for cmdarg in "php %{phpunit}" php74 php80 php81; do
  if which $cmdarg; then
    set $cmdarg
    $1 ${2:-%{_bindir}/phpunit9} \
      --filter '^((?!(testCodeGeneration)).)*$' \
      --verbose || ret=1
  fi
done
exit $ret
%else
: Tests skipped
%endif


%files
# remirepo:1
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc README.md
%doc composer.json
%dir %{phpdir}/%{github_owner}
     %{phpdir}/%{github_owner}/%{ns_project}%{major}


%changelog
* Thu Mar  3 2022 Remi Collet <remi@remirepo.net> - 1.0.7-1
- update to 1.0.7

* Mon Feb 28 2022 Remi Collet <remi@remirepo.net> - 1.0.6-1
- update to 1.0.6

* Tue May 25 2021 Remi Collet <remi@remirepo.net> - 1.0.5-1
- update to 1.0.5

* Thu May 20 2021 Remi Collet <remi@remirepo.net> - 1.0.4-1
- update to 1.0.4

* Thu Jan 28 2021 Remi Collet <remi@remirepo.net> - 1.0.3-2
- fix description and summary

* Thu Jan 28 2021 Remi Collet <remi@remirepo.net> - 1.0.3-1
- Initial package