From 92f765c5e0f4a29491f5aff5ecc5902d3e4b05ad Mon Sep 17 00:00:00 2001 From: Muhammad Aqeel Date: Thu, 9 Jul 2026 19:01:25 +0500 Subject: [PATCH] Fix Makefile PG version check breaking on pre-release versions The check-pg-version target derived pg_version_num with a regex that required a MAJOR.MINOR dotted format. PostgreSQL pre-release builds report a version like "19beta1" with no dot, so the substitution did not match and left the full descriptive string in place. On Debian/Ubuntu, pg_config --version also appends a distro suffix, e.g. "PostgreSQL 19beta1 (Ubuntu 19~beta1-1.noble)". The unmatched string then flowed into the shell test as: if [ 19beta1 (Ubuntu 19~beta1-1.noble) -lt 14 ]; then which fails under dash (/bin/sh on Debian/Ubuntu) with: /bin/sh: 1: Syntax error: "(" unexpected (expecting "then") breaking the PG19 .deb build. (RPM builds happened to survive only because their version string has no parenthetical suffix.) Parse just the leading major-version integer and quote the value in the test so it is robust for both pre-release and stable versions on dash and bash. --- Makefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index aaf3ab9..fd22d4e 100644 --- a/Makefile +++ b/Makefile @@ -63,13 +63,17 @@ endif include $(PGXS) # Version compatibility check -pg_version_num := $(shell $(PG_CONFIG) --version | sed 's/^PostgreSQL *//' | \ - sed 's/\([0-9]*\)\.\([0-9]*\).*/\1\2/') +# Extract only the leading major version integer. This must cope with +# pre-release strings such as "PostgreSQL 19beta1 (Ubuntu 19~beta1-1.noble)" +# where there is no MAJOR.MINOR dot; a dotted regex would leave the whole +# descriptive string (including the "(...)" suffix) in place and break the +# shell test below under dash (/bin/sh on Debian/Ubuntu). +pg_version_num := $(shell $(PG_CONFIG) --version | sed -E 's/^PostgreSQL ([0-9]+).*/\1/') # Ensure we're building for PostgreSQL 14+ check-pg-version: @echo "Building for PostgreSQL version: $(shell $(PG_CONFIG) --version)" - @if [ $(pg_version_num) -lt 14 ]; then \ + @if [ "$(pg_version_num)" -lt 14 ]; then \ echo "Error: PostgreSQL 14 or later is required"; \ exit 1; \ fi