summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2017-10-08 14:50:53 +0000
committerNiels Thykier <niels@thykier.net>2017-10-08 14:51:36 +0000
commit841170155bec2f60a2c4bcc03346bc296ff7525f (patch)
tree2c8c79a656029834a48cafa2ffa759c48cba3e80
parentd3b4ccdb7c219ae6b692565e9f54056da176e412 (diff)
downloaddebhelper-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/changelog3
-rwxr-xr-xdh_systemd_enable6
-rwxr-xr-xdh_systemd_start11
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);