summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xphp-doctrine-orm-get-source.sh62
-rw-r--r--php-doctrine-orm-upstream.patch73
-rw-r--r--php-doctrine-orm.spec115
3 files changed, 145 insertions, 105 deletions
diff --git a/php-doctrine-orm-get-source.sh b/php-doctrine-orm-get-source.sh
new file mode 100755
index 0000000..e283587
--- /dev/null
+++ b/php-doctrine-orm-get-source.sh
@@ -0,0 +1,62 @@
+#/bin/sh
+
+GIT=`which git`
+RPM=`which rpm`
+
+if [ -z "$GIT" ]
+then
+ echo "ERROR: 'git' command not found" 1>&2
+ exit 1
+elif [ -z "$RPM" ]
+then
+ echo "ERROR: 'rpm' command not found" 1>&2
+ exit 1
+fi
+
+function print {
+ echo -e "\e[0;33m>>>>> ${1}\e[0m"
+}
+
+SPEC=`ls *.spec`
+NAME=`echo $SPEC | sed 's#\.spec##'`
+VERSION=`egrep '%global\s*github_version' $SPEC | awk '{print $3}'`
+
+print "SPEC = $SPEC"
+print "NAME = $NAME"
+
+GIT_OWNER=`egrep '%global\s*github_owner' $SPEC | awk '{print $3}'`
+GIT_NAME=`egrep '%global\s*github_name' $SPEC | awk '{print $3}'`
+GIT_COMMIT=`egrep '%global\s*github_commit' $SPEC | awk '{print $3}'`
+GIT_REPO=https://github.com/${GIT_OWNER}/${GIT_NAME}
+GIT_DIR=`echo $GIT_REPO | sed 's#.*/##'`
+
+print "GIT_OWNER = $GIT_OWNER"
+print "GIT_NAME = $GIT_NAME"
+print "GIT_COMMIT = $GIT_COMMIT"
+print "GIT_REPO = $GIT_REPO"
+print "GIT_DIR = $GIT_DIR"
+
+TEMP_DIR=$(mktemp --dir)
+
+pushd $TEMP_DIR
+ print "Cloning git repo..."
+ $GIT clone $GIT_REPO
+
+ pushd $GIT_DIR
+ print "Checking out commit..."
+ $GIT checkout $GIT_COMMIT
+ popd
+
+ TAR_DIR=${GIT_NAME}-${GIT_COMMIT}
+ print "TAR_DIR = $TAR_DIR"
+
+ mv $GIT_DIR $TAR_DIR
+
+ TAR_FILE=`$RPM --eval='%{_sourcedir}'`/${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz
+ print "TAR_FILE = $TAR_FILE"
+
+ [ -e $TAR_FILE ] && rm -f $TAR_FILE
+ tar --exclude-vcs -czf $TAR_FILE $TAR_DIR
+popd
+
+rm -rf $TEMP_DIR
diff --git a/php-doctrine-orm-upstream.patch b/php-doctrine-orm-upstream.patch
deleted file mode 100644
index b2dff4c..0000000
--- a/php-doctrine-orm-upstream.patch
+++ /dev/null
@@ -1,73 +0,0 @@
-Adapted for 2.4 from:
-
-From 361ec2a474d78168473fb82a041f32c4b7665643 Mon Sep 17 00:00:00 2001
-From: Marco Pivetta <ocramius@gmail.com>
-Date: Thu, 14 Aug 2014 15:51:48 +0200
-Subject: [PATCH] DDC-3120 - using `Doctrine\Instantiator` when building new
- instances
-
----
- lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php | 21 +++++++--------------
- 1 file changed, 7 insertions(+), 14 deletions(-)
-
-diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
-index 5d36f64..f8b4bb7 100644
---- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
-+++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
-@@ -20,6 +20,7 @@
- namespace Doctrine\ORM\Mapping;
-
- use BadMethodCallException;
-+use Doctrine\Instantiator\Instantiator;
- use InvalidArgumentException;
- use RuntimeException;
- use Doctrine\DBAL\Types\Type;
-@@ -610,11 +611,9 @@ class ClassMetadataInfo implements Class
- public $reflFields = array();
-
- /**
-- * The prototype from which new instances of the mapped class are created.
-- *
-- * @var object
-+ * @var \Doctrine\Instantiator\InstantiatorInterface|null
- */
-- private $_prototype;
-+ private $instantiator;
-
- /**
- * Initializes a new ClassMetadata instance that will hold the object-relational mapping
-@@ -628,6 +627,7 @@ class ClassMetadataInfo implements Class
- $this->name = $entityName;
- $this->rootEntityName = $entityName;
- $this->namingStrategy = $namingStrategy ?: new DefaultNamingStrategy();
-+ $this->instantiator = new Instantiator();
- }
-
- /**
-@@ -865,15 +865,7 @@ class ClassMetadataInfo implements Class
- */
- public function newInstance()
- {
-- if ($this->_prototype === null) {
-- if (PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513 || PHP_VERSION_ID >= 50600) {
-- $this->_prototype = $this->reflClass->newInstanceWithoutConstructor();
-- } else {
-- $this->_prototype = unserialize(sprintf('O:%d:"%s":0:{}', strlen($this->name), $this->name));
-- }
-- }
--
-- return clone $this->_prototype;
-+ return $this->instantiator->instantiate($this->name);
- }
- /**
- * Restores some state that can not be serialized/unserialized.
-@@ -885,7 +877,8 @@ class ClassMetadataInfo implements Class
- public function wakeupReflection($reflService)
- {
- // Restore ReflectionClass and properties
-- $this->reflClass = $reflService->getClass($this->name);
-+ $this->reflClass = $reflService->getClass($this->name);
-+ $this->instantiator = $this->instantiator ?: new Instantiator();
-
- foreach ($this->fieldMappings as $field => $mapping) {
- $this->reflFields[$field] = isset($mapping['declared'])
diff --git a/php-doctrine-orm.spec b/php-doctrine-orm.spec
index 67ed6e9..b313239 100644
--- a/php-doctrine-orm.spec
+++ b/php-doctrine-orm.spec
@@ -31,6 +31,11 @@
%global symfony_min_ver 2.1
%global symfony_max_ver 3.0
+%{!?__phpunit: %global __phpunit %{_bindir}/phpunit}
+
+# Build using "--without tests" to disable tests
+%global with_tests %{?_without_tests:0}%{!?_without_tests:1}
+
Name: php-%{composer_vendor}-%{composer_project}
Version: %{github_version}
Release: 1%{?dist}
@@ -39,37 +44,61 @@ Summary: Doctrine Object-Relational-Mapper (ORM)
Group: Development/Libraries
License: MIT
URL: http://www.doctrine-project.org/projects/orm.html
-Source0: https://github.com/%{github_owner}/%{github_name}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz
+
+# Run "php-doctrine-orm-get-source.sh" to create source
+Source0: %{name}-%{version}-%{github_commit}.tar.gz
+Source1: %{name}-get-source.sh
+
# Update bin script:
# 1) Add she-bang
# 2) Auto-load using Doctrine\Common\ClassLoader
Patch0: %{name}-bin.patch
-# Upstream fix for latest PHP
-Patch1: %{name}-upstream.patch
-Requires: php-composer(doctrine/instantiator) >= 1.0.2
-
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
-
-Requires: php(language) >= %{php_min_ver}
-Requires: php-composer(doctrine/collections) >= %{collections_min_ver}
-Requires: php-composer(doctrine/collections) < %{collections_max_ver}
-Requires: php-composer(doctrine/dbal) >= %{dbal_min_ver}
-Requires: php-composer(doctrine/dbal) < %{dbal_max_ver}
-Requires: php-symfony-console >= %{symfony_min_ver}
-Requires: php-symfony-console < %{symfony_max_ver}
-Requires: php-symfony-yaml >= %{symfony_min_ver}
-Requires: php-symfony-yaml < %{symfony_max_ver}
-# phpcompatinfo (computed from v2.4.2)
-Requires: php-ctype
-Requires: php-dom
-Requires: php-pcre
-Requires: php-pdo
-Requires: php-reflection
-Requires: php-simplexml
-Requires: php-spl
-Requires: php-tokenizer
+%if %{with_tests}
+BuildRequires: php-phpunit-PHPUnit
+# composer.json
+BuildRequires: php(language) >= %{php_min_ver}
+BuildRequires: php-composer(doctrine/collections) >= %{collections_min_ver}
+BuildRequires: php-composer(doctrine/collections) < %{collections_max_ver}
+BuildRequires: php-composer(doctrine/dbal) >= %{dbal_min_ver}
+BuildRequires: php-composer(doctrine/dbal) < %{dbal_max_ver}
+BuildRequires: php-symfony-console >= %{symfony_min_ver}
+BuildRequires: php-symfony-console < %{symfony_max_ver}
+BuildRequires: php-symfony-yaml >= %{symfony_min_ver}
+BuildRequires: php-symfony-yaml < %{symfony_max_ver}
+# phpcompatinfo (computed from version 2.4.6)
+BuildRequires: php-ctype
+BuildRequires: php-date
+BuildRequires: php-dom
+BuildRequires: php-pcre
+BuildRequires: php-pdo
+BuildRequires: php-reflection
+BuildRequires: php-simplexml
+BuildRequires: php-spl
+BuildRequires: php-tokenizer
+%endif
+
+# composer.json
+Requires: php(language) >= %{php_min_ver}
+Requires: php-composer(doctrine/collections) >= %{collections_min_ver}
+Requires: php-composer(doctrine/collections) < %{collections_max_ver}
+Requires: php-composer(doctrine/dbal) >= %{dbal_min_ver}
+Requires: php-composer(doctrine/dbal) < %{dbal_max_ver}
+Requires: php-symfony-console >= %{symfony_min_ver}
+Requires: php-symfony-console < %{symfony_max_ver}
+Requires: php-symfony-yaml >= %{symfony_min_ver}
+Requires: php-symfony-yaml < %{symfony_max_ver}
+# phpcompatinfo (computed from version 2.4.6)
+Requires: php-ctype
+Requires: php-dom
+Requires: php-pcre
+Requires: php-pdo
+Requires: php-reflection
+Requires: php-simplexml
+Requires: php-spl
+Requires: php-tokenizer
# Composer
Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version}
@@ -100,16 +129,10 @@ Optional caches (see Doctrine\ORM\Tools\Setup::createConfiguration()):
# Patch bin script
%patch0 -p1
-# For PHP 5.5.13+
-%patch1 -p1
-
# Remove empty file
rm -f lib/Doctrine/ORM/README.markdown
-# Clenup backup files
-find . -name \*.orig -exec rm {} \;
-
-# Remove unnecessary executable bit
+# Remove unnecessary executable bits
chmod a-x lib/Doctrine/ORM/Tools/Pagination/Paginator.php
@@ -128,7 +151,29 @@ install -pm 0755 bin/doctrine.php %{buildroot}/%{_bindir}/doctrine
%check
-# No upstream tests provided in source
+%if %{with_tests}
+# Rewrite "tests/Doctrine/Tests/TestInit.php"
+mv tests/Doctrine/Tests/TestInit.php tests/Doctrine/Tests/TestInit.php.dist
+cat > tests/Doctrine/Tests/TestInit.php <<'TEST_INIT'
+<?php
+
+spl_autoload_register(function ($class) {
+ $src = str_replace('\\', '/', $class).'.php';
+ @include_once $src;
+});
+TEST_INIT
+
+# Weird el6 error
+# TODO: Investigate and submit upstream patch
+%if 0%{?el6}
+sed 's#$this->_em->clear();#if (isset($this->_em)) { $this->_em->clear(); }#' \
+ -i tests/Doctrine/Tests/OrmFunctionalTestCase.php
+%endif
+
+%{__phpunit} --include-path ./lib:./tests -d date.timezone="UTC"
+%else
+: Tests skipped
+%endif
%clean
@@ -145,6 +190,12 @@ rm -rf %{buildroot}
%changelog
+* Tue Oct 14 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.6-1
+- Updated to 2.4.6 (BZ #1108129)
+- Manual git clone source instead of GitHub archive URL (to include tests)
+- Removed Patch1 (%%{name}-upstream.patch)
+- Added tests
+
* Tue Oct 7 2014 Remi Collet <remi@fedoraproject.org> 2.4.6-1
- Update to 2.4.6