1
0
Fork 0

Force dev packages to be installed from source

pull/329/head
Jordi Boggiano 2012-02-18 23:21:45 +01:00
parent f73c08043f
commit 3fe87b1e35
6 changed files with 31 additions and 12 deletions

View File

@ -125,14 +125,14 @@ class DownloadManager
$sourceType = $package->getSourceType();
$distType = $package->getDistType();
if (!($preferSource && $sourceType) && $distType) {
if (!$package->isDev() && !($preferSource && $sourceType) && $distType) {
$package->setInstallationSource('dist');
} elseif ($sourceType) {
$package->setInstallationSource('source');
} elseif ($package->isDev()) {
throw new \InvalidArgumentException('Dev package '.$package.' must have a source specified');
} else {
throw new \InvalidArgumentException(
'Package '.$package.' should have source or dist specified'
);
throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
}
$fs = new Filesystem();

View File

@ -109,8 +109,10 @@ class LibraryInstaller implements InstallerInterface
$this->downloadManager->update($initial, $target, $downloadPath);
$this->installBinaries($target);
$this->repository->removePackage($initial);
if (!$this->repository->hasPackage($target)) {
$this->repository->addPackage(clone $target);
}
}
/**
* {@inheritDoc}

View File

@ -41,6 +41,7 @@ class MemoryPackage extends BasePackage
protected $extra = array();
protected $binaries = array();
protected $scripts = array();
protected $dev;
protected $requires = array();
protected $conflicts = array();
@ -63,6 +64,16 @@ class MemoryPackage extends BasePackage
$this->version = $version;
$this->prettyVersion = $prettyVersion;
$this->dev = 'dev-' === substr($version, 0, 4) || '-dev' === substr($version, -4);
}
/**
* {@inheritDoc}
*/
public function isDev()
{
return $this->dev;
}
/**

View File

@ -68,6 +68,13 @@ interface PackageInterface
*/
function matches($name, LinkConstraintInterface $constraint);
/**
* Returns whether the package is a development virtual package or a concrete one
*
* @return Boolean
*/
function isDev();
/**
* Returns the package type, e.g. library
*

View File

@ -67,9 +67,9 @@ class InstallerInstallerTest extends \PHPUnit_Framework_TestCase
->method('getPackages')
->will($this->returnValue(array($this->packages[0])));
$this->repository
->expects($this->once())
->expects($this->exactly(2))
->method('hasPackage')
->will($this->returnValue(true));
->will($this->onConsecutiveCalls(true, false));
$installer = new InstallerInstallerMock(__DIR__.'/Fixtures/', __DIR__.'/Fixtures/bin', $this->dm, $this->repository, $this->io, $this->im);
$test = $this;
@ -90,9 +90,9 @@ class InstallerInstallerTest extends \PHPUnit_Framework_TestCase
->method('getPackages')
->will($this->returnValue(array($this->packages[1])));
$this->repository
->expects($this->once())
->expects($this->exactly(2))
->method('hasPackage')
->will($this->returnValue(true));
->will($this->onConsecutiveCalls(true, false));
$installer = new InstallerInstallerMock(__DIR__.'/Fixtures/', __DIR__.'/Fixtures/bin', $this->dm, $this->repository, $this->io, $this->im);
$test = $this;

View File

@ -128,10 +128,9 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue('package1'));
$this->repository
->expects($this->exactly(2))
->expects($this->exactly(3))
->method('hasPackage')
->with($initial)
->will($this->onConsecutiveCalls(true, false));
->will($this->onConsecutiveCalls(true, false, false));
$this->dm
->expects($this->once())