From 72c1a0177d421712c1bc2856a9563a35714b5d92 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 21 Aug 2017 13:09:30 +0200 Subject: sync with Fedora --- php-symfony3-generate-autoloaders.php | 97 ++++++++++++++++++++++++------ php-symfony3.spec | 108 ++++++++++++++++++---------------- 2 files changed, 136 insertions(+), 69 deletions(-) diff --git a/php-symfony3-generate-autoloaders.php b/php-symfony3-generate-autoloaders.php index 9b6f152..3f0fcc3 100755 --- a/php-symfony3-generate-autoloaders.php +++ b/php-symfony3-generate-autoloaders.php @@ -16,7 +16,8 @@ $finder->in(SYMFONY_SOURCE_DIR)->name('composer.json')->sortByName(); foreach ($finder as $composerFile) { $autoloadGenerator = new AutoloadGenerator($composerFile); - echo $autoloadGenerator->getFilename(), "\n"; + echo $autoloadGenerator->getFilename().PHP_EOL; + echo $autoloadGenerator->getDevFilename().PHP_EOL; } @@ -25,6 +26,10 @@ foreach ($finder as $composerFile) { final class AutoloadGenerator { private static $pkgMap = [ + 'cache/integration-tests' => [ + 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', + 'path' => 'Cache/IntegrationTests/autoload.php', + ], 'doctrine/annotations' => [ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', 'path' => 'Doctrine/Common/Annotations/autoload.php', @@ -33,6 +38,10 @@ final class AutoloadGenerator { 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', 'path' => 'Doctrine/Common/Cache/autoload.php', ], + 'doctrine/collections' => [ + 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', + 'path' => 'Doctrine/Common/Collections/autoload.php', + ], 'doctrine/common' => [ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', 'path' => 'Doctrine/Common/autoload.php', @@ -45,6 +54,10 @@ final class AutoloadGenerator { 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', 'path' => 'Doctrine/DBAL/autoload.php', ], + 'doctrine/doctrine-bundle' => [ + 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', + 'path' => 'Doctrine/Bundle/DoctrineBundle/autoload.php', + ], 'doctrine/orm' => [ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', 'path' => 'Doctrine/ORM/autoload.php', @@ -69,6 +82,7 @@ final class AutoloadGenerator { 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', 'path' => 'phpDocumentor/Reflection/DocBlock/autoload.php', ], + 'predis/predis' => false, 'psr/cache-implementation' => false, 'psr/cache' => [ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', @@ -90,6 +104,7 @@ final class AutoloadGenerator { 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', 'path' => 'Psr/SimpleCache/autoload.php', ], + 'sensio/framework-extra-bundle' => false, 'symfony/asset' => [ 'prefix' => 'FEDORA_SYMFONY3_DIR', 'path' => 'Component/Asset/autoload.php', @@ -255,7 +270,7 @@ final class AutoloadGenerator { ], 'symfony/security-acl' => [ 'prefix' => 'FEDORA_SYMFONY3_PHP_DIR', - 'path' => 'Component/Security/Acl/autoload.php', + 'path' => 'Symfony/Component/Security/Acl/autoload.php', ], 'symfony/security-bundle' => [ 'prefix' => 'FEDORA_SYMFONY3_DIR', @@ -321,6 +336,10 @@ final class AutoloadGenerator { 'prefix' => 'FEDORA_SYMFONY3_DIR', 'path' => 'Bundle/WebProfilerBundle/autoload.php', ], + 'symfony/workflow' => [ + 'prefix' => 'FEDORA_SYMFONY3_DIR', + 'path' => 'Component/Workflow/autoload.php', + ], 'symfony/yaml' => [ 'prefix' => 'FEDORA_SYMFONY3_DIR', 'path' => 'Component/Yaml/autoload.php', @@ -336,22 +355,39 @@ final class AutoloadGenerator { private $filename = null; + private $devFilename = null; + public function __construct(SplFileInfo $composerFile) { $composerJson = static::composerJson($composerFile); + + // autoload.php $content = static::content( $composerJson, - static::dependencyAutoloaders($composerJson, true), - static::dependencyAutoloaders($composerJson, false) + static::dependencyAutoloaders($composerJson, 'require'), + static::dependencyAutoloaders($composerJson, 'suggest') ); - $this->filename = $composerFile->getPath() . '/autoload.php'; - if (FALSE == file_put_contents($this->filename, $content)) { throw new Exception(sprintf( 'Failed to generate autoload file "%s"', $this->filename )); } + + // autoload-dev.php + $content = static::content( + $composerJson, + static::dependencyAutoloaders($composerJson, 'require-dev'), + [], + true + ); + $this->devFilename = $composerFile->getPath() . '/autoload-dev.php'; + if (FALSE == file_put_contents($this->devFilename, $content)) { + throw new Exception(sprintf( + 'Failed to generate autoload file "%s"', + $this->filename + )); + } } private static function composerJson(SplFileInfo $composerFile) { @@ -370,9 +406,8 @@ final class AutoloadGenerator { return $composerJson; } - private static function dependencyAutoloaders($composerJson, $required) { + private static function dependencyAutoloaders($composerJson, $composerKey) { $dependencyAutoloaders = []; - $composerKey = $required ? 'require' : 'suggest'; if (isset($composerJson[$composerKey])) { $dependencies = array_keys(array_filter( @@ -384,6 +419,15 @@ final class AutoloadGenerator { )); foreach ($dependencies as $pkg) { + // Use Symfony cache component as PSR cache implementation + // for "require-dev" dependency. + if ( + ('require-dev' == $composerKey) + && ('psr/cache-implementation' == $pkg) + ) { + $pkg = 'symfony/cache'; + } + if ($autoloader = self::pkg2Autoload($pkg)) { $dependencyAutoloaders[] = $autoloader; } @@ -413,7 +457,7 @@ final class AutoloadGenerator { : sprintf("%s.'/%s'", $prefix, $path); } - public function content($composerJson, array $dependencyAutoloadersRequired, array $dependencyAutoloadersOptional) { + public function content($composerJson, array $dependencyAutoloadersRequired, array $dependencyAutoloadersOptional = [], $dev = false) { $pkg = explode('/', $composerJson['name'])[1]; $content = <<filename; } + + public function getDevFilename() { + return $this->devFilename; + } } diff --git a/php-symfony3.spec b/php-symfony3.spec index 8f62142..05ff17c 100644 --- a/php-symfony3.spec +++ b/php-symfony3.spec @@ -120,7 +120,7 @@ Name: php-%{composer_project}3 Version: %{github_version} -Release: 3%{?dist} +Release: 4%{?dist} Summary: Symfony PHP framework (version 3) Group: Development/Libraries @@ -2000,66 +2000,20 @@ for PKG in %{buildroot}%{symfony3_dir}/*/*; do continue fi %endif + if [ "$(basename $PKG)" = "PhpUnit" ]; then continue + elif [ "$(basename $PKG)" = "composer" ]; then + continue elif [ -d $PKG ]; then echo -e "\n>>>>>>>>>>>>>>>>>>>> ${PKG}\n" : Create tests bootstrap cat << BOOTSTRAP | tee bootstrap.php - 3.3.6-4 +- Dynamically generate dev autoloaders +- Add build conditionals to make backporting to remirepo easier + * Fri Aug 18 2017 Shawn Iwinski - 3.3.6-3 - Fix some tests' dev requires (thanks Remi!) -- cgit