Make sure we do not overwrite binaries but only re-create missing ones, refs #5127
parent
88d5b74c74
commit
59596ff012
|
@ -297,10 +297,9 @@ class Installer
|
|||
$this->eventDispatcher->dispatchScript($eventName, $this->devMode);
|
||||
}
|
||||
|
||||
// force binaries re-generation
|
||||
$this->io->writeError('<info>Installing binaries files</info>');
|
||||
// force binaries re-generation in case they are missing
|
||||
foreach ($localRepo->getPackages() as $package) {
|
||||
$this->installationManager->installBinary($package);
|
||||
$this->installationManager->ensureBinariesPresence($package);
|
||||
}
|
||||
|
||||
$vendorDir = $this->config->get('vendor-dir');
|
||||
|
|
|
@ -47,7 +47,7 @@ class BinaryInstaller
|
|||
$this->filesystem = $filesystem ?: new Filesystem();
|
||||
}
|
||||
|
||||
public function installBinaries(PackageInterface $package, $installPath)
|
||||
public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
|
||||
{
|
||||
$binaries = $this->getBinaries($package);
|
||||
if (!$binaries) {
|
||||
|
@ -75,7 +75,9 @@ class BinaryInstaller
|
|||
// is a fresh install of the vendor.
|
||||
Silencer::call('chmod', $link, 0777 & ~umask());
|
||||
}
|
||||
$this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
|
||||
if ($warnOnOverwrite) {
|
||||
$this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,14 @@ use Composer\Package\PackageInterface;
|
|||
/**
|
||||
* Interface for the package installation manager that handle binary installation.
|
||||
*
|
||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
* @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
|
||||
*/
|
||||
public function installBinary(PackageInterface $package);
|
||||
public function ensureBinariesPresence(PackageInterface $package);
|
||||
}
|
|
@ -133,7 +133,7 @@ class InstallationManager
|
|||
*
|
||||
* @param PackageInterface $package Package instance
|
||||
*/
|
||||
public function installBinary(PackageInterface $package)
|
||||
public function ensureBinariesPresence(PackageInterface $package)
|
||||
{
|
||||
try {
|
||||
$installer = $this->getInstaller($package->getType());
|
||||
|
@ -143,8 +143,8 @@ class InstallationManager
|
|||
}
|
||||
|
||||
// if the given installer support installing binaries
|
||||
if ($installer instanceof InstallerBinaryInterface) {
|
||||
$installer->installBinary($package);
|
||||
if ($installer instanceof BinaryPresenceInterface) {
|
||||
$installer->ensureBinariesPresence($package);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ use Composer\Util\Silencer;
|
|||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @author Konstantin Kudryashov <ever.zet@gmail.com>
|
||||
*/
|
||||
class LibraryInstaller implements InstallerInterface, InstallerBinaryInterface
|
||||
class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
|
||||
{
|
||||
protected $composer;
|
||||
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
|
||||
*/
|
||||
public function installBinary(PackageInterface $package)
|
||||
public function ensureBinariesPresence(PackageInterface $package)
|
||||
{
|
||||
$this->binaryInstaller->removeBinaries($package);
|
||||
$this->binaryInstaller->installBinaries($package, $this->getInstallPath($package));
|
||||
$this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,4 +11,3 @@ Updating dependencies (including require-dev)
|
|||
Nothing to install or update
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
|
|
@ -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>
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
||||
--EXPECT--
|
||||
Installing a/a (1.0.0)
|
||||
|
|
|
@ -38,7 +38,6 @@ Loading composer repositories with package information
|
|||
Updating dependencies (including require-dev)
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
||||
--EXPECT--
|
||||
Updating a (1.0.0) to a (1.1.0)
|
||||
|
|
|
@ -40,6 +40,5 @@ Updating dependencies (including require-dev)
|
|||
Nothing to install or update
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
||||
--EXPECT--
|
||||
|
|
|
@ -23,7 +23,6 @@ Loading composer repositories with package information
|
|||
Updating dependencies (including require-dev)
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
||||
--EXPECT--
|
||||
Installing a/a (1.0.0)
|
||||
|
|
|
@ -21,7 +21,6 @@ Loading composer repositories with package information
|
|||
Updating dependencies
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
||||
--EXPECT--
|
||||
Installing a/a (1.0.0)
|
||||
|
|
|
@ -23,7 +23,6 @@ Loading composer repositories with package information
|
|||
Updating dependencies (including require-dev)
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
||||
--EXPECT--
|
||||
Installing c/c (1.0.0)
|
||||
|
|
|
@ -22,7 +22,6 @@ Updating dependencies (including require-dev)
|
|||
a/a suggests installing b/b (an obscure reason)
|
||||
Writing lock file
|
||||
Generating autoload files
|
||||
Installing binaries files
|
||||
|
||||
--EXPECT--
|
||||
Installing a/a (1.0.0)
|
||||
|
|
|
@ -263,10 +263,10 @@ class InstallationManagerTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$installer
|
||||
->expects($this->once())
|
||||
->method('installBinary')
|
||||
->method('ensureBinariesPresence')
|
||||
->with($package);
|
||||
|
||||
$manager->installBinary($package);
|
||||
$manager->ensureBinariesPresence($package);
|
||||
}
|
||||
|
||||
private function createInstallerMock()
|
||||
|
|
|
@ -259,7 +259,7 @@ class LibraryInstallerTest extends TestCase
|
|||
* @depends testInstallerCreationShouldNotCreateVendorDirectory
|
||||
* @depends testInstallerCreationShouldNotCreateBinDirectory
|
||||
*/
|
||||
public function testInstallBinary()
|
||||
public function testEnsureBinariesInstalled()
|
||||
{
|
||||
$binaryInstallerMock = $this->getMockBuilder('Composer\Installer\BinaryInstaller')
|
||||
->disableOriginalConstructor()
|
||||
|
@ -269,16 +269,16 @@ class LibraryInstallerTest extends TestCase
|
|||
$package = $this->createPackageMock();
|
||||
|
||||
$binaryInstallerMock
|
||||
->expects($this->once())
|
||||
->expects($this->never())
|
||||
->method('removeBinaries')
|
||||
->with($package);
|
||||
|
||||
$binaryInstallerMock
|
||||
->expects($this->once())
|
||||
->method('installBinaries')
|
||||
->with($package, $library->getInstallPath($package));
|
||||
->with($package, $library->getInstallPath($package), false);
|
||||
|
||||
$library->installBinary($package);
|
||||
$library->ensureBinariesPresence($package);
|
||||
}
|
||||
|
||||
protected function createPackageMock()
|
||||
|
|
Loading…
Reference in New Issue