summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2014-07-01 08:58:19 +0200
committerPavel Raiskup <praiskup@redhat.com>2014-07-01 09:46:37 +0200
commit00683dad1a27a49e99f4a28e3924e1c97b1b9594 (patch)
tree5199fa1034c14edf53fb7f2ffafe3ea3b44eac3a
parent3768b99c83410e9744f35494624f41f78e5ab867 (diff)
downloadpostgresql-setup-00683dad1a27a49e99f4a28e3924e1c97b1b9594.tar.gz
postgresql-setup-00683dad1a27a49e99f4a28e3924e1c97b1b9594.tar.xz
postgresql-setup-00683dad1a27a49e99f4a28e3924e1c97b1b9594.zip
postgresql-ctl, DISTSUFF: introduce
We need postgresql-ctl for to keep backward compatibility with clients setting "PGPORT" directly in service file. DISTSUFF variable (which is read by ./configure) may be used to generated namespaced binary names -- e.g. DISTSUFF=93 results in postgresql93-setup is generated instead of postgresql-setup. This commit also adjusts autotools build system to not generate scripts by ./configure, but rather by make.
-rw-r--r--.gitignore5
-rw-r--r--Makefile.am16
-rw-r--r--configure.ac9
-rw-r--r--doc/Makefile.am11
-rw-r--r--postgresql-ctl.in9
-rw-r--r--postgresql-setup.in2
6 files changed, 43 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index f195af0..904aec5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,7 +8,8 @@ configure
install-sh
missing
*.log
-postgresql-setup
INSTALL
-postgresql-setup.1
+postgresql*-setup
+postgresql*-ctl
+postgresql*-setup.1
*.tar.gz
diff --git a/Makefile.am b/Makefile.am
index c197a0c..d981ecc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,17 @@
SUBDIRS = . doc
-bin_SCRIPTS = postgresql-setup
+bin_SCRIPTS = postgresql$(DISTSUFF)-setup
+
+libexec_SCRIPTS = postgresql$(DISTSUFF)-ctl
+
+config_status = $(top_srcdir)/config.status
+
+postgresql$(DISTSUFF)-ctl: postgresql-ctl.in
+ $(AM_V_GEN)cmd="$(config_status) --file=$@:$<" ; \
+ if $(AM_V_P); then $$cmd; else $$cmd &>/dev/null; fi && chmod +x $@
+
+postgresql$(DISTSUFF)-setup: postgresql-setup.in
+ $(AM_V_GEN)cmd="$(config_status) --file=$@:$<" ; \
+ if $(AM_V_P); then $$cmd; else $$cmd &>/dev/null; fi && chmod +x $@
+
+CLEANFILES = $(bin_SCRIPTS) $(libexec_SCRIPTS)
diff --git a/configure.ac b/configure.ac
index c7eafb8..1a013ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,14 @@
AC_INIT([postgresql-setup], [0.9], [praiskup@redhat.com])
+AC_CONFIG_AUX_DIR(auxdir)
+config_aux_dir=auxdir
+AC_SUBST([config_aux_dir])
+
AM_INIT_AUTOMAKE([-Wall])
AC_CONFIG_FILES([Makefile doc/Makefile])
-AC_CONFIG_FILES([postgresql-setup], [chmod +x postgresql-setup])
+AM_SILENT_RULES([yes])
+
+AC_ARG_VAR([DISTSUFF], [Append string suffix to all binaries])
+AC_SUBST([DISTSUFF])
# For SELinux purposes use rather runuser
AC_PATH_PROG([SU], [runuser])
diff --git a/doc/Makefile.am b/doc/Makefile.am
index c099ad8..d1ed4e5 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,7 +1,10 @@
HELP2MAN = $(SHELL) $(top_srcdir)/$(config_aux_dir)/missing --run help2man
-dist_man_MANS = $(srcdir)/postgresql-setup.1
+man_MANS = $(srcdir)/postgresql$(DISTSUFF)-setup.1
-$(srcdir)/postgresql-setup.1: $(top_srcdir)/postgresql-setup.in
- @echo "Updating the man page '$@'"; \
- $(HELP2MAN) --output=$@ $(top_srcdir)/postgresql-setup -N
+# TODO: distribute also help2man
+
+$(srcdir)/postgresql$(DISTSUFF)-setup.1: $(top_srcdir)/postgresql-setup.in
+ $(AM_V_GEN)$(HELP2MAN) --output=$@ $(top_srcdir)/postgresql$(DISTSUFF)-setup -N
+
+CLEANFILES=$(man_MANS) $(srcdir)/*.1
diff --git a/postgresql-ctl.in b/postgresql-ctl.in
new file mode 100644
index 0000000..1fe9838
--- /dev/null
+++ b/postgresql-ctl.in
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# This script is compat-wrapper for PGPORT specifying directly in
+# postgresql.service. There is not possible to do conditional step in service
+# file based on (non)existence of PGPORT variable.
+
+PG_CTL=/usr/bin/pg_ctl
+
+$PG_CTL "$@" ${PGPORT+-o "-p $PGPORT"}
diff --git a/postgresql-setup.in b/postgresql-setup.in
index 6cd9893..bd96e09 100644
--- a/postgresql-setup.in
+++ b/postgresql-setup.in
@@ -81,7 +81,7 @@ debug() { test "$option_debug" = "1" && echo >&2 $"DEBUG: $@"; }
print_version()
{
- echo "@PACKAGE@ @VERSION@"
+ echo "postgresql@DISTSUFF@-setup @VERSION@"
echo $"Built against PostgreSQL version @PGMAJORVERSION@ and configured"
echo $"to upgrade from PostgreSQL version @PREVMAJORVERSION@."
}