mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
Refactor Linux and macOS tool checks for improved error handling and command execution (#1025)
This commit is contained in:
parent
041b08f10f
commit
82bf317911
2
config/artifact/musl-wrapper.yml
Normal file
2
config/artifact/musl-wrapper.yml
Normal file
@ -0,0 +1,2 @@
|
||||
musl-wrapper:
|
||||
source: 'https://musl.libc.org/releases/musl-1.2.5.tar.gz'
|
||||
@ -73,10 +73,14 @@ class LinuxMuslCheck
|
||||
$prefix = 'sudo ';
|
||||
logger()->warning('Current user is not root, using sudo for running command');
|
||||
}
|
||||
shell()->cd(SOURCE_PATH . '/musl-wrapper')
|
||||
$shell = shell()->cd(SOURCE_PATH . '/musl-wrapper')
|
||||
->exec('CC=gcc CXX=g++ AR=ar LD=ld ./configure --disable-gcc-wrapper')
|
||||
->exec('CC=gcc CXX=g++ AR=ar LD=ld make -j')
|
||||
->exec("CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
|
||||
->exec('CC=gcc CXX=g++ AR=ar LD=ld make -j');
|
||||
if ($prefix !== '') {
|
||||
f_passthru('cd ' . SOURCE_PATH . "/musl-wrapper && CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
|
||||
} else {
|
||||
$shell->exec("CC=gcc CXX=g++ AR=ar LD=ld {$prefix}make install");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -97,7 +101,7 @@ class LinuxMuslCheck
|
||||
$downloader->add('musl-toolchain')->download(false);
|
||||
$extractor->extract('musl-toolchain');
|
||||
$pkg_root = PKG_ROOT_PATH . '/musl-toolchain';
|
||||
shell()->exec("{$prefix}cp -rf {$pkg_root}/* /usr/local/musl");
|
||||
f_passthru("{$prefix}cp -rf {$pkg_root}/* /usr/local/musl");
|
||||
FileSystem::removeDir($pkg_root);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@ class LinuxToolCheck
|
||||
}
|
||||
}
|
||||
if (!empty($missing)) {
|
||||
return CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', [$distro, $missing]);
|
||||
return CheckResult::fail(implode(', ', $missing) . ' not installed on your system', 'install-linux-tools', ['distro' => $distro, 'missing' => $missing]);
|
||||
}
|
||||
return CheckResult::ok();
|
||||
}
|
||||
@ -96,7 +96,7 @@ class LinuxToolCheck
|
||||
if (LinuxUtil::isMuslDist()) {
|
||||
// check linux-headers installation
|
||||
if (!file_exists('/usr/include/linux/mman.h')) {
|
||||
return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', [LinuxUtil::getOSRelease(), ['linux-headers']]);
|
||||
return CheckResult::fail('linux-headers not installed on your system', 'install-linux-tools', ['distro' => LinuxUtil::getOSRelease(), 'missing' => ['linux-headers']]);
|
||||
}
|
||||
}
|
||||
return CheckResult::ok();
|
||||
@ -137,7 +137,7 @@ class LinuxToolCheck
|
||||
$to_install = $is_debian ? str_replace('xz', 'xz-utils', $missing) : $missing;
|
||||
// debian, alpine libtool -> libtoolize
|
||||
$to_install = str_replace('libtoolize', 'libtool', $to_install);
|
||||
shell()->exec($prefix . $install_cmd . ' ' . implode(' ', $to_install));
|
||||
f_passthru($prefix . $install_cmd . ' ' . implode(' ', $to_install));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ class MacOSToolCheck
|
||||
}
|
||||
}
|
||||
if (!empty($missing)) {
|
||||
return CheckResult::fail('missing system commands: ' . implode(', ', $missing), 'build-tools', [$missing]);
|
||||
return CheckResult::fail('missing system commands: ' . implode(', ', $missing), 'build-tools', ['missing' => $missing]);
|
||||
}
|
||||
return CheckResult::ok();
|
||||
}
|
||||
@ -63,7 +63,7 @@ class MacOSToolCheck
|
||||
{
|
||||
// if the bison command is /usr/bin/bison, it is the system bison that may be too old
|
||||
if (($bison = MacOSUtil::findCommand('bison', $command_path)) === null) {
|
||||
return CheckResult::fail('bison is not installed or too old', 'build-tools', [['bison']]);
|
||||
return CheckResult::fail('bison is not installed or too old', 'build-tools', ['missing' => ['bison']]);
|
||||
}
|
||||
// check version: bison (GNU Bison) x.y(.z)
|
||||
$version = shell()->execWithResult("{$bison} --version", false);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user