summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-05-04 10:45:13 +0200
committerRemi Collet <fedora@famillecollet.com>2014-05-04 10:45:13 +0200
commitab39f0d94fc657b15151022519b273e1f973e29f (patch)
tree04b3a5a555b57ee85fe552a7bfe866bbfa546f26
parent08f620605fde50336a3a1ef5384c53c25535a3cf (diff)
php-phpunit-phpcpd: 2.0.1, sources from github
-rw-r--r--autoload.php.in62
-rw-r--r--php-phpunit-phpcpd.spec113
-rw-r--r--phpcpd-rpm.patch34
3 files changed, 163 insertions, 46 deletions
diff --git a/autoload.php.in b/autoload.php.in
new file mode 100644
index 0000000..2f41bdb
--- /dev/null
+++ b/autoload.php.in
@@ -0,0 +1,62 @@
+<?php
+/**
+ * phpcpd
+ *
+ * Copyright (c) 2009-2013, Sebastian Bergmann <sebastian@phpunit.de>.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Sebastian Bergmann nor the names of his
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @package phpcpd
+ * @author Sebastian Bergmann <sebastian@phpunit.de>
+ * @copyright 2009-2013 Sebastian Bergmann <sebastian@phpunit.de>
+ * @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
+ * @since File available since Release 1.1.0
+ */
+
+require_once 'SebastianBergmann/FinderFacade/autoload.php';
+require_once 'SebastianBergmann/Version/autoload.php';
+require_once 'Symfony/Component/Console/autoloader.php';
+require_once 'PHP/Timer/Autoload.php';
+
+spl_autoload_register(
+ function ($class) {
+ static $classes = null;
+ if ($classes === null) {
+ $classes = array(
+ ___CLASSLIST___
+ );
+ }
+ $cn = strtolower($class);
+ if (isset($classes[$cn])) {
+ require ___BASEDIR___$classes[$cn];
+ }
+ }
+);
diff --git a/php-phpunit-phpcpd.spec b/php-phpunit-phpcpd.spec
index efef1c3..e3751cc 100644
--- a/php-phpunit-phpcpd.spec
+++ b/php-phpunit-phpcpd.spec
@@ -1,41 +1,57 @@
-%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
-%global pear_name phpcpd
-%global channel pear.phpunit.de
+%global gh_commit a9462153f2dd90466a010179901d31fbff598365
+%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_owner sebastianbergmann
+%global gh_project phpcpd
+%global php_home %{_datadir}/php/SebastianBergmann
+%global pear_name phpcpd
+%global pear_channel pear.phpunit.de
+%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
Name: php-phpunit-phpcpd
-Version: 2.0.0
+Version: 2.0.1
Release: 1%{?dist}
Summary: Copy/Paste Detector (CPD) for PHP code
Group: Development/Libraries
License: BSD
-URL: http://github.com/sebastianbergmann/phpcpd
-Source0: http://pear.phpunit.de/get/%{pear_name}-%{version}.tgz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+URL: https://github.com/%{gh_owner}/%{gh_project}
+Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}.tar.gz
+
+# Autoload template
+Source1: autoload.php.in
+# Fix for RPM, use autoload
+Patch0: %{gh_project}-rpm.patch
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: php(language) >= 5.3.3
-BuildRequires: php-pear(PEAR) >= 1.9.4
-BuildRequires: php-channel(%{channel})
-
-Requires(post): %{__pear}
-Requires(postun): %{__pear}
-# From package.xml
+BuildRequires: %{_bindir}/phpab
+%if %{with_tests}
+BuildRequires: %{_bindir}/phpunit
+BuildRequires: php-phpunit-FinderFacade >= 1.1.0
+BuildRequires: php-phpunit-Version >= 1.0.3
+BuildRequires: php-symfony-console >= 2.2.0
+BuildRequires: php-phpunit-PHP-Timer >= 1.0.4
+BuildRequires: php-theseer-fDOMDocument >= 1.4
+%endif
+
+# From composer.json
Requires: php(language) >= 5.3.3
-Requires: php-tokenizer
-Requires: php-pear(PEAR) >= 1.9.4
-Requires: php-channel(%{channel})
-Requires: php-pear(pear.phpunit.de/FinderFacade) >= 1.1.0
-Requires: php-pear(pear.phpunit.de/PHP_Timer) >= 1.0.4
-Requires: php-pear(pear.phpunit.de/Version) >= 1.0.0
-Requires: php-pear(pear.symfony.com/Console) >= 2.2.0
-# From phpcompatinfo report for version 2.0.0
+Requires: php-phpunit-FinderFacade >= 1.1.0
+Requires: php-phpunit-Version >= 1.0.3
+Requires: php-symfony-console >= 2.2.0
+Requires: php-phpunit-PHP-Timer >= 1.0.4
+Requires: php-theseer-fDOMDocument >= 1.4
+# From phpcompatinfo report for version 2.0.1
Requires: php-dom
Requires: php-mbstring
Requires: php-spl
+Requires: php-tokenizer
Requires: php-xml
-Provides: php-pear(%{channel}/%{pear_name}) = %{version}
+# For compatibility with pear
+Provides: php-pear(%{pear_channel}/%{pear_name}) = %{version}
%description
@@ -47,27 +63,33 @@ need to get a quick overview of duplicated code in a project.
%prep
-%setup -q -c
-cd %{pear_name}-%{version}
-mv ../package.xml %{name}.xml
+%setup -q -n %{gh_project}-%{gh_commit}
+
+%patch0 -p1 -b .rpm
%build
-cd %{pear_name}-%{version}
-# Empty build section, most likely nothing required.
+phpab \
+ --output src/autoload.php \
+ --template %{SOURCE1} \
+ src
%install
-rm -rf %{buildroot}
-cd %{pear_name}-%{version}
-%{__pear} install --nodeps --packagingroot %{buildroot} %{name}.xml
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{php_home}
+cp -pr src %{buildroot}%{php_home}/PHPCPD
+
+install -D -p -m 755 phpcpd %{buildroot}%{_bindir}/phpcpd
-# 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}
+%if %{with_tests}
+%check
+phpunit \
+ --bootstrap src/autoload.php \
+ -d date.timezone=UTC \
+ tests
+%endif
%clean
@@ -75,26 +97,25 @@ rm -rf %{buildroot}
%post
-%{__pear} install --nodeps --soft --force --register-only \
- %{pear_xmldir}/%{name}.xml >/dev/null || :
-
-
-%postun
-if [ $1 -eq 0 ] ; then
- %{__pear} uninstall --nodeps --ignore-errors --register-only \
- %{channel}/%{pear_name} >/dev/null || :
+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}/SebastianBergmann/PHPCPD
+%doc LICENSE README.md composer.json
+%{php_home}/PHPCPD
%{_bindir}/phpcpd
%changelog
+* Sun May 4 2014 Remi Collet <remi@fedoraproject.org> - 2.0.1-1
+- Update to 2.0.1
+- sources from github
+- run test suite during build
+
* Fri Nov 08 2013 Remi Collet <remi@fedoraproject.org> - 2.0.0-1
- Update to 2.0.0
- drop dependency on components.ez.no/ConsoleTools
diff --git a/phpcpd-rpm.patch b/phpcpd-rpm.patch
new file mode 100644
index 0000000..d904f78
--- /dev/null
+++ b/phpcpd-rpm.patch
@@ -0,0 +1,34 @@
+diff -up ./phpcpd.rpm ./phpcpd
+--- ./phpcpd.rpm 2014-05-04 10:32:06.000000000 +0200
++++ ./phpcpd 2014-05-04 10:32:59.000000000 +0200
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env php
++#!/usr/bin/php
+ <?php
+ /**
+ * phpcpd
+@@ -46,23 +46,7 @@
+ ini_set('mbstring.func_overload', 0);
+ ini_set('mbstring.internal_encoding', NULL);
+
+-$loaded = false;
+-
+-foreach (array(__DIR__ . '/../../autoload.php', __DIR__ . '/vendor/autoload.php') as $file) {
+- if (file_exists($file)) {
+- require $file;
+- $loaded = true;
+- break;
+- }
+-}
+-
+-if (!$loaded) {
+- die(
+- 'You need to set up the project dependencies using the following commands:' . PHP_EOL .
+- 'wget http://getcomposer.org/composer.phar' . PHP_EOL .
+- 'php composer.phar install' . PHP_EOL
+- );
+-}
++require 'SebastianBergmann/PHPCPD/autoload.php';
+
+ $application = new SebastianBergmann\PHPCPD\CLI\Application;
+ $application->run();