summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@debian.org>2019-05-14 15:41:52 +0000
committerDmitry Bogatov <KAction@debian.org>2019-05-14 15:57:15 +0000
commitcb411affcbc2eb183ee5f35e50c3863c0b94f98a (patch)
tree81ed7bee8bc1bf60a637a47b158450c6e76dbc50
parentff2177c68252c80e75c2e0fbc4d40e8193d4cb36 (diff)
Add option to mark service as non-restartable
-rwxr-xr-xdh_runit18
-rw-r--r--t/924903.t5
-rw-r--r--t/928935.t10
3 files changed, 32 insertions, 1 deletions
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;
5use strict; 5use strict;
6use Debian::Debhelper::Dh_Lib; 6use Debian::Debhelper::Dh_Lib;
7use File::Find; 7use File::Find;
8use File::Path qw(make_path);
8use File::stat; 9use File::stat;
9use feature 'signatures'; 10use feature 'signatures';
10no warnings 'experimental'; 11no warnings 'experimental';
@@ -17,6 +18,7 @@ sub parse_options($opts) {
17 when (/^name=(.*)$/) { $conf->{name} = $1; }; 18 when (/^name=(.*)$/) { $conf->{name} = $1; };
18 when (/^since=(.*)$/) { $conf->{since} = $1; }; 19 when (/^since=(.*)$/) { $conf->{since} = $1; };
19 when (/^logscript$/) { $conf->{logscript} = 1}; 20 when (/^logscript$/) { $conf->{logscript} = 1};
21 when (/^noreplace$/) { $conf->{noreplace} = 1};
20 when (/^defaults$/) { "do nothing"; }; 22 when (/^defaults$/) { "do nothing"; };
21 default { error("unknown option `$opt'"); } 23 default { error("unknown option `$opt'"); }
22 } 24 }
@@ -59,6 +61,13 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
59 my $conf = parse_options($opts); 61 my $conf = parse_options($opts);
60 my $name = $conf->{name} || basename($path); 62 my $name = $conf->{name} || basename($path);
61 63
64 if ($conf->{noreplace}) {
65 make_path("${tmp}/var/lib/runit/noreplace/");
66 open(my $fh, ">", "${tmp}/var/lib/runit/noreplace/${name}")
67 || die $!;
68 close($fh);
69 }
70
62 if ( -f $path) { 71 if ( -f $path) {
63 install_dir("$sv_dir/$name"); 72 install_dir("$sv_dir/$name");
64 install_prog($path, "$sv_dir/$name/run"); 73 install_prog($path, "$sv_dir/$name/run");
@@ -182,6 +191,15 @@ version of package. See #923233.
182If this option is not specified, it means that runscript was provided 191If this option is not specified, it means that runscript was provided
183all history of package. 192all history of package.
184 193
194=item I<noreplace>
195
196Mark service as non-restartible. Interpreter B<invoke-run>, provided by
197I<runit> package does not stop sysvinit-managed instance of service to
198replace it with runit-managed instance when service is marked as
199non-restartible.
200
201Display managers (xdm, kdm, ...) are examples of non-restartible services.
202
185=item I<defaults> 203=item I<defaults>
186 204
187If you don't need other options, specify this one. 205If 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 @@
1#!/usr/bin/perl 1#!/usr/bin/perl
2use strict; 2use strict;
3use warnings; 3use warnings;
4use Test::More tests => 3; 4use Test::More tests => 4;
5use File::stat; 5use File::stat;
6use T; 6use T;
7 7
@@ -11,3 +11,6 @@ ok(-d $path, 'supervise directory correctly created');
11my $info = stat($path); 11my $info = stat($path);
12my $mode = sprintf("%o", $info->mode & 0777); 12my $mode = sprintf("%o", $info->mode & 0777);
13is($mode, '700', 'supervise directory have conservative permissions'); 13is($mode, '700', 'supervise directory have conservative permissions');
14
15my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test';
16ok(!-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 @@
1#!/usr/bin/perl
2use strict;
3use warnings;
4use Test::More tests => 2;
5use T;
6
7system_ok('dh_runit', 'debian/test.runscript', 'name=test,noreplace');
8
9my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test';
10ok(-f $noreplace, 'noreplace file correctly created');