Enhance musl-wrapper and musl-toolchain installation process (#988)

This commit is contained in:
Jerry Ma
2025-12-06 16:50:36 +08:00
committed by GitHub
parent 106b55d4e7
commit 9ad7147155
6 changed files with 31 additions and 10 deletions

View File

@@ -13,13 +13,14 @@ class LinuxUtil extends UnixUtil
* Get current linux distro name and version.
*
* @noinspection PhpMissingBreakStatementInspection
* @return array{dist: string, ver: string} Linux distro info (unknown if not found)
* @return array{dist: string, ver: string, family: string} Linux distro info (unknown if not found)
*/
public static function getOSRelease(): array
{
$ret = [
'dist' => 'unknown',
'ver' => 'unknown',
'family' => 'unknown',
];
switch (true) {
case file_exists('/etc/centos-release'):
@@ -44,6 +45,9 @@ class LinuxUtil extends UnixUtil
if (preg_match('/^ID=(.*)$/', $line, $matches)) {
$ret['dist'] = $matches[1];
}
if (preg_match('/^ID_LIKE=(.*)$/', $line, $matches)) {
$ret['family'] = $matches[1];
}
if (preg_match('/^VERSION_ID=(.*)$/', $line, $matches)) {
$ret['ver'] = $matches[1];
}
@@ -103,6 +107,16 @@ class LinuxUtil extends UnixUtil
];
}
/**
* Check if current linux distro is debian-based.
*/
public static function isDebianDist(): bool
{
$dist = static::getOSRelease()['dist'];
$family = explode(' ', static::getOSRelease()['family']);
return in_array($dist, ['debian', 'ubuntu', 'Deepin', 'neon']) || in_array('debian', $family);
}
/**
* Get libc version string from ldd.
*/