mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 05:14:52 +08:00
Add legacy CentOS distro support (#585)
This commit is contained in:
parent
20dad4cdb3
commit
2ca5ad075b
@ -21,13 +21,16 @@ class SystemUtil
|
|||||||
switch (true) {
|
switch (true) {
|
||||||
case file_exists('/etc/centos-release'):
|
case file_exists('/etc/centos-release'):
|
||||||
$lines = file('/etc/centos-release');
|
$lines = file('/etc/centos-release');
|
||||||
|
$centos = true;
|
||||||
goto rh;
|
goto rh;
|
||||||
case file_exists('/etc/redhat-release'):
|
case file_exists('/etc/redhat-release'):
|
||||||
$lines = file('/etc/redhat-release');
|
$lines = file('/etc/redhat-release');
|
||||||
|
$centos = false;
|
||||||
rh:
|
rh:
|
||||||
foreach ($lines as $line) {
|
foreach ($lines as $line) {
|
||||||
if (preg_match('/release\s+(\d*(\.\d+)*)/', $line, $matches)) {
|
if (preg_match('/release\s+(\d*(\.\d+)*)/', $line, $matches)) {
|
||||||
$ret['dist'] = 'redhat';
|
/* @phpstan-ignore-next-line */
|
||||||
|
$ret['dist'] = $centos ? 'centos' : 'redhat';
|
||||||
$ret['ver'] = $matches[1];
|
$ret['ver'] = $matches[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,6 +174,8 @@ class SystemUtil
|
|||||||
'debian', 'ubuntu', 'Deepin',
|
'debian', 'ubuntu', 'Deepin',
|
||||||
// rhel-like
|
// rhel-like
|
||||||
'redhat',
|
'redhat',
|
||||||
|
// centos
|
||||||
|
'centos',
|
||||||
// alpine
|
// alpine
|
||||||
'alpine',
|
'alpine',
|
||||||
// arch
|
// arch
|
||||||
|
|||||||
@ -57,7 +57,7 @@ class LinuxToolCheckList
|
|||||||
|
|
||||||
$required = match ($distro['dist']) {
|
$required = match ($distro['dist']) {
|
||||||
'alpine' => self::TOOLS_ALPINE,
|
'alpine' => self::TOOLS_ALPINE,
|
||||||
'redhat' => self::TOOLS_RHEL,
|
'redhat', 'centos' => self::TOOLS_RHEL,
|
||||||
'arch' => self::TOOLS_ARCH,
|
'arch' => self::TOOLS_ARCH,
|
||||||
default => self::TOOLS_DEBIAN,
|
default => self::TOOLS_DEBIAN,
|
||||||
};
|
};
|
||||||
@ -72,6 +72,7 @@ class LinuxToolCheckList
|
|||||||
'ubuntu',
|
'ubuntu',
|
||||||
'alpine',
|
'alpine',
|
||||||
'redhat',
|
'redhat',
|
||||||
|
'centos',
|
||||||
'Deepin',
|
'Deepin',
|
||||||
'arch',
|
'arch',
|
||||||
'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
|
'debian' => CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]),
|
||||||
@ -121,13 +122,14 @@ class LinuxToolCheckList
|
|||||||
'ubuntu', 'debian', 'Deepin' => 'apt-get install -y',
|
'ubuntu', 'debian', 'Deepin' => 'apt-get install -y',
|
||||||
'alpine' => 'apk add',
|
'alpine' => 'apk add',
|
||||||
'redhat' => 'dnf install -y',
|
'redhat' => 'dnf install -y',
|
||||||
|
'centos' => 'yum install -y',
|
||||||
'arch' => 'pacman -S --noconfirm',
|
'arch' => 'pacman -S --noconfirm',
|
||||||
default => throw new RuntimeException('Current linux distro does not have an auto-install script for musl packages yet.'),
|
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 (($user = exec('whoami')) !== 'root') {
|
||||||
$prefix = 'sudo ';
|
$prefix = 'sudo ';
|
||||||
logger()->warning('Current user is not root, using sudo for running command');
|
logger()->warning('Current user (' . $user . ') is not root, using sudo for running command');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$is_debian = in_array($distro['dist'], ['debian', 'ubuntu', 'Deepin']);
|
$is_debian = in_array($distro['dist'], ['debian', 'ubuntu', 'Deepin']);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user