summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2015-07-02 10:26:30 +0200
committerRemi Collet <fedora@famillecollet.com>2015-07-02 10:26:30 +0200
commit7113f13a659c56a2dc66219131795123ef517e4a (patch)
treece99c728bff7b677ba6d0544f048029cb918003b
parentc8995562e0a6c31143dcbf54d74cdfcd41cd8b9c (diff)
php-pdepend-PHP-Depend: 2.2.3
-rwxr-xr-xmakesrc.sh26
-rw-r--r--php-phpmd-PHP-PMD-autoload.php22
-rw-r--r--php-phpmd-PHP-PMD-rpm.patch45
-rw-r--r--php-phpmd-PHP-PMD.spec156
4 files changed, 206 insertions, 43 deletions
diff --git a/makesrc.sh b/makesrc.sh
new file mode 100755
index 0000000..05a6054
--- /dev/null
+++ b/makesrc.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+NAME=$(sed -n '/^Name:/{s/.* //;p}' *.spec)
+OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec)
+PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec)
+VERSION=$(sed -n '/^Version:/{s/.* //;p}' $NAME.spec)
+COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec)
+SHORT=${COMMIT:0:7}
+
+echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n"
+
+echo "Cloning..."
+git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
+
+echo "Getting commit..."
+pushd $PROJECT-$COMMIT
+git checkout $COMMIT
+popd
+
+echo "Archiving..."
+tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT
+
+echo "Cleaning..."
+rm -rf $PROJECT-$COMMIT
+
+echo "Done."
diff --git a/php-phpmd-PHP-PMD-autoload.php b/php-phpmd-PHP-PMD-autoload.php
new file mode 100644
index 0000000..0d8d87e
--- /dev/null
+++ b/php-phpmd-PHP-PMD-autoload.php
@@ -0,0 +1,22 @@
+<?php
+/* Autoloader for pdepend/pdepend and its dependencies */
+
+$vendorDir = '/usr/share/php';
+// Use Symfony autoloader
+if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
+ if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
+ require_once $vendorDir . '/Symfony/Component/ClassLoader/ClassLoader.php';
+ }
+
+ $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
+ $fedoraClassLoader->register();
+}
+
+/* PHPMD */
+$fedoraClassLoader->addPrefix('PHPMD\\', dirname(__DIR__));
+
+/* for symfony/dependency-injection, filesystem and config */
+$fedoraClassLoader->addPrefix('Symfony\\Component\\', $vendorDir);
+
+/* PDepend */
+require_once $vendorDir . '/PDepend/autoload.php';
diff --git a/php-phpmd-PHP-PMD-rpm.patch b/php-phpmd-PHP-PMD-rpm.patch
new file mode 100644
index 0000000..98be5bc
--- /dev/null
+++ b/php-phpmd-PHP-PMD-rpm.patch
@@ -0,0 +1,45 @@
+diff -up src/bin/phpmd.rpm src/bin/phpmd
+--- src/bin/phpmd.rpm 2015-07-02 10:03:08.578182650 +0200
++++ src/bin/phpmd 2015-07-02 10:04:10.727496791 +0200
+@@ -3,23 +3,7 @@
+
+ use PHPMD\TextUI\Command;
+
+-if (file_exists(__DIR__ . '/../../../../autoload.php')) {
+- // phpmd is part of a composer installation
+- require_once __DIR__ . '/../../../../autoload.php';
+-} else {
+- require_once __DIR__ . '/../../vendor/autoload.php';
+-
+- // PEAR installation workaround
+- if (strpos('@package_version@', '@package_version') === 0) {
+- set_include_path(
+- dirname(__FILE__) . '/../main/php' .
+- PATH_SEPARATOR .
+- dirname(__FILE__) . '/../../vendor/pdepend/pdepend/src/main/php' .
+- PATH_SEPARATOR .
+- '.'
+- );
+- }
+-}
++require '/usr/share/php/PHPMD/autoload.php';
+
+ if (!ini_get('date.timezone') && !date_default_timezone_get()) {
+ date_default_timezone_set('UTC');
+diff -up src/main/php/PHPMD/RuleSetFactory.php.rpm src/main/php/PHPMD/RuleSetFactory.php
+--- src/main/php/PHPMD/RuleSetFactory.php.rpm 2015-07-02 10:05:14.076816993 +0200
++++ src/main/php/PHPMD/RuleSetFactory.php 2015-07-02 10:06:06.854083755 +0200
+@@ -79,12 +79,7 @@ class RuleSetFactory
+ */
+ public function __construct()
+ {
+- // PEAR installer workaround
+- if (strpos($this->location, '@data_dir') === 0) {
+- $this->location = __DIR__ . '/../../resources';
+- } else {
+- $this->location .= '/PHPMD/resources';
+- }
++ $this->location = __DIR__ . '/../../php-phpmd-PHP-PMD/resources';
+ }
+
+ /**
diff --git a/php-phpmd-PHP-PMD.spec b/php-phpmd-PHP-PMD.spec
index 5a37df7..db9e38d 100644
--- a/php-phpmd-PHP-PMD.spec
+++ b/php-phpmd-PHP-PMD.spec
@@ -1,36 +1,85 @@
+# remirepo spec file for php-phpmd-PHP-PMD
+# using git sources, from:
+#
+# Fedora spec file for php-phpmd-PHP-PMD
+#
+# License: MIT
+# http://opensource.org/licenses/MIT
+#
+# Please, preserve the changelog entries
+#
+%global gh_commit 5eeb5a4d39c8304910b33ae49f8813905346cc35
+%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_owner phpmd
+%global gh_project phpmd
%{!?__pear: %{expand: %%global __pear %{_bindir}/pear}}
%global pear_name PHP_PMD
%global pear_channel pear.phpmd.org
+%global php_home %{_datadir}/php/PHPMD
+%global with_tests 0%{!?_without_tests:1}
Name: php-phpmd-PHP-PMD
-Version: 1.5.0
+Version: 2.2.3
Release: 1%{?dist}
Summary: PHPMD - PHP Mess Detector
Group: Development/Libraries
License: BSD
-URL: http://www.phpmd.org/
-Source0: http://pear.phpmd.org/get/%{pear_name}-%{version}.tgz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+URL: http://phpmd.org/
+# git snashop to get upstream test suite
+Source0: %{name}-%{version}-%{gh_short}.tgz
+Source1: makesrc.sh
+# Autoloader
+Source2: %{name}-autoload.php
+Patch0: %{name}-rpm.patch
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-BuildRequires: php-pear
-BuildRequires: php-channel(%{pear_channel})
-
-Requires: php-channel(%{pear_channel})
-Requires: php(language) >= 5.2.3
-Requires: php-dom
+%if %{with_tests}
+# For tests
+BuildRequires: %{_bindir}/phpunit
+BuildRequires: php(language) >= 5.3
+BuildRequires: php-composer(pdepend/pdepend) >= 2.0
+BuildRequires: php-composer(symfony/dependency-injection) >= 2.4
+BuildRequires: php-composer(symfony/filesystem) >= 2.4
+BuildRequires: php-composer(symfony/config) >= 2.4
+BuildRequires: php-date
+BuildRequires: php-libxml
+BuildRequires: php-pcre
+BuildRequires: php-simplexml
+BuildRequires: php-spl
+BuildRequires: php-composer(symfony/class-loader)
+%endif
+
+# From composer.json, "require": {
+# "php": ">=5.3.0",
+# "pdepend/pdepend": "~2.0",
+# "symfony/dependency-injection": ">=2.4",
+# "symfony/filesystem": ">=2.4",
+# "symfony/config": ">=2.4"
+Requires: php(language) >= 5.3
+Requires: php-composer(pdepend/pdepend) >= 2.0
+Requires: php-composer(pdepend/pdepend) < 3
+Requires: php-composer(symfony/dependency-injection) >= 2.4
+Requires: php-composer(symfony/dependency-injection) < 3
+Requires: php-composer(symfony/filesystem) >= 2.4
+Requires: php-composer(symfony/filesystem) < 3
+Requires: php-composer(symfony/config) >= 2.4
+Requires: php-composer(symfony/config) < 3
+# From phpcompatinfo report for version 2.2.3
+Requires: php-date
+Requires: php-libxml
Requires: php-pcre
Requires: php-simplexml
Requires: php-spl
-# phpcompatinfo detected
-Requires: php-date
-Requires: php-libxml
-Requires: php-pear(pear.pdepend.org/PHP_Depend) >= 1.1.1
-Requires(post): %{__pear}
-Requires(postun): %{__pear}
+# Autoloader
+Requires: php-composer(symfony/class-loader)
+
+# Single package in this channel
+Obsoletes: php-channel-phpmd <= 1.3
Provides: php-pear(%{pear_channel}/%{pear_name}) = %{version}
+Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version}
%description
@@ -41,55 +90,76 @@ stream measured by PHP Depend.
%prep
-%setup -q -c
-cd %{pear_name}-%{version}
-mv ../package.xml %{name}.xml
+%setup -q -n %{gh_project}-%{gh_commit}
+
+%patch0 -p0
+cp %{SOURCE2} src/main/php/PHPMD/autoload.php
+
+find src/main/php -name \*php -exec sed -e 's:@package_version@:%{version}:' -i {} \;
+find src/test -type f -exec sed -e 's:@package_version@:%{version}:' -i {} \;
%build
-cd %{pear_name}-%{version}
# Empty build section, most likely nothing required.
%install
rm -rf %{buildroot}
-cd %{pear_name}-%{version}
-%{__pear} install --nodeps --packagingroot %{buildroot} %{name}.xml
-# Clean up unnecessary files
-rm -rf %{buildroot}%{pear_metadir}/.??*
+: Library
+mkdir -p $(dirname %{buildroot}%{php_home})
+cp -pr src/main/php/PHPMD %{buildroot}%{php_home}
-# Install XML package description
-mkdir -p %{buildroot}%{pear_xmldir}
-install -pm 644 %{name}.xml %{buildroot}%{pear_xmldir}
+: Resources
+mkdir -p %{buildroot}%{_datadir}/%{name}
+cp -pr src/main/resources %{buildroot}%{_datadir}/%{name}/resources
+: Command
+install -Dpm 0755 src/bin/phpmd %{buildroot}%{_bindir}/phpmd
-%clean
-rm -rf %{buildroot}
+%check
+%if %{with_tests}
+cat <<EOF | tee src/test/php/bootstrap.php
+<?php
+require '%{buildroot}%{php_home}/autoload.php';
+\$fedoraClassLoader->addPrefix('PHPMD\\\\', __DIR__);
+EOF
-%post
-%{__pear} install --nodeps --soft --force --register-only \
- %{pear_xmldir}/%{name}.xml >/dev/null || :
+%{_bindir}/phpunit --verbose
+%else
+: Test suite disabled
+%endif
-%postun
-if [ $1 -eq 0 ] ; then
- %{__pear} uninstall --nodeps --ignore-errors --register-only \
- %{pear_channel}/%{pear_name} >/dev/null || :
+%pre
+if [ -x %{_bindir}/pear ]; then
+ %{_bindir}/pear uninstall --nodeps --ignore-errors --register-only \
+ %{pear_channel}/%{pear_name} >/dev/null || :
fi
+%clean
+rm -rf %{buildroot}
+
+
%files
%defattr(-,root,root,-)
-%doc %{pear_docdir}/%{pear_name}
-%{pear_xmldir}/%{name}.xml
-%{pear_phpdir}/PHP/PMD.php
-%{pear_phpdir}/PHP/PMD
-%{pear_datadir}/PHP_PMD
+%{!?_licensedir:%global license %%doc}
+%license LICENSE
+%doc composer.json
+%doc CONTRIBUTING.md README.rst AUTHORS.rst
+%{php_home}
+%{_datadir}/%{name}
%{_bindir}/phpmd
+
%changelog
+* Thu Jul 2 2015 Remi Collet <remi@fedoraproject.org> - 2.2.3-1
+- update to 2.2.3
+- switch from pear channel to git snapshot sources
+- run upstream test suite during build
+
* Fri Jul 26 2013 Remi Collet <remi@fedoraproject.org> - 1.5.0-1
- Update to 1.5.0
@@ -170,7 +240,7 @@ fi
* Sun Apr 4 2010 Christof Damian <christof@damian.net> - 0.2.5-1
- upsteam 0.2.5: bugfixes
-* Thu Mar 9 2010 Remi Collet <RPMS@FamilleCollet.com> - 0.2.4-1
+* Tue Mar 9 2010 Remi Collet <RPMS@FamilleCollet.com> - 0.2.4-1
- rebuild for remi repository
* Tue Mar 9 2010 Christof Damian <christof@damian.net> - 0.2.4-1
@@ -198,6 +268,6 @@ fi
* Tue Jan 12 2010 Christof Damian <christof@damian.net> - 0.2.1-1
- upstream 0.2.1
-* Fri Jan 1 2010 Christof Damian <christof@damian.net> 0.2.0-1
+* Fri Jan 1 2010 Christof Damian <christof@damian.net> 0.2.0-1
- initial release