From 2522d781a1fe724f8433160f0df9a3091aeacfb6 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Wed, 8 Jun 2016 23:12:38 +0300 Subject: Improve created /etc/sv/${NAME} directory * ensure that run/finish scripts are executable * create 'supervise' symlink to not pollute /etc/ directory --- dh_runit | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'dh_runit') diff --git a/dh_runit b/dh_runit index ba066d8..28daea0 100755 --- a/dh_runit +++ b/dh_runit @@ -11,6 +11,8 @@ use Debian::Debhelper::Dh_Lib; use File::Find; use Path::Tiny; use File::stat; +use feature 'signatures'; +no warnings 'experimental::signatures'; =head1 SYNOPSIS @@ -64,6 +66,13 @@ specify, that it should not be enabled. =cut +sub ensure_executable($directory) { + for my $f ('run', 'finish', 'log/run', 'log/finish') { + my $file = "$directory/$f"; + doit('chmod', '+x', $file) if (-e $file); + } +} + init(option => { 'no-enable' => \$dh{NO_ENABLE} }); PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { @@ -85,10 +94,16 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { error("can't read `$path'") unless -r $path; if ( -f $path) { - doit('install', 'd', '-m755', $path, "$sv_dir/$name/run"); + install_dir("$sv_dir/$name"); + install_prog($path, "$sv_dir/$name/run"); } elsif ( -d $path) { doit('cp', '-r', $path, "$sv_dir/$name"); + # Unfortunately, dh_fixperms does not handle executable bit here. + ensure_executable("$sv_dir/$name"); } + make_symlink("/etc/sv/$name/supervise", + "/var/lib/runit/supervise/$name", $tmp); + if ($enable eq 'enable' && !$dh{NO_ENABLE}) { autoscript($pkg, 'postinst', 'postinst-runit', "s/#NAME#/$name/"); } -- cgit v1.2.3