[Pkg-ceph-commits] [ceph] 01/01: d/ceph-common.{preinst, postinst, postrm}: Ensure that rename of /etc/default/ceph/ceph -> /etc/default/ceph is handled correctly and that any end-user changes are preserved (LP: #1587516).
James Downing Page
jamespage at moszumanska.debian.org
Mon Jun 13 10:00:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
jamespage pushed a commit to branch ubuntu-xenial
in repository ceph.
commit e60a517a4ce621364153765a497a70480c7f19ce
Author: James Page <james.page at ubuntu.com>
Date: Mon Jun 13 10:57:03 2016 +0100
d/ceph-common.{preinst,postinst,postrm}: Ensure that rename of /etc/default/ceph/ceph -> /etc/default/ceph is handled correctly and that any end-user changes are preserved (LP: #1587516).
(cherry picked from commit b65513d8bcc4a63e91f72df1139693b36f849f04)
---
debian/ceph-common.postinst | 22 ++++++++++++++++++++++
debian/ceph-common.postrm | 16 +++++++++++++++-
debian/ceph-common.preinst | 26 ++++++++++++++++++++++++++
debian/changelog | 8 ++++++--
4 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/debian/ceph-common.postinst b/debian/ceph-common.postinst
index 020b89b..791b4a2 100644
--- a/debian/ceph-common.postinst
+++ b/debian/ceph-common.postinst
@@ -34,6 +34,22 @@ set -e
# Groups that the user will be added to, if undefined, then none.
[ -z "$SERVER_ADDGROUP" ] && SERVER_ADDGROUP=
+finish_mv_ceph_defaults() {
+ rm -rf "/etc/default/ceph.dpkg-remove"
+
+ [ -e "/etc/default/ceph/ceph" ] || return 0
+
+ echo "Preserving user changes to /etc/default/ceph (renamed from /etc/default/ceph/ceph)..."
+ if [ -f "/etc/default/ceph" ]; then
+ mv -f "/etc/default/ceph" "/etc/default/ceph.dpkg-new"
+ fi
+ # Move ceph default file via staging location to allow deletion
+ # of nested ceph directory
+ mv -f "/etc/default/ceph/ceph" "/etc/default/ceph.dpkg-staging"
+ rm -rf "/etc/default/ceph"
+ mv -f "/etc/default/ceph.dpkg-staging" "/etc/default/ceph"
+}
+
case "$1" in
configure)
# create user to avoid running server as root
@@ -80,6 +96,12 @@ case "$1" in
# create /run/ceph. fail softly if systemd isn't present or
# something.
[ -x /bin/systemd-tmpfiles ] && systemd-tmpfiles --create || true
+
+ # Complete renames of /etc/default/ceph
+ if [ -n "$2" ] &&
+ dpkg --compare-versions -- "$2" le-nl 10.2.1-0ubuntu1; then
+ finish_mv_ceph_defaults
+ fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
:
diff --git a/debian/ceph-common.postrm b/debian/ceph-common.postrm
index 6d4fa5e..25769c5 100644
--- a/debian/ceph-common.postrm
+++ b/debian/ceph-common.postrm
@@ -19,6 +19,13 @@ set -e
# the debian-policy package
+abort_mv_ceph_defaults() {
+ if [ -e "/etc/default/ceph.dpkg-remove" ]; then
+ echo "Reinstalling /etc/default/ceph/ceph that was moved away"
+ mv "/etc/default/ceph.dpkg-remove" "/etc/default/ceph"
+ fi
+}
+
case "$1" in
remove)
;;
@@ -28,7 +35,14 @@ case "$1" in
rm -rf /etc/ceph
;;
- upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+ abort-install|abort-upgrade)
+ if [ -n "$2" ] &&
+ dpkg --compare-versions -- "$2" le-nl 10.2.1-0ubuntu1; then
+ abort_mv_ceph_defaults
+ fi
+ ;;
+
+ upgrade|failed-upgrade|disappear)
;;
*)
diff --git a/debian/ceph-common.preinst b/debian/ceph-common.preinst
new file mode 100644
index 0000000..c56a850
--- /dev/null
+++ b/debian/ceph-common.preinst
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+
+prepare_mv_ceph_defaults() {
+ local md5sum old_md5sum
+ md5sum="$(md5sum "/etc/default/ceph/ceph" | sed -e 's/ .*//')"
+ old_md5sum="$(dpkg-query -W -f='${Conffiles}' "ceph-common" | \
+ sed -n -e "\'^ /etc/default/ceph/ceph ' { s/ obsolete$//; s/.* //; p }")"
+ if [ "$md5sum" = "$old_md5sum" ]; then
+ mv -f "/etc/default/ceph" "/etc/default/ceph.dpkg-remove"
+ fi
+}
+
+case "$1" in
+ upgrade|install)
+ if [ -d /etc/default/ceph ] && [ -n "$2" ] &&
+ dpkg --compare-versions -- "$2" le-nl 10.2.1-0ubuntu1; then
+ prepare_mv_ceph_defaults
+ fi
+ ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/changelog b/debian/changelog
index eaee189..6b64968 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,12 @@ ceph (10.2.1-0ubuntu0.16.04.1) UNRELEASED; urgency=medium
* New upstream stable release (LP: #1585660).
- d/p/drop-user-group-osd-prestart.patch: Dropped, included upstream.
- * d/rules,ceph-common.install: Ensure that /etc/default/ceph is a file
- and not a directory (LP: #1587516).
+ * Rename /etc/default/ceph/ceph -> /etc/default/ceph (LP: #1587516):
+ - d/rules,ceph-common.install: Ensure that /etc/default/ceph is a file
+ and not a directory.
+ - d/ceph-common.{preinst,postinst,postrm}: Ensure that rename of
+ /etc/default/ceph/ceph -> /etc/default/ceph is handled correctly
+ and that any end-user changes are preserved.
-- James Page <james.page at ubuntu.com> Wed, 25 May 2016 15:29:41 +0100
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ceph/ceph.git
More information about the Pkg-ceph-commits
mailing list