summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2015-02-27 15:57:08 +0100
committerPavel Raiskup <praiskup@redhat.com>2015-02-27 16:08:11 +0100
commit9094981751e776fa93537c91bc0e678f4d806b91 (patch)
treef8fae32b51dbd08ef2343da8084d6dbab9d0f6f3
parent28c5dbbab21fb19606cb548582885458928eda30 (diff)
downloadpostgresql-setup-9094981751e776fa93537c91bc0e678f4d806b91.tar.gz
postgresql-setup-9094981751e776fa93537c91bc0e678f4d806b91.tar.xz
postgresql-setup-9094981751e776fa93537c91bc0e678f4d806b91.zip
configury: another scl-izing commit
* Makefile.am: Move systemd directory definitions into configure.ac. This is then easily configurable via config.site. * configure.ac (PGENGINE, PG_CTL_BIN): Remove, bindir is sufficient. (PREVMAJORVERSION, PREVPGENGINE): Removed. It si configurable now. (INIDB_SCLS): Generalize into SCLS variable. (SCLS): Moved from INIDB_SCLS. (PGDATADIR): Default changed to have ${prefix} inside. (SED_RULES): Remove unused variables (or to not be used, TODO for next commit). (conf_dir): New macro to define config.site friendly directory variable. (SCL_SHELL_WRAPPER): Convenient macro to generate appropriate call to scl binary (only when building for software collections). * postgresql-check-db-dir.in: Use new variable layout. * postgresql-ctl.in: Likewise. * postgresql-setup.in: Likewise. * postgresql.service.in: Likewise. This fixes regression of not using ${bindir} properly.
-rw-r--r--Makefile.am7
-rw-r--r--configure.ac85
-rw-r--r--postgresql-check-db-dir.in4
-rw-r--r--postgresql-ctl.in2
-rw-r--r--postgresql-setup.in6
-rw-r--r--postgresql.service.in8
6 files changed, 36 insertions, 76 deletions
diff --git a/Makefile.am b/Makefile.am
index b575702..21d448a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,17 +28,14 @@ SUBDIRS = . doc tests
bin_SCRIPTS = $(setup)
libexec_SCRIPTS = $(ctl) $(checkdb)
-userunitsdir = /etc/systemd/system
+legacyscriptsdir = $(systemdlegacyscriptsdir)/$(NAME_SERVICE)
# TODO: Ideally, 'make distcheck' should check every file we generate.
if WANT_SYSVINIT
-initscriptsdir = $(sysconfdir)/rc.d/init.d
initscripts_DATA = $(initscript)
else
-systemdunitsdir = $(prefix)/lib/systemd/system
systemdunits_DATA = $(service) $(serviceat)
-systemdlegacyscriptsdir = $(libexecdir)/initscripts/legacy-actions/$(NAME_SERVICE)
-systemdlegacyscripts_SCRIPTS = initdb upgrade
+legacyscripts_SCRIPTS = initdb upgrade
endif
doc_DATA = $(README_DIST_BASENAME)
diff --git a/configure.ac b/configure.ac
index 5d31cb9..022c22a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,37 +36,42 @@ sed_subst_var_pattern(bindir)
sed_subst_var_pattern(docdir)
sed_subst_var_pattern(libdir)
sed_subst_var_pattern(libexecdir)
-sed_subst_var_pattern(PG_CTL_BIN)
sed_subst_var_pattern(top_srcdir)
sed_subst_var_pattern(pgcontribdocdir)
sed_subst_var_pattern(PGDATADIR)
sed_subst_var_pattern(pgdocdir)
-sed_subst_var_pattern(PGENGINE)
sed_subst_var_pattern(PGMAJORVERSION)
sed_subst_var_pattern(PG_UPGRADE_BIN_USER_OPT)
sed_subst_var_pattern(PGVERSION)
sed_subst_var_pattern(PKGCONFIG_DIR)
sed_subst_var_pattern(pkgname)
sed_subst_var_pattern(POSTGRES_HOMEDIR)
-sed_subst_var_pattern(PREVMAJORVERSION)
-sed_subst_var_pattern(PREVPGENGINE)
sed_subst_var_pattern(rawpkgdatadir)
sed_subst_var_pattern(README_DIST)
sed_subst_var_pattern(SU_POSTGRES)
sed_subst_var_pattern(sysconfdir)
-sed_subst_var_pattern(systemdunitsdir)
-sed_subst_var_pattern(userunitsdir)
sed_subst_var_pattern(TEST_GEN_FILES_LIST)
sed_subst_var_pattern(VERSION)"
m4_define([add_sed_subst_var], [
SED_RULES="$SED_RULES
sed_subst_var_pattern($1)"
+AC_SUBST($1)
+])
+
+m4_define([conf_dir], [dnl
+test -z "$$1" && $1=$2
+add_sed_subst_var($1)
])
SED_CALL="\$(SED) \$(SED_RULES)"
m4_pattern_allow(AM_V_GEN)
+conf_dir([systemdunitsdir], ['${prefix}/lib/systemd/system'])
+conf_dir([systemduserunitsdir], ['${prefix}/etc/systemd/system'])
+conf_dir([systemdlegacyscriptsdir], ['${libexecdir}/initscripts/legacy-actions'])
+conf_dir([initscriptsdir], ['${sysconfdir}/rc.d/init.d'])
+
INSTANTIATE_CONV="\$(AM_V_GEN)rm -rf \$@; \$(MKDIR_P) \$(@D)"
INSTANTIATE="\$(INSTANTIATE_CONV) && \$(SED_CALL) \$< > \$@ && chmod -w \$@"
INSTANTIATE_SCRIPT="\$(INSTANTIATE) && chmod +x \$@"
@@ -117,54 +122,8 @@ AX_COMPARE_VERSION([9.4], [le], [$PGVERSION],
[PG_UPGRADE_BIN_USER_OPT="--user"])
AC_SUBST([PG_UPGRADE_BIN_USER_OPT])
-# 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
-
-# pg_ctl binary
-test -z "$PG_CTL_BIN" &&
- PG_CTL_BIN=$PGENGINE/pg_ctl
-AC_SUBST([PG_CTL_BIN])
-
AC_PATH_PROG([PG_UPGRADE_BIN], [pg_upgrade])
-# Either the PREVMAJORVERSION must be passed explicitly, or per-distro
-# scripting must be done.
-if test -z "$PREVMAJORVERSION"; then
- 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)
- test -z "$ac_cv_path_PG_UPGRADE_BIN" &&
- AC_MSG_ERROR([pg_upgrade not found, plese \$PREVMAJORVERSION set])
-
- PREV_POSTGRES_BIN=$(rpm -ql \
- $(rpm -qf "$ac_cv_path_PG_UPGRADE_BIN") \
- | grep 'bin/postgres' )
-
- PREVMAJORVERSION=$(echo $PREV_POSTGRES_BIN \
- | sed 's/.*postgresql-\([[0-9\.]]\+\).*/\1/')
- ;;
- esac
- AC_MSG_RESULT($PREVMAJORVERSION)
-fi
-
-# Detect PREVPGENGINE
-if test -z "$PREVPGENGINE"; then
- if test -z "$PREV_POSTGRES_BIN"; then
- AC_MSG_ERROR([can not detect \$PREV_POSTGRES_BIN])
- fi
-
- PREVPGENGINE=`AS_DIRNAME($PREV_POSTGRES_BIN)`
-fi
-
if test -z "$PKGCONFIG_DIR" -a "$pgsetup_cv_os_family" = redhat; then
PKGCONFIG_DIR=/etc/postgresql
fi
@@ -174,7 +133,7 @@ if test -z "$POSTGRES_HOMEDIR" -a "$pgsetup_cv_os_family" = redhat; then
fi
if test -z "$PGDATADIR" -a "$pgsetup_cv_os_family" = redhat; then
- PGDATADIR=/var/lib/pgsql/data
+ PGDATADIR="\${prefix}/var/lib/pgsql/data"
fi
pgdocdir="\${datarootdir}/doc/\${pkgname}"
@@ -190,9 +149,6 @@ AC_SUBST([README_DIST_BASENAME])
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([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])
@@ -213,9 +169,18 @@ PGSETUP_SUBST_OPT([NAME_DEFAULT_PREV_SERVICE], [postgresql],
[name of service to upgrade from by default (defaults to
'postgresql'])
-PGSETUP_SUBST_OPT([INITDB_SCLS], [],
- [mention software collections which should be
- enabled for '--initdb' command])
+PGSETUP_SUBST_OPT([SCLS], [],
+ [mention software collections which should be enabled
+ for all binaries from ${bindir}])
+
+SCL_BINDIR=/usr/bin
+SCL_BINARY=scl
+SCL_SHELL_WRAPPER=
+if test -n "$SCLS"
+then
+ SCL_SHELL_WRAPPER="$SCL_BINDIR/$SCL_BINARY enable $SCLS -- "
+fi
+add_sed_subst_var(SCL_SHELL_WRAPPER)
NAME_BINARYBASE="$NAME_BIN_PFX""postgresql$NAME_BIN_SFX"
NAME_PACKAGE="$NAME_PKG_PFX""postgresql$NAME_PKG_SFX"
@@ -244,8 +209,6 @@ AC_MSG_NOTICE([Configured the folowing way:
PostgreSQL version: $PGVERSION
PGDATADIR: $PGDATADIR
- Upgrade from: $PREVMAJORVERSION
- PREV_POSTGRES_BIN: $PREV_POSTGRES_BIN
PostgreSQL service: $NAME_SERVICE
PostgreSQL package: $NAME_PACKAGE
PostgreSQL bin_pfx: $NAME_BINARYBASE
diff --git a/postgresql-check-db-dir.in b/postgresql-check-db-dir.in
index f8adc2d..fec7891 100644
--- a/postgresql-check-db-dir.in
+++ b/postgresql-check-db-dir.in
@@ -17,7 +17,7 @@ service_name="$1"
if [ -z "$PGDATA" ]; then
echo $"You try to start '$service_name' service"
echo $"but the required \$PGDATA environment variable is not set."
- echo $"You should use the @userunitsdir@/$service_name.service.d/ANYTHING.conf"
+ echo $"You should use the @systemduserunitsdir@/$service_name.service.d/ANYTHING.conf"
echo $"configuration file to set \$PGDATA. For more info see"
echo $"the @README_DIST@ file."
@@ -27,7 +27,7 @@ fi
# Warn the user that the configuration should be adjusted via drop-in, in case
# the $PGDATA variable is set different way (and non-default service name is
# used).
-conf_dir="@userunitsdir@/$service_name.service.d"
+conf_dir="@systemduserunitsdir@/$service_name.service.d"
if [[ "$service_name" == *@* ]] && test ! -d "$conf_dir"; then
echo >&2 $"WARNING: Note that the '$conf_dir'"
echo >&2 $"directory does not exist while you are using non-default service"
diff --git a/postgresql-ctl.in b/postgresql-ctl.in
index 1327b41..05bf60b 100644
--- a/postgresql-ctl.in
+++ b/postgresql-ctl.in
@@ -4,4 +4,4 @@
# postgresql.service. There is not possible to do conditional step in service
# file based on (non)existence of PGPORT variable.
-@PG_CTL_BIN@ "$@" ${PGPORT+-o "-p $PGPORT"}
+@bindir@/pg_ctl "$@" ${PGPORT+-o "-p $PGPORT"}
diff --git a/postgresql-setup.in b/postgresql-setup.in
index e1384cc..33021f5 100644
--- a/postgresql-setup.in
+++ b/postgresql-setup.in
@@ -7,7 +7,7 @@ test -z "$PATH" && export PATH="/sbin:/usr/sbin:/bin:/usr/bin"
test x"$PGSETUP_DEBUG" != x && set -x && PS4='${LINENO}: '
# Directory containing the postmaster executable
-PGENGINE=@PGENGINE@
+PGENGINE=@bindir@
# Distribution README file
README_DIST=@README_DIST@
@@ -25,7 +25,7 @@ PGPORT_DEF=5432
option_upgradefrom="@NAME_DEFAULT_PREV_SERVICE@"
# Space separated list of SCLS to be enabled during upgrade
-initdb_scls="@INITDB_SCLS@"
+initdb_scls="@SCLS@"
USAGE_STRING=$"\
Usage: $0 MODE_OPTION [--unit=UNIT_NAME] [OPTION...]
@@ -403,7 +403,7 @@ upgrade()
generate_systemd_dropin()
{
local service="$1"
- local dropindir="@userunitsdir@/$service.service.d"
+ local dropindir="@systemduserunitsdir@/$service.service.d"
local dropin="$dropindir/30-@NAME_BINARYBASE@-setup.conf"
test -e "$dropindir" \
diff --git a/postgresql.service.in b/postgresql.service.in
index 116675d..560114d 100644
--- a/postgresql.service.in
+++ b/postgresql.service.in
@@ -1,7 +1,7 @@
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. It is recommended to use systemd
# "dropin" feature; i.e. create file with suffix .conf under
-# @userunitsdir@/UNITNAME.service.d directory overriding the
+# @systemduserunitsdir@/UNITNAME.service.d directory overriding the
# unit's defaults. Look at systemd.unit(5) manual page for more info.
[Unit]
@@ -32,9 +32,9 @@ ExecStartPre=@libexecdir@/postgresql-check-db-dir %N
# Temporarily use postgresql-ctl wrapper around pg_ctl until there will
# exist clients which set PGPORT in service file.
-ExecStart=@libexecdir@/postgresql-ctl start -D ${PGDATA} -s -w -t 300
-ExecStop=/usr/bin/pg_ctl stop -D ${PGDATA} -s -m fast
-ExecReload=/usr/bin/pg_ctl reload -D ${PGDATA} -s
+ExecStart=@SCL_SHELL_WRAPPER@@libexecdir@/postgresql-ctl start -D ${PGDATA} -s -w -t 300
+ExecStop=@SCL_SHELL_WRAPPER@@bindir@/pg_ctl stop -D ${PGDATA} -s -m fast
+ExecReload=@SCL_SHELL_WRAPPER@@bindir@/pg_ctl reload -D ${PGDATA} -s
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300