mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 16:55:38 +08:00
Add --no-alt and --skip-extract option to install-pkg command
This commit is contained in:
@@ -608,6 +608,29 @@ class Downloader
|
||||
return "{$source}-{$os_family}-{$gnu_arch}-{$libc}-{$libc_version}";
|
||||
}
|
||||
|
||||
public static function getDefaultAlternativeSource(string $source_name): array
|
||||
{
|
||||
return [
|
||||
'type' => 'custom',
|
||||
'func' => function (bool $force, array $source, int $download_as) use ($source_name) {
|
||||
logger()->debug("Fetching alternative source for {$source_name}");
|
||||
// get from dl.static-php.dev
|
||||
$url = "https://dl.static-php.dev/static-php-cli/deps/spc-download-mirror/{$source_name}/?format=json";
|
||||
$json = json_decode(Downloader::curlExec(url: $url, retries: intval(getenv('SPC_DOWNLOAD_RETRIES') ?: 0)), true);
|
||||
if (!is_array($json)) {
|
||||
throw new RuntimeException('failed http fetch');
|
||||
}
|
||||
$item = $json[0] ?? null;
|
||||
if ($item === null) {
|
||||
throw new RuntimeException('failed to parse json');
|
||||
}
|
||||
$full_url = 'https://dl.static-php.dev' . $item['full_path'];
|
||||
$filename = basename($item['full_path']);
|
||||
Downloader::downloadFile($source_name, $full_url, $filename, $source['path'] ?? null, $download_as);
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register CTRL+C event for different OS.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user