[debhelper-devel] Bug#805878: dh-systemd: dh_systemd_start --no-start --restart-after-upgrade causes the service to be started on install
Felipe Sateler
fsateler at debian.org
Sun Oct 9 20:26:10 UTC 2016
Control: tags -1 patch
On 23 November 2015 at 11:34, Felipe Sateler <fsateler at debian.org> wrote:
> Package: dh-systemd
> Version: 1.24
> Severity: normal
>
> Current autoscript has:
>
> if [ -d /run/systemd/system ]; then
> systemctl --system daemon-reload >/dev/null || true
> if [ -n "$2" : ]; then
> _dh_action=try-restart
> else
> _dh_action=start
> fi
> deb-systemd-invoke $_dh_action #UNITFILES# >/dev/null || true
> fi
>
>
> And this does not take into account that --no-start was passed. If it
> was passed, then try-restart should always be used.
This is more problematic now that restart-on-upgrade is default. The
following patch fixes the issue:
diff --git a/autoscripts/postinst-systemd-restartnostart
b/autoscripts/postinst-systemd-restartnostart
index e69de29..eb52e27 100644
--- a/autoscripts/postinst-systemd-restartnostart
+++ b/autoscripts/postinst-systemd-restartnostart
@@ -0,0 +1,6 @@
+if [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload >/dev/null || true
+ if [ -n "$2" ]; then
+ deb-systemd-invoke try-restart #UNITFILES# >/dev/null || true
+ fi
+fi
diff --git a/dh_systemd_start b/dh_systemd_start
index 940fc80..46c14a7 100755
--- a/dh_systemd_start
+++ b/dh_systemd_start
@@ -225,7 +225,8 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
};
if ($dh{RESTART_AFTER_UPGRADE}) {
- $sd_autoscript->("postinst", "postinst-systemd-restart");
+ my $snippet = "postinst-systemd-restart" . ($dh{NO_START} ? "nostart" : "");
+ $sd_autoscript->("postinst", $snippet);
} elsif (!$dh{NO_START}) {
# We need to stop/start before/after the upgrade.
$sd_autoscript->("postinst", "postinst-systemd-start");
--
Saludos,
Felipe Sateler
More information about the debhelper-devel
mailing list