2023-04-09 12:11:14 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace SPC\store\source;
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
use SPC\exception\DownloaderException;
|
|
|
|
|
use SPC\exception\FileSystemException;
|
2023-04-09 12:11:14 +08:00
|
|
|
use SPC\store\Downloader;
|
|
|
|
|
|
|
|
|
|
class PostgreSQLSource extends CustomSourceBase
|
|
|
|
|
{
|
|
|
|
|
public const NAME = 'postgresql';
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws DownloaderException
|
|
|
|
|
* @throws FileSystemException
|
|
|
|
|
*/
|
2025-03-30 16:53:14 +08:00
|
|
|
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWN_SOURCE): void
|
2023-04-09 12:11:14 +08:00
|
|
|
{
|
2024-03-10 10:58:58 +08:00
|
|
|
Downloader::downloadSource('postgresql', self::getLatestInfo(), $force);
|
2023-04-09 12:11:14 +08:00
|
|
|
}
|
|
|
|
|
|
2023-08-20 19:51:45 +08:00
|
|
|
/**
|
|
|
|
|
* @throws DownloaderException
|
|
|
|
|
*/
|
2023-04-09 12:11:14 +08:00
|
|
|
public function getLatestInfo(): array
|
|
|
|
|
{
|
2023-08-20 19:51:45 +08:00
|
|
|
[, $filename, $version] = Downloader::getFromFileList('postgresql', [
|
2023-04-09 12:11:14 +08:00
|
|
|
'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",
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|