diff --git a/config/source.json b/config/source.json index f1aed51d..3b04add9 100644 --- a/config/source.json +++ b/config/source.json @@ -1122,6 +1122,10 @@ "repo": "skvadrik/re2c", "match": "re2c.+\\.tar\\.xz", "prefer-stable": true, + "alt": { + "type": "url", + "url": "https://dl.static-php.dev/static-php-cli/deps/re2c/re2c-4.3.tar.xz" + }, "license": { "type": "file", "path": "LICENSE" diff --git a/src/SPC/doctor/item/Re2cVersionCheck.php b/src/SPC/doctor/item/Re2cVersionCheck.php index 8a10cad5..bb3ddf7f 100644 --- a/src/SPC/doctor/item/Re2cVersionCheck.php +++ b/src/SPC/doctor/item/Re2cVersionCheck.php @@ -9,6 +9,8 @@ use SPC\builder\traits\UnixSystemUtilTrait; use SPC\doctor\AsCheckItem; use SPC\doctor\AsFixItem; use SPC\doctor\CheckResult; +use SPC\exception\DownloaderException; +use SPC\store\Config; use SPC\store\Downloader; use Symfony\Component\Console\Input\ArgvInput; @@ -35,7 +37,14 @@ class Re2cVersionCheck #[AsFixItem('build-re2c')] public function buildRe2c(): bool { - Downloader::downloadSource('re2c'); + try { + Downloader::downloadSource('re2c'); + } catch (DownloaderException) { + logger()->warning('Failed to download re2c version, trying alternative'); + $alt = Config::getSource('re2c'); + $alt = [...$alt, ...$alt['alt'] ?? []]; + Downloader::downloadSource('re2c', $alt); + } $builder = BuilderProvider::makeBuilderByInput(new ArgvInput([])); $builder->proveLibs(['re2c']); $builder->setupLibs();