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

41 lines
1015 B
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;
use SPC\exception\RuntimeException;
2023-04-09 12:11:14 +08:00
use SPC\store\Downloader;
class PostgreSQLSource extends CustomSourceBase
{
public const NAME = 'postgresql';
/**
* @throws DownloaderException
* @throws RuntimeException
* @throws FileSystemException
*/
public function fetch(): void
2023-04-09 12:11:14 +08:00
{
2023-04-30 12:42:19 +08:00
Downloader::downloadSource('postgresql', self::getLatestInfo());
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",
];
}
}