summaryrefslogtreecommitdiffstats
path: root/php-rmccue-requests.spec
blob: 9b342565d491b8353164bb25f0d9a24f83ef7964 (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
# 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.8.0
Release:    1%{?dist}
BuildArch:  noarch

License:    ISC and BSD
Summary:    Requests for PHP is a humble HTTP request library
URL:        https://github.com/WordPress/Requests
Source0:    %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
# Upstream strips docs, examples and tests from the tarball,
# so we have to generate it manually.
# dlothers.sh is used to do this, and is included in this repository.
Source1:    docs-v%{version}.tar.bz2
Source2:    examples-v%{version}.tar.bz2
Source3:    tests-v%{version}.tar.bz2
# This is only needed to run the test suite.
Source4:    requests-tests-26334a75.tar.gz

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

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} -p1

tar xvf %{S:1}
tar xvf %{S:2}
tar xvf %{S:3}
tar xvf %{S:4}

# 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 >serve.log 2>&1 &
PHPPID=$!

# 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 tests/bootstrap.php \
    --filter \
	^\(\(?!\(testHTTPS\|testExpiredHTTPS\|testRevokedHTTPS\|testBadDomain\|testResponseByteLimit\|testResponseByteLimitWithFile\|testAlternateNameSupport\|testSNISupport\)\).\)*$ || \
    (kill $PHPPID && exit 1)

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
* Wed May 12 2021 Sundeep Anand <suanand@redhat.com> - 1.8.0-1
- Update to 1.8.0 (rhbz#1954316)
- Add dlothers.sh to download docs, examples and tests
- Drop php-rmccue-requests-pr297.patch

* Mon Oct 23 2017 Remi Collet <remi@remirepo.net> - 1.7.0-4
- fix FTBFS from Koschei, add path for recent PHPUnit
  from https://github.com/rmccue/Requests/pull/297

* 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.