Package: kdump-tools
Followup-For: Bug #877250

Here is a patch for the issue.
commit effbf6dcdd75f3f127dee72c8817ffd17c50e931
Author: Thadeu Lima de Souza Cascardo <casca...@debian.org>
Date:   Fri Oct 20 12:18:52 2017 -0200

    Add ucf support
    
    /etc/default/kdump-tools was already changed by the maintainer script,
    so it should not be a conffile. ucf allows the maintainer scripts to ask
    the user about changes done by the user to the config file.
    
    Invoking debconf first in the script is desired, because the frontend
    might exec and invoke the script itself again. Also, we install the
    generated file instead of the original file, as we will replace some of
    the settings.
    
    Signed-off-by: Thadeu Lima de Souza Cascardo <casca...@debian.org>

diff --git a/debian/control b/debian/control
index c44cb0c..06159f4 100644
--- a/debian/control
+++ b/debian/control
@@ -22,7 +22,7 @@ Description: VMcore extraction tool
 Package: kdump-tools
 Architecture: i386 amd64 powerpc ia64 x32 arm64 armel armhf ppc64el s390x
 Depends: ${shlibs:Depends}, ${misc:Depends}, ${dist:Depends}, makedumpfile,
-         debconf, bsdmainutils, lsb-base (>= 3.0-6), file
+         debconf, bsdmainutils, lsb-base (>= 3.0-6), file, ucf
 Description: scripts and tools for automating kdump (Linux crash dumps)
  kdump-tools provides an init script and a configuration script for
  automating the use of kdump.  It uses the makedumpfile utility to
diff --git a/debian/kdump-tools.default b/debian/kdump-tools.conf
similarity index 100%
rename from debian/kdump-tools.default
rename to debian/kdump-tools.conf
diff --git a/debian/kdump-tools.install b/debian/kdump-tools.install
index 86ef7e4..fd3dc6d 100644
--- a/debian/kdump-tools.install
+++ b/debian/kdump-tools.install
@@ -1 +1,2 @@
 debian/kdump-config    /usr/sbin
+debian/kdump-tools.conf /usr/share/kdump-tools/
diff --git a/debian/kdump-tools.postinst b/debian/kdump-tools.postinst
index 8ea7108..9183180 100755
--- a/debian/kdump-tools.postinst
+++ b/debian/kdump-tools.postinst
@@ -3,6 +3,7 @@
 set -e
 
 update_param() {
+       . $INITCONFFILE
         eval old=\"'$'$1\"
         eval new=\"'$'new_$1\"
 
@@ -32,8 +33,20 @@ update_param() {
 
 case "$1" in
     configure)
-        # create smaller initrd.img files for kdump use
-            /etc/kernel/postinst.d/kdump-tools $(uname -r) > /dev/null 2>&1
+# ------------------------- Debconf questions start ---------------------
+       # Handle debconf
+       . /usr/share/debconf/confmodule
+       db_get kdump-tools/use_kdump || RET=true
+       if [ "${RET}" = "true" ]; then
+               new_USE_KDUMP="1"
+       else
+               new_USE_KDUMP="0"
+       fi
+# ------------------------- Debconf questions end ---------------------
+
+       INITCONFFILE=`mktemp /etc/default/kdump-tools.XXXXXX`
+       cp -pf /usr/share/kdump-tools/kdump-tools.conf $INITCONFFILE
+       update_param USE_KDUMP
 
        # Customize crashkernel= value according to architecture
        ARCH="$(arch)"
@@ -45,14 +58,19 @@ case "$1" in
                                sed -i "/parameters/{s|\"$| 
crashkernel=${DEF_PRESET}\"|}" /etc/zipl.conf
                                zipl
                        fi
-                       HAS_CIO="$(grep cio_ignore /etc/default/kdump-tools)" 
|| true
-                       if test -z "$HAS_CIO"; then
-                               CIO_IGNORE="$(cio_ignore -u -k)"
-                               sed -i 
"s/\#KDUMP_CMDLINE_APPEND/KDUMP_CMDLINE_APPEND/" /etc/default/kdump-tools
-                               sed -i "/KDUMP_CMDLINE_APPEND/{s|\"$| 
${CIO_IGNORE}\"|}" /etc/default/kdump-tools
-                       fi
+                       CIO_IGNORE="$(cio_ignore -u -k)"
+                       sed -i "s/\#KDUMP_CMDLINE_APPEND/KDUMP_CMDLINE_APPEND/" 
$INITCONFFILE
+                       sed -i "/KDUMP_CMDLINE_APPEND/{s|\"$| 
${CIO_IGNORE}\"|}" $INITCONFFILE
                ;;
        esac
+
+       ucfr kdump-tools /etc/default/kdump-tools
+       UCF_FORCE_CONFFMISS=1 ucf --debconf-ok $INITCONFFILE 
/etc/default/kdump-tools
+       rm -f $INITCONFFILE
+       sync /etc/default/kdump-tools
+
+        # create smaller initrd.img files for kdump use
+       /etc/kernel/postinst.d/kdump-tools $(uname -r) > /dev/null 2>&1
     ;;
 
     abort-upgrade|abort-remove|abort-deconfigure)
@@ -65,27 +83,10 @@ case "$1" in
     ;;
 esac
 
-# Handle debconf
-. /usr/share/debconf/confmodule
-
-INITCONFFILE=/etc/default/kdump-tools
-
-# ------------------------- Debconf questions start ---------------------
-
-db_get kdump-tools/use_kdump || RET=true
-if [ "${RET}" = "true" ]; then
-        new_USE_KDUMP="1"
-else
-        new_USE_KDUMP="0"
-fi
-update_param USE_KDUMP
-
-# ------------------------- Debconf questions end ---------------------
 if [ -x /usr/sbin/update-grub ] && [ -e /boot/grub/grub.cfg ]; then
        update-grub
 fi
 
-
 # dh_installdeb will replace this with shell code automatically
 # generated by other debhelper scripts.
 
diff --git a/debian/kdump-tools.postrm b/debian/kdump-tools.postrm
index b8921f4..1f078af 100755
--- a/debian/kdump-tools.postrm
+++ b/debian/kdump-tools.postrm
@@ -21,6 +21,14 @@ case "$1" in
               ;;
        purge)
                rm -rf /var/lib/kdump
+               if which ucf > /dev/null 2>&1; then
+                       ucf --purge /etc/default/kdump-tools
+                       ucfr -p kdump-tools /etc/default/kdump-tools
+               fi
+               rm -f /etc/default/kdump-tools
+               for i in new old dist; do
+                       rm -f /etc/default/kdump-tools.ucf-$i
+               done
               ;;
 esac
 

Reply via email to