Bug#877250: conffile /etc/default/kdump-tools changed by maintainer scripts

2017-11-01 Thread Louis Bouchard
Hello Thadeu,

Le 24/10/2017 à 16:30, Thadeu Lima de Souza Cascardo a écrit :
> Package: kdump-tools
> Followup-For: Bug #877250
>
> Here is a patch for the issue.

Thank you very much for your patch !

Now that I've sorted out my GPG worries, I'll be able to include your
patch and upload a new version, so makedumpfile doesn't get dropped out
of testing.

Kind regards,

...Louis



Bug#877250: conffile /etc/default/kdump-tools changed by maintainer scripts

2017-10-24 Thread Thadeu Lima de Souza Cascardo
Package: kdump-tools
Followup-For: Bug #877250

Here is a patch for the issue.
commit effbf6dcdd75f3f127dee72c8817ffd17c50e931
Author: Thadeu Lima de Souza Cascardo 
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 

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.XX`
+   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

Bug#877250: conffile /etc/default/kdump-tools changed by maintainer scripts

2017-10-13 Thread Louis Bouchard
Hello,

I based my change on the kexec prompting, but I now realise that kexec
doesn't touch a conffile.

I'm split between your suggestion of using a template (more complex) and
simply leaving the file as a conffile and making it enabled by default
which is closer to what is expected from a package which should be ready
to be used one installed.

Any suggestion ?

Kind regards,

...Louis



Bug#877250: conffile /etc/default/kdump-tools changed by maintainer scripts

2017-09-29 Thread Thadeu Lima de Souza Cascardo
Package: kdump-tools
Version: 1:1.6.2-0.1
Severity: serious

Per Debian Policy, a conffile must not be modified by a maintainer
script. We should make /etc/default/kdump-tools not be a conffile
anymore, and create it during the installation.

We will probably need to do something with dpkg-maintscript-helper in
some upgrade/removal cases, have a template/base file in
/usr/share/kdump-tools/ that we use.

As an additional requirement, as kdump-tools is usually tested by
crashing the system after it's installed, the maintainer scripts should
sync/fsync the files it touches.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, armhf

Kernel: Linux 4.11.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages kdump-tools depends on:
ii  bsdmainutils 9.0.12+nmu1
ii  debconf  1.5.63
ii  file 1:5.32-1
ii  init-system-helpers  1.49
ii  kexec-tools  1:2.0.15-1
ii  lsb-base 9.20170808
ii  makedumpfile 1:1.6.2-0.1

kdump-tools recommends no packages.

kdump-tools suggests no packages.

-- debconf information:
* kdump-tools/use_kdump: true