[Pkg-openldap-devel] [openldap] 01/02: Dump databases in prerm (#665199)
Ryan Tandy
rtandy-guest at moszumanska.debian.org
Mon Apr 17 03:24:28 UTC 2017
This is an automated email from the git hooks/post-receive script.
rtandy-guest pushed a commit to branch master
in repository openldap.
commit 198e3fc678b7a3663b11549c4cf9b7060b6e514c
Author: Ryan Tandy <ryan at nardis.ca>
Date: Sat Apr 8 09:46:44 2017 -0700
Dump databases in prerm (#665199)
---
debian/changelog | 3 +++
debian/slapd.preinst | 12 +++++++++++-
debian/slapd.prerm | 23 +++++++++++++++++++++++
debian/slapd.scripts-common | 4 ++++
4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index d0d5cfe..fccb6b8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -36,6 +36,9 @@ openldap (2.4.44+dfsg-4) UNRELEASED; urgency=medium
the expected time during build. (Closes: #854158)
* Update Portuguese debconf translation. (Closes: #859943)
Thanks to Rui Branco and DebianPT.
+ * Dump the configuration and databases to LDIF before removing slapd, so
+ that they are available if a newer version requiring migration is
+ installed later. (Closes: #665199)
-- Ryan Tandy <ryan at nardis.ca> Sun, 08 Jan 2017 12:39:19 -0800
diff --git a/debian/slapd.preinst b/debian/slapd.preinst
index b9cc540..21367de 100755
--- a/debian/slapd.preinst
+++ b/debian/slapd.preinst
@@ -94,13 +94,23 @@ preinst_check_config() { # {{{
# }}}
# If we are upgrading from an old version then stop slapd and attempt to
-# slapcat out the data so we can use it in postinst to do the upgrade
+# slapcat out the data so we can use it in postinst to do the upgrade.
+# If slapd was removed and is being reinstalled, slapcat is not
+# available at this time, so the data should have been dumped before the
+# old slapd was removed.
if [ "$MODE" = upgrade ]; then
dump_config
+fi
+
+if [ "$MODE" = upgrade ] || [ "$MODE" = install -a -n "$OLD_VERSION" ]; then
+ # Do not assume slapcat is available in this phase
if [ -d "$SLAPD_CONF" ]; then
preinst_check_config
fi
+fi
+
+if [ "$MODE" = upgrade ]; then
dump_databases
fi
diff --git a/debian/slapd.prerm b/debian/slapd.prerm
index 075342a..ce7d281 100755
--- a/debian/slapd.prerm
+++ b/debian/slapd.prerm
@@ -4,8 +4,31 @@ set -e
. /usr/share/debconf/confmodule
+# This will be replaced with debian/slapd.scripts-common which includes
+# various helper functions and $OLD_VERSION and $SLAPD_CONF
+#SCRIPTSCOMMON#
+
#DEBHELPER#
+# Dump config and data to LDIF before removing slapd.
+# If a later version is reinstalled without being purged first, the LDIF
+# files may be required for the upgrade, and the old slapcat won't be
+# available any more.
+# During an upgrade, the new preinst will be in a better position to
+# control whether dumping is needed.
+
+# If the config is badly broken, slapcat may fail, but this should not
+# prevent the package from being removed or purged.
+set +e
+
+if [ "$MODE" = remove ]; then
+ # scripts-common sets OLD_VERSION incorrectly for remove
+ OLD_VERSION="$(dpkg-query -W -f '${Version}' slapd)"
+
+ dump_config
+ dump_databases
+fi
+
exit 0
# vim: set foldmethod=marker:
diff --git a/debian/slapd.scripts-common b/debian/slapd.scripts-common
index 7160d67..2af6a88 100644
--- a/debian/slapd.scripts-common
+++ b/debian/slapd.scripts-common
@@ -22,6 +22,10 @@ database_dumping_enabled() { # {{{
# Return success if yes.
# Usage: if database_dumping_enabled; then ... fi
+ # If the package is being removed, dump unconditionally as we
+ # don't know whether the next version will require reload.
+ [ "$MODE" = remove ] && return 0
+
db_get slapd/dump_database
case "$RET" in
always)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openldap/openldap.git
More information about the Pkg-openldap-devel
mailing list