Package: runit-helper Version: 2.8.14 Severity: normal Tags: patch Hi,
there is a problem in runit-helper with the following logic postinst () { local action="${1}" previous="${2:-}" # Fresh installation (not upgrade). It is important to not override # local admin decision (see #899242). if [ "${ENABLE}" = yes ] && \ dpkg --compare-versions "${previous}" '<<' "${SINCE}" ; 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" ... if I remove (without purging) a package with version >= SINCE and then I reinstall such package, runit-helper will not enable the service. This is unexpected, since the local admin never tell that he/she wants to keep the service disabled (and currently has no mean to do that). I propose to use .service symlinks to mark a service as disabled (directories starting with dots are ignored, this is already documented in runsvdir(8) manpage). I've documented this in update-service manpage (see #942320); maybe this need also a 'POLICY' section in dh_runit(1) or a notice to users of runit on upgrade? Lorenzo -- System Information: Debian Release: bullseye/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 4.20.3-van (SMP w/4 CPU cores; PREEMPT) Kernel taint flags: TAINT_OOT_MODULE Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: runit (via /run/runit.stopit) -- no debconf information -- debsums errors found: debsums: changed file /lib/runit-helper/runit-helper (from runit-helper package)
>From 66b2ba56358d2742704f8108c338d2ec29d5e76a Mon Sep 17 00:00:00 2001 From: Lorenzo Puliti <lorenzo.r...@gmail.com> Date: Thu, 10 Oct 2019 23:54:53 +0200 Subject: [PATCH] Use .link to mark a service as disabled Use '.link' instead of removing 'link' to disable a service. This allow to preserve local admin choice to disable a service both on package upgrade and when the package is removed but not purged. --- runit-helper | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/runit-helper b/runit-helper index 70c42f2..4d4970a 100755 --- a/runit-helper +++ b/runit-helper @@ -21,13 +21,14 @@ set -e postinst () { local action="${1}" previous="${2:-}" - # Fresh installation (not upgrade). It is important to not override - # local admin decision (see #899242). + # It is important to not override local admin + # decision (see #899242). if [ "${ENABLE}" = yes ] && \ - dpkg --compare-versions "${previous}" '<<' "${SINCE}" ; then + [ ! -h "/etc/runit/runsvdir/default/.$NAME" ] ; then ln -sf "/etc/sv/$NAME" "/etc/runit/runsvdir/default/$NAME" fi - + # "ENABLE=no" is always a no-op + # Upgrade will changes destination of /etc/sv/{name}/supervise symlink from # /var/* to /run/*. If service was running, it important that its supervise # directory is still accessible via /etc/sv/{name}/supervise symlink. @@ -56,8 +57,12 @@ postrm () { return fi + # When "ENABLE=no" the $NAME link is an admin decision + # so we don't remove it. # Links in other runsvdirs is responsibility of administrator. - rm -f "/etc/runit/runsvdir/default/$NAME" + if [ "${action}" = 'remove' ] && [ "${ENABLE}" = yes ] ; then + rm -f "/etc/runit/runsvdir/default/$NAME" + fi # If runscript was never invoked, there will be no files # in this directory, and `dpkg' will remove it. In this case, @@ -84,6 +89,8 @@ postrm () { fi done if [ "${action}" = 'purge' ] ; then + rm -f "/etc/runit/runsvdir/default/$NAME" + rm -f "/etc/runit/runsvdir/default/.$NAME" logdir="/var/log/runit/$NAME" if [ -d "$logdir" ] ; then rm -r "$logdir" -- 2.23.0