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 /dh_systemd_enable | |
parent | ae55a1d2684e836b4aa89333a04ce2c41c5e9939 (diff) |
dh_systemd_*: Fix incorrect error for "missing" files
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_systemd_enable')
-rwxr-xr-x | dh_systemd_enable | 23 |
1 files changed, 21 insertions, 2 deletions
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)> |