Blob Blame History Raw
#
# Fedora spec file for php-doctrine-orm
#
# Copyright (c) 2013-2017 Shawn Iwinski <shawn.iwinski@gmail.com>
#                         Remi Collet <remi@fedoraproject.org>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     doctrine
%global github_name      doctrine2
%global github_version   2.5.12
%global github_commit    984535cadc609e9eef8c89414aa3568ee97aa79f

%global composer_vendor  doctrine
%global composer_project orm

# "php": ">=5.4"
%global php_min_ver 5.4
# "doctrine/cache": "~1.4"
#     NOTE: Min version not 1.4.0 because autoloader required
%global cache_min_ver 1.4.1
%global cache_max_ver 2
# "doctrine/collections": "~1.2"
#     NOTE: Min version not 1.2 because autoloader required
%global collections_min_ver 1.3
%global collections_max_ver 2.0
# "doctrine/common": ">=2.5-dev,<2.9-dev"
%global common_min_ver 2.5
%global common_max_ver 2.9
# "doctrine/dbal": ">=2.5-dev,<2.7-dev"
#     NOTE: Min version not 2.4 because autoloader required
%global dbal_min_ver 2.5.4
%global dbal_max_ver 2.7
# "doctrine/instantiator": "^1.0.1"
%global instantiator_min_ver 1.0.1
%global instantiator_max_ver 2.0
# "symfony/console": "~2.5|~3.0"
# "symfony/yaml": "~2.3|~3.0"
#     NOTE: Min version not 2.5 because autoloader required
%global symfony_min_ver 2.7.1
%global symfony_max_ver 4.0

%{!?phpdir:  %global phpdir  %{_datadir}/php}

# 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:       4%{?dist}
Summary:       Doctrine Object-Relational-Mapper (ORM)

Group:         Development/Libraries
License:       MIT
URL:           http://www.doctrine-project.org/projects/orm.html

# 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

Patch1:        %{name}-php72.patch

BuildArch: noarch
# Tests
%if %{with_tests}
## composer.json
BuildRequires: php(language) >= %{php_min_ver}
BuildRequires: php-composer(doctrine/cache) <  %{cache_max_ver}
BuildRequires: php-composer(doctrine/cache) >= %{cache_min_ver}
BuildRequires: php-composer(doctrine/collections) <  %{collections_max_ver}
BuildRequires: php-composer(doctrine/collections) >= %{collections_min_ver}
BuildRequires: php-composer(doctrine/common) <  %{common_max_ver}
BuildRequires: php-composer(doctrine/common) >= %{common_min_ver}
BuildRequires: php-composer(doctrine/dbal) <  %{dbal_max_ver}
BuildRequires: php-composer(doctrine/dbal) >= %{dbal_min_ver}
BuildRequires: php-composer(doctrine/instantiator) <  %{instantiator_max_ver}
BuildRequires: php-composer(doctrine/instantiator) >= %{instantiator_min_ver}
BuildRequires: php-composer(phpunit/phpunit)
BuildRequires: php-composer(symfony/console) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/console) >= %{symfony_min_ver}
BuildRequires: php-composer(symfony/yaml) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/yaml) >= %{symfony_min_ver}
BuildRequires: php-pdo
# phpcompatinfo (computed from version 2.5.11)
BuildRequires: php-ctype
BuildRequires: php-date
BuildRequires: php-dom
BuildRequires: php-json
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-simplexml
BuildRequires: php-spl
BuildRequires: php-tokenizer
## Autoloader
BuildRequires: php-composer(fedora/autoloader)
%endif

# composer.json
Requires:      php(language) >= %{php_min_ver}
Requires:      php-composer(doctrine/cache) <  %{cache_max_ver}
Requires:      php-composer(doctrine/cache) >= %{cache_min_ver}
Requires:      php-composer(doctrine/collections) <  %{collections_max_ver}
Requires:      php-composer(doctrine/collections) >= %{collections_min_ver}
Requires:      php-composer(doctrine/common) <  %{common_max_ver}
Requires:      php-composer(doctrine/common) >= %{common_min_ver}
Requires:      php-composer(doctrine/dbal) <  %{dbal_max_ver}
Requires:      php-composer(doctrine/dbal) >= %{dbal_min_ver}
Requires:      php-composer(doctrine/instantiator) <  %{instantiator_max_ver}
Requires:      php-composer(doctrine/instantiator) >= %{instantiator_min_ver}
Requires:      php-composer(symfony/console) <  %{symfony_max_ver}
Requires:      php-composer(symfony/console) >= %{symfony_min_ver}
Requires:      php-pdo
# composer.json: suggest
Requires:      php-composer(symfony/yaml) <  %{symfony_max_ver}
Requires:      php-composer(symfony/yaml) >= %{symfony_min_ver}
# phpcompatinfo (computed from version 2.5.11)
Requires:      php-ctype
Requires:      php-date
Requires:      php-dom
Requires:      php-json
Requires:      php-pcre
Requires:      php-reflection
Requires:      php-simplexml
Requires:      php-spl
Requires:      php-tokenizer
# Autoloader
Requires:      php-composer(fedora/autoloader)

# Weak dependencies
%if 0%{?fedora} >= 21
## Optional caches (see Doctrine\ORM\Tools\Setup::createConfiguration())
Suggests:      php-pecl(apcu)
Suggests:      php-pecl(memcache)
Suggests:      php-pecl(redis)
Suggests:      php-xcache
%endif

# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}
# PEAR
Provides:      php-pear(pear.doctrine-project.org/DoctrineORM) = %{version}
# Rename
Obsoletes:     php-doctrine-DoctrineORM < %{version}
Provides:      php-doctrine-DoctrineORM = %{version}

%description
Object relational mapper (ORM) for PHP that sits on top of a powerful database
abstraction layer (DBAL). One of its' key features is the option to write
database queries in a proprietary object oriented SQL dialect called Doctrine
Query Language (DQL), inspired by Hibernate's HQL. This provides developers
with a powerful alternative to SQL that maintains flexibility without requiring
unnecessary code duplication.

Autoloader: %{phpdir}/Doctrine/ORM/autoload.php


%prep
%setup -qn %{github_name}-%{github_commit}

: Patch bin script
%patch0 -p1
sed -i 's#__PHPDIR__#%{phpdir}#g' bin/doctrine.php
%patch1 -p1

: Remove empty file
rm -f lib/Doctrine/ORM/README.markdown


%build
: Create autoloader
cat <<'AUTOLOAD' | tee lib/Doctrine/ORM/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 */
require_once '%{phpdir}/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('Doctrine\\ORM\\', __DIR__);

\Fedora\Autoloader\Dependencies::required([
    '%{phpdir}/Doctrine/Common/autoload.php',
    '%{phpdir}/Doctrine/Common/Cache/autoload.php',
    '%{phpdir}/Doctrine/Common/Collections/autoload.php',
    '%{phpdir}/Doctrine/DBAL/autoload.php',
    '%{phpdir}/Doctrine/Instantiator/autoload.php',
    [
      '%{phpdir}/Symfony3/Component/Console/autoload.php',
      '%{phpdir}/Symfony/Component/Console/autoload.php',
    ],
]);

\Fedora\Autoloader\Dependencies::optional([
  [
    '%{phpdir}/Symfony3/Component/Yaml/autoload.php',
    '%{phpdir}/Symfony/Component/Yaml/autoload.php',
  ],
]);
AUTOLOAD


%install
: Lib
mkdir -p %{buildroot}%{phpdir}
cp -rp lib/Doctrine %{buildroot}%{phpdir}/

: Bin
mkdir -p %{buildroot}/%{_bindir}
install -pm 0755 bin/doctrine.php %{buildroot}/%{_bindir}/doctrine


%check
%if %{with_tests}
: Remove load of TestInit
mv tests/Doctrine/Tests/TestInit.php tests/Doctrine/Tests/TestInit.php.dist
grep -r --files-with-matches 'TestInit' tests \
    | xargs sed '/TestInit/d' -i

: Load annotation register file from buildroot
sed 's#__DIR__\s*\.\s*"/\(\.\./\)*lib#"%{buildroot}%{phpdir}#' \
    -i tests/Doctrine/Tests/OrmTestCase.php

: Create tests bootstrap
cat > bootstrap.php <<'BOOTSTRAP'
<?php
require_once '%{buildroot}%{phpdir}/Doctrine/ORM/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('Doctrine\\Tests\\', __DIR__.'/tests/Doctrine/Tests');
BOOTSTRAP

: Skip tests known to fail
sed \
    -e 's/function testLoadedAssociationToManyShouldTriggerEvent/function SKIP_testLoadedAssociationToManyShouldTriggerEvent/' \
    -e 's/function testLoadedAssociationToOneShouldTriggerEvent/function SKIP_testLoadedAssociationToOneShouldTriggerEvent/' \
    -e 's/function testLoadedEntityUsingFindShouldTriggerEvent/function SKIP_testLoadedEntityUsingFindShouldTriggerEvent/' \
    -e 's/function testLoadedEntityUsingQueryShouldTriggerEvent/function SKIP_testLoadedEntityUsingQueryShouldTriggerEvent/' \
    -e 's/function testLoadedProxyAssociationToManyShouldTriggerEvent/function SKIP_testLoadedProxyAssociationToManyShouldTriggerEvent/' \
    -e 's/function testLoadedProxyAssociationToOneShouldTriggerEvent/function SKIP_testLoadedProxyAssociationToOneShouldTriggerEvent/' \
    -e 's/function testLoadedProxyEntityShouldTriggerEvent/function SKIP_testLoadedProxyEntityShouldTriggerEvent/' \
    -e 's/function testLoadedProxyPartialShouldTriggerEvent/function SKIP_testLoadedProxyPartialShouldTriggerEvent/' \
    -i tests/Doctrine/Tests/ORM/Functional/PostLoadEventTest.php
sed 's/function testQueryCache_NoHitSaveParserResult/function SKIP_testQueryCache_NoHitSaveParserResult/' \
    -i tests/Doctrine/Tests/ORM/Functional/QueryCacheTest.php
rm -f \
    tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2692Test.php \
    tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3123Test.php

%if 0%{?rhel} < 7
rm tests/Doctrine/Tests/ORM/Functional/Ticket/GH6464Test.php
%endif

: Upstream tests
RETURN_CODE=0
PHPUNIT=$(which phpunit)
for PHP_EXEC in "" %{?rhel:php55} php56 php70 php71 php72; do
    if [ -z "$PHP_EXEC" ] || which $PHP_EXEC; then
        $PHP_EXEC $PHPUNIT --verbose -d memory_limit="512M" --bootstrap bootstrap.php \
            || RETURN_CODE=1
    fi
done
exit $RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md *.markdown composer.json
%{phpdir}/Doctrine/ORM
%{_bindir}/doctrine


%changelog
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.12-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.12-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Fri Nov 10 2017 Remi Collet <remi@remirepo.net> - 2.5.12-2
- fix more tests failing since 7.1

* Fri Nov 10 2017 Remi Collet <remi@remirepo.net> - 2.5.12-1
- Update to 2.5.12
- fix FTBFS from Koschei add patch for PHP 7.2 from
  https://github.com/doctrine/doctrine2/pull/6821

* Wed Sep 20 2017 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.5.11-1
- Updated to 2.5.11 (RHBZ #1207905)

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.8-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 25 2017 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.8-3
- Fix FTBFS in rawhide (RHBZ #1424060)
- Use php-composer(fedora/autoloader)
- Test SCLs if available

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Sat Jul 09 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.8-1
- Updated to 2.4.8 (RHBZ #1347926 / CVE-2015-5723)
- Added autoloader

* Mon Jun 13 2016 Remi Collet <remi@fedoraproject.org> - 2.4.7-5
- add workaround for test suite with PHPUnit 5.4

* Sun Feb 28 2016 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.7-4
- Skip additional tests known to fail (RHBZ #1307857)

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 2.4.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sun Dec 28 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.7-1
- Updated to 2.4.7 (BZ #1175217)
- %%license usage

* Mon Nov 03 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.6-2
- Ensure 512M of memory (instead of default 128M) so mock x86_64
  builds pass (BZ #1159650)

* 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

* Sat Jun 21 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.2-4
- Added php-composer(%%{composer_vendor}/%%{composer_project}) virtual provide
- Updated Doctrine dependencies to use php-composer virtual provides

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Fri May 30 2014 Remi Collet <remi@fedoraproject.org> - 2.4.2-2
- upstream fix for latest PHP (#1103219)

* Wed Feb 12 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.2-1
- Updated to 2.4.2 (BZ #1063021)

* Sat Jan 04 2014 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.1-2
- Conditional %%{?dist}
- Bin script patch instead of inline update and use Doctrine Common classloader
- Updated optional cache information in %%description
- Removed empty file
- Removed unnecessary executable bit

* Sat Dec 28 2013 Shawn Iwinski <shawn.iwinski@gmail.com> - 2.4.1-1
- Initial package