Fix PEAR binaries when the bin dir is non standard, fixes #1001
parent
b7d0892e46
commit
269b3481c4
|
@ -241,7 +241,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
$this->binDir = realpath($this->binDir);
|
$this->binDir = realpath($this->binDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateWindowsProxyCode($bin, $link)
|
protected function generateWindowsProxyCode($bin, $link)
|
||||||
{
|
{
|
||||||
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
||||||
if ('.bat' === substr($bin, -4)) {
|
if ('.bat' === substr($bin, -4)) {
|
||||||
|
@ -266,7 +266,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
$caller." \"%BIN_TARGET%\" %*\r\n";
|
$caller." \"%BIN_TARGET%\" %*\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateUnixyProxyCode($bin, $link)
|
protected function generateUnixyProxyCode($bin, $link)
|
||||||
{
|
{
|
||||||
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class PearInstaller extends LibraryInstaller
|
||||||
parent::installCode($package);
|
parent::installCode($package);
|
||||||
parent::initializeBinDir();
|
parent::initializeBinDir();
|
||||||
|
|
||||||
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD') ? true : false;
|
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD');
|
||||||
$php_bin = $this->binDir . ($isWindows ? '/composer-php.bat' : '/composer-php');
|
$php_bin = $this->binDir . ($isWindows ? '/composer-php.bat' : '/composer-php');
|
||||||
|
|
||||||
$installPath = $this->getInstallPath($package);
|
$installPath = $this->getInstallPath($package);
|
||||||
|
@ -100,15 +100,53 @@ class PearInstaller extends LibraryInstaller
|
||||||
chmod($this->binDir.'/composer-php.bat', 0777);
|
chmod($this->binDir.'/composer-php.bat', 0777);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function generateWindowsProxyCode($bin, $link)
|
||||||
|
{
|
||||||
|
$binPath = $this->filesystem->findShortestPath($link, $bin);
|
||||||
|
if ('.bat' === substr($bin, -4)) {
|
||||||
|
$caller = 'call';
|
||||||
|
} else {
|
||||||
|
$handle = fopen($bin, 'r');
|
||||||
|
$line = fgets($handle);
|
||||||
|
fclose($handle);
|
||||||
|
if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
|
||||||
|
$caller = trim($match[1]);
|
||||||
|
} else {
|
||||||
|
$caller = 'php';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($caller === 'php') {
|
||||||
|
return "@echo off\r\n".
|
||||||
|
"pushd .\r\n".
|
||||||
|
"cd %~dp0\r\n".
|
||||||
|
"set PHP_PROXY=%CD%\\composer-php.bat\r\n".
|
||||||
|
"cd ".escapeshellarg(dirname($binPath))."\r\n".
|
||||||
|
"set BIN_TARGET=%CD%\\".basename($binPath)."\r\n".
|
||||||
|
"popd\r\n".
|
||||||
|
"%PHP_PROXY% \"%BIN_TARGET%\" %*\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "@echo off\r\n".
|
||||||
|
"pushd .\r\n".
|
||||||
|
"cd %~dp0\r\n".
|
||||||
|
"cd ".escapeshellarg(dirname($binPath))."\r\n".
|
||||||
|
"set BIN_TARGET=%CD%\\".basename($binPath)."\r\n".
|
||||||
|
"popd\r\n".
|
||||||
|
$caller." \"%BIN_TARGET%\" %*\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
private function generateWindowsPhpProxyCode()
|
private function generateWindowsPhpProxyCode()
|
||||||
{
|
{
|
||||||
|
$binToVendor = $this->filesystem->findShortestPath($this->binDir, $this->vendorDir, true);
|
||||||
|
|
||||||
return
|
return
|
||||||
"@echo off\r\n" .
|
"@echo off\r\n" .
|
||||||
"setlocal enabledelayedexpansion\r\n" .
|
"setlocal enabledelayedexpansion\r\n" .
|
||||||
"set BIN_DIR=%~dp0\r\n" .
|
"set BIN_DIR=%~dp0\r\n" .
|
||||||
"set VENDOR_DIR=%BIN_DIR%..\\\r\n" .
|
"set VENDOR_DIR=%BIN_DIR%\\".$binToVendor."\r\n" .
|
||||||
" set DIRS=.\r\n" .
|
"set DIRS=.\r\n" .
|
||||||
"FOR /D %%V IN (%VENDOR_DIR%*) DO (\r\n" .
|
"FOR /D %%V IN (%VENDOR_DIR%\\*) DO (\r\n" .
|
||||||
" FOR /D %%P IN (%%V\\*) DO (\r\n" .
|
" FOR /D %%P IN (%%V\\*) DO (\r\n" .
|
||||||
" set DIRS=!DIRS!;%%~fP\r\n" .
|
" set DIRS=!DIRS!;%%~fP\r\n" .
|
||||||
" )\r\n" .
|
" )\r\n" .
|
||||||
|
@ -118,12 +156,13 @@ class PearInstaller extends LibraryInstaller
|
||||||
|
|
||||||
private function generateUnixyPhpProxyCode()
|
private function generateUnixyPhpProxyCode()
|
||||||
{
|
{
|
||||||
|
$binToVendor = $this->filesystem->findShortestPath($this->binDir, $this->vendorDir, true);
|
||||||
|
|
||||||
return
|
return
|
||||||
"#!/usr/bin/env sh\n".
|
"#!/usr/bin/env sh\n".
|
||||||
"SRC_DIR=`pwd`\n".
|
"SRC_DIR=`pwd`\n".
|
||||||
"BIN_DIR=`dirname $(readlink -f $0)`\n".
|
"BIN_DIR=`dirname $(readlink -f $0)`\n".
|
||||||
"VENDOR_DIR=`dirname \$BIN_DIR`\n".
|
"VENDOR_DIR=\$BIN_DIR/".escapeshellarg($binToVendor)."\n".
|
||||||
"cd \$BIN_DIR\n".
|
|
||||||
"DIRS=\"\"\n".
|
"DIRS=\"\"\n".
|
||||||
"for vendor in \$VENDOR_DIR/*; do\n".
|
"for vendor in \$VENDOR_DIR/*; do\n".
|
||||||
" if [ -d \"\$vendor\" ]; then\n".
|
" if [ -d \"\$vendor\" ]; then\n".
|
||||||
|
@ -134,7 +173,6 @@ class PearInstaller extends LibraryInstaller
|
||||||
" done\n".
|
" done\n".
|
||||||
" fi\n".
|
" fi\n".
|
||||||
"done\n".
|
"done\n".
|
||||||
"cd \$SRC_DIR\n".
|
"php -d include_path=\".\$DIRS\" $@\n";
|
||||||
"`which php` -d include_path=\".\$DIRS\" $@\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue