From bad883cd8c4e4a2a520015141a4b685a85c450ba Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Tue, 5 Mar 2019 15:17:43 +0000 Subject: Correctly create symlinks in /etc/service in post-inst on first revision of package, that introduced runscript. (Closes: #923233) --- debian/changelog | 2 ++ dh_runit | 17 +++++++++++++++-- postinst-runit | 1 + postrm-runit | 1 + runit-helper | 3 ++- 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 * Do not create /etc/sv directory if there is no runscript (Closes: #923439) + Thanks: Mathieu Mirmont + * Correctly create symlinks in /etc/service in post-inst on first + revision of package, that introduced runscript. (Closes: #923233) -- Dmitry Bogatov Thu, 28 Feb 2019 12:15:20 +0000 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'; no warnings 'experimental'; sub parse_options($opts) { - my $conf = { enable => 1 }; + my $conf = { enable => 1, since => '0.0-0' }; for my $opt (split(/,/, $opts)) { given($opt) { when (/^disable$/) { $conf->{enable} = 0; }; when (/^name=(.*)$/) { $conf->{name} = $1; }; + when (/^since=(.*)$/) { $conf->{since} = $1; }; when (/^logscript$/) { $conf->{logscript} = 1}; when (/^defaults$/) { "do nothing"; }; default { error("unknown option `$opt'"); } @@ -73,7 +74,8 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { my $substitutions = { NAME => $name, - ENABLE => $conf->{enable} ? "yes" : "no" + ENABLE => $conf->{enable} ? "yes" : "no", + SINCE => $conf->{since} }; runit_autoscript($pkg, 'postrm', $substitutions); @@ -166,6 +168,17 @@ the rights of the dedicated user. Specifying this option produces an error if the path argument names a directory that already contains a F script. +=item I + +Specify what version of package introduced runscript. Correct +installation of symlinks in F requires this information to +correctly distinguish cases, when system administrator deliberately +disabled service and case, when runscript was not provided in previous +version of package. See #923233. + +If this option is not specified, it means that runscript was provided +all history of package. + =item I If 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 @@ # -*- shell-script -*- export NAME='#NAME#' export ENABLE='#ENABLE#' +export SINCE='#SINCE#' # Unlike postrm, I can be sure, that runit-helper is present on # postinst. diff --git a/postrm-runit b/postrm-runit index d5748c9..9a912f1 100644 --- a/postrm-runit +++ b/postrm-runit @@ -1,6 +1,7 @@ # -*- shell-script -*- export NAME='#NAME#' export ENABLE='#ENABLE#' +export SINCE='#SINCE' # Unfortunately, we can not assume, that bin:runit-helper package # 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 () { # Fresh installation (not upgrade). It is important to not override # local admin decision (see #899242). - if [ "${ENABLE}" = yes ] && [ -z "${previous}" ] ; then + if [ "${ENABLE}" = yes ] && \ + dpkg --compare-versions "${previous}" '<<' "${SINCE}" ; then ln -sf "/etc/sv/$NAME" "/etc/runit/runsvdir/default/$NAME" fi } -- cgit v1.2.3