Supporting bin_compat option
parent
f1a2f5b1d0
commit
6a776c5edf
|
@ -34,6 +34,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
protected $io;
|
protected $io;
|
||||||
protected $type;
|
protected $type;
|
||||||
protected $filesystem;
|
protected $filesystem;
|
||||||
|
protected $binCompat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes library installer.
|
* Initializes library installer.
|
||||||
|
@ -53,6 +54,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
$this->filesystem = $filesystem ?: new Filesystem();
|
$this->filesystem = $filesystem ?: new Filesystem();
|
||||||
$this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
|
$this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
|
||||||
$this->binDir = rtrim($composer->getConfig()->get('bin-dir'), '/');
|
$this->binDir = rtrim($composer->getConfig()->get('bin-dir'), '/');
|
||||||
|
$this->binCompat = trim(getenv("COMPOSER_BIN_COMPAT")) ?: 'auto';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,10 +221,26 @@ class LibraryInstaller implements InstallerInterface
|
||||||
$this->io->write(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
|
$this->io->write(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ($this->binCompat === "auto") {
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||||
|
$this->installFullBinaries($binPath, $link, $bin, $package);
|
||||||
|
} else {
|
||||||
|
$this->installSymlinkBinaries($binPath, $link);
|
||||||
|
}
|
||||||
|
} elseif($this->binCompat === "nosymlink") {
|
||||||
|
$this->installUnixyProxyBinaries($binPath, $link);
|
||||||
|
} elseif($this->binCompat === "full") {
|
||||||
|
$this->installFullBinaries($binPath, $link, $bin, $package);
|
||||||
|
}
|
||||||
|
@chmod($link, 0777 & ~umask());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
|
||||||
|
{
|
||||||
// add unixy support for cygwin and similar environments
|
// add unixy support for cygwin and similar environments
|
||||||
if ('.bat' !== substr($binPath, -4)) {
|
if ('.bat' !== substr($binPath, -4)) {
|
||||||
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
|
$this->installUnixyProxyBinaries($binPath, $link);
|
||||||
@chmod($link, 0777 & ~umask());
|
@chmod($link, 0777 & ~umask());
|
||||||
$link .= '.bat';
|
$link .= '.bat';
|
||||||
if (file_exists($link)) {
|
if (file_exists($link)) {
|
||||||
|
@ -232,7 +250,10 @@ class LibraryInstaller implements InstallerInterface
|
||||||
if (!file_exists($link)) {
|
if (!file_exists($link)) {
|
||||||
file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
|
file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
protected function installSymlinkBinaries($binPath, $link)
|
||||||
|
{
|
||||||
$cwd = getcwd();
|
$cwd = getcwd();
|
||||||
try {
|
try {
|
||||||
// under linux symlinks are not always supported for example
|
// under linux symlinks are not always supported for example
|
||||||
|
@ -243,12 +264,14 @@ class LibraryInstaller implements InstallerInterface
|
||||||
throw new \ErrorException();
|
throw new \ErrorException();
|
||||||
}
|
}
|
||||||
} catch (\ErrorException $e) {
|
} catch (\ErrorException $e) {
|
||||||
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
|
$this->installUnixyProxyBinaries($binPath, $link);
|
||||||
}
|
}
|
||||||
chdir($cwd);
|
chdir($cwd);
|
||||||
}
|
}
|
||||||
@chmod($link, 0777 & ~umask());
|
|
||||||
}
|
protected function installUnixyProxyBinaries($binPath, $link)
|
||||||
|
{
|
||||||
|
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function removeBinaries(PackageInterface $package)
|
protected function removeBinaries(PackageInterface $package)
|
||||||
|
|
Loading…
Reference in New Issue