[debhelper-devel] [debhelper] 02/02: dh_installsystemd: Avoid invalid scripts when there are no units
Niels Thykier
nthykier at moszumanska.debian.org
Fri Nov 10 06:21:09 UTC 2017
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository debhelper.
commit 5f2fb00423fb0d352671a45b3345f69213ee368d
Author: Felipe Sateler <fsateler at debian.org>
Date: Fri Nov 10 06:19:49 2017 +0000
dh_installsystemd: Avoid invalid scripts when there are no units
Signed-off-by: Niels Thykier <niels at thykier.net>
---
debian/changelog | 6 +++++
dh_installsystemd | 66 ++++++++++++++++++++++++++++---------------------------
2 files changed, 40 insertions(+), 32 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 6320679..1dbe728 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,12 @@ debhelper (10.10.6) UNRELEASED; urgency=medium
* dh_installsystemd: Optimize the search for files installed in the
tmpfiles.d directories to only look in the tmpfiles.d directories.
+ [ Felipe Sateler ]
+ * dh_installsystemd: Fix a bug where dh_installsystemd would generate
+ invalid maintscript, when there were no units to start or enable.
+ Thanks to Ben Hutchings and Bastian Blank for the bug report.
+ (Closes: #881190)
+
-- Axel Beckert <abe at debian.org> Fri, 27 Oct 2017 23:48:44 +0200
debhelper (10.10.5) unstable; urgency=medium
diff --git a/dh_installsystemd b/dh_installsystemd
index 671fb48..8dd4edc 100755
--- a/dh_installsystemd
+++ b/dh_installsystemd
@@ -347,43 +347,45 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
}
- next if @start_units == 0 && @enable_units == 0;
-
- for my $unit (sort @enable_units) {
- my $base = q{'} . basename($unit) . q{'};
- if ($dh{NO_ENABLE}) {
- autoscript($package, 'postinst', 'postinst-systemd-dont-enable', { 'UNITFILE' => $base });
- } else {
- autoscript($package, 'postinst', 'postinst-systemd-enable', { 'UNITFILE' => $base });
+ if (@enable_units) {
+ for my $unit (sort @enable_units) {
+ my $base = q{'} . basename($unit) . q{'};
+ if ($dh{NO_ENABLE}) {
+ autoscript($package, 'postinst', 'postinst-systemd-dont-enable', { 'UNITFILE' => $base });
+ } else {
+ autoscript($package, 'postinst', 'postinst-systemd-enable', { 'UNITFILE' => $base });
+ }
}
+ my $enableunitargs = join(' ', sort map { q{'} . basename($_) . q{'} } @enable_units);
+ autoscript($package, 'postrm', 'postrm-systemd', {'UNITFILES' => $enableunitargs });
}
- my $enableunitargs = join(' ', sort map { q{'} . basename($_) . q{'} } @enable_units);
- autoscript($package, 'postrm', 'postrm-systemd', {'UNITFILES' => $enableunitargs });
- # The $package and $sed parameters are always the same.
- # This wrapper function makes the following logic easier to read.
- my $startunitargs = join(' ', sort map { q{'} . basename($_) . q{'} } @start_units);
- my $start_autoscript = sub {
- my ($script, $filename) = @_;
- autoscript($package, $script, $filename, { 'UNITFILES' => $startunitargs });
- };
-
- if ($dh{RESTART_AFTER_UPGRADE}) {
- my $snippet = "postinst-systemd-restart" . ($dh{NO_START} ? "nostart" : "");
- $start_autoscript->("postinst", $snippet);
- } elsif (!$dh{NO_START}) {
- # We need to stop/start before/after the upgrade.
- $start_autoscript->("postinst", "postinst-systemd-start");
- }
+ if (@start_units) {
+ # The $package and $sed parameters are always the same.
+ # This wrapper function makes the following logic easier to read.
+ my $startunitargs = join(' ', sort map { q{'} . basename($_) . q{'} } @start_units);
+ my $start_autoscript = sub {
+ my ($script, $filename) = @_;
+ autoscript($package, $script, $filename, { 'UNITFILES' => $startunitargs });
+ };
+
+ if ($dh{RESTART_AFTER_UPGRADE}) {
+ my $snippet = "postinst-systemd-restart" . ($dh{NO_START} ? "nostart" : "");
+ $start_autoscript->("postinst", $snippet);
+ } elsif (!$dh{NO_START}) {
+ # We need to stop/start before/after the upgrade.
+ $start_autoscript->("postinst", "postinst-systemd-start");
+ }
- $start_autoscript->("postrm", "postrm-systemd-reload-only");
+ $start_autoscript->("postrm", "postrm-systemd-reload-only");
- if ($dh{R_FLAG} || $dh{RESTART_AFTER_UPGRADE}) {
- # stop service only on remove
- $start_autoscript->("prerm", "prerm-systemd-restart");
- } elsif (!$dh{NO_START}) {
- # always stop service
- $start_autoscript->("prerm", "prerm-systemd");
+ if ($dh{R_FLAG} || $dh{RESTART_AFTER_UPGRADE}) {
+ # stop service only on remove
+ $start_autoscript->("prerm", "prerm-systemd-restart");
+ } elsif (!$dh{NO_START}) {
+ # always stop service
+ $start_autoscript->("prerm", "prerm-systemd");
+ }
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git
More information about the debhelper-devel
mailing list