summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2014-09-18 10:47:47 +0200
committerPavel Raiskup <praiskup@redhat.com>2014-09-18 10:47:47 +0200
commitcbb845482abafc917241240e88f3c0271093b98c (patch)
treebdd1dfe061aff1b902b83270b5cfbafeeaa2e0d2
parent168cc7aa947ed992c17d2f6e4db353518338b4a1 (diff)
downloadpostgresql-setup-cbb845482abafc917241240e88f3c0271093b98c.tar.gz
postgresql-setup-cbb845482abafc917241240e88f3c0271093b98c.tar.xz
postgresql-setup-cbb845482abafc917241240e88f3c0271093b98c.zip
configury: some steps making the macros more consistent
-rw-r--r--configure.ac115
-rw-r--r--m4/packaging.m435
2 files changed, 68 insertions, 82 deletions
diff --git a/configure.ac b/configure.ac
index 6abf154..554810d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,9 +5,10 @@ AC_SUBST([config_aux_dir])
AM_INIT_AUTOMAKE([-Wall])
AC_CONFIG_FILES([Makefile doc/Makefile])
+AC_CONFIG_MACRO_DIR([m4])
AM_SILENT_RULES([yes])
-AC_ARG_VAR([DISTSUFF], [Append string suffix to all binaries])
+AC_ARG_VAR([DISTSUFF], [Append string suffix to all binaries and package names])
AC_SUBST([DISTSUFF])
# Initialize the test suite.
@@ -61,65 +62,24 @@ AC_SUBST([INSTANTIATE])
AC_SUBST([INSTANTIATE_SCRIPT])
AC_SUBST([c_s])
+
AC_PATH_PROG([SED], [sed])
test -z "$ac_cv_path_SED" &&
AC_MSG_ERROR([Sed is needed but not found.])
-# For SELinux purposes use rather runuser
-AC_PATH_PROG([SU], [runuser])
-test -z "$ac_cv_path_SU" &&
- AC_PATH_PROG([SU], [su])
+AC_PATH_PROGS([SU], [runuser su])
test -z "$ac_cv_path_SU" &&
AC_MSG_ERROR([Neither 'runuser' nor 'su' program found])
-distro_family=redhat
-test -r /etc/redhat-release ||
- AC_MSG_ERROR([This still works for Red Hat distributions only])
-
-# Check package manager is installed
-case "$distro_family" in
-redhat)
- AC_PATH_PROG([RPM], [rpm])
- test -z "$ac_cv_path_RPM" &&
- AC_MSG_ERROR([RPM package manager is required])
- ;;
-esac
-
-# Make sure that the variable is in './configure --help' output and that it is
-# not empty.
-m4_define([subst_required_var], [
- AC_ARG_VAR([$1], [$2])
- test -z "$[]$1" &&
- AC_MSG_ERROR([the \$$1 variable is not set])
-])
-
-
-# Check for main PostgreSQL binaries
-# ----------------------------------
+PGSETUP_PACKAGING_INIT
+# check for main PostgreSQL binaries
AC_ARG_VAR([POSTGRES_BIN], [Full path to postgres binary. Note that based on
package ownership of this file the package names (like
postgresql-server, postgresql, ..) are detected.])
AC_PATH_PROG([POSTGRES_BIN], [postgres])
-
-# Check for main PostgreSQL packages
-# ----------------------------------
-
-case "$distro_family" in
-redhat)
- rpm_pkgname_server=$(rpm -qf $POSTGRES_BIN --qf '%{NAME}')
- rpm_pkgname=${rpm_pkgname_server%%-*}
- ;;
-esac
-
-
-AC_PATH_PROG([POSTGRES_BIN], [postgres])
-
-
-# PGVERSION & PGMAJORVERSION
-# --------------------------
-
+# check for PGVERSION & PGMAJORVERSION, if needed
if test -z "$PGVERSION" -a -z "$PGMAJORVERSION"; then
test -z "$ac_cv_path_POSTGRES_BIN" &&
AC_MSG_ERROR([no postgres binary, can not detect version])
@@ -134,37 +94,33 @@ if test -z "$PGVERSION" -a -z "$PGMAJORVERSION"; then
PGMAJORVERSION=${PGVERSION%%.[[0-9]]}
fi
-# Detect PGENGINE location
-# ------------------------
-
+# detect PGENGINE location (where the binaries are), if needed
if test -z "$PGENGINE"; then
test -z "$ac_cv_path_POSTGRES_BIN" &&
AC_MSG_ERROR([no postgres binary, can not detect PGENGINE])
PGENGINE=`AS_DIRNAME($POSTGRES_BIN)`
fi
-# Detect pg_ctl binary
-# --------------------
+# pg_ctl binary
test -z "$PG_CTL_BIN" &&
PG_CTL_BIN=$PGENGINE/pg_ctl
AC_SUBST([PG_CTL_BIN])
-
-# pg_upgrade binary
-# -----------------
-
AC_PATH_PROG([PG_UPGRADE_BIN], [pg_upgrade])
-# Detect PREVMAJORVERSION
-# -----------------------
-# This sets as a side effect PREV_POSTGRES_BIN, which is used later on.
-
+# Either the PREVMAJORVERSION must be passed explicitly, or per-distro
+# scripting must be done.
if test -z "$PREVMAJORVERSION"; then
- case "$distro_family" in
+ if test -z "$ac_cv_path_PG_UPGRADE_BIN"; then
+ msg="pg_upgrade not found to detect \$PREVMAJORVERSION automatically"
+ AC_MSG_ERROR([$msg])
+ fi
+
+ AC_MSG_CHECKING([for prev major version])
+ case "$pgsetup_cv_os_family" in
redhat)
- AC_MSG_CHECKING([for prev major version])
test -z "$ac_cv_path_PG_UPGRADE_BIN" &&
- AC_MSG_ERROR([no pg_upgrade found])
+ AC_MSG_ERROR([pg_upgrade not found, plese \$PREVMAJORVERSION set])
PREV_POSTGRES_BIN=$(rpm -ql \
$(rpm -qf "$ac_cv_path_PG_UPGRADE_BIN") \
@@ -172,37 +128,33 @@ if test -z "$PREVMAJORVERSION"; then
PREVMAJORVERSION=$(echo $PREV_POSTGRES_BIN \
| sed 's/.*postgresql-\([[0-9\.]]\+\).*/\1/')
- AC_MSG_RESULT($PREVMAJORVERSION)
;;
esac
fi
+AC_MSG_RESULT($PREVMAJORVERSION)
# Detect PREVPGENGINE
-# -------------------
-
if test -z "$PREVPGENGINE"; then
PREVPGENGINE=`AS_DIRNAME($PREV_POSTGRES_BIN)`
fi
# Detect where distribution-like README is
-# ----------------------------------------
-
-case "$distro_family" in
+case "$pgsetup_cv_os_family" in
redhat)
test -z "$README_DIST" &&
README_DIST=`rpm -ql postgresql | grep README | grep dist`
;;
esac
-if test -z "$PKGCONFIG_DIR" -a "$distro_family" = redhat; then
+if test -z "$PKGCONFIG_DIR" -a "$pgsetup_cv_os_family" = redhat; then
PKGCONFIG_DIR=/etc/postgresql
fi
-if test -z "$POSTGRES_HOMEDIR" -a "$distro_family" = redhat; then
+if test -z "$POSTGRES_HOMEDIR" -a "$pgsetup_cv_os_family" = redhat; then
POSTGRES_HOMEDIR=/var/lib/pgsql
fi
-if test -z "$PGDATADIR" -a "$distro_family" = redhat; then
+if test -z "$PGDATADIR" -a "$pgsetup_cv_os_family" = redhat; then
PGDATADIR=/var/lib/pgsql/data
fi
@@ -211,15 +163,14 @@ pgcontribdocdir="\${datarootdir}/doc/\${pkgname}-contrib"
AC_SUBST([pgdocdir])
AC_SUBST([pgcontribdocdir])
-# Deal with previous versions
-subst_required_var([PGVERSION], [full PG version])
-subst_required_var([PGMAJORVERSION], [major PG version])
-subst_required_var([PGENGINE], [directory where PG server resides])
-subst_required_var([PREVMAJORVERSION], [PG major version to upgrade _from_])
-subst_required_var([PREVPGENGINE], [directory where old PG server resides])
-subst_required_var([README_DIST], [README file for distribution])
-subst_required_var([PKGCONFIG_DIR], [where configuration should be stored])
-subst_required_var([POSTGRES_HOMEDIR], [full path to postgres home dir])
-subst_required_var([PGDATADIR], [full path to postgres data dir])
+PGSETUP_SUBST_REQ([PGVERSION], [full PG version])
+PGSETUP_SUBST_REQ([PGMAJORVERSION], [major PG version])
+PGSETUP_SUBST_REQ([PGENGINE], [directory where PG server resides])
+PGSETUP_SUBST_REQ([PREVMAJORVERSION], [PG major version to upgrade _from_])
+PGSETUP_SUBST_REQ([PREVPGENGINE], [directory where old PG server resides])
+PGSETUP_SUBST_REQ([README_DIST], [README file for distribution])
+PGSETUP_SUBST_REQ([PKGCONFIG_DIR], [where configuration should be stored])
+PGSETUP_SUBST_REQ([POSTGRES_HOMEDIR], [full path to postgres home dir])
+PGSETUP_SUBST_REQ([PGDATADIR], [full path to postgres data dir])
AC_OUTPUT
diff --git a/m4/packaging.m4 b/m4/packaging.m4
new file mode 100644
index 0000000..7160ae8
--- /dev/null
+++ b/m4/packaging.m4
@@ -0,0 +1,35 @@
+AC_DEFUN([PGSETUP_PACKAGING_INIT], [
+ AC_CACHE_CHECK(
+ [for oprating system (distribution)],
+ [pgsetup_cv_os_family], [
+ pgsetup_cv_os_family=
+ if test -r /etc/redhat-release; then
+ pgsetup_cv_os_family=redhat
+ fi
+ ]
+ )
+
+ case $pgsetup_cv_os_family in
+ redhat)
+ AC_PATH_PROG([RPM], [rpm])
+ if test -z "$ac_cv_path_RPM"; then
+ AC_MSG_ERROR("can not find RPM package manager")
+ fi
+ ;;
+ *)
+ AC_MSG_ERROR([rpm distro only ATM (todo)])
+ ;;
+ esac
+])
+
+# PGSETUP_SUBST_REQ(VARIABLE,DESCRIPTION)
+# ---------------------------------------
+# Make sure that the VARIABLE is mentioned in './configure --help' output and
+# that it is not empty after processing this macro. Use the DESCRIPTION as a
+# comment.
+m4_define([PGSETUP_SUBST_REQ], [
+ AC_ARG_VAR([$1], [$2])
+ test -z "$[]$1" &&
+ AC_MSG_ERROR([the \$$1 variable is not set])
+])
+