From 2704ab0536981d1bd1fdac2a0ed300c8adb68818 Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 19 Apr 2017 10:12:52 +0900 Subject: [PATCH] Improve PostgreSQL version detection Need to consider different numbering system from PostgreSQL 10. --- configure | 35 ++++++++++++++++++++++++----------- configure.in | 33 +++++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/configure b/configure index c7b35565..8c7c0a30 100755 --- a/configure +++ b/configure @@ -1803,23 +1803,36 @@ if test -z "$PG_CONFIG"; then fi pgac_pg_config_version=$($PG_CONFIG --version 2>/dev/null) -version_num=$(echo "$pgac_pg_config_version"| - $SED -e 's/^PostgreSQL \([0-9]*\)\.\([0-9]*\)\([a-zA-Z0-9.]*\)$/\1.\2/') -if test -z "$version_num"; then - as_fn_error $? "could not detect the PostgreSQL version, wrong or broken pg_config?" "$LINENO" 5 -fi +major_version_num=$(echo "$pgac_pg_config_version"| + $SED -e 's/^PostgreSQL \([0-9]\{1,2\}\).*$/\1/') -version_num_int=$(echo "$version_num"| - $SED -e 's/^\([0-9]*\)\.\([0-9]*\)$/\1\2/') +if test "$major_version_num" -lt '10'; then + version_num=$(echo "$pgac_pg_config_version"| + $SED -e 's/^PostgreSQL \([0-9]*\)\.\([0-9]*\)\([a-zA-Z0-9.]*\)$/\1.\2/') -if test "$version_num_int" -lt '93'; then - as_fn_error $? "repmgr is not compatible with detected PostgreSQL version: $version_num" "$LINENO" 5 + if test -z "$version_num"; then + as_fn_error $? "could not detect the PostgreSQL version, wrong or broken pg_config?" "$LINENO" 5 + fi + + version_num_int=$(echo "$version_num"| + $SED -e 's/^\([0-9]*\)\.\([0-9]*\)$/\1\2/') + + if test "$version_num_int" -lt '93'; then + as_fn_error $? "repmgr is not compatible with detected PostgreSQL version: $version_num" "$LINENO" 5 + fi else - { $as_echo "$as_me:${as_lineno-$LINENO}: building against PostgreSQL $version_num" >&5 -$as_echo "$as_me: building against PostgreSQL $version_num" >&6;} + version_num=$(echo "$pgac_pg_config_version"| + $SED -e 's/^PostgreSQL \(.\+\)$/\1/') + + if test -z "$version_num"; then + as_fn_error $? "could not detect the PostgreSQL version, wrong or broken pg_config?" "$LINENO" 5 + fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: building against PostgreSQL $version_num" >&5 +$as_echo "$as_me: building against PostgreSQL $version_num" >&6;} + # add includedir to prerequisites, so tests for headers can succeed CPPFLAGS="-I$($PG_CONFIG --includedir-server) $CFLAGS" diff --git a/configure.in b/configure.in index e2c8aa05..b8a505d0 100644 --- a/configure.in +++ b/configure.in @@ -15,22 +15,35 @@ if test -z "$PG_CONFIG"; then fi pgac_pg_config_version=$($PG_CONFIG --version 2>/dev/null) -version_num=$(echo "$pgac_pg_config_version"| - $SED -e 's/^PostgreSQL \([[0-9]]*\)\.\([[0-9]]*\)\([[a-zA-Z0-9.]]*\)$/\1.\2/') -if test -z "$version_num"; then - AC_MSG_ERROR([could not detect the PostgreSQL version, wrong or broken pg_config?]) -fi +major_version_num=$(echo "$pgac_pg_config_version"| + $SED -e 's/^PostgreSQL \([[0-9]]\{1,2\}\).*$/\1/') -version_num_int=$(echo "$version_num"| - $SED -e 's/^\([[0-9]]*\)\.\([[0-9]]*\)$/\1\2/') +if test "$major_version_num" -lt '10'; then + version_num=$(echo "$pgac_pg_config_version"| + $SED -e 's/^PostgreSQL \([[0-9]]*\)\.\([[0-9]]*\)\([[a-zA-Z0-9.]]*\)$/\1.\2/') -if test "$version_num_int" -lt '93'; then - AC_MSG_ERROR([repmgr is not compatible with detected PostgreSQL version: $version_num]) + if test -z "$version_num"; then + AC_MSG_ERROR([could not detect the PostgreSQL version, wrong or broken pg_config?]) + fi + + version_num_int=$(echo "$version_num"| + $SED -e 's/^\([[0-9]]*\)\.\([[0-9]]*\)$/\1\2/') + + if test "$version_num_int" -lt '93'; then + AC_MSG_ERROR([repmgr is not compatible with detected PostgreSQL version: $version_num]) + fi else - AC_MSG_NOTICE([building against PostgreSQL $version_num]) + version_num=$(echo "$pgac_pg_config_version"| + $SED -e 's/^PostgreSQL \(.\+\)$/\1/') + + if test -z "$version_num"; then + AC_MSG_ERROR([could not detect the PostgreSQL version, wrong or broken pg_config?]) + fi fi +AC_MSG_NOTICE([building against PostgreSQL $version_num]) + # add includedir to prerequisites, so tests for headers can succeed CPPFLAGS="-I$($PG_CONFIG --includedir-server) $CFLAGS"