1
0
Fork 0

BinaryInstaller: install full binaries on WSL when bin-compat=auto (#9855)

pull/9873/head
Markus Staab 2021-05-02 16:50:42 +02:00 committed by GitHub
parent 4842f213a1
commit bfea0f7d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -82,7 +82,7 @@ class BinaryInstaller
} }
if ($this->binCompat === "auto") { if ($this->binCompat === "auto") {
if (Platform::isWindows()) { if (Platform::isWindows() || Platform::isWindowsSubsystemForLinux()) {
$this->installFullBinaries($binPath, $link, $bin, $package); $this->installFullBinaries($binPath, $link, $bin, $package);
} else { } else {
$this->installSymlinkBinaries($binPath, $link); $this->installSymlinkBinaries($binPath, $link);

View File

@ -21,6 +21,8 @@ class Platform
{ {
/** @var ?bool */ /** @var ?bool */
private static $isVirtualBoxGuest = null; private static $isVirtualBoxGuest = null;
/** @var ?bool */
private static $isWindowsSubsystemForLinux = null;
/** /**
* Parses tildes and environment variables in paths. * Parses tildes and environment variables in paths.
@ -67,6 +69,27 @@ class Platform
throw new \RuntimeException('Could not determine user directory'); throw new \RuntimeException('Could not determine user directory');
} }
/**
* @return bool Whether the host machine is running on the Windows Subsystem for Linux (WSL)
*/
public static function isWindowsSubsystemForLinux()
{
if (null === self::$isWindowsSubsystemForLinux) {
self::$isWindowsSubsystemForLinux = false;
// while WSL will be hosted within windows, WSL itself cannot be windows based itself.
if (self::isWindows()) {
return self::$isWindowsSubsystemForLinux = false;
}
if (is_readable('/proc/version') && false !== stripos(file_get_contents('/proc/version'), 'microsoft')) {
return self::$isWindowsSubsystemForLinux = true;
}
}
return self::$isWindowsSubsystemForLinux;
}
/** /**
* @return bool Whether the host machine is running a Windows OS * @return bool Whether the host machine is running a Windows OS
*/ */