diff --git a/bin/composer b/bin/composer index cfdb05174..94c5c19b2 100755 --- a/bin/composer +++ b/bin/composer @@ -12,8 +12,11 @@ use Composer\Console\Application as ComposerApplication; // initialize repository manager $rm = new Repository\RepositoryManager(); -$rm->setLocalRepository(new Repository\FilesystemRepository('.composer/installed.json')); -$rm->setRepository('Platform', new Repository\PlatformRepository()); +$localRepository = new Repository\WrapperRepository(array( + new Repository\ArrayRepository('.composer/installed.json'), + new Repository\PlatformRepository(), +)); +$rm->setLocalRepository($localRepository); $rm->setRepository('Packagist', new Repository\ComposerRepository('http://packagist.org')); // initialize download manager @@ -24,7 +27,7 @@ $dm->setDownloader('git', new Downloader\GitDownloader()); // initialize installation manager $im = new Installer\InstallationManager(); -$im->setInstaller('vendor', new Installer\LibraryInstaller('vendor', $dm, $rm->getLocalRepository())); +$im->setInstaller('library', new Installer\LibraryInstaller('vendor', $dm, $rm->getLocalRepository())); // load package $loader = new Package\Loader\JsonLoader(); diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index d93ef434d..3e63318df 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -63,13 +63,14 @@ EOT // creating repository pool $pool = new Pool; + $pool->addRepository($composer->getRepositoryManager()->getLocalRepository()); foreach ($composer->getRepositoryManager()->getRepositories() as $repository) { $pool->addRepository($repository); } // creating requirements request $request = new Request($pool); - foreach ($this->getPackage()->getRequires() as $link) { + foreach ($composer->getPackage()->getRequires() as $link) { $request->install($link->getTarget(), $link->getConstraint()); } diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index ab2cf3346..c21918262 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -50,6 +50,7 @@ class Solver protected $watches = array(); protected $removeWatches = array(); protected $decisionMap; + protected $installedPackageMap; protected $packageToUpdateRule = array(); protected $packageToFeatureRule = array(); @@ -252,7 +253,7 @@ class Solver $this->addedMap[$package->getId()] = true; $dontFix = 0; - if ($this->installed === $package->getRepository() && !isset($this->fixMap[$package->getId()])) { + if (isset($this->installedPackageMap[$package->getId()]) && !isset($this->fixMap[$package->getId()])) { $dontFix = 1; } @@ -271,7 +272,7 @@ class Solver if ($dontFix) { $foundInstalled = false; foreach ($possibleRequires as $require) { - if ($this->installed === $require->getRepository()) { + if (isset($this->installedPackageMap[$require->getId()])) { $foundInstalled = true; break; } @@ -294,7 +295,7 @@ class Solver $possibleConflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint()); foreach ($possibleConflicts as $conflict) { - if ($dontFix && $this->installed === $conflict->getRepository()) { + if ($dontFix && isset($this->installedPackageMap[$conflict->getId()])) { continue; } @@ -309,7 +310,7 @@ class Solver /** @TODO: if ($this->noInstalledObsoletes) */ if (true) { $noObsoletes = isset($this->noObsoletes[$package->getId()]); - $isInstalled = ($this->installed === $package->getRepository()); + $isInstalled = (isset($this->installedPackageMap[$package->getId()])); foreach ($package->getReplaces() as $link) { $obsoleteProviders = $this->pool->whatProvides($link->getTarget(), $link->getConstraint()); @@ -758,7 +759,7 @@ class Solver switch ($job['cmd']) { case 'install': foreach ($job['packages'] as $package) { - if ($this->installed === $package->getRepository()) { + if (isset($this->installedPackageMap[$package->getId()])) { $disableQueue[] = array('type' => 'update', 'package' => $package); } @@ -871,7 +872,7 @@ class Solver case 'remove': foreach ($job['packages'] as $package) { - if ($this->installed === $package->getRepository()) { + if (isset($this->installedPackageMap[$package->getId()])) { $disableQueue[] = array('type' => 'update', 'package' => $package); } } @@ -933,6 +934,10 @@ class Solver { $this->jobs = $request->getJobs(); $installedPackages = $this->installed->getPackages(); + $this->installedPackageMap = array(); + foreach ($installedPackages as $package) { + $this->installedPackageMap[$package->getId()] = $package; + } $this->decisionMap = new \SplFixedArray($this->pool->getMaxId() + 1); @@ -954,12 +959,12 @@ class Solver foreach ($job['packages'] as $package) { switch ($job['cmd']) { case 'fix': - if ($this->installed === $package->getRepository()) { + if (isset($this->installedPackageMap[$package->getId()])) { $this->fixMap[$package->getId()] = true; } break; case 'update': - if ($this->installed === $package->getRepository()) { + if (isset($this->installedPackageMap[$package->getId()])) { $this->updateMap[$package->getId()] = true; } break; @@ -1039,7 +1044,7 @@ class Solver break; case 'lock': foreach ($job['packages'] as $package) { - if ($this->installed === $package->getRepository()) { + if (isset($this->installedPackageMap[$package->getId()])) { $rule = $this->createInstallRule($package, self::RULE_JOB_LOCK); } else { $rule = $this->createRemoveRule($package, self::RULE_JOB_LOCK); @@ -1083,7 +1088,7 @@ class Solver $package = $literal->getPackage(); // !wanted & installed - if (!$literal->isWanted() && $this->installed === $package->getRepository()) { + if (!$literal->isWanted() && isset($this->installedPackageMap[$package->getId()])) { $updateRule = $this->packageToUpdateRule[$package->getId()]; foreach ($updateRule->getLiterals() as $updateLiteral) { @@ -1098,7 +1103,7 @@ class Solver $package = $literal->getPackage(); // wanted & installed || !wanted & !installed - if ($literal->isWanted() == ($this->installed === $package->getRepository())) { + if ($literal->isWanted() == (isset($this->installedPackageMap[$package->getId()]))) { continue; } diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 2f5ffad74..83a6e2051 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -110,8 +110,5 @@ class ArrayLoader if (!isset($config['version'])) { throw new \UnexpectedValueException('version is required for package'); } - if (!isset($config['type'])) { - throw new \UnexpectedValueException('type is required for package'); - } } }