From 5f6c1a0f402d9d0fb0801aba0fed68ae1b704c81 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Mon, 26 Feb 2024 19:55:47 +0800 Subject: [PATCH] update postgresql version to 16.2 (#355) * update postgresql version to 16.2 * add tests * add tests --- config/source.json | 2 +- src/SPC/builder/unix/library/postgresql.php | 29 +++++++++++++++++---- src/globals/test-extensions.php | 3 +-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/config/source.json b/config/source.json index 11b65f53..d9287da2 100644 --- a/config/source.json +++ b/config/source.json @@ -449,7 +449,7 @@ }, "postgresql": { "type": "url", - "url": "https://ftp.postgresql.org/pub/source/v16.1/postgresql-16.1.tar.gz", + "url": "https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.bz2", "license": { "type": "file", "path": "COPYRIGHT" diff --git a/src/SPC/builder/unix/library/postgresql.php b/src/SPC/builder/unix/library/postgresql.php index 4061f13e..0b3c7c61 100644 --- a/src/SPC/builder/unix/library/postgresql.php +++ b/src/SPC/builder/unix/library/postgresql.php @@ -58,11 +58,17 @@ trait postgresql FileSystem::resetDir($this->source_dir . '/build'); - # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile - shell()->cd($this->source_dir . '/build') - ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') - ->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib') - ->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib'); + $version = $this->getVersion(); + // 16.1 workaround + if (version_compare($version, '16.1') >= 0) { + # 有静态链接配置 参考文件: src/interfaces/libpq/Makefile + shell()->cd($this->source_dir . '/build') + ->exec('sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" ../src/interfaces/libpq/Makefile') + ->exec('sed -i.backup "278 s/^/# /" ../src/Makefile.shlib') + ->exec('sed -i.backup "402 s/^/# /" ../src/Makefile.shlib'); + } else { + throw new RuntimeException('Unsupported version for postgresql: ' . $version . ' !'); + } // configure shell()->cd($this->source_dir . '/build') @@ -101,4 +107,17 @@ trait postgresql ->exec("rm -rf {$builddir}/lib/*.so") ->exec("rm -rf {$builddir}/lib/*.dylib"); } + + private function getVersion(): string + { + try { + $file = FileSystem::readFile($this->source_dir . '/meson.build'); + if (preg_match("/^\\s+version:\\s?'(.*)'/m", $file, $match)) { + return $match[1]; + } + return 'unknown'; + } catch (FileSystemException) { + return 'unknown'; + } + } } diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 29c0e0a1..0f93a9ea 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -13,8 +13,7 @@ declare(strict_types=1); // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'event,gettext', - 'Linux', 'Darwin' => 'event,gettext', + 'Linux', 'Darwin' => 'pgsql,pdo_pgsql', 'Windows' => 'mbstring,pdo_sqlite,mbregex', };