summaryrefslogtreecommitdiffstats
path: root/php-rmccue-requests.spec
blob: 379f39dc878c7e35d539776290e8b7dada5477c4 (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
# remirepo spec file for php-rmccue-requests
#
# Fedora spec file for php-rmccue-requests
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#
Name:       php-rmccue-requests
Version:    1.7.0
Release:    2%{?dist}
BuildArch:  noarch

License:    ISC and BSD
Summary:    Requests for PHP is a humble HTTP request library
URL:        https://github.com/rmccue/Requests
Source0:    %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
# This is only needed to run the test suite.
Source1:    https://github.com/RequestsPHP/test-server/archive/26334a7583c96ae1f966a5d88af9aafaf279f948/requests-tests-26334a75.tar.gz

BuildRequires: php-composer(fedora/autoloader)
BuildRequires: php-fedora-autoloader-devel
BuildRequires: php-zip
BuildRequires: phpunit 
#BuildRequires: procps-ng

Requires:   php(language) >= 5.5.0
Requires:   php-composer(fedora/autoloader)
Requires:   php-curl
Requires:   php-date
Requires:   php-json
Requires:   php-openssl
Requires:   php-pcre
Requires:   php-spl
Requires:   php-zlib

Provides:   php-composer(rmccue/requests) = %{version}


%description
Requests for PHP simplifies how you interact with other sites and takes
away all your worries.

Requests is a HTTP library written in PHP, for human beings. It is
roughly based on the API from the excellent Requests Python library.
Requests is ISC Licensed (similar to the new BSD license) and has no
dependencies, except for PHP 5.2+.

Despite PHP's use as a language for the web, its tools for sending HTTP
requests are severely lacking. cURL has an interesting API, to say the
least, and you can't always rely on it being available. Sockets provide
only low level access, and require you to build most of the HTTP
response parsing yourself.

We all have better things to do. That's why Requests was born.


%prep
%autosetup -n Requests-%{version}

tar xvf %{S:1}

# Remove the bundled CA list and use Fedora's
rm library/Requests/Transport/cacert.pem
ln -s %{_sysconfdir}/pki/ca-trust/extracted/pem/tls-ca-bundle.pem \
    library/Requests/Transport/cacert.pem


%build
%{_bindir}/phpab --format fedora --output library/autoload.php library


%install
install -d -p -m 0755 %{buildroot}/%{_datadir}/php
install -d -p -m 0755 %{buildroot}/%{_datadir}/php/rmccue
install -d -p -m 0755 %{buildroot}/%{_datadir}/php/rmccue/Requests

cp -ar library/* %{buildroot}/%{_datadir}/php/rmccue/Requests


%check
sed -i "s:include.*:require('%{buildroot}/%{_datadir}/php/rmccue/Requests/autoload.php');:" \
    tests/bootstrap.php

port=$(expr 8070 + %{?fedora}%{?rhel})
: use port $port to allow parallel build

if [ "$(netstat -ln | grep $port)" != "" ]
then
    kill php
fi

%{_bindir}/php -S 127.0.0.1:$port \
    test-server-26334a7583c96ae1f966a5d88af9aafaf279f948/bin/serve.php &
PHPPID=$!

pushd tests
# The request test server doesn't run over TLS so we skip HTTPS tests. The other tests fail if they
# can't resolve domain names, so they are skipped as well.
REQUESTS_TEST_HOST="127.0.0.1:$port" phpunit --no-coverage --bootstrap bootstrap.php \
    --filter \
    ^\(\(?!\(testHTTPS\|testAlternateNameSupport\|testSNISupport\|testAlternatePort\)\).\)*$ || \
    (kill $PHPPID && exit 1)
popd

kill $PHPPID


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc CHANGELOG.md
%doc composer.json
%doc docs
%doc examples
%doc README.md
%{_datadir}/php/rmccue


%changelog
* Thu Mar  9 2017 Remi Collet <remi@remirepo.net> - 1.7.0-2
- backport for #remirepo

* Sun Mar 05 2017 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.7.0-2
- Change license tag to ISC and BSD.
- Use a better method for killing the test server.

* Sun Feb 19 2017 Randy Barlow <bowlofeggs@fedoraproject.org> - 1.7.0-1
- Initial release.