1
0
Fork 0

Make sure we do not overwrite binaries but only re-create missing ones, refs #5127

pull/5490/head
Jordi Boggiano 2016-07-02 16:35:09 +01:00
parent 88d5b74c74
commit 59596ff012
15 changed files with 22 additions and 31 deletions

View File

@ -297,10 +297,9 @@ class Installer
$this->eventDispatcher->dispatchScript($eventName, $this->devMode); $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
} }
// force binaries re-generation // force binaries re-generation in case they are missing
$this->io->writeError('<info>Installing binaries files</info>');
foreach ($localRepo->getPackages() as $package) { foreach ($localRepo->getPackages() as $package) {
$this->installationManager->installBinary($package); $this->installationManager->ensureBinariesPresence($package);
} }
$vendorDir = $this->config->get('vendor-dir'); $vendorDir = $this->config->get('vendor-dir');

View File

@ -47,7 +47,7 @@ class BinaryInstaller
$this->filesystem = $filesystem ?: new Filesystem(); $this->filesystem = $filesystem ?: new Filesystem();
} }
public function installBinaries(PackageInterface $package, $installPath) public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
{ {
$binaries = $this->getBinaries($package); $binaries = $this->getBinaries($package);
if (!$binaries) { if (!$binaries) {
@ -75,7 +75,9 @@ class BinaryInstaller
// is a fresh install of the vendor. // is a fresh install of the vendor.
Silencer::call('chmod', $link, 0777 & ~umask()); Silencer::call('chmod', $link, 0777 & ~umask());
} }
if ($warnOnOverwrite) {
$this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file'); $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
}
continue; continue;
} }

View File

@ -17,15 +17,14 @@ use Composer\Package\PackageInterface;
/** /**
* Interface for the package installation manager that handle binary installation. * Interface for the package installation manager that handle binary installation.
* *
* @author Konstantin Kudryashov <ever.zet@gmail.com>
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
interface InstallerBinaryInterface interface BinaryPresenceInterface
{ {
/** /**
* Installs binary file for a specific package. * Make sure binaries are installed for a given package.
* *
* @param PackageInterface $package package instance * @param PackageInterface $package package instance
*/ */
public function installBinary(PackageInterface $package); public function ensureBinariesPresence(PackageInterface $package);
} }

View File

@ -133,7 +133,7 @@ class InstallationManager
* *
* @param PackageInterface $package Package instance * @param PackageInterface $package Package instance
*/ */
public function installBinary(PackageInterface $package) public function ensureBinariesPresence(PackageInterface $package)
{ {
try { try {
$installer = $this->getInstaller($package->getType()); $installer = $this->getInstaller($package->getType());
@ -143,8 +143,8 @@ class InstallationManager
} }
// if the given installer support installing binaries // if the given installer support installing binaries
if ($installer instanceof InstallerBinaryInterface) { if ($installer instanceof BinaryPresenceInterface) {
$installer->installBinary($package); $installer->ensureBinariesPresence($package);
} }
} }

View File

@ -25,7 +25,7 @@ use Composer\Util\Silencer;
* @author Jordi Boggiano <j.boggiano@seld.be> * @author Jordi Boggiano <j.boggiano@seld.be>
* @author Konstantin Kudryashov <ever.zet@gmail.com> * @author Konstantin Kudryashov <ever.zet@gmail.com>
*/ */
class LibraryInstaller implements InstallerInterface, InstallerBinaryInterface class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
{ {
protected $composer; protected $composer;
protected $vendorDir; protected $vendorDir;
@ -150,14 +150,13 @@ class LibraryInstaller implements InstallerInterface, InstallerBinaryInterface
} }
/** /**
* Re-install binary by removing previous one * Make sure binaries are installed for a given package.
* *
* @param PackageInterface $package Package instance * @param PackageInterface $package Package instance
*/ */
public function installBinary(PackageInterface $package) public function ensureBinariesPresence(PackageInterface $package)
{ {
$this->binaryInstaller->removeBinaries($package); $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
$this->binaryInstaller->installBinaries($package, $this->getInstallPath($package));
} }
/** /**

View File

@ -11,4 +11,3 @@ Updating dependencies (including require-dev)
Nothing to install or update Nothing to install or update
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files

View File

@ -30,7 +30,6 @@ Updating dependencies (including require-dev)
<warning>Package c/c is abandoned, you should avoid using it. Use b/b instead.</warning> <warning>Package c/c is abandoned, you should avoid using it. Use b/b instead.</warning>
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files
--EXPECT-- --EXPECT--
Installing a/a (1.0.0) Installing a/a (1.0.0)

View File

@ -38,7 +38,6 @@ Loading composer repositories with package information
Updating dependencies (including require-dev) Updating dependencies (including require-dev)
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files
--EXPECT-- --EXPECT--
Updating a (1.0.0) to a (1.1.0) Updating a (1.0.0) to a (1.1.0)

View File

@ -40,6 +40,5 @@ Updating dependencies (including require-dev)
Nothing to install or update Nothing to install or update
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files
--EXPECT-- --EXPECT--

View File

@ -23,7 +23,6 @@ Loading composer repositories with package information
Updating dependencies (including require-dev) Updating dependencies (including require-dev)
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files
--EXPECT-- --EXPECT--
Installing a/a (1.0.0) Installing a/a (1.0.0)

View File

@ -21,7 +21,6 @@ Loading composer repositories with package information
Updating dependencies Updating dependencies
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files
--EXPECT-- --EXPECT--
Installing a/a (1.0.0) Installing a/a (1.0.0)

View File

@ -23,7 +23,6 @@ Loading composer repositories with package information
Updating dependencies (including require-dev) Updating dependencies (including require-dev)
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files
--EXPECT-- --EXPECT--
Installing c/c (1.0.0) Installing c/c (1.0.0)

View File

@ -22,7 +22,6 @@ Updating dependencies (including require-dev)
a/a suggests installing b/b (an obscure reason) a/a suggests installing b/b (an obscure reason)
Writing lock file Writing lock file
Generating autoload files Generating autoload files
Installing binaries files
--EXPECT-- --EXPECT--
Installing a/a (1.0.0) Installing a/a (1.0.0)

View File

@ -263,10 +263,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
$installer $installer
->expects($this->once()) ->expects($this->once())
->method('installBinary') ->method('ensureBinariesPresence')
->with($package); ->with($package);
$manager->installBinary($package); $manager->ensureBinariesPresence($package);
} }
private function createInstallerMock() private function createInstallerMock()

View File

@ -259,7 +259,7 @@ class LibraryInstallerTest extends TestCase
* @depends testInstallerCreationShouldNotCreateVendorDirectory * @depends testInstallerCreationShouldNotCreateVendorDirectory
* @depends testInstallerCreationShouldNotCreateBinDirectory * @depends testInstallerCreationShouldNotCreateBinDirectory
*/ */
public function testInstallBinary() public function testEnsureBinariesInstalled()
{ {
$binaryInstallerMock = $this->getMockBuilder('Composer\Installer\BinaryInstaller') $binaryInstallerMock = $this->getMockBuilder('Composer\Installer\BinaryInstaller')
->disableOriginalConstructor() ->disableOriginalConstructor()
@ -269,16 +269,16 @@ class LibraryInstallerTest extends TestCase
$package = $this->createPackageMock(); $package = $this->createPackageMock();
$binaryInstallerMock $binaryInstallerMock
->expects($this->once()) ->expects($this->never())
->method('removeBinaries') ->method('removeBinaries')
->with($package); ->with($package);
$binaryInstallerMock $binaryInstallerMock
->expects($this->once()) ->expects($this->once())
->method('installBinaries') ->method('installBinaries')
->with($package, $library->getInstallPath($package)); ->with($package, $library->getInstallPath($package), false);
$library->installBinary($package); $library->ensureBinariesPresence($package);
} }
protected function createPackageMock() protected function createPackageMock()