summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2013-09-14 02:35:55 +0000
committerMichael Stapelberg <michael@stapelberg.de>2013-09-14 02:35:55 +0000
commite1d1e1212fb90c838c0cd674dfef816007da3e2d (patch)
tree001ebe3bc756f19fb8c3b19fc515dc8921c2b12a
parent0cfba9414a0fbb374727d029632267fa7373dd20 (diff)
downloadinit-system-helpers-e1d1e1212fb90c838c0cd674dfef816007da3e2d.tar.gz
dh_systemd_enable: skip unit files without an [Install] section
fixes #721241
-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;
}