Control: retitle 853016 nodm: regression: restarts during upgrade, causing data 
loss

(Retitling bug to something more prosaic.)

On Sun, 29 Jan 2017 at 06:06:58 +0800, 積丹尼 Dan Jacobson wrote:
> Upon reaching nodm, the entire X-windows is lost and the user thinks the
> computer has rebooted and all his work in other windows is lost.

On Sun, 03 Mar 2019 at 14:47:57 +0000, Mike Gabriel wrote:
> Please, can you possibly help finding a ptach for this issue?

This appears to have been a regression when raising the debhelper compat
level from 9 to 12 in 0.13-3. Each debhelper compat level causes some
incompatible behaviour changes, which is why the compat level mechanism
exists (so that maintainers can opt-in to the new behaviour at a time
that is convenient to make the necessary packaging changes).

In particular, the behaviour of dh_installinit changed in compat level 10
(see #837528 for some discussion of this), and the relationship between
dh_installinit and dh_installsystemd changed in compat level 12.

The attached patches, also available as
<https://salsa.debian.org/debian/nodm/merge_requests/2>, seem to be
enough. Note that patches 0001 and 0002 are both necessary to fix this
on machines that boot with systemd: the change in 0001 should have been
applied on moving from debhelper compat level 9 to 10, and the change
in 0002 is for the move from debhelper compat level 11 to 12.

Patch 0003 fixes a related bug caused by the move to debhelper compat
level 12, which is arguably also RC (a missing dependency), and patch
0004 is a "would be nice" feature related to this bug (copied from dbus,
which also isn't safe to restart).

Regards,
    smcv
>From 59cd62ef18a458e73a6e0f20d7140cf56a8d210c Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Tue, 12 Mar 2019 09:55:34 +0000
Subject: [PATCH 1/5] d/rules: Don't restart nodm if using sysvinit

In debhelper compat levels up to 10, dh_installinit would normally stop
the service in prerm and start it again in postinst, with the former
possible to disable via the -r option. Since compat level 11, the
default behaviour is to restart the service in postinst for reduced
downtime, and this is not disabled by -r: we have to specify
the new --no-restart-after-upgrade option.

See also #837528.

Fixes: af32a593
---
 debian/rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index 667709f..37bcf23 100755
--- a/debian/rules
+++ b/debian/rules
@@ -21,7 +21,7 @@ override_dh_auto_test:
 	#make check
 
 override_dh_installinit:
-	dh_installinit -r -- defaults
+	dh_installinit -r --no-restart-after-upgrade -- defaults
 
 get-orig-source:
 	uscan --noconf --force-download --rename --download-current-version --destdir=..
-- 
2.20.1

>From a9901e3598e97f090f08bd67c109a543439e49c3 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Tue, 12 Mar 2019 09:17:33 +0000
Subject: [PATCH 2/5] d/rules: Don't restart nodm if using systemd init

In debhelper compat levels up to 11, systemd services that have a
corresponding LSB init script were handled by dh_installinit.
In compat level 12, dh_installsystemd takes over responsibility for
these services, so overriding dh_installinit is no longer sufficient to
prevent the systemd unit from being restarted after upgrade:

    If you have an override for dh_installinit (e.g. to call it with
    --no-start) then you will probably need one for dh_installsystemd
    as well now.
    -- debhelper(7)

In combination with the previous commit (which fixed the sysvinit code
path), this stops nodm from restarting and ending the user's graphical
login session (#853016)

Closes: #853016
Fixes: af32a593
---
 debian/rules | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/debian/rules b/debian/rules
index 37bcf23..fc924e9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -23,5 +23,8 @@ override_dh_auto_test:
 override_dh_installinit:
 	dh_installinit -r --no-restart-after-upgrade -- defaults
 
+override_dh_installsystemd:
+	dh_installsystemd -r --no-restart-after-upgrade
+
 get-orig-source:
 	uscan --noconf --force-download --rename --download-current-version --destdir=..
-- 
2.20.1

>From a6f0b9d6575d31645a1a578adc04a3cd02863fcd Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Tue, 12 Mar 2019 09:19:23 +0000
Subject: [PATCH 3/5] d/control: Add missing ${misc:Pre-Depends}

In compat level 12, dh_installsystemd uses this substitution to generate
its required Pre-Depends on init-system-helpers (>= 1.54~).

Fixes: af32a593
---
 debian/control | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/debian/control b/debian/control
index c78f35c..e6caa82 100644
--- a/debian/control
+++ b/debian/control
@@ -22,6 +22,8 @@ Homepage: https://github.com/spanezz/nodm/
 
 Package: nodm
 Architecture: linux-any
+Pre-Depends:
+ ${misc:Pre-Depends},
 Depends:
  lsb-base,
  x11-common,
-- 
2.20.1

>From 6e1b4695165f724e6f95f9a0f71eebe542759659 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Tue, 12 Mar 2019 09:22:22 +0000
Subject: [PATCH 4/5] postinst: Create reboot-required flag file

This is used by packages like dbus that cannot be restarted without a
reboot. Some apt frontends monitor this file, and recommend rebooting the
system (at a more convenient time for the user) when it is created.
nodm can't restart itself without ending the user's GUI session, so the
same mechanism seems appropriate.
---
 debian/nodm.postinst | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/debian/nodm.postinst b/debian/nodm.postinst
index 05d0154..68511c8 100644
--- a/debian/nodm.postinst
+++ b/debian/nodm.postinst
@@ -133,4 +133,8 @@ fi
 # tell debconf we are done. otherwise, it hangs waiting for the daemon.
 db_stop;
 
+if [ "$1" = configure ] && [ -n "$2" ]; then
+	touch /var/run/reboot-required || true
+fi
+
 exit 0
-- 
2.20.1

>From 0c22c3f7dd8a44152c4ea8a9dc2d121dd5f416ff Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Tue, 12 Mar 2019 09:22:54 +0000
Subject: [PATCH 5/5] Update changelog

---
 debian/changelog | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index c34ee8e..26421f3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+nodm (0.13-4.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload
+  * d/rules: Don't restart nodm, fixing regressions from the move to
+    debhelper compat level 12 (Closes: #853016)
+  * d/control: Add missing ${misc:Pre-Depends} needed in compat level 12
+  * postinst: Create reboot-required flag file to notify apt frontends
+    that the user should reboot when convenient
+
+ -- Simon McVittie <s...@debian.org>  Tue, 12 Mar 2019 09:57:07 +0000
+
 nodm (0.13-4) unstable; urgency=medium
 
   * debian/po:
-- 
2.20.1

Reply via email to