1
0
Fork 0

Supporting bin_compat option

pull/3704/head
Kocsis Máté 2015-02-03 00:37:11 +01:00
parent f1a2f5b1d0
commit 6a776c5edf
1 changed files with 49 additions and 26 deletions

View File

@ -34,6 +34,7 @@ class LibraryInstaller implements InstallerInterface
protected $io;
protected $type;
protected $filesystem;
protected $binCompat;
/**
* Initializes library installer.
@ -53,6 +54,7 @@ class LibraryInstaller implements InstallerInterface
$this->filesystem = $filesystem ?: new Filesystem();
$this->vendorDir = rtrim($composer->getConfig()->get('vendor-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');
continue;
}
if ($this->binCompat === "auto") {
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
if ('.bat' !== substr($binPath, -4)) {
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
$this->installUnixyProxyBinaries($binPath, $link);
@chmod($link, 0777 & ~umask());
$link .= '.bat';
if (file_exists($link)) {
@ -232,7 +250,10 @@ class LibraryInstaller implements InstallerInterface
if (!file_exists($link)) {
file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
}
} else {
}
protected function installSymlinkBinaries($binPath, $link)
{
$cwd = getcwd();
try {
// under linux symlinks are not always supported for example
@ -243,12 +264,14 @@ class LibraryInstaller implements InstallerInterface
throw new \ErrorException();
}
} catch (\ErrorException $e) {
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
$this->installUnixyProxyBinaries($binPath, $link);
}
chdir($cwd);
}
@chmod($link, 0777 & ~umask());
}
protected function installUnixyProxyBinaries($binPath, $link)
{
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
}
protected function removeBinaries(PackageInterface $package)