summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscript/dh_systemd_enable18
1 files changed, 18 insertions, 0 deletions
diff --git a/script/dh_systemd_enable b/script/dh_systemd_enable
index 358d95a..e6182c6 100755
--- a/script/dh_systemd_enable
+++ b/script/dh_systemd_enable
@@ -76,6 +76,21 @@ init(options => {
"no-enable" => \$dh{NO_ENABLE},
});
+sub contains_install_section {
+ my ($unit_path) = @_;
+ my $fh;
+ if (!open($fh, '<', $unit_path)) {
+ warning("Cannot open($unit_path) for extracting the Also= line(s)");
+ return;
+ }
+ while (my $line = <$fh>) {
+ chomp($line);
+ return 1 if $line =~ /^\s*\[Install\]$/i;
+ }
+ close($fh);
+ return 0;
+}
+
foreach my $package (@{$dh{DOPACKAGES}}) {
my $tmpdir = tmpdir($package);
my @installed_units;
@@ -170,6 +185,9 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
next;
}
+ # Skip unit files that don’t have an [Install] section.
+ next unless contains_install_section($name);
+
push @units, $name;
}