From cf0989b01ac6df63062549068842c62033bff644 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 2 Jul 2015 08:54:29 +0200 Subject: php-pdepend-PHP-Depend: 2.1.0 --- makesrc.sh | 26 ++++++ php-pdepend-PHP-Depend-autoload.php | 19 ++++ php-pdepend-PHP-Depend-rpm.patch | 46 ++++++++++ php-pdepend-PHP-Depend.spec | 169 +++++++++++++++++++++++++----------- 4 files changed, 211 insertions(+), 49 deletions(-) create mode 100755 makesrc.sh create mode 100644 php-pdepend-PHP-Depend-autoload.php create mode 100644 php-pdepend-PHP-Depend-rpm.patch 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-pdepend-PHP-Depend-autoload.php b/php-pdepend-PHP-Depend-autoload.php new file mode 100644 index 0000000..77ae7b1 --- /dev/null +++ b/php-pdepend-PHP-Depend-autoload.php @@ -0,0 +1,19 @@ +register(); +} + +/* PDepend */ +$fedoraClassLoader->addPrefix('PDepend\\', dirname(__DIR__)); + +/* for symfony/dependency-injection, filesystem and config */ +$fedoraClassLoader->addPrefix('Symfony\\Component\\', $vendorDir); diff --git a/php-pdepend-PHP-Depend-rpm.patch b/php-pdepend-PHP-Depend-rpm.patch new file mode 100644 index 0000000..845b162 --- /dev/null +++ b/php-pdepend-PHP-Depend-rpm.patch @@ -0,0 +1,46 @@ +diff -up src/bin/pdepend.rpm src/bin/pdepend +--- src/bin/pdepend.rpm 2015-07-02 08:09:31.386769752 +0200 ++++ src/bin/pdepend 2015-07-02 08:09:38.708807234 +0200 +@@ -43,17 +43,7 @@ + + use PDepend\TextUI\Command; + +-// PEAR/svn workaround +-if (strpos('@php_bin@', '@php_bin') === 0) { +- set_include_path('.' . PATH_SEPARATOR . dirname(__FILE__) . '/../main/php'); +-} +- +-// check for pdepend installed as composer package +-if (file_exists(__DIR__ . '/../../../../autoload.php')) { +- require_once __DIR__ . '/../../../../autoload.php'; +-} else { +- require_once __DIR__ . '/../../vendor/autoload.php'; +-} ++require '/usr/share/php/PDepend/autoload.php'; + + // Allow as much memory as possible by default + if (extension_loaded('suhosin') && is_numeric(ini_get('suhosin.memory_limit'))) { +diff -up src/main/php/PDepend/Application.php.rpm src/main/php/PDepend/Application.php +--- src/main/php/PDepend/Application.php.rpm 2015-07-02 08:26:18.911899973 +0200 ++++ src/main/php/PDepend/Application.php 2015-07-02 08:27:25.327236899 +0200 +@@ -136,7 +136,7 @@ class Application + $container->prependExtensionConfig('pdepend', array()); + $container->addCompilerPass(new DependencyInjection\Compiler\ProcessListenerPass()); + +- $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../resources')); ++ $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../php-pdepend-PHP-Depend/resources')); + + foreach ($extensions as $extension) { + $container->registerExtension($extension); +diff -up src/main/php/PDepend/DependencyInjection/PdependExtension.php.rpm src/main/php/PDepend/DependencyInjection/PdependExtension.php +--- src/main/php/PDepend/DependencyInjection/PdependExtension.php.rpm 2015-07-02 08:27:39.270307644 +0200 ++++ src/main/php/PDepend/DependencyInjection/PdependExtension.php 2015-07-02 08:29:02.808731429 +0200 +@@ -80,7 +80,7 @@ class PdependExtension extends SymfonyEx + $configuration = new Configuration($extensionManager->getActivatedExtensions()); + $config = $this->processConfiguration($configuration, $configs); + +- $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../resources')); ++ $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../php-pdepend-PHP-Depend/resources')); + $loader->load('services.xml'); + + foreach ($extensionManager->getActivatedExtensions() as $extension) { diff --git a/php-pdepend-PHP-Depend.spec b/php-pdepend-PHP-Depend.spec index 8a8d784..873da9b 100644 --- a/php-pdepend-PHP-Depend.spec +++ b/php-pdepend-PHP-Depend.spec @@ -1,97 +1,168 @@ +# remirepo spec file for php-pdepend-PHP-Depend +# using git sources, from: +# +# Fedora spec file for php-pdepend-PHP-Depend +# +# License: MIT +# http://opensource.org/licenses/MIT +# +# Please, preserve the changelog entries +# +%global gh_commit f58902a774449f73f1a1d9cd1a07aeac8fbee367 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner pdepend +%global gh_project pdepend %{!?__pear: %global __pear %{_bindir}/pear} -%global pear_name PHP_Depend -%global channel pear.pdepend.org +%global pear_name PHP_Depend +%global pear_channel pear.pdepend.org +%global php_home %{_datadir}/php/PDepend +%global with_tests 0%{!?_without_tests:1} Name: php-pdepend-PHP-Depend -Version: 1.1.4 +Version: 2.1.0 Release: 1%{?dist} Summary: PHP_Depend design quality metrics for PHP package Group: Development/Libraries License: BSD -URL: http://www.pdepend.org/ -Source0: http://pear.pdepend.org/get/%{pear_name}-%{version}.tgz +URL: http://pdepend.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(%{channel}) - -Requires(post): %{__pear} -Requires(postun): %{__pear} -Requires: php-channel(%{channel}) -# From upstream -Requires: php(language) >= 5.2.3 -Requires: php-dom -Requires: php-pcre -Requires: php-spl -Requires: php-tokenizer -Requires: php-simplexml -# From upstream, optional -Requires: php-pecl(imagick) >= 2.2.0b2 -# From phpcompatinfo +%if %{with_tests} +# For tests +BuildRequires: %{_bindir}/phpunit +BuildRequires: php(language) >= 5.3.7 +BuildRequires: php-composer(symfony/dependency-injection) >= 2.4 +BuildRequires: php-composer(symfony/filesystem) >= 2.4 +BuildRequires: php-composer(symfony/config) >= 2.4 +BuildRequires: php-bcmath +BuildRequires: php-date +BuildRequires: php-dom +BuildRequires: php-libxml +BuildRequires: php-pcre +BuildRequires: php-reflection +BuildRequires: php-simplexml +BuildRequires: php-spl +BuildRequires: php-tokenizer +BuildRequires: php-composer(symfony/class-loader) +%endif + +# From composer.json, "require": { +# "php": ">=5.3.7" +# "symfony/dependency-injection": ">=2.4", +# "symfony/filesystem": ">=2.4", +# "symfony/config": ">=2.4" +Requires: php(language) >= 5.3.7 +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.1.0 Requires: php-bcmath Requires: php-date +Requires: php-dom Requires: php-libxml +Requires: php-pcre Requires: php-reflection +Requires: php-simplexml +Requires: php-spl +Requires: php-tokenizer +# Autoloader +Requires: php-composer(symfony/class-loader) -Provides: php-pear(%{channel}/%{pear_name}) = %{version} +# Single package in this channel +Obsoletes: php-channel-pdepend <= 1.3 + +Provides: php-pear(%{pear_channel}/%{pear_name}) = %{version} +Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version} %description -PHP_Depend is an adaption of the Java design quality metrics software JDepend -and the NDepend metric tool. +PHP_Depend is an adaption of the established Java development tool JDepend. +This tool shows you the quality of your design in the terms of extensibility, +reusability and maintainability. %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/PDepend/autoload.php + +find src/main/php -name \*php -exec sed -e 's:@package_version@:%{version}:' -i {} \; +find src/test/php -name \*xml -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/PDepend %{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/pdepend %{buildroot}%{_bindir}/pdepend -%clean -rm -rf %{buildroot} +%check +%if %{with_tests} +mkdir vendor +cat <addPrefix('PDepend\\\\', dirname(__DIR__)); +EOF -%post -%{__pear} install --nodeps --soft --force --register-only \ - %{pear_xmldir}/%{name}.xml >/dev/null || : +%{_bindir}/phpunit -d memory_limit=1G --verbose +%else +: Test suite disabled +%endif -%postun -if [ $1 -eq 0 ] ; then - %{__pear} uninstall --nodeps --ignore-errors --register-only \ - %{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,-) -%{pear_xmldir}/%{name}.xml -%{pear_phpdir}/PHP +%{!?_licensedir:%global license %%doc} +%license LICENSE +%doc composer.json +%{php_home} +%{_datadir}/%{name} %{_bindir}/pdepend -%doc %{pear_docdir}/%{pear_name} %changelog +* Thu Jul 2 2015 Remi Collet - 2.1.0-1 +- update to 2.1.0 +- switch from pear channel to git snapshot sources +- run upstream test suite during build + * Sun May 04 2014 Remi Collet - 1.1.4-1 - Update to 1.1.4 @@ -204,7 +275,7 @@ fi * Sat May 22 2010 Christof Damian - 0.9.14-1 - upstream 0.9.14 -* Tue May 10 2010 Remi Collet - 0.9.13-1 +* Mon May 10 2010 Remi Collet - 0.9.13-1 - rebuild for remi repository * Mon May 10 2010 Christof Damian - 0.9.13-1 @@ -240,5 +311,5 @@ fi - own /usr/share/pear/PHP - include test files (which currently don't work) -* Fri Jan 1 2010 Christof Damian 0.9.9-1 +* Fri Jan 1 2010 Christof Damian 0.9.9-1 - initial release -- cgit