adjust doctor for os and linux musl check

This commit is contained in:
crazywhalecc 2023-10-30 00:35:58 +08:00
parent 90b2e5568c
commit 2768dc0c40
No known key found for this signature in database
GPG Key ID: 1F4BDD59391F2680
2 changed files with 6 additions and 4 deletions

View File

@ -26,7 +26,7 @@ class LinuxMuslCheck
} }
$musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m'));
if (file_exists($musl_wrapper_lib)) { if (file_exists($musl_wrapper_lib) && file_exists('/usr/local/musl/bin/musl-gcc')) {
return CheckResult::ok(); return CheckResult::ok();
} }
return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper'); return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper');
@ -71,7 +71,7 @@ class LinuxMuslCheck
Downloader::downloadSource($musl_version_name, $musl_source); Downloader::downloadSource($musl_version_name, $musl_source);
FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz"); FileSystem::extractSource($musl_version_name, DOWNLOAD_PATH . "/{$musl_version_name}.tar.gz");
logger()->info('Installing musl wrapper'); logger()->info('Installing musl wrapper');
shell(true)->cd(SOURCE_PATH . "/{$musl_version_name}") shell()->cd(SOURCE_PATH . "/{$musl_version_name}")
->exec('./configure') ->exec('./configure')
->exec('make -j') ->exec('make -j')
->exec("{$prefix}make install"); ->exec("{$prefix}make install");
@ -106,7 +106,7 @@ class LinuxMuslCheck
Downloader::downloadSource('musl-compile', $musl_compile_source); Downloader::downloadSource('musl-compile', $musl_compile_source);
logger()->info('Extracting musl-cross'); logger()->info('Extracting musl-cross');
FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz"); FileSystem::extractSource('musl-compile', DOWNLOAD_PATH . "/{$arch}-musl-toolchain.tgz");
shell(true)->exec($prefix . 'cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl'); shell()->exec($prefix . 'cp -rf ' . SOURCE_PATH . '/musl-compile/* /usr/local/musl');
return true; return true;
} catch (RuntimeException) { } catch (RuntimeException) {
return false; return false;

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace SPC\doctor\item; namespace SPC\doctor\item;
use SPC\builder\linux\SystemUtil;
use SPC\builder\traits\UnixSystemUtilTrait; use SPC\builder\traits\UnixSystemUtilTrait;
use SPC\doctor\AsCheckItem; use SPC\doctor\AsCheckItem;
use SPC\doctor\CheckResult; use SPC\doctor\CheckResult;
@ -18,6 +19,7 @@ class OSCheckList
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) { if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) {
return CheckResult::fail('Current OS is not supported'); return CheckResult::fail('Current OS is not supported');
} }
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . ', supported'); $distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported');
} }
} }