mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-19 21:34:53 +08:00
39 lines
1.0 KiB
PHP
39 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace SPC\store\source;
|
|
|
|
use SPC\exception\DownloaderException;
|
|
use SPC\exception\FileSystemException;
|
|
use SPC\store\Downloader;
|
|
|
|
class PostgreSQLSource extends CustomSourceBase
|
|
{
|
|
public const NAME = 'postgresql';
|
|
|
|
/**
|
|
* @throws DownloaderException
|
|
* @throws FileSystemException
|
|
*/
|
|
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_SOURCE): void
|
|
{
|
|
Downloader::downloadSource('postgresql', self::getLatestInfo(), $force);
|
|
}
|
|
|
|
/**
|
|
* @throws DownloaderException
|
|
*/
|
|
public function getLatestInfo(): array
|
|
{
|
|
[, $filename, $version] = Downloader::getFromFileList('postgresql', [
|
|
'url' => 'https://www.postgresql.org/ftp/source/',
|
|
'regex' => '/href="(?<file>v(?<version>[^"]+)\/)"/',
|
|
]);
|
|
return [
|
|
'type' => 'url',
|
|
'url' => "https://ftp.postgresql.org/pub/source/{$filename}postgresql-{$version}.tar.gz",
|
|
];
|
|
}
|
|
}
|