diff options
Diffstat (limited to 'php-react-async.spec')
-rw-r--r-- | php-react-async.spec | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/php-react-async.spec b/php-react-async.spec new file mode 100644 index 0000000..fe99883 --- /dev/null +++ b/php-react-async.spec @@ -0,0 +1,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 |