From c870dcaa53988f709b1152221e76992972365fb5 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Wed, 23 May 2018 08:23:08 +0300 Subject: Do not re-enable serice on upgrade * Do not make symbolic link /etc/runit/runsvdir/default/$name -> /etc/sv/$name part of package files {in which case it will be unconditionally created on upgrade}; instead manage it in maintainer scripts: create it in postinst script on fresh install and remove on purge/remove in postrm. * Force versioned dependency on runit-helper, to make sure that versioned dependency on dh-runit would close #899242 --- debian/changelog | 7 +++++++ debian/dh-runit.install | 1 + dh_runit | 17 +++++++++++------ postinst-runit | 12 ++++++++++++ postrm-runit | 1 + runit-helper | 23 +++++++++++++++++++---- 6 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 postinst-runit diff --git a/debian/changelog b/debian/changelog index 9a92168..578581d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +dh-runit (2.7.3) unstable; urgency=medium + + * Do not re-enable serice on upgrade, if it was disable by local + administrator (See #899242) + + -- Dmitry Bogatov Wed, 23 May 2018 08:19:55 +0300 + dh-runit (2.7.2) unstable; urgency=medium * Invoke runit-helper only if it is available. It ensures, that in diff --git a/debian/dh-runit.install b/debian/dh-runit.install index 762f76a..e3f2d9d 100644 --- a/debian/dh-runit.install +++ b/debian/dh-runit.install @@ -1,3 +1,4 @@ dh_runit /usr/bin postrm-runit /usr/share/debhelper/autoscripts +postinst-runit /usr/share/debhelper/autoscripts runit.pm /usr/share/perl5/Debian/Debhelper/Sequence diff --git a/dh_runit b/dh_runit index 36031ed..e0a8d7e 100755 --- a/dh_runit +++ b/dh_runit @@ -72,11 +72,14 @@ PKG: foreach my $pkg (@{$dh{DOPACKAGES}}) { "/var/lib/runit/supervise/$name", $tmp); install_dir("$tmp/var/lib/runit/supervise/$name"); - if ($conf->{enable}) { - make_symlink("/etc/runit/runsvdir/default/$name", - "/etc/sv/$name", $tmp); - } - runit_autoscript($pkg, 'postrm', "s/#NAME#/$name/"); + my $substitutions = { + NAME => $name, + ENABLE => $conf->{enable} ? "yes" : "no" + }; + + runit_autoscript($pkg, 'postrm', $substitutions); + runit_autoscript($pkg, 'postinst', $substitutions); + if ($conf->{logscript}) { my $logdir = "/var/log/runit/$name"; @@ -100,7 +103,7 @@ HERE } } addsubstvar($pkg, 'misc:Depends', 'runit', '>= 2.1.2-7'); - addsubstvar($pkg, 'misc:Depends', 'runit-helper'); + addsubstvar($pkg, 'misc:Depends', 'runit-helper', '>= 2.7.3'); } # PROMISE: DH NOOP WITHOUT runit @@ -184,3 +187,5 @@ This section contains several example snippets from F.runit> path/to/directory name=my-preferred-name,logscript =cut + +# vim: et:sw=4 diff --git a/postinst-runit b/postinst-runit new file mode 100644 index 0000000..6110707 --- /dev/null +++ b/postinst-runit @@ -0,0 +1,12 @@ +# -*- shell-script -*- +export NAME='#NAME#' +export ENABLE='#ENABLE#' + +# Unlike postrm, I can be sure, that runit-helper is present on +# postinst. +/lib/runit-helper/runit-helper postinst "$@" + +# Local Variables: +# eval: (sh-set-shell "sh" t nil) +# End: +# vim: ft=sh:sw=4 diff --git a/postrm-runit b/postrm-runit index a306688..d5748c9 100644 --- a/postrm-runit +++ b/postrm-runit @@ -1,5 +1,6 @@ # -*- shell-script -*- export NAME='#NAME#' +export ENABLE='#ENABLE#' # Unfortunately, we can not assume, that bin:runit-helper package # is installed at postrm stage. diff --git a/runit-helper b/runit-helper index e48020b..05724af 100755 --- a/runit-helper +++ b/runit-helper @@ -18,7 +18,25 @@ set -e +postinst () { + local action="${1}" previous="${2:-}" + + # Fresh installation (not upgrade). It is important to not override + # local admin decision (see #899242). + if [ "${ENABLE}" = yes ] && [ -z "${previous}" ] ; then + ln -sf "/etc/sv/$NAME" "/etc/runit/runsvdir/default/$NAME" + fi +} + postrm () { + local action="${1}" + + if [ "${action}" != 'purge' ] && [ "${action}" != 'remove' ] ; then + return + fi + + # Links in other runsvdirs is responsibility of administrator. + rm -f "/etc/runit/runsvdir/default/$NAME" # Following code makes sure, that after removal of package, in default # setup, the only files belonged to log user, belong to root. @@ -33,10 +51,6 @@ postrm () { chown --recursive root:root "/var/log/runit/$NAME" fi - if [ "$1" != 'purge' ] ; then - return - fi - # If runscript was never invoked, there will be no files # in this directory, and `dpkg' will remove it. In this case, # we have nothing to do. @@ -64,3 +78,4 @@ postrm () { } "$@" +# vim: sw=4:et -- cgit v1.2.3