mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-06 08:15:39 +08:00
Enhance Linux distribution detection and package installation commands (forward-port #1109)
This commit is contained in:
@@ -16,8 +16,11 @@ class OSCheck
|
||||
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'Windows'])) {
|
||||
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
|
||||
}
|
||||
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . LinuxUtil::getOSRelease()['dist']) : '';
|
||||
$known_distro = PHP_OS_FAMILY !== 'Linux' || in_array(LinuxUtil::getOSRelease()['dist'], LinuxUtil::getSupportedDistros());
|
||||
$release = PHP_OS_FAMILY === 'Linux' ? LinuxUtil::getOSRelease() : null;
|
||||
$distro = $release !== null ? (' ' . $release['dist']) : '';
|
||||
$known_distro = $release === null
|
||||
|| in_array($release['dist'], LinuxUtil::getSupportedDistros())
|
||||
|| count(array_intersect(explode(' ', $release['family']), LinuxUtil::getSupportedDistros())) > 0;
|
||||
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported' . ($known_distro ? '' : ' (but not tested on this distro)'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user