summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Bogatov <KAction@debian.org>2019-03-05 15:17:43 +0000
committerDmitry Bogatov <KAction@debian.org>2019-03-05 15:17:43 +0000
commitbad883cd8c4e4a2a520015141a4b685a85c450ba (patch)
treeb1237bbf3475f3d2fe178dd34a839b2a44da703c
parent51fb67fb3fcec62888e0eccfaaaf366da1a2d31d (diff)
Correctly create symlinks in /etc/service in post-inst on first revision of package, that introduced runscript. (Closes: #923233)
-rw-r--r--debian/changelog2
-rwxr-xr-xdh_runit17
-rw-r--r--postinst-runit1
-rw-r--r--postrm-runit1
-rwxr-xr-xrunit-helper3
5 files changed, 21 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 90c3ea8..520f214 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ dh-runit (2.8.8) UNRELEASED; urgency=medium
2 2
3 * Do not create /etc/sv directory if there is no runscript (Closes: #923439) 3 * Do not create /etc/sv directory if there is no runscript (Closes: #923439)
4 + Thanks: Mathieu Mirmont <mat@parad0x.org> 4 + Thanks: Mathieu Mirmont <mat@parad0x.org>
5 * Correctly create symlinks in /etc/service in post-inst on first
6 revision of package, that introduced runscript. (Closes: #923233)
5 7
6 -- Dmitry Bogatov <KAction@debian.org> Thu, 28 Feb 2019 12:15:20 +0000 8 -- Dmitry Bogatov <KAction@debian.org> Thu, 28 Feb 2019 12:15:20 +0000
7 9
diff --git a/dh_runit b/dh_runit
index 5b345d6..f7c81a2 100755
--- a/dh_runit
+++ b/dh_runit
@@ -10,11 +10,12 @@ use feature 'signatures';
10no warnings 'experimental'; 10no warnings 'experimental';
11 11
12sub parse_options($opts) { 12sub parse_options($opts) {
13 my $conf = { enable => 1 }; 13 my $conf = { enable => 1, since => '0.0-0' };
14 for my $opt (split(/,/, $opts)) { 14 for my $opt (split(/,/, $opts)) {
15 given($opt) { 15 given($opt) {
16 when (/^disable$/) { $conf->{enable} = 0; }; 16 when (/^disable$/) { $conf->{enable} = 0; };
17 when (/^name=(.*)$/) { $conf->{name} = $1; }; 17 when (/^name=(.*)$/) { $conf->{name} = $1; };
18 when (/^since=(.*)$/) { $conf->{since} = $1; };
18 when (/^logscript$/) { $conf->{logscript} = 1}; 19 when (/^logscript$/) { $conf->{logscript} = 1};
19 when (/^defaults$/) { "do nothing"; }; 20 when (/^defaults$/) { "do nothing"; };
20 default { error("unknown option `$opt'"); } 21 default { error("unknown option `$opt'"); }
@@ -73,7 +74,8 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) {
73 74
74 my $substitutions = { 75 my $substitutions = {
75 NAME => $name, 76 NAME => $name,
76 ENABLE => $conf->{enable} ? "yes" : "no" 77 ENABLE => $conf->{enable} ? "yes" : "no",
78 SINCE => $conf->{since}
77 }; 79 };
78 80
79 runit_autoscript($pkg, 'postrm', $substitutions); 81 runit_autoscript($pkg, 'postrm', $substitutions);
@@ -166,6 +168,17 @@ the rights of the dedicated user. Specifying this option produces
166an error if the path argument names a directory that already 168an error if the path argument names a directory that already
167contains a F</log/run> script. 169contains a F</log/run> script.
168 170
171=item I<since>
172
173Specify what version of package introduced runscript. Correct
174installation of symlinks in F</etc/service> requires this information to
175correctly distinguish cases, when system administrator deliberately
176disabled service and case, when runscript was not provided in previous
177version of package. See #923233.
178
179If this option is not specified, it means that runscript was provided
180all history of package.
181
169=item I<defaults> 182=item I<defaults>
170 183
171If you don't need other options, specify this one. 184If you don't need other options, specify this one.
diff --git a/postinst-runit b/postinst-runit
index 6110707..41fd76a 100644
--- a/postinst-runit
+++ b/postinst-runit
@@ -1,6 +1,7 @@
1# -*- shell-script -*- 1# -*- shell-script -*-
2export NAME='#NAME#' 2export NAME='#NAME#'
3export ENABLE='#ENABLE#' 3export ENABLE='#ENABLE#'
4export SINCE='#SINCE#'
4 5
5# Unlike postrm, I can be sure, that runit-helper is present on 6# Unlike postrm, I can be sure, that runit-helper is present on
6# postinst. 7# postinst.
diff --git a/postrm-runit b/postrm-runit
index d5748c9..9a912f1 100644
--- a/postrm-runit
+++ b/postrm-runit
@@ -1,6 +1,7 @@
1# -*- shell-script -*- 1# -*- shell-script -*-
2export NAME='#NAME#' 2export NAME='#NAME#'
3export ENABLE='#ENABLE#' 3export ENABLE='#ENABLE#'
4export SINCE='#SINCE'
4 5
5# Unfortunately, we can not assume, that bin:runit-helper package 6# Unfortunately, we can not assume, that bin:runit-helper package
6# is installed at postrm stage. 7# is installed at postrm stage.
diff --git a/runit-helper b/runit-helper
index 051cbfa..a9cab5b 100755
--- a/runit-helper
+++ b/runit-helper
@@ -23,7 +23,8 @@ postinst () {
23 23
24 # Fresh installation (not upgrade). It is important to not override 24 # Fresh installation (not upgrade). It is important to not override
25 # local admin decision (see #899242). 25 # local admin decision (see #899242).
26 if [ "${ENABLE}" = yes ] && [ -z "${previous}" ] ; then 26 if [ "${ENABLE}" = yes ] && \
27 dpkg --compare-versions "${previous}" '<<' "${SINCE}" ; then
27 ln -sf "/etc/sv/$NAME" "/etc/runit/runsvdir/default/$NAME" 28 ln -sf "/etc/sv/$NAME" "/etc/runit/runsvdir/default/$NAME"
28 fi 29 fi
29} 30}