Enhance Linux distribution detection and package installation commands (forward-port #1109)

This commit is contained in:
crazywhalecc
2026-04-29 15:53:52 +08:00
parent 9ed2b18d06
commit c454a1dc8e
3 changed files with 22 additions and 6 deletions

View File

@@ -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)'));
}
}