diff options
author | Niels Thykier <niels@thykier.net> | 2017-11-09 21:23:44 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-11-09 21:25:31 +0000 |
commit | 86d05e41e4549ca01aa27ebf12f68da84b2d45fd (patch) | |
tree | 98d981121d77e6e9496080f36b5e84609ccc8144 /dh_installsystemd | |
parent | 9a87aeb8f962aa77ea49b599fc694becd21d5951 (diff) | |
download | debhelper-86d05e41e4549ca01aa27ebf12f68da84b2d45fd.tar.gz |
dh_installsystemd: Avoid invalid scripts when there are no units
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_installsystemd')
-rwxr-xr-x | dh_installsystemd | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/dh_installsystemd b/dh_installsystemd index 671fb480..ebe25a31 100755 --- a/dh_installsystemd +++ b/dh_installsystemd @@ -349,17 +349,20 @@ 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 }); - + + next if not @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); |