summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@debian.org>2013-07-24 20:09:57 +0200
committerMichael Stapelberg <michael@stapelberg.de>2013-07-24 20:12:43 +0200
commit23b7a3dd33cb9ba5249c571572f7b5abda49104e (patch)
treed77364f0cd2c47bb727e718b958826f3e478f58b
parent237da59d8db54048cb4c2aee5ae09abfeeebbfe8 (diff)
downloadinit-system-helpers-23b7a3dd33cb9ba5249c571572f7b5abda49104e.tar.gz
dh_systemd_enable: deal with changes in the [Install] section
autoscripts/postinst-systemd-dont-enable now uses update-state instead of enable/disable which fixes accidental re-disabling of services. Both autoscripts call enable to create new symlinks, if necessary. Both autoscripts call update-state in case the service is not enabled in order to update the state file so that all service files will be removed on purge. See also http://bugs.debian.org/#717603
-rw-r--r--autoscripts/postinst-systemd-dont-enable15
-rw-r--r--autoscripts/postinst-systemd-enable11
-rwxr-xr-xscript/dh_systemd_enable10
3 files changed, 24 insertions, 12 deletions
diff --git a/autoscripts/postinst-systemd-dont-enable b/autoscripts/postinst-systemd-dont-enable
index 7641052..2bf34ec 100644
--- a/autoscripts/postinst-systemd-dont-enable
+++ b/autoscripts/postinst-systemd-dont-enable
@@ -1,7 +1,10 @@
-if [ -x "/usr/bin/deb-systemd-helper" ]; then
- # This might seem weird at first glance, but the seemingly useless
- # enable/disable is necessary to make deb-systemd-helper create its
- # state file to properly disable the unit files at purge time.
- deb-systemd-helper --quiet enable #UNITFILES# >/dev/null || true
- deb-systemd-helper --quiet disable #UNITFILES# >/dev/null || true
+if deb-systemd-helper debian-is-installed #UNITFILE#; then
+ if deb-systemd-helper was-enabled #UNITFILE#; then
+ # Create new symlinks, if any.
+ deb-systemd-helper enable #UNITFILE# >/dev/null || true
+ fi
fi
+
+# Update the statefile to add new symlinks (if any), which need to be cleaned
+# up on purge. Also remove old symlinks.
+deb-systemd-helper update-state #UNITFILE# >/dev/null || true
diff --git a/autoscripts/postinst-systemd-enable b/autoscripts/postinst-systemd-enable
index 0503034..859b7f4 100644
--- a/autoscripts/postinst-systemd-enable
+++ b/autoscripts/postinst-systemd-enable
@@ -1,3 +1,10 @@
-if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper enable #UNITFILES# >/dev/null || true
+# was-enabled defaults to true, so new installations run enable.
+if deb-systemd-helper was-enabled #UNITFILE#; then
+ # Enables the unit on first installation, creates new
+ # symlinks on upgrades if the unit file has changed.
+ deb-systemd-helper enable #UNITFILE# >/dev/null || true
+else
+ # Update the statefile to add new symlinks (if any), which need to be
+ # cleaned up on purge. Also remove old symlinks.
+ deb-systemd-helper update-state #UNITFILE# >/dev/null || true
fi
diff --git a/script/dh_systemd_enable b/script/dh_systemd_enable
index 63f2e3d..12c555c 100755
--- a/script/dh_systemd_enable
+++ b/script/dh_systemd_enable
@@ -159,10 +159,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
next if @units == 0;
my $unitargs = join(" ", map { basename($_) } @units);
- if ($dh{NO_ENABLE}) {
- autoscript($package, "postinst", "postinst-systemd-dont-enable", "s/#UNITFILES#/$unitargs/");
- } else {
- autoscript($package, "postinst", "postinst-systemd-enable", "s/#UNITFILES#/$unitargs/");
+ for my $unit (@units) {
+ if ($dh{NO_ENABLE}) {
+ autoscript($package, "postinst", "postinst-systemd-dont-enable", "s/#UNITFILE#/$unit/");
+ } else {
+ autoscript($package, "postinst", "postinst-systemd-enable", "s/#UNITFILE#/$unit/");
+ }
}
autoscript($package, "postrm", "postrm-systemd", "s/#UNITFILES#/$unitargs/");