summaryrefslogtreecommitdiffstats
path: root/php-guzzle-Guzzle.spec
blob: fafd40010f04e08ccb9995de75f55684873599ce (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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# remirepo spec file for php-guzzle-Guzzle, from Fedora:
#
# RPM spec file for php-guzzle-Guzzle
#
# Copyright (c) 2012-2015 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%if 0%{?rhel} == 5
%global with_cacert 0
%else
%global with_cacert 1
%endif

%global github_owner     guzzle
%global github_name      guzzle3
%global github_version   3.9.3
%global github_commit    0645b70d953bc1c067bbc8d5bc53194706b628d9

%global composer_vendor  guzzle
%global composer_project guzzle

%global pear_channel     guzzlephp.org/pear
%global pear_name        Guzzle

# "php": ">=5.3.3"
%global php_min_ver 5.3.3
# "doctrine/cache": "~1.3"
%global doctrine_cache_min_ver 1.3
%global doctrine_cache_max_ver 2.0
# "monolog/monolog": "~1.0"
%global monolog_min_ver 1.0
%global monolog_max_ver 2.0
# "psr/log": "~1.0"
%global psr_log_min_ver 1.0
%global psr_log_max_ver 2.0
# "symfony/class-loader": "~2.1"
# "symfony/event-dispatcher": "~2.1"
%global symfony_min_ver 2.1
%global symfony_max_ver 3.0
# "zendframework/zend-cache": "2.*,<2.3",
# "zendframework/zend-log": "2.*,<2.3"
#     NOTE: Max 2.4 instead of 2.3 because tests with 2.3 pass
%global zend_min_ver 2.0
%global zend_max_ver 2.4

%if 0%{?fedora} < 18 && 0%{?rhel} < 6
# Missing nodejs
%global with_tests 0
%else
# Build using "--without tests" to disable tests
%global with_tests 0%{!?_without_tests:1}
%endif

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

Name:          php-guzzle-%{pear_name}
Version:       %{github_version}
Release:       3%{?dist}
Summary:       PHP HTTP client library and framework for building RESTful web service clients

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

BuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:     noarch
# Tests
%if %{with_tests}
BuildRequires: nodejs
## composer.json
BuildRequires: %{_bindir}/phpunit
BuildRequires: php(language)                          >= %{php_min_ver}
BuildRequires: php-composer(doctrine/cache)           >= %{doctrine_cache_min_ver}
BuildRequires: php-composer(monolog/monolog)          >= %{monolog_min_ver}
BuildRequires: php-composer(psr/log)                  >= %{psr_log_min_ver}
BuildRequires: php-composer(symfony/class-loader)     >= %{symfony_min_ver}
BuildRequires: php-composer(symfony/event-dispatcher) >= %{symfony_min_ver}
BuildRequires: php-composer(zendframework/zend-cache) >= %{zend_min_ver}
BuildRequires: php-composer(zendframework/zend-log)   >= %{zend_min_ver}
BuildRequires: php-curl
## phpcompatinfo (computed from version 3.9.3)
BuildRequires: php-ctype
BuildRequires: php-date
BuildRequires: php-filter
BuildRequires: php-hash
BuildRequires: php-intl
BuildRequires: php-json
BuildRequires: php-libxml
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-simplexml
BuildRequires: php-spl
BuildRequires: php-xmlwriter
BuildRequires: php-zlib
%endif

# composer.json
Requires:      php(language)                          >= %{php_min_ver}
Requires:      php-composer(symfony/event-dispatcher) >= %{symfony_min_ver}
Requires:      php-composer(symfony/event-dispatcher) <  %{symfony_max_ver}
Requires:      php-curl
# phpcompatinfo (computed from version 3.9.3)
Requires:      php-ctype
Requires:      php-date
Requires:      php-filter
Requires:      php-hash
Requires:      php-json
Requires:      php-libxml
Requires:      php-pcre
Requires:      php-reflection
Requires:      php-simplexml
Requires:      php-spl
Requires:      php-xmlwriter
%if %{with_cacert}
# Unbundled CA certificate
Requires:      ca-certificates
%endif
# Autoloader
Requires:      php-composer(symfony/class-loader)

# Standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming
Provides:      php-%{composer_vendor}-%{composer_project} = %{version}-%{release}
Provides:      php-%{composer_project} = %{version}-%{release}
# Composer
Provides:  php-composer(%{composer_vendor}/%{composer_project})   = %{version}
## Sub-packages
Provides:  php-composer(%{composer_vendor}/batch)                 = %{version}
Provides:  php-composer(%{composer_vendor}/cache)                 = %{version}
Provides:  php-composer(%{composer_vendor}/common)                = %{version}
Provides:  php-composer(%{composer_vendor}/http)                  = %{version}
Provides:  php-composer(%{composer_vendor}/inflection)            = %{version}
Provides:  php-composer(%{composer_vendor}/iterator)              = %{version}
Provides:  php-composer(%{composer_vendor}/log)                   = %{version}
Provides:  php-composer(%{composer_vendor}/parser)                = %{version}
Provides:  php-composer(%{composer_vendor}/plugin)                = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-async)          = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-backoff)        = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-cache)          = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-cookie)         = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-curlauth)       = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-error-response) = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-history)        = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-log)            = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-md5)            = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-mock)           = %{version}
Provides:  php-composer(%{composer_vendor}/plugin-oauth)          = %{version}
Provides:  php-composer(%{composer_vendor}/service)               = %{version}
Provides:  php-composer(%{composer_vendor}/stream)                = %{version}
# PEAR
Provides:  php-pear(%{pear_channel}/%{pear_name})                 = %{version}

# This pkg was the only one in this channel so the channel is no longer needed
Obsoletes: php-channel-guzzle

# Optional dependency version conflicts
Conflicts: php-composer(doctrine/cache)           <  %{doctrine_cache_min_ver}
Conflicts: php-composer(doctrine/cache)           >= %{doctrine_cache_max_ver}
Conflicts: php-composer(monolog/monolog)          <  %{monolog_min_ver}
Conflicts: php-composer(monolog/monolog)          >= %{monolog_max_ver}
Conflicts: php-composer(zendframework/zend-cache) <  %{zend_min_ver}
Conflicts: php-composer(zendframework/zend-cache) >= %{zend_max_ver}
Conflicts: php-composer(zendframework/zend-log)   <  %{zend_min_ver}
Conflicts: php-composer(zendframework/zend-log)   >= %{zend_max_ver}

%description
Guzzle takes the pain out of sending HTTP requests and the redundancy out
of creating web service clients.

Guzzle is a framework that includes the tools needed to create a robust web
service client, including: Service descriptions for defining the inputs and
outputs of an API, resource iterators for traversing paginated resources,
batching for sending a large number of requests as efficiently as possible.

* All the power of cURL with a simple interface
* Persistent connections and parallel requests
* Streams request and response bodies
* Service descriptions for quickly building clients
* Powered by the Symfony2 EventDispatcher
* Use all of the code or only specific components
* Plugins for caching, logging, OAuth, mocks, and more

Optional dependencies:
* Doctrine Cache (%{doctrine_cache_min_ver} <= php-doctrine-cache < %{doctrine_cache_max_ver})
* Monolog (%{monolog_min_ver} <= php-Monolog < %{monolog_max_ver})
* Zend Framework 2 Cache (%{zend_min_ver} <= php-ZendFramework2-Cache < %{zend_max_ver})
* Zend Framework 2 Log (%{zend_min_ver} <= php-ZendFramework2-Log < %{zend_max_ver})

***** EOL NOTICE *****

This package is for Guzzle 3.x. Guzzle 5.x+, the new versions of Guzzle, has
been released and is available as the package "php-guzzlehttp-guzzle". The
documentation for Guzzle version 5+ can be found at http://guzzlephp.org.

Guzzle 3 is only maintained for bug and security fixes. Guzzle 3 will be EOL at
some point in late 2015.

**********************


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

%if %{with_cacert}
: Unbundle CA certificate
sed -e "s#__DIR__\s*.\s*'/Resources/cacert.pem'#'%{_sysconfdir}/pki/tls/cert.pem'#" \
    -e 's#$expectedMd5\s*=\s*.*#$expectedMd5 = $actualMd5;  // RPM NOTE: cacert.pem is managed by the ca-certificates package#' \
    -i src/Guzzle/Http/Client.php
rm src/Guzzle/Http/Resources/cacert.pem
%endif

: Create autoloader
(cat <<'AUTOLOAD'
<?php
/**
 * Autoloader 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('Guzzle\\', dirname(__DIR__));

// Not all dependency autoloaders exist or are in every dist yet so fallback
// to using include path for dependencies for now
$fedoraClassLoader->setUseIncludePath(true);

return $fedoraClassLoader;
AUTOLOAD
) | tee src/Guzzle/autoload.php


%build
# Empty build section, nothing to build


%install
rm -rf %{buildroot}

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


%check
%if %{with_tests}
: Create tests autoloader
(cat <<'AUTOLOAD'
<?php

$fedoraClassLoader =
    require_once '%{buildroot}%{phpdir}/Guzzle/autoload.php';

$fedoraClassLoader->addPrefix('Guzzle\\Tests', __DIR__);
AUTOLOAD
) | tee tests/autoload.php

: Modify tests bootstrap
sed "s#require.*autoload.*#require __DIR__ . '/autoload.php';#" \
    -i tests/bootstrap.php

: Skip tests known to fail
%if 0%{?rhel} == 6 || 0%{?rhel} == 5
rm -f tests/Guzzle/Tests/Http/RedirectPluginTest.php
sed 's/function testCanCreateStreamsUsingDefaultFactory/function SKIP_testCanCreateStreamsUsingDefaultFactory/' \
    -i tests/Guzzle/Tests/Http/StaticClientTest.php
sed -e 's/function testOpensValidStreamByCreatingContext/function SKIP_testOpensValidStreamByCreatingContext/' \
    -e 's/function testAddsPostFields/function SKIP_testAddsPostFields/' \
    -e 's/function testAddsBody/function SKIP_testAddsBody/' \
    -i tests/Guzzle/Tests/Stream/PhpStreamRequestFactoryTest.php
sed 's/function testSendsPostRequestsWithFiles/function SKIP_testSendsPostRequestsWithFiles/' \
    -i tests/Guzzle/Tests/Http/Curl/CurlHandleTest.php
sed 's/function testSetPostFiles/function SKIP_testSetPostFiles/' \
    -i tests/Guzzle/Tests/Http/Message/EntityEnclosingRequestTest.php
sed -e 's/function testThrowsExceptionWithStrictMode/function SKIP_testThrowsExceptionWithStrictMode/' \
    -e 's/function testValidatesCookies/function SKIP_testValidatesCookies/' \
    -i tests/Guzzle/Tests/Plugin/Cookie/CookieTest.php
sed 's/function testThrowsExceptionWithStrictMode/function SKIP_testThrowsExceptionWithStrictMode/' \
    -i tests/Guzzle/Tests/Plugin/Cookie/CookieJar/ArrayCookieJarTest.php
sed 's/function testMustReturnRequest/function SKIP_testMustReturnRequest/' \
    -i tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php
%endif

%{_bindir}/phpunit --verbose
%else
: Tests skipped
%endif

%if %{with_cacert}
# Ensure bundled CA cert is not referenced
grep -r "'/Resources/cacert.pem'" \
    %{buildroot}%{_datadir}/php/Guzzle \
    && exit 1
%endif


%clean
rm -rf %{buildroot}


%post
# Unregister PEAR pkg (ignore errors if it was not registered)
if [ -x %{_bindir}/pear ]; then
    %{_bindir}/pear uninstall --nodeps --ignore-errors --register-only \
        %{pear_channel}/%{pear_name} >/dev/null || :
fi


%files
%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc composer.json
%{phpdir}/Guzzle
%exclude %{phpdir}/Guzzle/*/composer.json
%exclude %{phpdir}/Guzzle/*/*/composer.json

%changelog
* Sat Jul 11 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.9.3-3
- Autoloader updates
- Added standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming provides

* Mon Jun 15 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.9.3-1
- Updated to 3.9.3
- Updated dependencies to use php-composer(*)
- Added composer sub-packages' provides
- Added optional dependency version conflicts
- Added EOL notice to %%description
- Added autoloader
- Excluded sub-packages' composer.json

* Sat Aug 23 2014 Remi Collet <remi@fedoraproject.org> - 3.9.2-2
- really drop bundled cacert

* Fri Aug 22 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.9.2-1
- Updated to 3.9.2 (BZ #1090936)
- PEAR install changed to Composer-ish install
- Obsoleted php-channel-guzzle
- Added tests

* Tue Apr 22 2014 Remi Collet <remi@fedoraproject.org> - 3.8.1-1
- backport 3.8.1 for remi repo

* Mon Apr 21 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.8.1-1
- Updated to 3.8.1 (BZ #1039260)

* Sun Feb 23 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.7.4-3
- Fixed unbundled cacert issue (Guzzle/Http/Client::preparePharCacert())
- Added test to ensure unbundled cacert is referenced

* Fri Feb 21 2014 Remi Collet <remi@fedoraproject.org> - 3.7.4-1.1
- EL-5 don't have ca-certificates

* Fri Nov 15 2013 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.7.4-2
- Updated PHP min version from 5.3.2 to 5.3.3
- php-common => php(language)

* Fri Nov 15 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.7.4-1
- Updated to 3.7.4
- Added php-libxml require

* Thu Oct 03 2013 Remi Collet <remi@fedoraproject.org> - 3.7.4-1
- Update to 3.7.4

* Mon Sep 16 2013 Remi Collet <remi@fedoraproject.org> - 3.7.3-1
- backport 3.7.3 for remi repo

* Sat Sep 14 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.7.3-1
- Updated to 3.7.3
- Added php-xmlwriter require

* Mon Aug 05 2013 Remi Collet <remi@fedoraproject.org> - 3.7.2-1
- Update to 3.7.2

* Mon Jul 08 2013 Remi Collet <remi@fedoraproject.org> - 3.7.1-1
- Update to 3.7.1

* Fri Jul 05 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.7.1-1
- Updated to 3.7.1

* Fri Jul 05 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.7.0-1
- Updated to 3.7.0 (BZ #973065)

* Wed Jun 12 2013 Remi Collet <remi@fedoraproject.org> - 3.7.0-1
- Update to 3.7.0

* Fri Jun 07 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.6.0-1
- Updated to 3.6.0

* Fri Jun 07 2013 Remi Collet <remi@fedoraproject.org> - 3.6.0-1
- Update to 3.6.0

* Wed May 08 2013 Remi Collet <remi@fedoraproject.org> - 3.4.3-1
- backport 3.3.0 for remi repo.

* Wed May 08 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.4.3-1
- Updated to version 3.4.3

* Tue Mar 12 2013 Remi Collet <remi@fedoraproject.org> - 3.3.1-1
- Update to 3.3.1

* Thu Mar 07 2013 Remi Collet <remi@fedoraproject.org> - 3.3.0-1
- backport 3.3.0 for remi repo.

* Mon Mar 04 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.3.0-1
- Updated to upstream version 3.3.0

* Tue Feb 26 2013 Remi Collet <remi@fedoraproject.org> - 3.2.0-1
- backport 3.2.0 for remi repo.

* Fri Feb 15 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.2.0-1
- Updated to upstream version 3.2.0

* Thu Feb  7 2013 Remi Collet <remi@fedoraproject.org> - 3.1.2-1
- backport 3.1.2 for remi repo.

* Mon Feb 04 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.1.2-1
- Updated to upstream version 3.1.2
- Removed bundled cert

* Sat Jan 26 2013 Shawn Iwinski <shawn.iwinski@gmail.com> 3.1.1-1
- Updated to upstream version 3.1.1

* Sun Dec 16 2012 Shawn Iwinski <shawn.iwinski@gmail.com> 3.0.6-1
- Updated to upstream version 3.0.6

* Sat Dec  8 2012 Shawn Iwinski <shawn.iwinski@gmail.com> 3.0.5-1
- Initial package