From 7c3022b7e3bf947e837d3fc43ccd97277cf9260f Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 24 Mar 2026 12:07:57 +0800 Subject: [PATCH] Add postgresql (replace postgresql-win) --- config/pkg/lib/postgresql.yml | 12 +++++++++--- src/StaticPHP/Package/PackageInstaller.php | 5 +++++ src/StaticPHP/Util/FileSystem.php | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config/pkg/lib/postgresql.yml b/config/pkg/lib/postgresql.yml index 1237b184..ee78072e 100644 --- a/config/pkg/lib/postgresql.yml +++ b/config/pkg/lib/postgresql.yml @@ -5,19 +5,25 @@ postgresql: type: ghtagtar repo: postgres/postgres match: REL_18_\d+ + binary: + windows-x86_64: { type: url, url: 'https://get.enterprisedb.com/postgresql/postgresql-16.8-1-windows-x64-binaries.zip', extract: { lib/libpq.lib: '{build_root_path}/lib/libpq.lib', lib/libpgport.lib: '{build_root_path}/lib/libpgport.lib', lib/libpgcommon.lib: '{build_root_path}/lib/libpgcommon.lib', include/libpq-fe.h: '{build_root_path}/include/libpq-fe.h', include/postgres_ext.h: '{build_root_path}/include/postgres_ext.h', include/pg_config_ext.h: '{build_root_path}/include/pg_config_ext.h', include/libpq/libpq-fs.h: '{build_root_path}/include/libpq/libpq-fs.h' } } metadata: - license-files: [COPYRIGHT] + license-files: ['@/postgresql.txt'] license: PostgreSQL - depends: + depends@unix: - libiconv - libxml2 - openssl - zlib - libedit - suggests: + suggests@unix: - icu - libxslt - ldap - zstd pkg-configs: - libpq + static-libs@windows: + - libpq.lib + - libpgport.lib + - libpgcommon.lib diff --git a/src/StaticPHP/Package/PackageInstaller.php b/src/StaticPHP/Package/PackageInstaller.php index f5c03a7d..16e8f45a 100644 --- a/src/StaticPHP/Package/PackageInstaller.php +++ b/src/StaticPHP/Package/PackageInstaller.php @@ -323,6 +323,11 @@ class PackageInstaller $artifact = $package->getArtifact(); return $artifact->isBinaryExtracted(); } + // Fallback: if the download cache is missing (e.g. download failed or cache was cleared), + // still check whether the files are physically present in buildroot. + if ($package instanceof LibraryPackage) { + return $package->isInstalled(); + } return false; } diff --git a/src/StaticPHP/Util/FileSystem.php b/src/StaticPHP/Util/FileSystem.php index 144f81eb..38a614e0 100644 --- a/src/StaticPHP/Util/FileSystem.php +++ b/src/StaticPHP/Util/FileSystem.php @@ -405,6 +405,7 @@ class FileSystem public static function replacePathVariable(string $path): string { $replacement = [ + '{build_root_path}' => BUILD_ROOT_PATH, '{pkg_root_path}' => PKG_ROOT_PATH, '{php_sdk_path}' => getenv('PHP_SDK_PATH') ? getenv('PHP_SDK_PATH') : WORKING_DIR . '/php-sdk-binary-tools', '{working_dir}' => WORKING_DIR,