From 55697ce801d1b245410ee68d75731ae9a3eff025 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Thu, 16 Jul 2026 14:59:36 +0800 Subject: [PATCH] Remove LinuxMuslCheck --- src/StaticPHP/Doctor/Item/LinuxMuslCheck.php | 123 ------------------- 1 file changed, 123 deletions(-) delete mode 100644 src/StaticPHP/Doctor/Item/LinuxMuslCheck.php diff --git a/src/StaticPHP/Doctor/Item/LinuxMuslCheck.php b/src/StaticPHP/Doctor/Item/LinuxMuslCheck.php deleted file mode 100644 index 2d871f0c..00000000 --- a/src/StaticPHP/Doctor/Item/LinuxMuslCheck.php +++ /dev/null @@ -1,123 +0,0 @@ -isStatic() - ) - ); - } - - /** @noinspection PhpUnused */ - #[CheckItem('if musl-wrapper is installed', limit_os: 'Linux', level: 800)] - public function checkMusl(): ?CheckResult - { - $musl_wrapper_lib = sprintf('/lib/ld-musl-%s.so.1', php_uname('m')); - if (file_exists($musl_wrapper_lib) && (file_exists('/usr/local/musl/lib/libc.a') || getenv('SPC_TOOLCHAIN') === ZigToolchain::class)) { - return null; - } - return CheckResult::fail('musl-wrapper is not installed on your system', 'fix-musl-wrapper'); - } - - #[CheckItem('if musl-cross-make is installed', limit_os: 'Linux', level: 799)] - public function checkMuslCrossMake(): ?CheckResult - { - if (getenv('SPC_TOOLCHAIN') === ZigToolchain::class && !LinuxUtil::isMuslDist()) { - return null; - } - $arch = arch2gnu(php_uname('m')); - $cross_compile_lib = "/usr/local/musl/{$arch}-linux-musl/lib/libc.a"; - $cross_compile_gcc = "/usr/local/musl/bin/{$arch}-linux-musl-gcc"; - if (file_exists($cross_compile_lib) && file_exists($cross_compile_gcc)) { - return CheckResult::ok(); - } - return CheckResult::fail('musl-cross-make is not installed on your system', 'fix-musl-cross-make'); - } - - #[FixItem('fix-musl-wrapper')] - public function fixMusl(): bool - { - $downloader = new ArtifactDownloader(interactive: false); - $downloader->add('musl-wrapper')->download(); - $extractor = new ArtifactExtractor(ApplicationContext::get(ArtifactCache::class)); - $extractor->extract('musl-wrapper'); - - // Apply CVE-2025-26519 patch and install musl wrapper - SourcePatcher::patchFile('musl-1.2.5_CVE-2025-26519_0001.patch', SOURCE_PATH . '/musl-wrapper'); - SourcePatcher::patchFile('musl-1.2.5_CVE-2025-26519_0002.patch', SOURCE_PATH . '/musl-wrapper'); - - $prefix = ''; - if (get_current_user() !== 'root') { - $prefix = 'sudo '; - logger()->warning('Current user is not root, using sudo for running command'); - } - $sysEnv = ['CC' => 'gcc', 'CXX' => 'g++', 'AR' => 'ar', 'LD' => 'ld', 'RANLIB' => 'ranlib']; - $envFlags = ''; - foreach ($sysEnv as $k => $v) { - $envFlags .= "{$k}={$v} "; - } - $envFlags = rtrim($envFlags); - $shell = shell()->cd(SOURCE_PATH . '/musl-wrapper') - ->setEnv($sysEnv) - ->exec('./configure --disable-gcc-wrapper') - ->exec('make -j'); - if ($prefix !== '') { - f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && {$envFlags} {$prefix}make install"); - } else { - $shell->exec("{$prefix}make install"); - } - return true; - } - - #[FixItem('fix-musl-cross-make')] - public function fixMuslCrossMake(): bool - { - // sudo - $prefix = ''; - if (get_current_user() !== 'root') { - $prefix = 'sudo '; - logger()->warning('Current user is not root, using sudo for running command'); - } - Shell::passthruCallback(function () { - InteractiveTerm::advance(); - }); - $downloader = new ArtifactDownloader(interactive: false); - $extractor = new ArtifactExtractor(ApplicationContext::get(ArtifactCache::class)); - $downloader->add('musl-toolchain')->download(); - $extractor->extract('musl-toolchain'); - $pkg_root = PKG_ROOT_PATH . '/musl-toolchain'; - f_passthru("{$prefix}cp -rf {$pkg_root}/* /usr/local/musl"); - FileSystem::removeDir($pkg_root); - return true; - } -}