control: tags -1 +patch

[2008-01-24 14:45] A Mennucc <mennu...@debian.org>
> the usual invocation of dh_installinit never fails,
> if it finds package.init, it installs it, otherwise it simply exists.
> 
> Instead I think that the form 'dh_installinit --name foobar' , if it does
> not find package.foobar.init, should fail (so that debian/rules dies).
> The rationale is that, if the DD has set such a command in
> debian/rules , it  means that the script should exist; and if the
> script does not exists, it is most likely a bug (for example, a typo
> such as 'dh_installinit --name fobar'), so a failure should trigger.

Got bitten by this behaviour just today, so I decided to finally address
this issue.

Dear maintainer, please consider this patch. I read documentation on
submitting patches, but using merge request is so inconvenient. At
least, I added test :)

From f377d762a4e9635bf67e4759705655899ae4de0e Mon Sep 17 00:00:00 2001
From: Dmitry Bogatov <kact...@debian.org>
Date: Thu, 17 Jan 2019 02:19:27 +0000
Subject: [PATCH] dh_installinit: --name implies, that init script is present

Previously, `dh_installinit' silently did nothing, when --name option
was passed, but initscript debian/<package>.<name>.init was not found.

In almost all cases, explicit --name means that package maintainer meant
to install init script. If it is not present, it is bug, and must not be
hidden. Now, error is reported in this case. (Closes: #462389)
---
 dh_installinit                    | 4 ++++
 t/dh_installinit/dh_installinit.t | 1 +
 2 files changed, 5 insertions(+)

diff --git a/dh_installinit b/dh_installinit
index fca0a8af..6a490370 100755
--- a/dh_installinit
+++ b/dh_installinit
@@ -311,6 +311,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
        my $init=pkgfile($package,$scriptsrc) || pkgfile($package,"init") ||
                pkgfile($package,"init.d");
 
+       if (!$init && defined $dh{NAME}) {
+               error("--name=$dh{NAME} option specified, but init script not 
found");
+       }
+
        if ($init ne '' && ! $dh{ONLYSCRIPTS}) {
                install_dir("$tmp/etc/init.d");
                install_prog($init,"$tmp/etc/init.d/$script");
diff --git a/t/dh_installinit/dh_installinit.t 
b/t/dh_installinit/dh_installinit.t
index b20caa58..b210c867 100755
--- a/t/dh_installinit/dh_installinit.t
+++ b/t/dh_installinit/dh_installinit.t
@@ -28,6 +28,7 @@ each_compat_up_to_and_incl_subtest(10, sub {
 each_compat_from_and_above_subtest(11, sub {
        make_path(qw(debian/foo debian/bar debian/baz));
 
+       ok(! run_dh_tool('dh_installinit', '--name=missing'));
        ok(run_dh_tool('dh_installinit'));
        ok(! -e "debian/foo/lib/systemd/system/foo.service");
        ok(!find_script('foo', 'postinst'));

Reply via email to