[php-phpunit-phpdcd] - update to 1.0.2 - sources from github - run test suite during build - drop dependencies on php-php

Remi Collet remi at fedoraproject.org
Mon May 5 13:41:51 UTC 2014


commit 993c76f7cab71e9c79ad434100ac9299f13eb447
Author: Remi Collet <remi at fedoraproject.org>
Date:   Mon May 5 15:42:08 2014 +0200

    - update to 1.0.2
    - sources from github
    - run test suite during build
    - drop dependencies on php-phpunit-File_Iterator, php-ezc-ConsoleTools
    - add dependencies on php-phpunit-FinderFacade, php-phpunit-Version php-symfony-console

 .gitignore              |    2 +
 Autoload.php.in         |   30 ++++++++++++
 php-phpunit-phpdcd.spec |  120 ++++++++++++++++++++++++++++-------------------
 phpdcd-rpm.patch        |   34 +++++++++++++
 sources                 |    2 +-
 5 files changed, 139 insertions(+), 49 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 3ea38df..5264088 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
+clog
 phpdcd-0.9.2.tgz
 /phpdcd-0.9.3.tgz
+/phpdcd-1.0.2.tar.gz
diff --git a/Autoload.php.in b/Autoload.php.in
new file mode 100644
index 0000000..c7f66e0
--- /dev/null
+++ b/Autoload.php.in
@@ -0,0 +1,30 @@
+<?php
+/* Inspired from autoload from version 0.9.3 */
+
+require_once 'SebastianBergmann/FinderFacade/autoload.php';
+require_once 'SebastianBergmann/Version/autoload.php';
+require_once 'PHP/Token/Stream/Autoload.php';
+require_once 'PHP/Timer/Autoload.php';
+require_once 'Symfony/Component/Console/autoloader.php';
+
+spl_autoload_register(
+  function ($class)
+  {
+    static $classes = NULL;
+    static $path = NULL;
+
+    if ($classes === NULL) {
+        $classes = array(
+          ___CLASSLIST___
+        );
+
+        $path = dirname(__FILE__);
+    }
+
+    $cn = strtolower($class);
+
+    if (isset($classes[$cn])) {
+        require $path . $classes[$cn];
+    }
+  }
+);
diff --git a/php-phpunit-phpdcd.spec b/php-phpunit-phpdcd.spec
index 4a666bc..24c1e4b 100644
--- a/php-phpunit-phpdcd.spec
+++ b/php-phpunit-phpdcd.spec
@@ -1,32 +1,52 @@
-%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
-%{!?pear_metadir: %global pear_metadir %{pear_phpdir}}
-%global pear_name phpdcd
-%global channel pear.phpunit.de
+%global gh_commit    10246f167713d0bd0b74540ca81e4caf30b72157
+%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_owner     sebastianbergmann
+%global gh_project   phpdcd
+%global php_home     %{_datadir}/php/SebastianBergmann
+%global pear_name    phpdcd
+%global pear_channel pear.phpunit.de
+%global with_tests   %{?_without_tests:0}%{!?_without_tests:1}
 
 Name:           php-phpunit-phpdcd
-Version:        0.9.3
-Release:        5%{?dist}
+Version:        1.0.2
+Release:        1%{?dist}
 Summary:        Dead Code Detector (DCD) for PHP code
 
 Group:          Development/Libraries
 License:        BSD
-URL:            http://github.com/sebastianbergmann/phpdcd
-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
 
-BuildArch:      noarch
-BuildRequires:  php-pear >= 1:1.9.4
-BuildRequires:  php-channel(%{channel})
-Requires:       php-common >= 5.2.7
-Requires:       php-channel(%{channel})
-Requires(post): %{__pear}
-Requires(postun): %{__pear}
-Requires:       php-pear(pear.phpunit.de/File_Iterator) >= 1.3.0
-Requires:       php-pear(pear.phpunit.de/PHP_TokenStream) >= 1.1.0
-Requires:       php-pear(pear.phpunit.de/PHP_Timer) >= 1.0.1
-Requires:       php-pear(components.ez.no/ConsoleTools) >= 1.6 
+# Autoload template
+Source1:        Autoload.php.in
+
+# Fix for RPM, use autoload
+Patch0:         %{gh_project}-rpm.patch
 
-Provides:       php-pear(%{channel}/%{pear_name}) = %{version}
+BuildArch:      noarch
+BuildRequires:  php(language) >= 5.3.3
+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-phpunit-PHP-TokenStream >= 1.1.3
+%endif
+
+# From composer.json
+Requires:       php(language) >= 5.3.3
+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-phpunit-PHP-TokenStream >= 1.1.3
+# From phpcompatinfo report for version 1.0.2
+Requires:       php-pcre
+Requires:       php-spl
+
+Provides:       php-pear(%{pear_channel}/%{pear_name}) = %{version}
 
 
 %description
@@ -34,54 +54,58 @@ phpdcd is a Dead Code Detector (DCD) for PHP code. It scans a PHP project
 for all declared functions and methods and reports those as being "dead 
 code" that are not called at least once.
 
+
 %prep
-%setup -q -c
-[ -f package2.xml ] || mv package.xml package2.xml
-%{__mv} package2.xml %{pear_name}-%{version}/%{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
-cd %{pear_name}-%{version}
-%{__rm} -rf $RPM_BUILD_ROOT docdir
-%{__pear} install --nodeps --packagingroot $RPM_BUILD_ROOT %{name}.xml
+mkdir -p   %{buildroot}%{php_home}
+cp -pr src %{buildroot}%{php_home}/PHPDCD
 
-# Clean up unnecessary files
-rm -rf %{buildroot}/%{pear_metadir}/.??* 
+install -D -p -m 755 phpdcd %{buildroot}%{_bindir}/phpdcd
 
-# Install XML package description
-%{__mkdir} -p $RPM_BUILD_ROOT%{pear_xmldir}
-%{__install} -pm 644 %{name}.xml $RPM_BUILD_ROOT%{pear_xmldir}
 
-
-%clean
-%{__rm} -rf $RPM_BUILD_ROOT
+%if %{with_tests}
+%check
+phpunit \
+   --bootstrap src/Autoload.php \
+   -d date.timezone=UTC \
+   tests
+%endif
 
 
 %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,-)
-%{pear_xmldir}/%{name}.xml
-%{pear_phpdir}/PHPDCD
+%doc LICENSE README.md composer.json
+%{php_home}/PHPDCD
 %{_bindir}/phpdcd
 
 
 %changelog
+* Sun May  4 2014 Remi Collet <remi at fedoraproject.org> - 1.0.2-1
+- update to 1.0.2
+- sources from github
+- run test suite during build
+- drop dependencies on php-phpunit-File_Iterator, php-ezc-ConsoleTools
+- add dependencies on php-phpunit-FinderFacade, php-phpunit-Version
+  php-symfony-console
+
 * Sun Aug 04 2013 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.9.3-5
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
 
diff --git a/phpdcd-rpm.patch b/phpdcd-rpm.patch
new file mode 100644
index 0000000..96c27ea
--- /dev/null
+++ b/phpdcd-rpm.patch
@@ -0,0 +1,34 @@
+diff -up ./phpdcd.rpm ./phpdcd
+--- ./phpdcd.rpm	2014-05-04 09:36:58.000000000 +0200
++++ ./phpdcd	2014-05-04 09:38:12.000000000 +0200
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env php
++#!/usr/bin/php
+ <?php
+ /**
+  * phpdcd
+@@ -42,23 +42,7 @@
+  * @since     File available since Release 1.0.0
+  */
+ 
+-$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/PHPDCD/Autoload.php';
+ 
+ $application = new SebastianBergmann\PHPDCD\CLI\Application;
+ $application->run();
diff --git a/sources b/sources
index 0c6615f..b86b9e4 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-384ef936fcd078d625998082e8c2bbb7  phpdcd-0.9.3.tgz
+849765439fec2000d949d9289a8a60d9  phpdcd-1.0.2.tar.gz


More information about the scm-commits mailing list