summaryrefslogtreecommitdiffstats
path: root/php-react-async.spec
blob: fe99883b25e869c16f952d1951320e8be977e0bf (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
# remirepo/Fedora spec file for php-react-async
#
# Copyright (c) 2022 Remi Collet
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     reactphp
%global github_name      async
%global github_version   3.0.0
%global github_commit    3c3b812be77aec14bf8300b052ba589c9a5bc95b

%global composer_vendor  react
%global composer_project async

%global ns_vendor        React
%global ns_project       Async

# "php": ">=7.1"
%global php_min_ver 7.1
# "react/event-loop": "^1.2",
%global react_event_loop_min_ver 1.2
%global react_event_loop_max_ver 2
# "react/promise": "^3.0 || ^2.8 || ^1.2.1"
%global react_promise_min_ver 2.8
%global react_promise_max_ver 4

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

# Range dependencies supported?
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
%global with_range_dependencies 1
%else
%global with_range_dependencies 0
%endif

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

Name:          php-%{composer_vendor}-%{composer_project}
Version:       %{github_version}
Release:       1%{?github_release}%{?dist}
Summary:       Async utilities for ReactPHP

License:       MIT
URL:           https://reactphp.org/async/

# GitHub export does not include tests
# Run php-react-async-get-source.sh to create full source
Source0:       %{name}-%{github_version}-%{github_commit}.tar.gz
Source1:       %{name}-get-source.sh

BuildArch:     noarch
# Tests
%if %{with tests}
## composer.json
BuildRequires: php(language) >= %{php_min_ver}
BuildRequires: phpunit9 >= 9.3
%if %{with_range_dependencies}
BuildRequires: (php-composer(react/promise)    >= %{react_promise_min_ver}    with php-composer(react/promise)    < %{react_promise_max_ver})
BuildRequires: (php-composer(react/event-loop) >= %{react_event_loop_min_ver} with php-composer(react/event-loop) < %{react_event_loop_max_ver})
%else
BuildRequires: php-composer(react/promise)    <  %{react_promise_max_ver}
BuildRequires: php-composer(react/promise)    >= %{react_promise_min_ver}
BuildRequires: php-composer(react/event-loop) <  %{react_event_loop_max_ver}
BuildRequires: php-composer(react/event-loop) >= %{react_event_loop_min_ver}
%endif
# phpcompatinfo (computed from version 3.0.0)
BuildRequires: php-spl
%endif
## Autoloader
BuildRequires: php-fedora-autoloader-devel

# composer.json
Requires:      php(language) >= %{php_min_ver}
%if %{with_range_dependencies}
Requires:      (php-composer(react/promise)    >= %{react_promise_min_ver}    with php-composer(react/promise)    < %{react_promise_max_ver})
Requires:      (php-composer(react/event-loop) >= %{react_event_loop_min_ver} with php-composer(react/event-loop) < %{react_event_loop_max_ver})
%else
Requires:      php-composer(react/promise)    <  %{react_promise_max_ver}
Requires:      php-composer(react/promise)    >= %{react_promise_min_ver}
Requires:      php-composer(react/event-loop) <  %{react_event_loop_max_ver}
Requires:      php-composer(react/event-loop) >= %{react_event_loop_min_ver}
%endif
# phpcompatinfo (computed from version 3.0.0)
Requires:      php-spl
# Autoloader
Requires:      php-composer(fedora/autoloader)

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


%description
Async utilities for ReactPHP.

This library allows you to manage async control flow. It provides a number of
combinators for Promise-based APIs. Instead of nesting or chaining promise
callbacks, you can declare them as a list, which is resolved sequentially in
an async manner. React/Async will not automagically change blocking code to
be async. You need to have an actual event loop and non-blocking libraries
interacting with that event loop for it to work. As long as you have a
Promise-based API that runs in an event loop, it can be used with this library.

Autoloader: %{phpdir}/%{ns_vendor}/%{ns_project}/autoload.php


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


%build
: Create autoloader
cat <<'AUTOLOAD' | tee src/autoload.php
<?php
require_once '%{phpdir}/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Dependencies::required(array(
    __DIR__ . '/functions_include.php',
    '%{phpdir}/%{ns_vendor}/Promise/autoload.php',
    '%{phpdir}/%{ns_vendor}/EventLoop/autoload.php',
));
AUTOLOAD


%install
mkdir -p   %{buildroot}%{phpdir}/%{ns_vendor}
cp -rp src %{buildroot}%{phpdir}/%{ns_vendor}/%{ns_project}


%check
%if %{with tests}
: Create tests bootstrap
cat <<'BOOTSTRAP' | tee bootstrap.php
<?php
require '%{buildroot}%{phpdir}/%{ns_vendor}/%{ns_project}/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('%{ns_vendor}\\Tests\\%{ns_project}\\', __DIR__.'/tests');
BOOTSTRAP

: Upstream tests
RETURN_CODE=0
for PHP_EXEC in php php80 php81 php82; do
    if which $PHP_EXEC; then
        $PHP_EXEC %{_bindir}/phpunit9 --verbose --bootstrap bootstrap.php \
            || RETURN_CODE=1
    fi
done
exit $RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc composer.json
%{phpdir}/%{ns_vendor}/%{ns_project}


%changelog
* Fri Sep 23 2022 Remi Collet <remi@remirepo.net> - 3.0.0-1
- Initial package