1
0
Fork 0

Prevent missing bins from breaking the whole install

pull/1016/head
Jordi Boggiano 2012-08-19 23:58:40 +02:00
parent de6bb0409b
commit b96c1dd5fa
1 changed files with 12 additions and 8 deletions

View File

@ -175,6 +175,12 @@ class LibraryInstaller implements InstallerInterface
return; return;
} }
foreach ($binaries as $bin) { foreach ($binaries as $bin) {
$binPath = $this->getInstallPath($package).'/'.$bin;
if (!file_exists($binPath)) {
$this->io->write(' <warning>Skipped installation of '.$bin.' for package '.$package->getName().': file not found in package</warning>');
continue;
}
$this->initializeBinDir(); $this->initializeBinDir();
$link = $this->binDir.'/'.basename($bin); $link = $this->binDir.'/'.basename($bin);
if (file_exists($link)) { if (file_exists($link)) {
@ -184,29 +190,27 @@ class LibraryInstaller implements InstallerInterface
// is a fresh install of the vendor. // is a fresh install of the vendor.
chmod($link, 0777 & ~umask()); chmod($link, 0777 & ~umask());
} }
$this->io->write('Skipped installation of '.$bin.' for package '.$package->getName().', name conflicts with an existing file'); $this->io->write(' Skipped installation of '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
continue; continue;
} }
$bin = $this->getInstallPath($package).'/'.$bin;
if (defined('PHP_WINDOWS_VERSION_BUILD')) { if (defined('PHP_WINDOWS_VERSION_BUILD')) {
// add unixy support for cygwin and similar environments // add unixy support for cygwin and similar environments
if ('.bat' !== substr($bin, -4)) { if ('.bat' !== substr($binPath, -4)) {
file_put_contents($link, $this->generateUnixyProxyCode($bin, $link)); file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
chmod($link, 0777 & ~umask()); chmod($link, 0777 & ~umask());
$link .= '.bat'; $link .= '.bat';
} }
file_put_contents($link, $this->generateWindowsProxyCode($bin, $link)); file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
} else { } else {
$cwd = getcwd(); $cwd = getcwd();
try { try {
// under linux symlinks are not always supported for example // under linux symlinks are not always supported for example
// when using it in smbfs mounted folder // when using it in smbfs mounted folder
$relativeBin = $this->filesystem->findShortestPath($link, $bin); $relativeBin = $this->filesystem->findShortestPath($link, $binPath);
chdir(dirname($link)); chdir(dirname($link));
symlink($relativeBin, $link); symlink($relativeBin, $link);
} catch (\ErrorException $e) { } catch (\ErrorException $e) {
file_put_contents($link, $this->generateUnixyProxyCode($bin, $link)); file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
} }
chdir($cwd); chdir($cwd);
} }