Skip to content

Commit

Permalink
Prevent missing bins from breaking the whole install
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Aug 19, 2012
1 parent de6bb04 commit b96c1dd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/Composer/Installer/LibraryInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ protected function installBinaries(PackageInterface $package)
return;
}
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();
$link = $this->binDir.'/'.basename($bin);
if (file_exists($link)) {
Expand All @@ -184,29 +190,27 @@ protected function installBinaries(PackageInterface $package)
// is a fresh install of the vendor.
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;
}
$bin = $this->getInstallPath($package).'/'.$bin;

if (defined('PHP_WINDOWS_VERSION_BUILD')) {
// add unixy support for cygwin and similar environments
if ('.bat' !== substr($bin, -4)) {
file_put_contents($link, $this->generateUnixyProxyCode($bin, $link));
if ('.bat' !== substr($binPath, -4)) {
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
chmod($link, 0777 & ~umask());
$link .= '.bat';
}
file_put_contents($link, $this->generateWindowsProxyCode($bin, $link));
file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
} else {
$cwd = getcwd();
try {
// under linux symlinks are not always supported for example
// when using it in smbfs mounted folder
$relativeBin = $this->filesystem->findShortestPath($link, $bin);
$relativeBin = $this->filesystem->findShortestPath($link, $binPath);
chdir(dirname($link));
symlink($relativeBin, $link);
} catch (\ErrorException $e) {
file_put_contents($link, $this->generateUnixyProxyCode($bin, $link));
file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
}
chdir($cwd);
}
Expand Down

0 comments on commit b96c1dd

Please sign in to comment.