static-php-cli/src/SPC/store/source/PostgreSQLSource.php

39 lines
1.0 KiB
PHP
Raw Normal View History

2023-04-09 12:11:14 +08:00
<?php
declare(strict_types=1);
namespace SPC\store\source;
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';
/**
* @throws DownloaderException
* @throws FileSystemException
*/
2025-03-30 23:27:43 +08:00
public function fetch(bool $force = false, ?array $config = null, int $lock_as = SPC_DOWNLOAD_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
}
/**
* @throws DownloaderException
*/
2023-04-09 12:11:14 +08:00
public function getLatestInfo(): array
{
[, $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",
];
}
}