summaryrefslogtreecommitdiffstats
path: root/php-phpseclib3.spec
blob: 4d4480024635531be3501b4c6bb94fc96b64dc64 (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
%global composer_vendor         phpseclib
%global composer_project        phpseclib

%global github_owner            phpseclib
%global github_name             phpseclib
%global github_commit           97a5a270e4a9ebfc1a7e2f462e917cbce1a8e6d9
%global github_short            %(c=%{github_commit}; echo ${c:0:7})
%global major                   3

%bcond_without                  tests

Name:       php-%{composer_vendor}%{major}
Version:    3.0.3
Release:    1%{?dist}
Summary:    PHP Secure Communications Library
License:    MIT
URL:        https://github.com/%{github_owner}/%{github_name}

Source0:    %{name}-%{version}-%{github_short}.tgz
Source1:    %{name}-autoload.php
# Generate a full archive from git snapshot, with tests
Source2:    makesrc.sh

# remirepo:3
# For test build on all available arch
#global debug_package %%{nil}
#global __debug_install_post /bin/true
BuildArch:      noarch

%if %{with tests}
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires:(php-composer(paragonie/constant_time_encoding) >= 2    with php-composer(paragonie/constant_time_encoding) < 3)
BuildRequires:(php-composer(paragonie/random_compat)          >= 2    with php-composer(paragonie/random_compat)          < 3)
%else
BuildRequires: php-paragonie-constant-time-encoding
BuildRequires: php-paragonie-random-compat
%endif
BuildRequires:  php-composer(fedora/autoloader)
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
%global phpunit %{_bindir}/phpunit9
%else
%global phpunit %{_bindir}/phpunit6
%endif
BuildRequires:  %{phpunit}
BuildRequires:  %{_bindir}/phpab
# Optional at runtime, to avoid too muck skipped tests
BuildRequires:  php-bcmath
BuildRequires:  php-gmp
%endif

# from composer.json, "require": {
#        "paragonie/constant_time_encoding": "^1|^2",
#        "paragonie/random_compat": "^1.4|^2.0",
#        "php": ">=5.6.1"
#
Requires:   php(language) >= 5.6.1
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:  (php-composer(paragonie/constant_time_encoding) >= 2    with php-composer(paragonie/constant_time_encoding) < 3)
Requires:  (php-composer(paragonie/random_compat)          >= 2    with php-composer(paragonie/random_compat)          < 3)
%else
Requires:   php-paragonie-constant-time-encoding
Requires:   php-paragonie-random-compat
%endif
Requires:   php-bcmath
Requires:   php-date
Requires:   php-gmp
Requires:   php-hash
Requires:   php-openssl
Requires:   php-pcre
Requires:   php-session
Requires:   php-standard
Requires:   php-xml
# Autoloader
Requires:   php-composer(fedora/autoloader)

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


%description
MIT-licensed pure-PHP implementations of an arbitrary-precision integer 
arithmetic library, Ed25519 / Ed449 / Curve25519 / Curve449, ECDSA / ECDH
(with support for 66 curves), RSA (PKCS#1 v2.2 compliant), DSA / DH,
DES / 3DES / RC4 / Rijndael / AES / Blowfish / Twofish / Salsa20 / ChaCha20,
GCM / Poly1305.


%prep
%setup -qn %{github_name}-%{github_commit}
cp %{SOURCE1} %{composer_vendor}/autoload.php


%build


%install
mkdir -p %{buildroot}%{_datadir}/php
cp -pr %{composer_vendor} %{buildroot}%{_datadir}/php/%{composer_vendor}%{major}


%if %{with tests}
%check
cat << 'EOF' | tee  tests/bootstrap.php
<?php
require "%{buildroot}%{_datadir}/php/%{composer_vendor}%{major}/autoload.php";
\Fedora\Autoloader\Autoload::addPsr0('', __DIR__);
date_default_timezone_set('UTC');
EOF

# avoid already defined class
sed -e 's/CreateKeyTest/RSACreateKeyTest/' -i tests/Unit/Crypt/RSA/CreateKeyTest.php
sed -e 's/CreateKeyTest/DSACreateKeyTest/' -i tests/Unit/Crypt/DSA/CreateKeyTest.php

# Not supported curves ? (need investigations)
%if 0%{?rhel} == 7
rm tests/Unit/Crypt/EC/CurveTest.php
%else
rm phpseclib/Crypt/EC/Curves/{brainpoolP160t1,secp128r2,secp112r1,secp160r2,secp192r1,brainpoolP192t1,brainpoolP160r1,secp112r2,secp192k1,prime192v3,secp160r1,brainpoolP192r1,secp128r1,prime192v2,secp160k1}.php
%endif

# from travis/run-phpunit.sh
if %{phpunit} --atleast-version 8
then
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUpBeforeClass()/n setUpBeforeClass(): void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n setUp()/n setUp(): void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/n tearDown()/n tearDown(): void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsArray([^)]*)\)/\1: void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsString([^)]*)\)/\1: void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsResource([^)]*)\)/\1: void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertIsObject([^)]*)\)/\1: void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringContainsString([^)]*)\)/\1: void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/\(n assertStringNotContainsString([^)]*)\)/\1: void/g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_Crypt_\(AES\|DSA\|EC\|RSA\)_/class /g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_File_\(X509\)_/class /g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_Math_\(BigInteger\)_/class /g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Unit_\(Crypt\|File\|Math\|Net\)_/class /g'
    find tests -type f -name "*.php" -print0 | xargs -0 sed -i 's/^class Functional_Net_/class /g'
fi

# testAuthorityInfoAccess fails without internet access
# testCurveExistance as we remove some files
ret=0
for cmd in "php %{phpunit}" php73 php74 php80; do
  if which $cmd; then
    set $cmd
    $1 -d memory_limit=1G ${2:-%{_bindir}/phpunit9} \
       --filter '^((?!(testAuthorityInfoAccess|testCurveExistance)).)*$' \
       --verbose || ret=1
  fi
done
exit $ret
%endif


%files
%{_datadir}/php/%{composer_vendor}%{major}
%doc AUTHORS CHANGELOG.md composer.json README.md
%{!?_licensedir:%global license %%doc}
%license LICENSE


%changelog
* Mon Jan 18 2021 Remi Collet <remi@remirepo.net> - 3.0.3-1
- update to 3.0.3

* Mon Jan  4 2021 Remi Collet <remi@remirepo.net> - 3.0.2-1
- update to 3.0.2

* Mon Dec 21 2020 Remi Collet <remi@remirepo.net> - 3.0.1-1
- update to 3.0.1

* Thu Dec 17 2020 Remi Collet <remi@remirepo.net> - 3.0.0-1
- update to 3.0.0
- rename to php-phpseclib3
- install in /usr/share/php/phpseclib3
- raise dependency on PHP 5.6
- add dependency on paragonie/constant_time_encoding
- add dependency on paragonie/random_compat

* Thu Dec 17 2020 Remi Collet <remi@remirepo.net> - 2.0.30-1
- update to 2.0.30
- switch to phpunit9 on Fedora

* Tue Sep  8 2020 Remi Collet <remi@remirepo.net> - 2.0.29-1
- update to 2.0.29

* Wed Jul  8 2020 Remi Collet <remi@remirepo.net> - 2.0.28-1
- update to 2.0.28

* Mon Apr  6 2020 Remi Collet <remi@remirepo.net> - 2.0.27-1
- update to 2.0.27

* Mon Mar 23 2020 Remi Collet <remi@remirepo.net> - 2.0.26-1
- update to 2.0.26

* Tue Feb 25 2020 Remi Collet <remi@remirepo.net> - 2.0.25-1
- update to 2.0.25

* Mon Feb 24 2020 Remi Collet <remi@remirepo.net> - 2.0.24-1
- update to 2.0.24

* Tue Sep 17 2019 Remi Collet <remi@remirepo.net> - 2.0.23-1
- update to 2.0.23

* Mon Sep 16 2019 Remi Collet <remi@remirepo.net> - 2.0.22-1
- update to 2.0.22

* Mon Jul 15 2019 Remi Collet <remi@remirepo.net> - 2.0.21-1
- update to 2.0.21

* Tue Jun 25 2019 Remi Collet <remi@remirepo.net> - 2.0.20-1
- update to 2.0.20

* Fri Jun 21 2019 Remi Collet <remi@remirepo.net> - 2.0.19-1
- update to 2.0.19

* Thu Jun 13 2019 Remi Collet <remi@remirepo.net> - 2.0.18-1
- update to 2.0.18

* Mon May 27 2019 Remi Collet <remi@remirepo.net> - 2.0.17-1
- update to 2.0.17

* Mon Mar 11 2019 Remi Collet <remi@remirepo.net> - 2.0.15-1
- update to 2.0.15

* Thu Jan 31 2019 Remi Collet <remi@remirepo.net> - 2.0.14-1
- update to 2.0.14

* Tue Dec 18 2018 Remi Collet <remi@remirepo.net> - 2.0.13-1
- update to 2.0.13

* Mon Nov  5 2018 Remi Collet <remi@remirepo.net> - 2.0.12-1
- update to 2.0.12

* Mon Apr 16 2018 Remi Collet <remi@remirepo.net> - 2.0.11-1
- update to 2.0.11

* Tue Feb 20 2018 Remi Collet <remi@remirepo.net> - 2.0.10-2
- allow to run with old PHPUnit

* Tue Feb 20 2018 Remi Collet <remi@remirepo.net> - 2.0.10-1
- Update to 2.0.10
- skip tests with PHPUnit < 4.8.35 (EPEL-6)

* Wed Nov 29 2017 Remi Collet <remi@remirepo.net> - 2.0.9-1
- Update to 2.0.9

* Mon Oct 23 2017 Remi Collet <remi@remirepo.net> - 2.0.7-1
- Update to 2.0.7

* Thu Jun  8 2017 Remi Collet <remi@remirepo.net> - 2.0.6-2
- define correct timezone for the test suite

* Mon Jun  5 2017 Remi Collet <remi@remirepo.net> - 2.0.6-1
- Update to 2.0.6

* Mon May  8 2017 Remi Collet <remi@remirepo.net> - 2.0.5-1
- Update to 2.0.5
- switch to fedora/autoloader
- use SCL of PHP when available for test suite
- open https://github.com/phpseclib/phpseclib/issues/1122 - regression with 5.3
- open https://github.com/phpseclib/phpseclib/pull/1121 - fix permission

* Tue Oct  4 2016 Remi Collet <remi@fedoraproject.org> - 2.0.4-1
- update to 2.0.4

* Fri Sep  2 2016 Remi Collet <remi@fedoraproject.org> - 2.0.3-1
- update to 2.0.3

* Tue Jun  7 2016 Remi Collet <remi@fedoraproject.org> - 2.0.2-1
- update to 2.0.2

* Tue Jan 19 2016 Remi Collet <remi@fedoraproject.org> - 2.0.1-1
- update to 2.0.1
- sources from git snapshot for tests
- run test suite with both PHP 5 and 7 when available

* Sun Sep  6 2015 Remi Collet <remi@fedoraproject.org> - 2.0.0-4
- change source0 to commit reference
- add BR for better test coverage
- add needed backport stuff for EL-5 in #remirepo

* Wed Sep 02 2015 François Kooman <fkooman@tuxed.net> - 2.0.0-3
- apply patch for test to avoid loading class that is now autoloaded

* Wed Sep 02 2015 François Kooman <fkooman@tuxed.net> - 2.0.0-2
- add autoload script
- make use of autoload script when running tests during build
- fix double inclusion of directory

* Sat Aug 08 2015 François Kooman <fkooman@tuxed.net> - 2.0.0-1
- initial package