Simplify bin-compat by removing the nosymlink option, refs #3704
parent
c9b51a5751
commit
615638c7c3
|
@ -1,6 +1,6 @@
|
||||||
# Config
|
# Config
|
||||||
|
|
||||||
This chapter will describe the `config` section of the `composer.json`
|
This chapter will describe the `config` section of the `composer.json`
|
||||||
[schema](04-schema.md).
|
[schema](04-schema.md).
|
||||||
|
|
||||||
## process-timeout
|
## process-timeout
|
||||||
|
@ -105,11 +105,11 @@ first until the cache fits.
|
||||||
## bin-compat
|
## bin-compat
|
||||||
|
|
||||||
Defaults to `auto`. Determines the compatibility of the binaries to be installed.
|
Defaults to `auto`. Determines the compatibility of the binaries to be installed.
|
||||||
If it is `auto` then Composer tries to automatically guess which compatibility mode
|
If it is `auto` then Composer only installs .bat proxy files when on Windows. If
|
||||||
to use. If it is `nosymlink` then the binaries will be compatible with Unix-based
|
set to `full` then both .bat files for Windows and scripts for Unix-based
|
||||||
operating systems (useful for cases when symlinks are not available).
|
operating systems will be installed for each binary. This is mainly useful if you
|
||||||
If its value is `full` then both .bat files for Windows and scripts for Unix-based
|
run Composer inside a linux VM but still want the .bat proxies available for use
|
||||||
operating systems will be installed for each binary.
|
in the Windows host OS.
|
||||||
|
|
||||||
## prepend-autoloader
|
## prepend-autoloader
|
||||||
|
|
||||||
|
|
|
@ -187,8 +187,8 @@
|
||||||
"description": "The cache max size for the files cache, defaults to \"300MiB\"."
|
"description": "The cache max size for the files cache, defaults to \"300MiB\"."
|
||||||
},
|
},
|
||||||
"bin-compat": {
|
"bin-compat": {
|
||||||
"enum": ["auto", "nosymlink", "full"],
|
"enum": ["auto", "full"],
|
||||||
"description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"nosymlink\" (compatible with Unix-based systems) or \"full\" (compatible with both Windows and Unix-based systems)."
|
"description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)."
|
||||||
},
|
},
|
||||||
"discard-changes": {
|
"discard-changes": {
|
||||||
"type": ["string", "boolean"],
|
"type": ["string", "boolean"],
|
||||||
|
|
|
@ -308,7 +308,7 @@ EOT
|
||||||
function ($val) { return $val; },
|
function ($val) { return $val; },
|
||||||
),
|
),
|
||||||
'bin-compat' => array(
|
'bin-compat' => array(
|
||||||
function ($val) { return in_array($val, array('auto', 'nosymlink', 'full')); },
|
function ($val) { return in_array($val, array('auto', 'full')); },
|
||||||
function ($val) { return $val; }
|
function ($val) { return $val; }
|
||||||
),
|
),
|
||||||
'discard-changes' => array(
|
'discard-changes' => array(
|
||||||
|
|
|
@ -222,9 +222,9 @@ class Config
|
||||||
case 'bin-compat':
|
case 'bin-compat':
|
||||||
$value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
|
$value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
|
||||||
|
|
||||||
if (!in_array($value, array('auto', 'nosymlink', 'full'))) {
|
if (!in_array($value, array('auto', 'full'))) {
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
"Invalid value for 'bin-compat': {$value}. Expected auto, nosymlink, full"
|
"Invalid value for 'bin-compat': {$value}. Expected auto, full"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,8 +229,6 @@ class LibraryInstaller implements InstallerInterface
|
||||||
} else {
|
} else {
|
||||||
$this->installSymlinkBinaries($binPath, $link);
|
$this->installSymlinkBinaries($binPath, $link);
|
||||||
}
|
}
|
||||||
} elseif ($this->binCompat === "nosymlink") {
|
|
||||||
$this->installUnixyProxyBinaries($binPath, $link);
|
|
||||||
} elseif ($this->binCompat === "full") {
|
} elseif ($this->binCompat === "full") {
|
||||||
$this->installFullBinaries($binPath, $link, $bin, $package);
|
$this->installFullBinaries($binPath, $link, $bin, $package);
|
||||||
}
|
}
|
||||||
|
@ -256,10 +254,7 @@ class LibraryInstaller implements InstallerInterface
|
||||||
|
|
||||||
protected function installSymlinkBinaries($binPath, $link)
|
protected function installSymlinkBinaries($binPath, $link)
|
||||||
{
|
{
|
||||||
try {
|
if (!$this->filesystem->relativeSymlink($binPath, $link)) {
|
||||||
$symlink = new Symlink($this->filesystem);
|
|
||||||
$symlink->symlinkBin($binPath, $link);
|
|
||||||
} catch (\ErrorException $e) {
|
|
||||||
$this->installUnixyProxyBinaries($binPath, $link);
|
$this->installUnixyProxyBinaries($binPath, $link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,6 +505,26 @@ class Filesystem
|
||||||
return unlink($path);
|
return unlink($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a relative symlink from $link to $target
|
||||||
|
*
|
||||||
|
* @param string $target The path of the binary file to be symlinked
|
||||||
|
* @param string $link The path where the symlink should be created
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function relativeSymlink($target, $link)
|
||||||
|
{
|
||||||
|
$cwd = getcwd();
|
||||||
|
|
||||||
|
$relativePath = $this->filesystem->findShortestPath($link, $target);
|
||||||
|
chdir(dirname($link));
|
||||||
|
$result = @symlink($relativePath, $link);
|
||||||
|
|
||||||
|
chdir($cwd);
|
||||||
|
|
||||||
|
return (bool) $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true if that directory is a symlink.
|
* return true if that directory is a symlink.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Composer.
|
|
||||||
*
|
|
||||||
* (c) Nils Adermann <naderman@naderman.de>
|
|
||||||
* Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Composer\Util;
|
|
||||||
|
|
||||||
use Composer\Config;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Kocsis Máté <kocsismate@woohoolabs.com>
|
|
||||||
*/
|
|
||||||
class Symlink
|
|
||||||
{
|
|
||||||
protected $filesystem;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the symlinking utility.
|
|
||||||
*
|
|
||||||
* @param Filesystem $filesystem
|
|
||||||
*/
|
|
||||||
public function __construct(Filesystem $filesystem = null)
|
|
||||||
{
|
|
||||||
$this->filesystem = $filesystem ?: new Filesystem();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a symlink for a binary file at a given path.
|
|
||||||
*
|
|
||||||
* @param string $binPath The path of the binary file to be symlinked
|
|
||||||
* @param string $link The path where the symlink should be created
|
|
||||||
* @throws \ErrorException
|
|
||||||
*/
|
|
||||||
public function symlinkBin($binPath, $link)
|
|
||||||
{
|
|
||||||
$cwd = getcwd();
|
|
||||||
|
|
||||||
$relativeBin = $this->filesystem->findShortestPath($link, $binPath);
|
|
||||||
chdir(dirname($link));
|
|
||||||
$result = @symlink($relativeBin, $link);
|
|
||||||
|
|
||||||
chdir($cwd);
|
|
||||||
if ($result === false) {
|
|
||||||
throw new \ErrorException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue