commit
d87b8d3493
|
@ -25,6 +25,7 @@ use Composer\Util\Filesystem;
|
||||||
*/
|
*/
|
||||||
class PearPackageExtractor
|
class PearPackageExtractor
|
||||||
{
|
{
|
||||||
|
private static $rolesWithoutPackageNamePrefix = array('php', 'script', 'www');
|
||||||
/** @var Filesystem */
|
/** @var Filesystem */
|
||||||
private $filesystem;
|
private $filesystem;
|
||||||
private $file;
|
private $file;
|
||||||
|
@ -141,13 +142,13 @@ class PearPackageExtractor
|
||||||
$packageName = (string) $package->name;
|
$packageName = (string) $package->name;
|
||||||
$packageVersion = (string) $package->release->version;
|
$packageVersion = (string) $package->release->version;
|
||||||
$sourceDir = $packageName . '-' . $packageVersion;
|
$sourceDir = $packageName . '-' . $packageVersion;
|
||||||
$result = $this->buildSourceList10($children, $roles, $sourceDir);
|
$result = $this->buildSourceList10($children, $roles, $sourceDir, '', null, $packageName);
|
||||||
} elseif ('2.0' == $packageSchemaVersion || '2.1' == $packageSchemaVersion) {
|
} elseif ('2.0' == $packageSchemaVersion || '2.1' == $packageSchemaVersion) {
|
||||||
$children = $package->contents->children();
|
$children = $package->contents->children();
|
||||||
$packageName = (string) $package->name;
|
$packageName = (string) $package->name;
|
||||||
$packageVersion = (string) $package->version->release;
|
$packageVersion = (string) $package->version->release;
|
||||||
$sourceDir = $packageName . '-' . $packageVersion;
|
$sourceDir = $packageName . '-' . $packageVersion;
|
||||||
$result = $this->buildSourceList20($children, $roles, $sourceDir);
|
$result = $this->buildSourceList20($children, $roles, $sourceDir, '', null, $packageName);
|
||||||
|
|
||||||
$namespaces = $package->getNamespaces();
|
$namespaces = $package->getNamespaces();
|
||||||
$package->registerXPathNamespace('ns', $namespaces['']);
|
$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();
|
$result = array();
|
||||||
|
|
||||||
|
@ -199,7 +200,7 @@ class PearPackageExtractor
|
||||||
$dirSource = $this->combine($source, (string) $child['name']);
|
$dirSource = $this->combine($source, (string) $child['name']);
|
||||||
$dirTarget = $child['baseinstalldir'] ? : $target;
|
$dirTarget = $child['baseinstalldir'] ? : $target;
|
||||||
$dirRole = $child['role'] ? : $role;
|
$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);
|
$result = array_merge($result, $dirFiles);
|
||||||
} elseif ($child->getName() == 'file') {
|
} elseif ($child->getName() == 'file') {
|
||||||
$fileRole = (string) $child['role'] ? : $role;
|
$fileRole = (string) $child['role'] ? : $role;
|
||||||
|
@ -207,6 +208,9 @@ class PearPackageExtractor
|
||||||
$fileName = (string) ($child['name'] ? : $child[0]); // $child[0] means text content
|
$fileName = (string) ($child['name'] ? : $child[0]); // $child[0] means text content
|
||||||
$fileSource = $this->combine($source, $fileName);
|
$fileSource = $this->combine($source, $fileName);
|
||||||
$fileTarget = $this->combine((string) $child['baseinstalldir'] ? : $target, $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());
|
$result[(string) $child['name']] = array('from' => $fileSource, 'to' => $fileTarget, 'role' => $fileRole, 'tasks' => array());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +219,7 @@ class PearPackageExtractor
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildSourceList20($children, $targetRoles, $source = '', $target = '', $role = null)
|
private function buildSourceList20($children, $targetRoles, $source = '', $target = '', $role = null, $packageName)
|
||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
|
@ -226,7 +230,7 @@ class PearPackageExtractor
|
||||||
$dirSource = $this->combine($source, $child['name']);
|
$dirSource = $this->combine($source, $child['name']);
|
||||||
$dirTarget = $child['baseinstalldir'] ? : $target;
|
$dirTarget = $child['baseinstalldir'] ? : $target;
|
||||||
$dirRole = $child['role'] ? : $role;
|
$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);
|
$result = array_merge($result, $dirFiles);
|
||||||
} elseif ('file' == $child->getName()) {
|
} elseif ('file' == $child->getName()) {
|
||||||
$fileRole = (string) $child['role'] ? : $role;
|
$fileRole = (string) $child['role'] ? : $role;
|
||||||
|
@ -239,6 +243,9 @@ class PearPackageExtractor
|
||||||
$fileTasks[] = array('from' => (string) $taskNode->attributes()->from, 'to' => (string) $taskNode->attributes()->to);
|
$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);
|
$result[(string) $child['name']] = array('from' => $fileSource, 'to' => $fileTarget, 'role' => $fileRole, 'tasks' => $fileTasks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ use Composer\DependencyResolver\Operation\UpdateOperation;
|
||||||
use Composer\DependencyResolver\Operation\UninstallOperation;
|
use Composer\DependencyResolver\Operation\UninstallOperation;
|
||||||
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
|
use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
|
||||||
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
|
||||||
use Composer\Util\Filesystem;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package operation manager.
|
* Package operation manager.
|
||||||
|
|
|
@ -15,10 +15,8 @@ namespace Composer\Installer;
|
||||||
use Composer\IO\IOInterface;
|
use Composer\IO\IOInterface;
|
||||||
use Composer\Composer;
|
use Composer\Composer;
|
||||||
use Composer\Downloader\PearPackageExtractor;
|
use Composer\Downloader\PearPackageExtractor;
|
||||||
use Composer\Downloader\DownloadManager;
|
|
||||||
use Composer\Repository\InstalledRepositoryInterface;
|
use Composer\Repository\InstalledRepositoryInterface;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Util\Filesystem;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Package installation manager.
|
* Package installation manager.
|
||||||
|
@ -31,9 +29,9 @@ class PearInstaller extends LibraryInstaller
|
||||||
/**
|
/**
|
||||||
* Initializes library installer.
|
* Initializes library installer.
|
||||||
*
|
*
|
||||||
* @param IOInterface $io io instance
|
* @param IOInterface $io io instance
|
||||||
* @param Composer $composer
|
* @param Composer $composer
|
||||||
* @param string $type package type that this installer handles
|
* @param string $type package type that this installer handles
|
||||||
*/
|
*/
|
||||||
public function __construct(IOInterface $io, Composer $composer, $type = 'pear-library')
|
public function __construct(IOInterface $io, Composer $composer, $type = 'pear-library')
|
||||||
{
|
{
|
||||||
|
@ -52,22 +50,25 @@ class PearInstaller extends LibraryInstaller
|
||||||
protected function installCode(PackageInterface $package)
|
protected function installCode(PackageInterface $package)
|
||||||
{
|
{
|
||||||
parent::installCode($package);
|
parent::installCode($package);
|
||||||
|
parent::initializeBinDir();
|
||||||
|
|
||||||
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD') ? true : false;
|
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD') ? true : false;
|
||||||
|
$php_bin = $this->binDir . ($isWindows ? '/composer-php.bat' : '/composer-php');
|
||||||
|
|
||||||
|
$installPath = $this->getInstallPath($package);
|
||||||
$vars = array(
|
$vars = array(
|
||||||
'os' => $isWindows ? 'windows' : 'linux',
|
'os' => $isWindows ? 'windows' : 'linux',
|
||||||
'php_bin' => ($isWindows ? getenv('PHPRC') .'php.exe' : trim(`which php`)),
|
'php_bin' => $php_bin,
|
||||||
'pear_php' => $this->getInstallPath($package),
|
'pear_php' => $installPath,
|
||||||
'bin_dir' => $this->getInstallPath($package) . '/bin',
|
'php_dir' => $installPath,
|
||||||
'php_dir' => $this->getInstallPath($package),
|
'bin_dir' => $installPath . '/bin',
|
||||||
'data_dir' => '@DATA_DIR@',
|
'data_dir' => $installPath . '/data',
|
||||||
'version' => $package->getPrettyVersion(),
|
'version' => $package->getPrettyVersion(),
|
||||||
);
|
);
|
||||||
|
|
||||||
$packageArchive = $this->getInstallPath($package).'/'.pathinfo($package->getDistUrl(), PATHINFO_BASENAME);
|
$packageArchive = $this->getInstallPath($package).'/'.pathinfo($package->getDistUrl(), PATHINFO_BASENAME);
|
||||||
$pearExtractor = new PearPackageExtractor($packageArchive);
|
$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()) {
|
if ($this->io->isVerbose()) {
|
||||||
$this->io->write(' Cleaning up');
|
$this->io->write(' Cleaning up');
|
||||||
|
@ -80,8 +81,10 @@ class PearInstaller extends LibraryInstaller
|
||||||
$binariesPath = $this->getInstallPath($package) . '/bin/';
|
$binariesPath = $this->getInstallPath($package) . '/bin/';
|
||||||
$binaries = array();
|
$binaries = array();
|
||||||
if (file_exists($binariesPath)) {
|
if (file_exists($binariesPath)) {
|
||||||
foreach (new \FilesystemIterator($binariesPath, \FilesystemIterator::KEY_AS_FILENAME) as $fileName => $value) {
|
foreach (new \FilesystemIterator($binariesPath, \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::CURRENT_AS_FILEINFO) as $fileName => $value) {
|
||||||
$binaries[] = 'bin/'.$fileName;
|
if (!$value->isDir()) {
|
||||||
|
$binaries[] = 'bin/'.$fileName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use Composer\Package\LinkConstraint\VersionConstraint;
|
||||||
*/
|
*/
|
||||||
class VersionParser
|
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
|
* Returns the stability of a version
|
||||||
|
@ -45,8 +45,16 @@ class VersionParser
|
||||||
return 'dev';
|
return 'dev';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($match[1]) && ($match[1] === 'beta' || $match[1] === 'alpha' || $match[1] === 'RC')) {
|
if (!empty($match[1])) {
|
||||||
return $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';
|
return 'stable';
|
||||||
|
|
|
@ -238,6 +238,9 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
||||||
array('stable', '3.1.2-patch'),
|
array('stable', '3.1.2-patch'),
|
||||||
array('alpha', '3.1.2-alpha5'),
|
array('alpha', '3.1.2-alpha5'),
|
||||||
array('beta', '3.1.2-beta'),
|
array('beta', '3.1.2-beta'),
|
||||||
|
array('beta', '2.0b1'),
|
||||||
|
array('alpha', '1.2.0a1'),
|
||||||
|
array('alpha', '1.2_a1'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue