diff options
author | Dmitry Bogatov <KAction@debian.org> | 2019-07-15 16:08:01 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2019-07-16 20:15:52 +0000 |
commit | 789eb18ba0e09f87fefc33c2ffd1e6f6e5654ce7 (patch) | |
tree | 47735234cc3949b61aa8c66af01a0b58b9edb2fe | |
parent | 3ac9a5c3c5dd725d8269a3dbd4575c646008769b (diff) | |
download | debhelper-789eb18ba0e09f87fefc33c2ffd1e6f6e5654ce7.tar.gz |
Fix logic error in --name sanity check
Commit [e5fc959e], resolving #462389 changed behaviour of `--name' option of
dh_installinit. Before this change, if `debian/{package}.{name}.init' is missing,
this option was silently ignored. This change made it error.
This change was incorrect, since it demanded presence of `debian/{package}.{name}.init'
file for /every/ binary package.
This commit instead throws error only if `debian/{package}.{name}.init' does
not exist for /all/ binary {package} names. Regression test is added.
Closes: #932073
Signed-off-by: Niels Thykier <niels@thykier.net>
-rwxr-xr-x | dh_installinit | 10 | ||||
-rw-r--r-- | t/dh_installinit/debian/bar.other.init | 4 | ||||
-rwxr-xr-x | t/dh_installinit/dh_installinit.t | 2 |
3 files changed, 12 insertions, 4 deletions
diff --git a/dh_installinit b/dh_installinit index 6a490370..cd038af1 100755 --- a/dh_installinit +++ b/dh_installinit @@ -232,6 +232,12 @@ init(options => { my %snippet_options = ('snippet-order' => 'service'); +if (my $name = $dh{NAME}) { + if (!grep { -f "debian/$_.${name}.init" } @{$dh{DOPACKAGES}}) { + error("--name=$dh{NAME} option specified, but init script not found"); + } +} + foreach my $package (@{$dh{DOPACKAGES}}) { my $tmp=tmpdir($package); @@ -311,10 +317,6 @@ 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/debian/bar.other.init b/t/dh_installinit/debian/bar.other.init new file mode 100644 index 00000000..ea948c58 --- /dev/null +++ b/t/dh_installinit/debian/bar.other.init @@ -0,0 +1,4 @@ +#!/bin/sh +cat << 'EOF' +I am init script to be installed into package "bar" into /etc/init.d/other path. +EOF
\ No newline at end of file diff --git a/t/dh_installinit/dh_installinit.t b/t/dh_installinit/dh_installinit.t index afe3821f..3b6bc038 100755 --- a/t/dh_installinit/dh_installinit.t +++ b/t/dh_installinit/dh_installinit.t @@ -12,6 +12,7 @@ our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw( debian/changelog debian/control debian/foo.service + debian/bar.other.init )); plan(tests => 2); @@ -30,6 +31,7 @@ each_compat_from_and_above_subtest(11, sub { ok(run_dh_tool('dh_installinit')); ok(! run_dh_tool({'quiet' => 1}, 'dh_installinit', '--name=missing')); + ok( run_dh_tool({'queit' => 1}, 'dh_installinit', '--name=other')); ok(! -e "debian/foo/lib/systemd/system/foo.service"); ok(!find_script('foo', 'postinst')); ok(run_dh_tool('dh_clean')); |