summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-08-23 09:16:53 +0200
committerRemi Collet <fedora@famillecollet.com>2014-08-23 09:16:53 +0200
commite7bd088ba80325991c577aefcc3f5f4a4f408758 (patch)
tree85a9f36afd05caab6fd3d3c520a38e6b1b90cba7
parent853e0da1ebcc0399b026304ce3c1372b6b272384 (diff)
php-guzzle-Guzzle: 3.9.2 (backport)
-rw-r--r--php-guzzle-Guzzle.spec279
1 files changed, 194 insertions, 85 deletions
diff --git a/php-guzzle-Guzzle.spec b/php-guzzle-Guzzle.spec
index 3ae0525..45528a1 100644
--- a/php-guzzle-Guzzle.spec
+++ b/php-guzzle-Guzzle.spec
@@ -1,7 +1,13 @@
-%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
-
-%global pear_channel guzzlephp.org/pear
-%global pear_name Guzzle
+#
+# RPM spec file for php-guzzle-Guzzle
+#
+# Copyright (c) 2012-2014 Shawn Iwinski <shawn.iwinski@gmail.com>
+#
+# License: MIT
+# http://opensource.org/licenses/MIT
+#
+# Please preserve changelog entries
+#
%if 0%{?rhel} == 5
%global with_cacert 0
@@ -9,46 +15,123 @@
%global with_cacert 1
%endif
-Name: php-guzzle-%{pear_name}
-Version: 3.8.1
-Release: 1%{?dist}
-Summary: PHP HTTP client library and framework for building RESTful web service clients
-
-Group: Development/Libraries
-License: MIT
-URL: http://guzzlephp.org
-Source0: http://%{pear_channel}/get/%{pear_name}-%{version}.tgz
-
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildArch: noarch
-BuildRequires: php-pear(PEAR)
-BuildRequires: php-channel(%{pear_channel})
-
-Requires: php(language) >= 5.3.3
-Requires: php-pear(PEAR)
-Requires: php-channel(%{pear_channel})
-Requires: php-pear(pear.symfony.com/EventDispatcher) >= 2.1.0
+%global github_owner guzzle
+%global github_name guzzle3
+%global github_version 3.9.2
+%global github_commit 54991459675c1a2924122afbb0e5609ade581155
+
+%global composer_vendor guzzle
+%global composer_project guzzle
+
+%global pear_channel guzzlephp.org/pear
+%global pear_name Guzzle
+
+# "php": ">=5.3.3"
+%global php_min_ver 5.3.3
+# "doctrine/cache": "~1.3"
+%global doctrine_cache_min_ver 1.3
+%global doctrine_cache_max_ver 2.0
+# "monolog/monolog": "~1.0"
+%global monolog_min_ver 1.0
+%global monolog_max_ver 2.0
+# "phpunit/phpunit": "3.7.*"
+# NOTE: Max version ignored on purpose
+%global _min_ver 3.7.0
+# "psr/log": "~1.0"
+%global psr_log_min_ver 1.0
+%global psr_log_max_ver 2.0
+# "symfony/class-loader": "~2.1"
+# "symfony/event-dispatcher": "~2.1"
+%global symfony_min_ver 2.1
+%global symfony_max_ver 3.0
+# "zendframework/zend-cache": "2.*,<2.3",
+# "zendframework/zend-log": "2.*,<2.3"
+# NOTE: Max 2.4 instead of 2.3 because tests with 2.3 pass
+%global zend_min_ver 2.0
+%global zend_max_ver 2.4
+
+%if 0%{?fedora} < 18 && 0%{?rhel} < 6
+# Missing nodejs
+%global with_tests 0
+%else
+# Build using "--without tests" to disable tests
+%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
+%endif
+
+Name: php-guzzle-%{pear_name}
+Version: 3.9.2
+Release: 1%{?dist}
+Summary: PHP HTTP client library and framework for building RESTful web service clients
+
+Group: Development/Libraries
+License: MIT
+URL: https://github.com/%{github_owner}/%{github_name}
+Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch: noarch
+%if %{with_tests}
+# For tests
+BuildRequires: nodejs
+# For tests: composer.json
+BuildRequires: php(language) >= %{php_min_ver}
+BuildRequires: php-composer(doctrine/cache) >= %{doctrine_cache_min_ver}
+BuildRequires: php-composer(doctrine/cache) < %{doctrine_cache_max_ver}
+BuildRequires: php-composer(monolog/monolog) >= %{monolog_min_ver}
+BuildRequires: php-composer(monolog/monolog) < %{monolog_max_ver}
+BuildRequires: php-composer(psr/log) >= %{psr_log_min_ver}
+BuildRequires: php-composer(psr/log) < %{psr_log_max_ver}
+BuildRequires: php-phpunit-PHPUnit
+BuildRequires: php-symfony-eventdispatcher >= %{symfony_min_ver}
+BuildRequires: php-symfony-eventdispatcher < %{symfony_max_ver}
+BuildRequires: php-ZendFramework2 >= %{zend_min_ver}
+BuildRequires: php-ZendFramework2 < %{zend_max_ver}
+BuildRequires: php-curl
+# For tests: phpcompatinfo (computed from version 3.9.2)
+BuildRequires: php-ctype
+BuildRequires: php-date
+BuildRequires: php-filter
+BuildRequires: php-hash
+BuildRequires: php-intl
+BuildRequires: php-json
+BuildRequires: php-libxml
+BuildRequires: php-pcre
+BuildRequires: php-reflection
+BuildRequires: php-simplexml
+BuildRequires: php-spl
+BuildRequires: php-xmlwriter
+BuildRequires: php-zlib
+%endif
+
%if %{with_cacert}
-Requires: ca-certificates
+Requires: ca-certificates
%endif
-Requires(post): %{__pear}
-Requires(postun): %{__pear}
-# phpcompatinfo (computed from version 3.8.1)
-Requires: php-ctype
-Requires: php-curl
-Requires: php-date
-Requires: php-filter
-Requires: php-hash
-Requires: php-intl
-Requires: php-json
-Requires: php-libxml
-Requires: php-pcre
-Requires: php-reflection
-Requires: php-simplexml
-Requires: php-spl
-Requires: php-xmlwriter
-
-Provides: php-pear(%{pear_channel}/%{pear_name}) = %{version}
+# composer.json
+Requires: php(language) >= %{php_min_ver}
+Requires: php-symfony-eventdispatcher >= %{symfony_min_ver}
+Requires: php-symfony-eventdispatcher < %{symfony_max_ver}
+Requires: php-curl
+# phpcompatinfo (computed from version 3.9.2)
+Requires: php-ctype
+Requires: php-date
+Requires: php-filter
+Requires: php-hash
+Requires: php-intl
+Requires: php-json
+Requires: php-libxml
+Requires: php-pcre
+Requires: php-reflection
+Requires: php-simplexml
+Requires: php-spl
+Requires: php-xmlwriter
+
+# Composer
+Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version}
+# PEAR
+Provides: php-pear(%{pear_channel}/%{pear_name}) = %{version}
+
+# This pkg was the only one in this channel so the channel is no longer needed
+Obsoletes: php-channel-guzzle
%description
Guzzle takes the pain out of sending HTTP requests and the redundancy out
@@ -68,35 +151,22 @@ batching for sending a large number of requests as efficiently as possible.
* Plugins for caching, logging, OAuth, mocks, and more
Optional dependencies:
-* Zend Framework
-* Doctrine
-* Monolog
+* Zend Framework (php-ZendFramework2)
+* Doctrine Cache (php-doctrine-cache)
+* Monolog (php-Monolog)
%prep
-%setup -q -c
-
-# Need to help upstream figure out why these files are showing up in package.xml
-# as role="data" instead of role="doc"
-# https://github.com/guzzle/guzzle/blob/master/phing/tasks/GuzzlePearPharPackageTask.php#L146
-sed '/\.md"/s/role="data"/role="doc"/' -i package.xml
+%setup -qn %{github_name}-%{github_commit}
%if %{with_cacert}
# Remove bundled cert
sed -e "s#__DIR__\s*.\s*'/Resources/cacert.pem'#'%{_sysconfdir}/pki/tls/cert.pem'#" \
-e 's#$expectedMd5\s*=\s*.*#$expectedMd5 = $actualMd5; // RPM NOTE: cacert.pem is managed by the ca-certificates package#' \
- -i %{pear_name}-%{version}/Guzzle/Http/Client.php
-sed -e '/cacert.pem/d' \
- -e '/name="Guzzle\/Http\/Client.php"/s:\s*md5sum="[^"]*"::' \
- -i package.xml
-%else
-# Code is broken, not aware of pear_datadir
-sed -e '/cacert/s/role="data"/role="php"/' \
- -i package.xml
-%endif
+ -i src/Guzzle/Http/Client.php
-# package.xml is version 2.0
-mv package.xml %{pear_name}-%{version}/%{name}.xml
+rm src/Guzzle/Http/Resources/cacert.pem
+%endif
%build
@@ -104,47 +174,86 @@ mv package.xml %{pear_name}-%{version}/%{name}.xml
%install
-cd %{pear_name}-%{version}
-%{__pear} install --nodeps --packagingroot %{buildroot} %{name}.xml
-
-# Clean up unnecessary files
-rm -rf %{buildroot}%{pear_metadir}/.??*
-
-# Install XML package description
-mkdir -p %{buildroot}%{pear_xmldir}
-install -pm 644 %{name}.xml %{buildroot}%{pear_xmldir}
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{_datadir}/php
+cp -rp src/* %{buildroot}%{_datadir}/php/
%check
-# No tests in upstream package
+%if %{with_tests}
+# Create autoloader
+mkdir vendor
+cat > vendor/autoload.php <<'AUTOLOAD'
+<?php
+spl_autoload_register(function ($class) {
+ $src = str_replace('\\', '/', $class).'.php';
+ @include_once $src;
+});
+AUTOLOAD
+
+# Create PHPUnit config w/ colors turned off
+sed 's/colors\s*=\s*"true"/colors="false"/' phpunit.xml.dist > phpunit.xml
+
+# Skip tests known to fail
+rm -f tests/Guzzle/Tests/Http/RedirectPluginTest.php
+sed 's/function testCanCreateStreamsUsingDefaultFactory/function SKIP_testCanCreateStreamsUsingDefaultFactory/' \
+ -i tests/Guzzle/Tests/Http/StaticClientTest.php
+sed -e 's/function testOpensValidStreamByCreatingContext/function SKIP_testOpensValidStreamByCreatingContext/' \
+ -e 's/function testAddsPostFields/function SKIP_testAddsPostFields/' \
+ -e 's/function testAddsBody/function SKIP_testAddsBody/' \
+ -i tests/Guzzle/Tests/Stream/PhpStreamRequestFactoryTest.php
+sed 's/function testSendsPostRequestsWithFiles/function SKIP_testSendsPostRequestsWithFiles/' \
+ -i tests/Guzzle/Tests/Http/Curl/CurlHandleTest.php
+sed 's/function testSetPostFiles/function SKIP_testSetPostFiles/' \
+ -i tests/Guzzle/Tests/Http/Message/EntityEnclosingRequestTest.php
+sed -e 's/function testThrowsExceptionWithStrictMode/function SKIP_testThrowsExceptionWithStrictMode/' \
+ -e 's/function testValidatesCookies/function SKIP_testValidatesCookies/' \
+ -i tests/Guzzle/Tests/Plugin/Cookie/CookieTest.php
+sed 's/function testThrowsExceptionWithStrictMode/function SKIP_testThrowsExceptionWithStrictMode/' \
+ -i tests/Guzzle/Tests/Plugin/Cookie/CookieJar/ArrayCookieJarTest.php
+
+%{_bindir}/phpunit --include-path=./src:./tests -d date.timezone="UTC" .
+%else
+: Tests skipped
+%endif
%if %{with_cacert}
-# Ensure unbundled CA cert is referenced
-grep '%{_sysconfdir}/pki/tls/cert.pem' --quiet \
- %{buildroot}%{_datadir}/pear/Guzzle/Http/Client.php
+# Ensure bundled CA cert is not referenced
+grep -r "'/Resources/cacert.pem'" \
+ %{buildroot}%{_datadir}/php/Guzzle \
+ && exit 1
%endif
-%post
-%{__pear} install --nodeps --soft --force --register-only \
- %{pear_xmldir}/%{name}.xml >/dev/null || :
+%clean
+rm -rf %{buildroot}
-%postun
-if [ $1 -eq 0 ] ; then
- %{__pear} uninstall --nodeps --ignore-errors --register-only \
+%post
+# Unregister PEAR pkg (ignore errors if it was not registered)
+if [ -x %{_bindir}/pear ]; then
+ %{_bindir}/pear uninstall --nodeps --ignore-errors --register-only \
%{pear_channel}/%{pear_name} >/dev/null || :
fi
%files
%defattr(-,root,root,-)
-%doc %{pear_docdir}/%{pear_name}
-%{pear_xmldir}/%{name}.xml
-%{pear_phpdir}/%{pear_name}
-
+%{!?_licensedir:%global license %%doc}
+%license LICENSE
+%doc *.md composer.json
+%{_datadir}/php/Guzzle
%changelog
+* Sat Aug 23 2014 Remi Collet <remi@fedoraproject.org> - 3.9.2-2
+- really drop bundled cacert
+
+* Fri Aug 22 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 3.9.2-1
+- Updated to 3.9.2 (BZ #1090936)
+- PEAR install changed to Composer-ish install
+- Obsoleted php-channel-guzzle
+- Added tests
+
* Tue Apr 22 2014 Remi Collet <remi@fedoraproject.org> - 3.8.1-1
- backport 3.8.1 for remi repo