From cb411affcbc2eb183ee5f35e50c3863c0b94f98a Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Tue, 14 May 2019 15:41:52 +0000 Subject: Add option to mark service as non-restartable --- dh_runit | 18 ++++++++++++++++++ t/924903.t | 5 ++++- t/928935.t | 10 ++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 t/928935.t diff --git a/dh_runit b/dh_runit index 5ed55b5..4c9820e 100755 --- a/dh_runit +++ b/dh_runit @@ -5,6 +5,7 @@ use v5.10.1; use strict; use Debian::Debhelper::Dh_Lib; use File::Find; +use File::Path qw(make_path); use File::stat; use feature 'signatures'; no warnings 'experimental'; @@ -17,6 +18,7 @@ sub parse_options($opts) { when (/^name=(.*)$/) { $conf->{name} = $1; }; when (/^since=(.*)$/) { $conf->{since} = $1; }; when (/^logscript$/) { $conf->{logscript} = 1}; + when (/^noreplace$/) { $conf->{noreplace} = 1}; when (/^defaults$/) { "do nothing"; }; default { error("unknown option `$opt'"); } } @@ -59,6 +61,13 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { my $conf = parse_options($opts); my $name = $conf->{name} || basename($path); + if ($conf->{noreplace}) { + make_path("${tmp}/var/lib/runit/noreplace/"); + open(my $fh, ">", "${tmp}/var/lib/runit/noreplace/${name}") + || die $!; + close($fh); + } + if ( -f $path) { install_dir("$sv_dir/$name"); install_prog($path, "$sv_dir/$name/run"); @@ -182,6 +191,15 @@ version of package. See #923233. If this option is not specified, it means that runscript was provided all history of package. +=item I + +Mark service as non-restartible. Interpreter B, provided by +I package does not stop sysvinit-managed instance of service to +replace it with runit-managed instance when service is marked as +non-restartible. + +Display managers (xdm, kdm, ...) are examples of non-restartible services. + =item I If you don't need other options, specify this one. diff --git a/t/924903.t b/t/924903.t index 710ea39..b969314 100644 --- a/t/924903.t +++ b/t/924903.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 4; use File::stat; use T; @@ -11,3 +11,6 @@ ok(-d $path, 'supervise directory correctly created'); my $info = stat($path); my $mode = sprintf("%o", $info->mode & 0777); is($mode, '700', 'supervise directory have conservative permissions'); + +my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test'; +ok(!-f $noreplace, 'noreplace file is correctly absent'); diff --git a/t/928935.t b/t/928935.t new file mode 100644 index 0000000..e31756b --- /dev/null +++ b/t/928935.t @@ -0,0 +1,10 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Test::More tests => 2; +use T; + +system_ok('dh_runit', 'debian/test.runscript', 'name=test,noreplace'); + +my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test'; +ok(-f $noreplace, 'noreplace file correctly created'); -- cgit v1.2.3