From bc2d30492afbcfcb88001e13229fc0f9f29022e2 Mon Sep 17 00:00:00 2001 From: Alexey Prilipko Date: Thu, 5 Jul 2012 23:44:25 +1100 Subject: [PATCH 1/4] Add php proxies to replacement vars. --- src/Composer/Installer/PearInstaller.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Composer/Installer/PearInstaller.php b/src/Composer/Installer/PearInstaller.php index 6b0655122..edc901438 100644 --- a/src/Composer/Installer/PearInstaller.php +++ b/src/Composer/Installer/PearInstaller.php @@ -54,20 +54,22 @@ class PearInstaller extends LibraryInstaller parent::installCode($package); $isWindows = defined('PHP_WINDOWS_VERSION_BUILD') ? true : false; + $php_bin = realpath($this->binDir . ($isWindows ? '/composer-php.bat' : '/composer-php')); + $installPath = $this->getInstallPath($package); $vars = array( 'os' => $isWindows ? 'windows' : 'linux', - 'php_bin' => ($isWindows ? getenv('PHPRC') .'php.exe' : trim(`which php`)), - 'pear_php' => $this->getInstallPath($package), - 'bin_dir' => $this->getInstallPath($package) . '/bin', - 'php_dir' => $this->getInstallPath($package), - 'data_dir' => '@DATA_DIR@', + 'php_bin' => $php_bin, + 'pear_php' => $installPath, + 'php_dir' => $installPath, + 'bin_dir' => $installPath . '/bin', + 'data_dir' => $installPath . '/data', 'version' => $package->getPrettyVersion(), ); $packageArchive = $this->getInstallPath($package).'/'.pathinfo($package->getDistUrl(), PATHINFO_BASENAME); $pearExtractor = new PearPackageExtractor($packageArchive); - $pearExtractor->extractTo($this->getInstallPath($package), array('php' => '/', 'script' => '/bin'), $vars); + $pearExtractor->extractTo($this->getInstallPath($package), array('php' => '/', 'script' => '/bin', 'data' => '/data'), $vars); if ($this->io->isVerbose()) { $this->io->write(' Cleaning up'); From 22d41845ae4b6b6a44c828a8dc5e1b3b23b29679 Mon Sep 17 00:00:00 2001 From: Alexey Prilipko Date: Sun, 8 Jul 2012 15:20:35 +1100 Subject: [PATCH 2/4] Exclude dirs from list of binaries --- src/Composer/Installer/InstallationManager.php | 1 - src/Composer/Installer/PearInstaller.php | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Composer/Installer/InstallationManager.php b/src/Composer/Installer/InstallationManager.php index ca8035eda..6ac4fca50 100644 --- a/src/Composer/Installer/InstallationManager.php +++ b/src/Composer/Installer/InstallationManager.php @@ -23,7 +23,6 @@ use Composer\DependencyResolver\Operation\UpdateOperation; use Composer\DependencyResolver\Operation\UninstallOperation; use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation; use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation; -use Composer\Util\Filesystem; /** * Package operation manager. diff --git a/src/Composer/Installer/PearInstaller.php b/src/Composer/Installer/PearInstaller.php index edc901438..8cea866d9 100644 --- a/src/Composer/Installer/PearInstaller.php +++ b/src/Composer/Installer/PearInstaller.php @@ -15,10 +15,8 @@ namespace Composer\Installer; use Composer\IO\IOInterface; use Composer\Composer; use Composer\Downloader\PearPackageExtractor; -use Composer\Downloader\DownloadManager; use Composer\Repository\InstalledRepositoryInterface; use Composer\Package\PackageInterface; -use Composer\Util\Filesystem; /** * Package installation manager. @@ -31,9 +29,9 @@ class PearInstaller extends LibraryInstaller /** * Initializes library installer. * - * @param IOInterface $io io instance - * @param Composer $composer - * @param string $type package type that this installer handles + * @param IOInterface $io io instance + * @param Composer $composer + * @param string $type package type that this installer handles */ public function __construct(IOInterface $io, Composer $composer, $type = 'pear-library') { @@ -52,9 +50,10 @@ class PearInstaller extends LibraryInstaller protected function installCode(PackageInterface $package) { parent::installCode($package); + parent::initializeBinDir(); $isWindows = defined('PHP_WINDOWS_VERSION_BUILD') ? true : false; - $php_bin = realpath($this->binDir . ($isWindows ? '/composer-php.bat' : '/composer-php')); + $php_bin = $this->binDir . ($isWindows ? '/composer-php.bat' : '/composer-php'); $installPath = $this->getInstallPath($package); $vars = array( @@ -82,8 +81,10 @@ class PearInstaller extends LibraryInstaller $binariesPath = $this->getInstallPath($package) . '/bin/'; $binaries = array(); if (file_exists($binariesPath)) { - foreach (new \FilesystemIterator($binariesPath, \FilesystemIterator::KEY_AS_FILENAME) as $fileName => $value) { - $binaries[] = 'bin/'.$fileName; + foreach (new \FilesystemIterator($binariesPath, \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::CURRENT_AS_FILEINFO) as $fileName => $value) { + if (!$value->isDir()) { + $binaries[] = 'bin/'.$fileName; + } } } From 490b2c02959dc5b4a717c30d5dd805d312f08e2b Mon Sep 17 00:00:00 2001 From: Alexey Prilipko Date: Mon, 9 Jul 2012 08:47:27 +1100 Subject: [PATCH 3/4] Add package name prefix for non 'php', 'script' and 'www' roles --- .../Downloader/PearPackageExtractor.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Composer/Downloader/PearPackageExtractor.php b/src/Composer/Downloader/PearPackageExtractor.php index e33cd07a8..d88dee937 100644 --- a/src/Composer/Downloader/PearPackageExtractor.php +++ b/src/Composer/Downloader/PearPackageExtractor.php @@ -25,6 +25,7 @@ use Composer\Util\Filesystem; */ class PearPackageExtractor { + private static $rolesWithoutPackageNamePrefix = array('php', 'script', 'www'); /** @var Filesystem */ private $filesystem; private $file; @@ -141,13 +142,13 @@ class PearPackageExtractor $packageName = (string) $package->name; $packageVersion = (string) $package->release->version; $sourceDir = $packageName . '-' . $packageVersion; - $result = $this->buildSourceList10($children, $roles, $sourceDir); + $result = $this->buildSourceList10($children, $roles, $sourceDir, '', null, $packageName); } elseif ('2.0' == $packageSchemaVersion || '2.1' == $packageSchemaVersion) { $children = $package->contents->children(); $packageName = (string) $package->name; $packageVersion = (string) $package->version->release; $sourceDir = $packageName . '-' . $packageVersion; - $result = $this->buildSourceList20($children, $roles, $sourceDir); + $result = $this->buildSourceList20($children, $roles, $sourceDir, '', null, $packageName); $namespaces = $package->getNamespaces(); $package->registerXPathNamespace('ns', $namespaces['']); @@ -188,7 +189,7 @@ class PearPackageExtractor } } - private function buildSourceList10($children, $targetRoles, $source = '', $target = '', $role = null) + private function buildSourceList10($children, $targetRoles, $source = '', $target = '', $role = null, $packageName) { $result = array(); @@ -199,7 +200,7 @@ class PearPackageExtractor $dirSource = $this->combine($source, (string) $child['name']); $dirTarget = $child['baseinstalldir'] ? : $target; $dirRole = $child['role'] ? : $role; - $dirFiles = $this->buildSourceList10($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole); + $dirFiles = $this->buildSourceList10($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName); $result = array_merge($result, $dirFiles); } elseif ($child->getName() == 'file') { $fileRole = (string) $child['role'] ? : $role; @@ -207,6 +208,9 @@ class PearPackageExtractor $fileName = (string) ($child['name'] ? : $child[0]); // $child[0] means text content $fileSource = $this->combine($source, $fileName); $fileTarget = $this->combine((string) $child['baseinstalldir'] ? : $target, $fileName); + if (!in_array($fileRole, self::$rolesWithoutPackageNamePrefix)) { + $fileTarget = $packageName . '/' . $fileTarget; + } $result[(string) $child['name']] = array('from' => $fileSource, 'to' => $fileTarget, 'role' => $fileRole, 'tasks' => array()); } } @@ -215,7 +219,7 @@ class PearPackageExtractor return $result; } - private function buildSourceList20($children, $targetRoles, $source = '', $target = '', $role = null) + private function buildSourceList20($children, $targetRoles, $source = '', $target = '', $role = null, $packageName) { $result = array(); @@ -226,7 +230,7 @@ class PearPackageExtractor $dirSource = $this->combine($source, $child['name']); $dirTarget = $child['baseinstalldir'] ? : $target; $dirRole = $child['role'] ? : $role; - $dirFiles = $this->buildSourceList20($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole); + $dirFiles = $this->buildSourceList20($child->children(), $targetRoles, $dirSource, $dirTarget, $dirRole, $packageName); $result = array_merge($result, $dirFiles); } elseif ('file' == $child->getName()) { $fileRole = (string) $child['role'] ? : $role; @@ -239,6 +243,9 @@ class PearPackageExtractor $fileTasks[] = array('from' => (string) $taskNode->attributes()->from, 'to' => (string) $taskNode->attributes()->to); } } + if (!in_array($fileRole, self::$rolesWithoutPackageNamePrefix)) { + $fileTarget = $packageName . '/' . $fileTarget; + } $result[(string) $child['name']] = array('from' => $fileSource, 'to' => $fileTarget, 'role' => $fileRole, 'tasks' => $fileTasks); } } From 75d3d57117337c93a0b0ca3f3a1b9c8b54cd4fef Mon Sep 17 00:00:00 2001 From: Alexey Prilipko Date: Mon, 9 Jul 2012 08:47:40 +1100 Subject: [PATCH 4/4] Version parser stability regexp update --- src/Composer/Package/Version/VersionParser.php | 14 +++++++++++--- .../Test/Package/Version/VersionParserTest.php | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 058ad1ee8..2523acffd 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -24,7 +24,7 @@ use Composer\Package\LinkConstraint\VersionConstraint; */ class VersionParser { - private static $modifierRegex = '[.-]?(?:(beta|RC|alpha|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; + private static $modifierRegex = '[._-]?(?:(beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; /** * Returns the stability of a version @@ -45,8 +45,16 @@ class VersionParser return 'dev'; } - if (!empty($match[1]) && ($match[1] === 'beta' || $match[1] === 'alpha' || $match[1] === 'RC')) { - return $match[1]; + if (!empty($match[1])) { + if ('beta' === $match[1] || 'b' === $match[1]) { + return 'beta'; + } + if ('alpha' === $match[1] || 'a' === $match[1]) { + return 'alpha'; + } + if ('RC' === $match[1]) { + return 'RC'; + } } return 'stable'; diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index ec99b3b27..272f37571 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -238,6 +238,9 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase array('stable', '3.1.2-patch'), array('alpha', '3.1.2-alpha5'), array('beta', '3.1.2-beta'), + array('beta', '2.0b1'), + array('alpha', '1.2.0a1'), + array('alpha', '1.2_a1'), ); } }