From cc769af923440207fcd4614caf6de2e34feb7313 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 2 Oct 2011 19:54:53 +0200 Subject: [PATCH] Reuse normal installer logic for locked installs --- src/Composer/Command/InstallCommand.php | 34 ++++++++++++------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 23dc89780..799d4acb7 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -16,6 +16,7 @@ use Composer\DependencyResolver; use Composer\DependencyResolver\Pool; use Composer\DependencyResolver\Request; use Composer\DependencyResolver\Operation; +use Composer\Package\LinkConstraint\VersionConstraint; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -47,20 +48,6 @@ EOT { $composer = $this->getComposer(); - if ($composer->getLocker()->isLocked()) { - $output->writeln('Found lockfile. Reading'); - - $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 $pool = new Pool; $pool->addRepository($composer->getRepositoryManager()->getLocalRepository()); @@ -70,8 +57,17 @@ EOT // creating requirements request $request = new Request($pool); - foreach ($composer->getPackage()->getRequires() as $link) { - $request->install($link->getTarget(), $link->getConstraint()); + if ($composer->getLocker()->isLocked()) { + $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 @@ -85,8 +81,10 @@ EOT $installationManager->execute($operation); } - $composer->getLocker()->lockPackages($localRepo->getPackages()); - $output->writeln('> Locked'); + if (!$composer->getLocker()->isLocked()) { + $composer->getLocker()->lockPackages($localRepo->getPackages()); + $output->writeln('> Locked'); + } $localRepo->write(); $output->writeln('> Done');