diff options
author | Niels Thykier <niels@thykier.net> | 2017-10-08 14:50:53 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-10-08 14:51:36 +0000 |
commit | 841170155bec2f60a2c4bcc03346bc296ff7525f (patch) | |
tree | 2c8c79a656029834a48cafa2ffa759c48cba3e80 | |
parent | d3b4ccdb7c219ae6b692565e9f54056da176e412 (diff) | |
download | debhelper-841170155bec2f60a2c4bcc03346bc296ff7525f.tar.gz |
dh_systemd_*: Error out if the unit file cannot be read
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r-- | debian/changelog | 3 | ||||
-rwxr-xr-x | dh_systemd_enable | 6 | ||||
-rwxr-xr-x | dh_systemd_start | 11 |
3 files changed, 7 insertions, 13 deletions
diff --git a/debian/changelog b/debian/changelog index 66f804b7..bb706202 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,9 @@ debhelper (10.9.1) UNRELEASED; urgency=medium init-system-helpers that is satisfied in oldstable. * Dh_Lib: Fix regression where --no-act would actually create maintscript snippets. + * dh_systemd_*: If an unit file cannot be read (e.g. to check for + the [Install] section), error out instead of emitting a warning + and continuing. [ Dmitry Shachnev ] * qmake.pm: Add basic cross-building support. (Closes: #877357) diff --git a/dh_systemd_enable b/dh_systemd_enable index db68b030..7c3f3385 100755 --- a/dh_systemd_enable +++ b/dh_systemd_enable @@ -120,11 +120,7 @@ init(options => { 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; - } + open(my $fh, '<', $unit_path) or error("Cannot open($unit_path) for extracting the Also= line(s)"); while (my $line = <$fh>) { chomp($line); return 1 if $line =~ /^\s*\[Install\]$/i; diff --git a/dh_systemd_start b/dh_systemd_start index 0a048749..d17bb287 100755 --- a/dh_systemd_start +++ b/dh_systemd_start @@ -97,16 +97,11 @@ init(options => { sub extract_key { my ($unit_path, $key) = @_; my @values; - my $fh; - if ($dh{NO_ALSO}) { - return @values; - } + return if $dh{NO_ALSO}; + + open(my $fh, '<', $unit_path) or error("Cannot open($unit_path) for extracting the Also= line(s)"); - if (!open($fh, '<', $unit_path)) { - warning("Cannot open($unit_path) for extracting the Also= line(s)"); - return; - } while (my $line = <$fh>) { chomp($line); |