Commit d349d211 authored by Christoph Berg's avatar Christoph Berg

* Replace the static logrotate configuration by generating the file

  dynamically using ucf, triggered by watching /usr/sbin/logrotate.
  This eases dist-upgrades that upgrade logrotate to >= 3.8 from an older
  version (squeeze->wheezy, precise->trusty).
* postgresql-common.postinst: Stop debconf later so ucf can use it.
parent 6a76101a
postgresql-common (153) UNRELEASED; urgency=medium
* Replace the static logrotate configuration by generating the file
dynamically using ucf, triggered by watching /usr/sbin/logrotate.
This eases dist-upgrades that upgrade logrotate to >= 3.8 from an older
version (squeeze->wheezy, precise->trusty).
* postgresql-common.postinst: Stop debconf later so ucf can use it.
* t/020_create_sql_remove.t: Make pipe writes unbuffered.
-- Christoph Berg <christoph.berg@credativ.de> Thu, 09 Jan 2014 12:49:19 +0100
......
......@@ -18,10 +18,10 @@ Depends: postgresql-client-common (>= ${source:Version}),
debconf (>= 0.5.00) | debconf-2.0,
lsb-base (>= 3.0-3),
ssl-cert (>= 1.0.11),
ucf,
${misc:Depends}
Recommends: logrotate
Breaks: postgresql-9.1 (<< 9.1.1-3~),
${common-breaks}
Breaks: postgresql-9.1 (<< 9.1.1-3~)
Description: PostgreSQL database-cluster manager
The postgresql-common package provides a structure under which
multiple versions of PostgreSQL may be installed and/or multiple
......
......@@ -6,4 +6,5 @@
compress
notifempty
missingok
su root root
}
debian/01autoremove-postgresql etc/apt/apt.conf.d
debian/init.d-functions usr/share/postgresql-common
debian/logrotate.template usr/share/postgresql-common
pg_lsclusters usr/bin
pg_createcluster usr/bin
pg_dropcluster usr/bin
......
......@@ -2,10 +2,27 @@
set -e
. /usr/share/debconf/confmodule
db_stop
SSL_ROOT=/etc/postgresql-common/root.crt
setup_logrotate ()
{
LRVERSION=$(dpkg-query -f '${Version}' --show logrotate 2> /dev/null) || return
[ "$LRVERSION" ] || return 0
LRTEMPLATE="/usr/share/postgresql-common/logrotate.template"
LRCONFIG="/etc/logrotate.d/postgresql-common"
if dpkg --compare-versions "$LRVERSION" ge 3.8; then
LRCONFSRC=$LRTEMPLATE
else
LRCONFSRC=`mktemp --tmpdir postgresql-common.XXXXXX`
trap "rm -f $LRCONFSRC" 0 2 3 15
sed -e '/ su /d' $LRTEMPLATE > $LRCONFSRC
chmod 644 $LRCONFSRC
fi
ucf --debconf-ok $LRCONFSRC $LRCONFIG
ucfr postgresql-common $LRCONFIG
}
if [ "$1" = configure ]; then
# Make sure the administrative user exists
if ! getent passwd postgres > /dev/null; then
......@@ -83,15 +100,22 @@ EOF
/usr/share/postgresql-common/pg_checksystem || true
# Create logrotate config
setup_logrotate
if dpkg --compare-versions "$2" lt 94; then
pg_updatedicts || true
fi
fi
if [ "$1" = triggered ]; then
setup_logrotate
pg_updatedicts || true
db_stop
exit 0 # skip daemon restart below
fi
db_stop
#DEBHELPER#
......@@ -16,6 +16,15 @@ if [ "$1" = purge ]; then
[ -d /etc/postgresql-common ] && rmdir --ignore-fail-on-non-empty /etc/postgresql-common || true
rm -rf /var/cache/postgresql
LRCONFIG="/etc/logrotate.d/postgresql-common"
if which ucf >/dev/null; then
ucf --purge $LRCONFIG
fi
if which ucfr >/dev/null; then
ucfr --purge postgresql-common $LRCONFIG
fi
rm -f $LRCONFIG $LRCONFIG.ucf-*
fi
#DEBHELPER#
......
interest /usr/share/myspell/dicts
interest /usr/share/hunspell
interest /usr/sbin/logrotate
......@@ -16,16 +16,12 @@ endif
SUPPORTED_VERSIONS := $(shell PG_SUPPORTED_VERSIONS="$(FLAVOR)" debian/supported-versions)
DEFAULT_VER := $(lastword $(SUPPORTED_VERSIONS))
LOGROTATE_VER := $(shell LC_ALL=C apt-cache policy logrotate | awk '/Candidate:/ { print $$2 }')
LOGROTATE38 := $(shell dpkg --compare-versions $(LOGROTATE_VER) ge 3.8 && echo yes)
%:
dh "$@"
version_info:
@echo "### Building postgresql-common flavor $(FLAVOR)"
@echo "### Supported PostgreSQL versions: $(SUPPORTED_VERSIONS) (default version: $(DEFAULT_VER))"
@echo "### Logrotate version: $(LOGROTATE_VER), is >= 3.8: $(LOGROTATE38)"
build build-arch build-indep: version_info
override_dh_install:
......@@ -49,12 +45,6 @@ override_dh_gencontrol:
dh_gencontrol -ppostgresql -ppostgresql-client -ppostgresql-doc -ppostgresql-contrib -- \
-Vdefault-version="$(DEFAULT_VER)" -v'$(DEFAULT_VER)+$${source:Version}'
ifeq ($(LOGROTATE38),yes)
dh_gencontrol -ppostgresql-common -- -Vcommon-breaks="logrotate (<< 3.8)"
else
dh_gencontrol -ppostgresql-common -- -Vcommon-breaks="logrotate (>= 3.8)"
endif
ifeq ($(FLAVOR),pgdg)
# for apt.postgresql.org builds, pull in the repository key package
dh_gencontrol -ppostgresql-client-common -- -Vpgdg:Depends="pgdg-keyring"
......@@ -62,15 +52,6 @@ endif
dh_gencontrol --remaining-packages
override_dh_installlogrotate:
dh_installlogrotate
ifeq ($(LOGROTATE38),yes)
# logrotate >= 3.8 requires an additional "su" command which is not
# backportable, see #640493
echo "Fixing logrotate configuration for logrotate >= 3.8..."
sed -i '/^}/ i\ su root root' debian/postgresql-common/etc/logrotate.d/*
endif
override_dh_clean:
dh_clean
for p in $(POD1PROGS) $(POD1PROGS_POD); do rm -f $$p.1 || exit 1; done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment