From e03739834e262e50f68c4831d9ac7e182bd9bc69 Mon Sep 17 00:00:00 2001 From: Shawn Iwinski Date: Fri, 7 Apr 2017 13:23:30 -0400 Subject: Fix rawhide (F27) FTBS - Switch autoloader to php-composer(fedora/autoloader) - Test with SCLs if available (cherry picked from commit 6b81006e0e1590a7a0617244e45fafc64e6f7c96) --- .gitignore | 2 + php-guzzlehttp-ringphp-upstream-pull-42.patch | 22 +++++ php-guzzlehttp-ringphp.spec | 120 ++++++++++++-------------- 3 files changed, 81 insertions(+), 63 deletions(-) create mode 100644 .gitignore create mode 100644 php-guzzlehttp-ringphp-upstream-pull-42.patch diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8bfadd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/a903f51b692427318bc813217c0e6505287e79a4.tar.gz +/php-guzzlehttp-ringphp-1.1.0-dbbb91d7f6c191e5e405e900e3102ac7f261bc0b.tar.gz diff --git a/php-guzzlehttp-ringphp-upstream-pull-42.patch b/php-guzzlehttp-ringphp-upstream-pull-42.patch new file mode 100644 index 0000000..6439a36 --- /dev/null +++ b/php-guzzlehttp-ringphp-upstream-pull-42.patch @@ -0,0 +1,22 @@ +From 6218c409739ab2db2a2c9d30d56925fd1936dff6 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Fri, 31 Mar 2017 08:29:47 +0200 +Subject: [PATCH] Fix #41 use proper proxy attribute without ending / + +--- + tests/Client/StreamHandlerTest.php | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/Client/StreamHandlerTest.php b/tests/Client/StreamHandlerTest.php +index 3cb9a8e..d491064 100644 +--- a/tests/Client/StreamHandlerTest.php ++++ b/tests/Client/StreamHandlerTest.php +@@ -375,7 +375,7 @@ public function testEmitsProgressInformationAndDebugInformation() + + public function testAddsProxyByProtocol() + { +- $url = str_replace('http', 'tcp', Server::$url); ++ $url = rtrim(str_replace('http', 'tcp', Server::$url), '/'); + $res = $this->getSendResult(['proxy' => ['http' => $url]]); + $opts = stream_context_get_options($res['body']); + $this->assertEquals($url, $opts['http']['proxy']); diff --git a/php-guzzlehttp-ringphp.spec b/php-guzzlehttp-ringphp.spec index edf3aed..11df973 100644 --- a/php-guzzlehttp-ringphp.spec +++ b/php-guzzlehttp-ringphp.spec @@ -2,7 +2,7 @@ # # Fedora spec file for php-guzzlehttp-ringphp # -# Copyright (c) 2014-2015 Shawn Iwinski +# Copyright (c) 2014-2017 Shawn Iwinski # # License: MIT # http://opensource.org/licenses/MIT @@ -29,20 +29,15 @@ %global promise_min_ver 2.2.0-6 %global promise_max_ver 3.0 -%if 0%{?rhel} == 5 -# no nodejs available in RHEL-5 -%global with_tests %{?_with_tests:1}%{!?_with_tests:0} -%else # Build using "--without tests" to disable tests %global with_tests %{?_without_tests:0}%{!?_without_tests:1} -%endif %{!?phpdir: %global phpdir %{_datadir}/php} %{!?testsdir: %global testsdir %{_datadir}/tests} Name: php-%{composer_vendor}-%{composer_project} Version: %{github_version} -Release: 6%{?github_release}%{?dist} +Release: 9%{?github_release}%{?dist} Summary: Simple handler system used to power clients and servers in PHP Group: Development/Libraries @@ -50,7 +45,11 @@ License: MIT URL: http://ringphp.readthedocs.org Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +# Fix #41 use proper proxy attribute without ending / +# https://github.com/guzzle/RingPHP/pull/42 +# https://github.com/guzzle/RingPHP/pull/42.patch +Patch0: %{name}-upstream-pull-42.patch + BuildArch: noarch # Tests %if %{with_tests} @@ -70,7 +69,7 @@ BuildRequires: php-reflection BuildRequires: php-spl BuildRequires: php-zlib ## Autoloader -BuildRequires: php-composer(symfony/class-loader) +BuildRequires: php-composer(fedora/autoloader) %endif # composer.json @@ -86,7 +85,7 @@ Requires: php-curl # phpcompatinfo (computed from version 1.1.0) Requires: php-spl # Autoloader -Requires: php-composer(symfony/class-loader) +Requires: php-composer(fedora/autoloader) # Composer Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} @@ -131,51 +130,52 @@ Requires: php-zlib %prep %setup -qn %{github_name}-%{github_commit} +# Fix #41 use proper proxy attribute without ending / +%patch0 -p1 + +: Modify tests bootstrap +sed -e "s#.*require.*autoload.*#require __DIR__ . '/autoload.php';#" \ + -i tests/bootstrap.php + + +%build : Create library autoloader cat <<'AUTOLOAD' | tee src/autoload.php register(); -} +\Fedora\Autoloader\Autoload::addPsr4('GuzzleHttp\\Ring\\', __DIR__); -$fedoraClassLoader->addPrefix('GuzzleHttp\\Ring\\', dirname(dirname(__DIR__))); - -require_once '%{phpdir}/GuzzleHttp/Stream/autoload.php'; -require_once '%{phpdir}/React/Promise/autoload.php'; - -return $fedoraClassLoader; +\Fedora\Autoloader\Dependencies::required([ + '%{phpdir}/GuzzleHttp/Stream/autoload.php', + '%{phpdir}/React/Promise/autoload.php', +]); AUTOLOAD : Create tests autoloader cat <<'AUTOLOAD' | tee tests/autoload.php addPrefix('GuzzleHttp\\Tests\\Ring\\', __DIR__); -$fedoraClassLoader->setUseIncludePath(true); +// Require library autoloader. Allow for both RPM builds of %{name} +// and other packages' usage of %{name}-tests. +$libraryAutoload = '%{phpdir}/GuzzleHttp/Ring/autoload.php'; +$rpmBuildRoot = getenv('RPM_BUILD_ROOT'); +if ($rpmBuildRoot && file_exists($rpmBuildRoot . $libraryAutoload)) { + require_once $rpmBuildRoot . $libraryAutoload; +} else { + require_once $libraryAutoload; +} +unset($libraryAutoload, $rpmBuildRoot); -return $fedoraClassLoader; +\Fedora\Autoloader\Autoload::addPsr4('GuzzleHttp\\Tests\\Ring\\', __DIR__); AUTOLOAD : Create custom tests PHPUnit config @@ -191,47 +191,36 @@ cat <<'PHPUNIT' | tee phpunit.xml.dist PHPUNIT -: Modify tests bootstrap -sed -e "s#.*require.*autoload.*#require __DIR__ . '/autoload.php';#" \ - -e "s#Client/Server.php#GuzzleHttp/Tests/Ring/Client/Server.php#" \ - -i tests/bootstrap.php - - -%build -# Empty build section, nothing required - %install -rm -rf %{buildroot} - : Library mkdir -p %{buildroot}%{phpdir}/GuzzleHttp/Ring cp -rp src/* %{buildroot}%{phpdir}/GuzzleHttp/Ring/ -: Tests -- classes must be PSR-0 -mkdir -p %{buildroot}%{testsdir}/%{name}/GuzzleHttp/Tests/Ring -cp -rp tests/* %{buildroot}%{testsdir}/%{name}/GuzzleHttp/Tests/Ring/ -mv %{buildroot}%{testsdir}/%{name}/GuzzleHttp/Tests/Ring/{autoload,bootstrap}.php \ - %{buildroot}%{testsdir}/%{name}/ +: Tests +mkdir -p %{buildroot}%{testsdir} +cp -rp tests %{buildroot}%{testsdir}/%{name} cp -p phpunit.xml.dist %{buildroot}%{testsdir}/%{name}/ %check %if %{with_tests} -%{_bindir}/phpunit --verbose \ - --configuration %{buildroot}%{testsdir}/%{name} \ - --include-path %{buildroot}%{phpdir} +: Upstream tests +RETURN_CODE=0 +for PHP_EXEC in php %{?rhel:php55} php56 php70 php71; do + if [ "php" == "$PHP_EXEC" ] || which $PHP_EXEC; then + $PHP_EXEC %{_bindir}/phpunit --verbose \ + --configuration %{buildroot}%{testsdir}/%{name} \ + || RETURN_CODE=1 + fi +done +exit $RETURN_CODE %else : Tests skipped %endif -%clean -rm -rf %{buildroot} - - %files -%defattr(-,root,root,-) %{!?_licensedir:%global license %%doc} %license LICENSE %doc *.md @@ -244,6 +233,11 @@ rm -rf %{buildroot} %changelog +* Fri Apr 07 2017 Shawn Iwinski - 1.1.0-9 +- Fix rawhide (F27) FTBS +- Switch autoloader to php-composer(fedora/autoloader) +- Test with SCLs if available + * Tue Sep 22 2015 Shawn Iwinski - 1.1.0-6 - Updated autoloader to load dependencies after self registration - Minor cleanups -- cgit