From b96c1dd5fa3fd1df17a60cc208326a8d710e0c09 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 19 Aug 2012 23:58:40 +0200 Subject: [PATCH] Prevent missing bins from breaking the whole install --- src/Composer/Installer/LibraryInstaller.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Composer/Installer/LibraryInstaller.php b/src/Composer/Installer/LibraryInstaller.php index e4e4cd9d7..137b38464 100644 --- a/src/Composer/Installer/LibraryInstaller.php +++ b/src/Composer/Installer/LibraryInstaller.php @@ -175,6 +175,12 @@ class LibraryInstaller implements InstallerInterface return; } foreach ($binaries as $bin) { + $binPath = $this->getInstallPath($package).'/'.$bin; + if (!file_exists($binPath)) { + $this->io->write(' Skipped installation of '.$bin.' for package '.$package->getName().': file not found in package'); + continue; + } + $this->initializeBinDir(); $link = $this->binDir.'/'.basename($bin); if (file_exists($link)) { @@ -184,29 +190,27 @@ class LibraryInstaller implements InstallerInterface // 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); }