mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-13 20:05:35 +08:00
add rhel and almalinux support
This commit is contained in:
@@ -24,7 +24,7 @@ class LinuxMuslCheck
|
|||||||
// non-exist, need to recognize distro
|
// non-exist, need to recognize distro
|
||||||
$distro = SystemUtil::getOSRelease();
|
$distro = SystemUtil::getOSRelease();
|
||||||
return match ($distro['dist']) {
|
return match ($distro['dist']) {
|
||||||
'ubuntu', 'alpine', 'debian' => CheckResult::fail('musl-libc is not installed on your system', 'fix-musl', [$distro]),
|
'ubuntu', 'alpine', 'debian', 'rhel', 'almalinux' => CheckResult::fail('musl-libc is not installed on your system', 'fix-musl', [$distro]),
|
||||||
default => CheckResult::fail('musl-libc is not installed on your system'),
|
default => CheckResult::fail('musl-libc is not installed on your system'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,9 @@ class LinuxMuslCheck
|
|||||||
$install_cmd = match ($distro['dist']) {
|
$install_cmd = match ($distro['dist']) {
|
||||||
'ubuntu', 'debian' => 'apt-get install musl musl-tools -y',
|
'ubuntu', 'debian' => 'apt-get install musl musl-tools -y',
|
||||||
'alpine' => 'apk add musl musl-utils musl-dev',
|
'alpine' => 'apk add musl musl-utils musl-dev',
|
||||||
default => throw new RuntimeException('Current linux distro is not supported for auto-install musl packages'),
|
'rhel' => 'dnf install tar wget git zip bison flex bzip2 cmake patch && wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && rm musl-1.2.4.tar.gz && cd musl-1.2.4 && ./configure && make -j && make install && cd ..',
|
||||||
|
'almalinux' => 'dnf install bison flex bzip2 cmake patch && wget https://musl.libc.org/releases/musl-1.2.4.tar.gz && tar -zxvf musl-1.2.4.tar.gz && rm musl-1.2.4.tar.gz && cd musl-1.2.4 && ./configure && make -j && make install && export PATH="/usr/local/musl/bin:$PATH" cd ..',
|
||||||
|
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
|
||||||
};
|
};
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
if (get_current_user() !== 'root') {
|
if (get_current_user() !== 'root') {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class LinuxToolCheckList
|
|||||||
use UnixSystemUtilTrait;
|
use UnixSystemUtilTrait;
|
||||||
|
|
||||||
public const TOOLS_ALPINE = [
|
public const TOOLS_ALPINE = [
|
||||||
'make', 'bison', 'flex',
|
'perl', 'make', 'bison', 'flex',
|
||||||
'git', 'autoconf', 'automake',
|
'git', 'autoconf', 'automake',
|
||||||
'tar', 'unzip', 'gzip',
|
'tar', 'unzip', 'gzip',
|
||||||
'bzip2', 'cmake', 'gcc',
|
'bzip2', 'cmake', 'gcc',
|
||||||
@@ -24,7 +24,7 @@ class LinuxToolCheckList
|
|||||||
];
|
];
|
||||||
|
|
||||||
public const TOOLS_DEBIAN = [
|
public const TOOLS_DEBIAN = [
|
||||||
'make', 'bison', 'flex',
|
'perl', 'make', 'bison', 'flex',
|
||||||
'git', 'autoconf', 'automake',
|
'git', 'autoconf', 'automake',
|
||||||
'tar', 'unzip', 'gzip',
|
'tar', 'unzip', 'gzip',
|
||||||
'bzip2', 'cmake', 'patch',
|
'bzip2', 'cmake', 'patch',
|
||||||
@@ -49,7 +49,11 @@ class LinuxToolCheckList
|
|||||||
}
|
}
|
||||||
if (!empty($missing)) {
|
if (!empty($missing)) {
|
||||||
return match ($distro['dist']) {
|
return match ($distro['dist']) {
|
||||||
'ubuntu', 'alpine', 'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
|
'ubuntu',
|
||||||
|
'alpine',
|
||||||
|
'rhel',
|
||||||
|
'almalinux',
|
||||||
|
'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
|
||||||
default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'),
|
default => CheckResult::fail(implode(', ', $missing) . ' not installed on your system'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -80,7 +84,9 @@ class LinuxToolCheckList
|
|||||||
$install_cmd = match ($distro['dist']) {
|
$install_cmd = match ($distro['dist']) {
|
||||||
'ubuntu', 'debian' => 'apt-get install -y',
|
'ubuntu', 'debian' => 'apt-get install -y',
|
||||||
'alpine' => 'apk add',
|
'alpine' => 'apk add',
|
||||||
default => throw new RuntimeException('Current linux distro is not supported for auto-install musl packages'),
|
'rhel' => 'dnf install -y',
|
||||||
|
'almalinux' => 'dnf install -y',
|
||||||
|
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
|
||||||
};
|
};
|
||||||
$prefix = '';
|
$prefix = '';
|
||||||
if (get_current_user() !== 'root') {
|
if (get_current_user() !== 'root') {
|
||||||
@@ -88,7 +94,9 @@ class LinuxToolCheckList
|
|||||||
logger()->warning('Current user is not root, using sudo for running command');
|
logger()->warning('Current user is not root, using sudo for running command');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', str_replace('xz', 'xz-utils', $missing)));
|
$is_rhel = in_array($distro['dist'], ['rhel', 'almalinux']);
|
||||||
|
$to_install = $is_rhel ? $missing : str_replace('xz', 'xz-utils', $missing);
|
||||||
|
shell(true)->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install));
|
||||||
} catch (RuntimeException) {
|
} catch (RuntimeException) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user