diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 5c4beba90..9e212af10 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -25,6 +25,8 @@ use Composer\Repository\PlatformRepository; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Composer\DependencyResolver\Operation\InstallOperation; +use Composer\DependencyResolver\Solver; /** * @author Jordi Boggiano @@ -142,7 +144,10 @@ EOT // TODO this belongs in the solver, but this will do for now to report top-level deps missing at least foreach ($request->getJobs() as $job) { if ('install' === $job['cmd']) { - foreach ($installedRepo->getPackages() as $package) { + foreach ($installedRepo->getPackages() as $package ) { + if ($installedRepo->hasPackage($package) && !$package->isPlatform() && !$installationManager->isPackageInstalled($package)) { + $operations[$job['packageName']] = new InstallOperation($package, Solver::RULE_PACKAGE_NOT_EXIST); + } if (in_array($job['packageName'], $package->getNames())) { continue 2; } diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index 319ac9e98..f9c4828fb 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -72,7 +72,7 @@ class LibraryInstaller implements InstallerInterface */ public function isInstalled(PackageInterface $package) { - return $this->repository->hasPackage($package); + return $this->repository->hasPackage($package) && is_readable($this->getInstallPath($package)); } /** @@ -80,11 +80,18 @@ class LibraryInstaller implements InstallerInterface */ public function install(PackageInterface $package) { - $downloadPath = $this->getInstallPath($package); + //remove the binaries first if its missing on filesystem + if (!is_readable($this->getInstallPath($package)) && $this->repository->hasPackage($package)) { + $this->removeBinaries($package); + } + $downloadPath = $this->getInstallPath($package); $this->downloadManager->download($package, $downloadPath); $this->installBinaries($package); - $this->repository->addPackage(clone $package); + + if(!$this->repository->hasPackage($package)) { + $this->repository->addPackage(clone $package); + } } /** diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index 786c58ae5..d5a0e5230 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -15,6 +15,7 @@ namespace Composer\Package; use Composer\Package\LinkConstraint\LinkConstraintInterface; use Composer\Package\LinkConstraint\VersionConstraint; use Composer\Repository\RepositoryInterface; +use Composer\Repository\PlatformRepository; /** * Base class for packages providing name storage and default match implementation @@ -134,6 +135,16 @@ abstract class BasePackage implements PackageInterface $this->repository = $repository; } + /** + * checks if this package is a platform package + * + * @return boolean + */ + public function isPlatform() + { + return $this->getRepository() instanceof PlatformRepository; + } + /** * Returns package unique name, constructed from name, version and release type. * diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index ed655f983..c5cb9d538 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/tests/Composer/Test/Installer/LibraryInstallerTest.php @@ -85,7 +85,7 @@ class LibraryInstallerTest extends \PHPUnit_Framework_TestCase $package = $this->createPackageMock(); $package - ->expects($this->once()) + ->expects($this->exactly(2)) ->method('getPrettyName') ->will($this->returnValue('some/package'));