浏览代码

Merge pull request #634 from igorw/bin-relative-symlink

[Installer] Make bin symlinks relative, closes #620
Jordi Boggiano 13 年之前
父节点
当前提交
41bd845c54
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/Composer/Installer/LibraryInstaller.php

+ 5 - 2
src/Composer/Installer/LibraryInstaller.php

@@ -168,14 +168,17 @@ class LibraryInstaller implements InstallerInterface
                 }
                 }
                 file_put_contents($link, $this->generateWindowsProxyCode($bin, $link));
                 file_put_contents($link, $this->generateWindowsProxyCode($bin, $link));
             } else {
             } else {
+                $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
-                    symlink($bin, $link);
+                    $relativeBin = $this->filesystem->findShortestPath($link, $bin);
+                    chdir(dirname($link));
+                    symlink($relativeBin, $link);
                 } catch (\ErrorException $e) {
                 } catch (\ErrorException $e) {
                     file_put_contents($link, $this->generateUnixyProxyCode($bin, $link));
                     file_put_contents($link, $this->generateUnixyProxyCode($bin, $link));
                 }
                 }
-
+                chdir($cwd);
             }
             }
             chmod($link, 0777 & ~umask());
             chmod($link, 0777 & ~umask());
         }
         }