diff options
author | Niels Thykier <niels@thykier.net> | 2017-10-21 12:20:59 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-10-21 12:21:05 +0000 |
commit | 740c628a1e571acded7e2aac5d6e7058e61da37f (patch) | |
tree | dfa839cc361d6829968f7e216fa43a7693305ef0 | |
parent | ae55a1d2684e836b4aa89333a04ce2c41c5e9939 (diff) | |
download | debhelper-740c628a1e571acded7e2aac5d6e7058e61da37f.tar.gz |
dh_systemd_*: Fix incorrect error for "missing" files
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r-- | debian/changelog | 4 | ||||
-rwxr-xr-x | dh_systemd_enable | 23 | ||||
-rwxr-xr-x | dh_systemd_start | 22 |
3 files changed, 46 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog index 3e4db406..3856b47c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,10 @@ debhelper (10.9.3) UNRELEASED; urgency=medium * dh_installinit: In compat 12, error out if an upstart init file is provided with a reminder message about how to remove the obsolete conffile. (Closes: #876453) + * dh_systemd_enable: Permit missing explicitly requested file in + package as long as another on being acted on ships it. + (Closes: #878911) + * dh_systemd_start: Ditto. -- Niels Thykier <niels@thykier.net> Sat, 14 Oct 2017 11:18:19 +0000 diff --git a/dh_systemd_enable b/dh_systemd_enable index e2e5add6..017bdd24 100755 --- a/dh_systemd_enable +++ b/dh_systemd_enable @@ -144,6 +144,9 @@ sub install_unit { # PROMISE: DH NOOP WITHOUT tmp(lib/systemd/system) mount path service socket target tmpfile timer +my %requested_files = map { basename($_) => 1 } @ARGV; +my %installed_files; + foreach my $package (@{$dh{DOPACKAGES}}) { my $tmpdir = tmpdir($package); my @installed_units; @@ -211,7 +214,6 @@ foreach my $package (@{$dh{DOPACKAGES}}) { for my $name (@args) { my $base = basename($name); - # Try to make the path absolute, so that the user can call # dh_installsystemd bacula-fd.service if ($base eq $name) { @@ -220,13 +222,19 @@ foreach my $package (@{$dh{DOPACKAGES}}) { my ($full) = grep { basename($_) eq $base } @installed_units; if (defined($full)) { $name = $full; - } else { + } elsif (not exists($requested_files{$base})) { warning(qq|Could not find "$name" in the /lib/systemd/system directory of $package. | . qq|This could be a typo, or using Also= with a service file from another package. | . qq|Please check carefully that this message is harmless.|); + } else { + # Ignore an explicitly requested file that is missing; happens when we are acting on + # multiple packages and only a subset of them have the unit file. + next; } } + $installed_files{$base} = 1 if exists($requested_files{$base}); + # Skip template service files like e.g. getty@.service. # Enabling, disabling, starting or stopping those services # without specifying the instance (e.g. getty@ttyS0.service) is @@ -259,6 +267,17 @@ foreach my $package (@{$dh{DOPACKAGES}}) { autoscript($package, 'postrm', 'postrm-systemd', {'UNITFILES' => $unitargs }); } +if (%requested_files) { + my $any_missing = 0; + for my $name (sort(keys(%requested_files))) { + if (not exists($installed_files{$name})) { + warning(qq{Requested unit "$name" but it was not found in any package acted on.}); + $any_missing = 1; + } + } + error("Could not handle all of the requested services") if $any_missing; +} + =head1 SEE ALSO L<dh_systemd_start(1)>, L<debhelper(7)> diff --git a/dh_systemd_start b/dh_systemd_start index 362d00ab..7f824be9 100755 --- a/dh_systemd_start +++ b/dh_systemd_start @@ -128,6 +128,9 @@ sub extract_key { # PROMISE: DH NOOP WITHOUT tmp(lib/systemd/system) +my %requested_files = map { basename($_) => 1 } @ARGV; +my %installed_files; + foreach my $package (@{$dh{DOPACKAGES}}) { my $tmpdir = tmpdir($package); my @installed_units; @@ -181,13 +184,19 @@ foreach my $package (@{$dh{DOPACKAGES}}) { my ($full) = grep { basename($_) eq $base } @installed_units; if (defined($full)) { $name = $full; - } else { + } elsif (not exists($requested_files{$base})) { warning(qq|Could not find "$name" in the /lib/systemd/system directory of $package. | . qq|This could be a typo, or using Also= with a service file from another package. | . qq|Please check carefully that this message is harmless.|); + } else { + # Ignore an explicitly requested file that is missing; happens when we are acting on + # multiple packages and only a subset of them have the unit file. + next; } } + $installed_files{$base} = 1 if exists($requested_files{$base}); + # Skip template service files like e.g. getty@.service. # Enabling, disabling, starting or stopping those services # without specifying the instance (e.g. getty@ttyS0.service) is @@ -246,6 +255,17 @@ foreach my $package (@{$dh{DOPACKAGES}}) { } } +if (%requested_files) { + my $any_missing = 0; + for my $name (sort(keys(%requested_files))) { + if (not exists($installed_files{$name})) { + warning(qq{Requested unit "$name" but it was not found in any package acted on.}); + $any_missing = 1; + } + } + error("Could not handle all of the requested services") if $any_missing; +} + =head1 SEE ALSO L<debhelper(7)> |