summaryrefslogtreecommitdiffstats
path: root/php-Metadata.spec
diff options
context:
space:
mode:
Diffstat (limited to 'php-Metadata.spec')
-rw-r--r--php-Metadata.spec107
1 files changed, 74 insertions, 33 deletions
diff --git a/php-Metadata.spec b/php-Metadata.spec
index 127f728..d36ea5b 100644
--- a/php-Metadata.spec
+++ b/php-Metadata.spec
@@ -1,7 +1,8 @@
+# remirepo spec file for php-Metadata, from Fedora:
#
# RPM spec file for php-Metadata
#
-# Copyright (c) 2013-2014 Shawn Iwinski <shawn.iwinski@gmail.com>
+# Copyright (c) 2013-2015 Shawn Iwinski <shawn.iwinski@gmail.com>
#
# License: MIT
# http://opensource.org/licenses/MIT
@@ -9,30 +10,29 @@
# Please preserve changelog entries
#
-%global github_owner schmittjoh
-%global github_name metadata
-%global github_version 1.5.1
-%global github_commit 22b72455559a25777cfd28c4ffda81ff7639f353
+%global github_owner schmittjoh
+%global github_name metadata
+%global github_version 1.5.1
+%global github_commit 22b72455559a25777cfd28c4ffda81ff7639f353
%global composer_vendor jms
%global composer_project metadata
-%global lib_name Metadata
-
# "php": ">=5.3.0"
%global php_min_ver 5.3.0
# "doctrine/cache" : "~1.0"
-%global doctrine_cache_min_ver 1.0
+# NOTE: min version not 1.0 because autoloader required
+%global doctrine_cache_min_ver 1.4.1
%global doctrine_cache_max_ver 2.0
# Build using "--without tests" to disable tests
-%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
+%global with_tests 0%{!?_without_tests:1}
-%{!?__phpunit: %global __phpunit %{_bindir}/phpunit}
+%{!?phpdir: %global phpdir %{_datadir}/php}
-Name: php-%{lib_name}
+Name: php-Metadata
Version: %{github_version}
-Release: 1%{?github_release}%{?dist}
+Release: 3%{?github_release}%{?dist}
Summary: A library for class/method/property metadata management in PHP
Group: Development/Libraries
@@ -42,29 +42,36 @@ Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{githu
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
+# Tests
%if %{with_tests}
-# For tests
-BuildRequires: php-phpunit-PHPUnit
-# For tests: composer.json
+BuildRequires: %{_bindir}/phpunit
+BuildRequires: php-composer(symfony/dependency-injection)
+## 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}
-# For tests: phpcompatinfo (computed from version 1.5.1)
+## phpcompatinfo (computed from version 1.5.1)
BuildRequires: php-date
BuildRequires: php-reflection
BuildRequires: php-spl
+## Autoloader
+BuildRequires: php-composer(symfony/class-loader)
%endif
Requires: php-composer(doctrine/cache) >= %{doctrine_cache_min_ver}
Requires: php-composer(doctrine/cache) < %{doctrine_cache_max_ver}
-Requires: php-symfony-dependencyinjection
+Requires: php-composer(symfony/dependency-injection)
# composer.json
Requires: php(language) >= %{php_min_ver}
# phpcompatinfo (computed from version 1.5.1)
Requires: php-date
Requires: php-reflection
Requires: php-spl
+# Autoloader
+Requires: php-composer(symfony/class-loader)
+# Standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming
+Provides: php-%{composer_vendor}-%{composer_project} = %{version}-%{release}
# Composer
Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version}
@@ -80,6 +87,37 @@ interface for all of them.
%prep
%setup -qn %{github_name}-%{github_commit}
+: Create autoloader
+cat <<'AUTOLOAD' | tee src/Metadata/autoload.php
+<?php
+/**
+ * Autoloader for %{name} and its' dependencies
+ *
+ * Created by %{name}-%{version}-%{release}
+ *
+ * @return \Symfony\Component\ClassLoader\ClassLoader
+ */
+
+require_once '%{phpdir}/Doctrine/Common/Cache/autoload.php';
+
+if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
+ if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
+ require_once '%{phpdir}/Symfony/Component/ClassLoader/ClassLoader.php';
+ }
+
+ $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
+ $fedoraClassLoader->register();
+}
+
+$fedoraClassLoader->addPrefix('Metadata\\', dirname(__DIR__));
+
+// Not all dependency autoloaders exist or are in every dist yet so fallback
+// to using include path for dependencies for now
+$fedoraClassLoader->setUseIncludePath(true);
+
+return $fedoraClassLoader;
+AUTOLOAD
+
%build
# Empty build section, nothing to build
@@ -87,25 +125,23 @@ interface for all of them.
%install
rm -rf %{buildroot}
-mkdir -pm 0755 %{buildroot}%{_datadir}/php
-cp -rp src/%{lib_name} %{buildroot}%{_datadir}/php/
+mkdir -p %{buildroot}%{phpdir}
+cp -rp src/* %{buildroot}%{phpdir}/
%check
%if %{with_tests}
-# Rewrite tests' bootstrap
-cat > tests/bootstrap.php <<'BOOTSTRAP'
+: Create tests bootstrap
+cat <<'BOOTSTRAP' | tee bootstrap.php
<?php
-spl_autoload_register(function ($class) {
- $src = str_replace('\\', '/', str_replace('_', '/', $class)).'.php';
- @include_once $src;
-});
-BOOTSTRAP
-# Create PHPUnit config w/ colors turned off
-sed 's/colors\s*=\s*"true"/colors="false"/' phpunit.xml.dist > phpunit.xml
+$fedoraClassLoader =
+ require_once '%{buildroot}%{phpdir}/Metadata/autoload.php';
+
+$fedoraClassLoader->addprefix('Metadata\\Tests\\', __DIR__ . '/tests');
+BOOTSTRAP
-%{__phpunit} --include-path="./src:./tests" -d date.timezone="UTC"
+%{_bindir}/phpunit --verbose --bootstrap ./bootstrap.php
%else
: Tests skipped
%endif
@@ -115,16 +151,21 @@ sed 's/colors\s*=\s*"true"/colors="false"/' phpunit.xml.dist > phpunit.xml
rm -rf %{buildroot}
-%{!?_licensedir:%global license %%doc}
-
%files
%defattr(-,root,root,-)
+%{!?_licensedir:%global license %%doc}
%license LICENSE
-%doc README.rst CHANGELOG.md composer.json
-%{_datadir}/php/%{lib_name}
+%doc *.md
+%doc *.rst
+%doc composer.json
+%{phpdir}/Metadata
%changelog
+* Sat Jul 11 2015 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.5.1-3
+- Added autoloader
+- Added standard "php-{COMPOSER_VENDOR}-{COMPOSER_PROJECT}" naming provides
+
* Sat Jul 19 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.5.1-1
- Updated to 1.5.1 (BZ #1119425)
- Added "php-composer(jms/metadata)" virtual provide