diff options
author | Dmitry Bogatov <KAction@debian.org> | 2019-05-14 15:41:52 +0000 |
---|---|---|
committer | Dmitry Bogatov <KAction@debian.org> | 2019-05-14 15:57:15 +0000 |
commit | cb411affcbc2eb183ee5f35e50c3863c0b94f98a (patch) | |
tree | 81ed7bee8bc1bf60a637a47b158450c6e76dbc50 | |
parent | ff2177c68252c80e75c2e0fbc4d40e8193d4cb36 (diff) |
Add option to mark service as non-restartable
-rwxr-xr-x | dh_runit | 18 | ||||
-rw-r--r-- | t/924903.t | 5 | ||||
-rw-r--r-- | t/928935.t | 10 |
3 files changed, 32 insertions, 1 deletions
@@ -5,6 +5,7 @@ use v5.10.1; | |||
5 | use strict; | 5 | use strict; |
6 | use Debian::Debhelper::Dh_Lib; | 6 | use Debian::Debhelper::Dh_Lib; |
7 | use File::Find; | 7 | use File::Find; |
8 | use File::Path qw(make_path); | ||
8 | use File::stat; | 9 | use File::stat; |
9 | use feature 'signatures'; | 10 | use feature 'signatures'; |
10 | no warnings 'experimental'; | 11 | no 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. | |||
182 | If this option is not specified, it means that runscript was provided | 191 | If this option is not specified, it means that runscript was provided |
183 | all history of package. | 192 | all history of package. |
184 | 193 | ||
194 | =item I<noreplace> | ||
195 | |||
196 | Mark service as non-restartible. Interpreter B<invoke-run>, provided by | ||
197 | I<runit> package does not stop sysvinit-managed instance of service to | ||
198 | replace it with runit-managed instance when service is marked as | ||
199 | non-restartible. | ||
200 | |||
201 | Display managers (xdm, kdm, ...) are examples of non-restartible services. | ||
202 | |||
185 | =item I<defaults> | 203 | =item I<defaults> |
186 | 204 | ||
187 | If you don't need other options, specify this one. | 205 | If you don't need other options, specify this one. |
@@ -1,7 +1,7 @@ | |||
1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl |
2 | use strict; | 2 | use strict; |
3 | use warnings; | 3 | use warnings; |
4 | use Test::More tests => 3; | 4 | use Test::More tests => 4; |
5 | use File::stat; | 5 | use File::stat; |
6 | use T; | 6 | use T; |
7 | 7 | ||
@@ -11,3 +11,6 @@ ok(-d $path, 'supervise directory correctly created'); | |||
11 | my $info = stat($path); | 11 | my $info = stat($path); |
12 | my $mode = sprintf("%o", $info->mode & 0777); | 12 | my $mode = sprintf("%o", $info->mode & 0777); |
13 | is($mode, '700', 'supervise directory have conservative permissions'); | 13 | is($mode, '700', 'supervise directory have conservative permissions'); |
14 | |||
15 | my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test'; | ||
16 | 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 @@ | |||
1 | #!/usr/bin/perl | ||
2 | use strict; | ||
3 | use warnings; | ||
4 | use Test::More tests => 2; | ||
5 | use T; | ||
6 | |||
7 | system_ok('dh_runit', 'debian/test.runscript', 'name=test,noreplace'); | ||
8 | |||
9 | my $noreplace = 'debian/dh-runit-test/var/lib/runit/noreplace/test'; | ||
10 | ok(-f $noreplace, 'noreplace file correctly created'); | ||