mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 13:24:51 +08:00
Merge branch 'main' into v3-refactor/new-extensions
# Conflicts: # src/SPC/store/SourcePatcher.php
This commit is contained in:
commit
5669642cf3
@ -361,7 +361,7 @@
|
||||
},
|
||||
"gmp": {
|
||||
"type": "filelist",
|
||||
"url": "https://gmplib.org/download/gmp/",
|
||||
"url": "https://ftp.gnu.org/gnu/gmp/",
|
||||
"regex": "/href=\"(?<file>gmp-(?<version>[^\"]+)\\.tar\\.xz)\"/",
|
||||
"provide-pre-built": true,
|
||||
"alt": {
|
||||
|
||||
@ -5,11 +5,21 @@ declare(strict_types=1);
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\linux\SystemUtil;
|
||||
use SPC\store\SourcePatcher;
|
||||
use SPC\util\CustomExt;
|
||||
|
||||
#[CustomExt('ffi')]
|
||||
class ffi extends Extension
|
||||
{
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
if (PHP_OS_FAMILY === 'Linux' && SystemUtil::getOSRelease()['dist'] === 'centos') {
|
||||
return SourcePatcher::patchFfiCentos7FixO3strncmp();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(bool $shared = false): string
|
||||
{
|
||||
return '--with-ffi' . ($shared ? '=shared' : '') . ' --enable-zend-signals';
|
||||
|
||||
@ -22,7 +22,7 @@ class SourcePatcher
|
||||
FileSystem::addSourceExtractHook('swoole', [__CLASS__, 'patchSwoole']);
|
||||
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchPhpLibxml212']); // migrated
|
||||
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchGDWin32']); // migrated
|
||||
FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']); // migrated
|
||||
// FileSystem::addSourceExtractHook('php-src', [__CLASS__, 'patchFfiCentos7FixO3strncmp']); // migrated
|
||||
FileSystem::addSourceExtractHook('sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
||||
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVWin32']);
|
||||
FileSystem::addSourceExtractHook('pdo_sqlsrv', [__CLASS__, 'patchSQLSRVPhp85']);
|
||||
|
||||
@ -6,11 +6,17 @@ namespace SPC\store\source;
|
||||
|
||||
use JetBrains\PhpStorm\ArrayShape;
|
||||
use SPC\exception\DownloaderException;
|
||||
use SPC\exception\SPCException;
|
||||
use SPC\store\Downloader;
|
||||
|
||||
class PhpSource extends CustomSourceBase
|
||||
{
|
||||
public const NAME = 'php-src';
|
||||
public const string NAME = 'php-src';
|
||||
|
||||
public const array WEB_PHP_DOMAINS = [
|
||||
'https://www.php.net',
|
||||
'https://phpmirror.static-php.dev',
|
||||
];
|
||||
|
||||
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void
|
||||
{
|
||||
@ -28,21 +34,26 @@ class PhpSource extends CustomSourceBase
|
||||
#[ArrayShape(['type' => 'string', 'path' => 'string', 'rev' => 'string', 'url' => 'string'])]
|
||||
public function getLatestPHPInfo(string $major_version): array
|
||||
{
|
||||
// 查找最新的小版本号
|
||||
$info = json_decode(Downloader::curlExec(
|
||||
url: "https://www.php.net/releases/index.php?json&version={$major_version}",
|
||||
retries: (int) getenv('SPC_DOWNLOAD_RETRIES') ?: 0
|
||||
), true);
|
||||
if (!isset($info['version'])) {
|
||||
throw new DownloaderException("Version {$major_version} not found.");
|
||||
foreach (self::WEB_PHP_DOMAINS as $domain) {
|
||||
try {
|
||||
$info = json_decode(Downloader::curlExec(
|
||||
url: "{$domain}/releases/index.php?json&version={$major_version}",
|
||||
retries: (int) getenv('SPC_DOWNLOAD_RETRIES') ?: 0
|
||||
), true);
|
||||
if (!isset($info['version'])) {
|
||||
throw new DownloaderException("Version {$major_version} not found.");
|
||||
}
|
||||
$version = $info['version'];
|
||||
return [
|
||||
'type' => 'url',
|
||||
'url' => "{$domain}/distributions/php-{$version}.tar.xz",
|
||||
];
|
||||
} catch (SPCException) {
|
||||
logger()->warning('Failed to fetch latest PHP version for major version {$major_version} from {$domain}, trying next mirror if available.');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$version = $info['version'];
|
||||
|
||||
// 从官网直接下载
|
||||
return [
|
||||
'type' => 'url',
|
||||
'url' => "https://www.php.net/distributions/php-{$version}.tar.xz",
|
||||
];
|
||||
// exception if all mirrors failed
|
||||
throw new DownloaderException("Failed to fetch latest PHP version for major version {$major_version} from all tried mirrors.");
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user