1
0
Fork 0

Reuse normal installer logic for locked installs

pull/41/merge
Jordi Boggiano 2011-10-02 19:54:53 +02:00
parent 96122aada8
commit cc769af923
1 changed files with 16 additions and 18 deletions

View File

@ -16,6 +16,7 @@ use Composer\DependencyResolver;
use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Pool;
use Composer\DependencyResolver\Request; use Composer\DependencyResolver\Request;
use Composer\DependencyResolver\Operation; use Composer\DependencyResolver\Operation;
use Composer\Package\LinkConstraint\VersionConstraint;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
@ -47,20 +48,6 @@ EOT
{ {
$composer = $this->getComposer(); $composer = $this->getComposer();
if ($composer->getLocker()->isLocked()) {
$output->writeln('<info>Found lockfile. Reading</info>');
$installationManager = $composer->getInstallationManager();
foreach ($composer->getLocker()->getLockedPackages() as $package) {
if (!$installationManager->isPackageInstalled($package)) {
$operation = new Operation\InstallOperation($package, 'lock resolving');
$installationManager->execute($operation);
}
}
return 0;
}
// creating repository pool // creating repository pool
$pool = new Pool; $pool = new Pool;
$pool->addRepository($composer->getRepositoryManager()->getLocalRepository()); $pool->addRepository($composer->getRepositoryManager()->getLocalRepository());
@ -70,8 +57,17 @@ EOT
// creating requirements request // creating requirements request
$request = new Request($pool); $request = new Request($pool);
foreach ($composer->getPackage()->getRequires() as $link) { if ($composer->getLocker()->isLocked()) {
$request->install($link->getTarget(), $link->getConstraint()); $output->writeln('> Found lockfile. Reading.');
foreach ($composer->getLocker()->getLockedPackages() as $package) {
$constraint = new VersionConstraint('=', $package->getVersion());
$request->install($package->getName(), $constraint);
}
} else {
foreach ($composer->getPackage()->getRequires() as $link) {
$request->install($link->getTarget(), $link->getConstraint());
}
} }
// prepare solver // prepare solver
@ -85,8 +81,10 @@ EOT
$installationManager->execute($operation); $installationManager->execute($operation);
} }
$composer->getLocker()->lockPackages($localRepo->getPackages()); if (!$composer->getLocker()->isLocked()) {
$output->writeln('> Locked'); $composer->getLocker()->lockPackages($localRepo->getPackages());
$output->writeln('> Locked');
}
$localRepo->write(); $localRepo->write();
$output->writeln('> Done'); $output->writeln('> Done');