Ubuntu Pastebin

Paste from jamespage at Mon, 13 Jun 2016 10:30:12 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
diff --git a/debian/ceph-common.postinst b/debian/ceph-common.postinst
index 020b89b..246249d 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=
 
+# Custom dpkg-maintscript-helper type function to deal with
+# nested /etc/default/ceph/ceph
+finish_mv_ceph_defaults() {
+    rm -rf "/etc/default/ceph.dpkg-old/ceph.dpkg-remove"
+
+    [ -e "/etc/default/ceph.dpkg-old/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
+    # Preserve /etc/default/ceph directory just in case users
+    # have added additional files to it.
+    mv -f "/etc/default/ceph.dpkg-old/ceph" "/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..3277de6 100644
--- a/debian/ceph-common.postrm
+++ b/debian/ceph-common.postrm
@@ -19,6 +19,16 @@ set -e
 # the debian-policy package
 
 
+# Custom dpkg-maintscript-helper type function to deal with
+# nested /etc/default/ceph/ceph
+abort_mv_ceph_defaults() {
+    if [ -e "/etc/default/ceph.dpkg-old/ceph.dpkg-remove" ]; then
+        echo "Reinstalling /etc/default/ceph/ceph that was moved away"
+        mv "/etc/default/ceph.dpkg-old" "/etc/default/ceph"
+        mv "/etc/default/ceph/ceph.dpkg-remove" "/etc/default/ceph/ceph"
+    fi
+}
+
 case "$1" in
     remove)
     ;;
@@ -28,7 +38,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..51e3800
--- /dev/null
+++ b/debian/ceph-common.preinst
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -e
+
+# Custom dpkg-maintscript-helper type function to deal with
+# nested /etc/default/ceph/ceph
+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/ceph" "/etc/default/ceph/ceph.dpkg-remove"
+        mv -f "/etc/default/ceph" "/etc/default/ceph.dpkg-old"
+    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 7844be1..28357a2 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+ceph (10.2.1-0ubuntu2) UNRELEASED; urgency=medium
+
+  * 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 Page <james.page@ubuntu.com>  Mon, 13 Jun 2016 10:55:26 +0100
+
 ceph (10.2.1-0ubuntu1) yakkety; urgency=medium
 
   * New upstream version (LP: #1585660).
Download as text