Package: git-daemon-run
Version: 1:2.24.0~rc2-1dotlink1
Severity: normal
Tags: patch

Dear Git Maintainer,
(runit maintainer in CC)

Since runit 2.1.2-36, update-service will be used also to record the local admin
settings about the wanted status of a service (enabled/disabled).
See #942323 to understand why this was done.
This change will make git-daemon-run buggy in that using update-service
in maintscripts will overwrite local admin preference.

I've attached a patch that tries to emulate the logic of dh-runit, can you
have a look? Ideally this should be uploaded before runit.

Thanks,
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)

Versions of packages git-daemon-run depends on:
ii  adduser  3.118
ii  git      1:2.24.0~rc2-1
ii  runit    2.1.2-35

git-daemon-run recommends no packages.

git-daemon-run suggests no packages.

-- no debconf information
>From 789e8e894973f529f3ee507143a44ffc1dea1bcc Mon Sep 17 00:00:00 2001
From: Lorenzo Puliti <lorenzo.r...@gmail.com>
Date: Sun, 3 Nov 2019 19:20:45 +0100
Subject: [PATCH] Git-daemon-run: preserve local admin settings

Preserve local admin decision to keep git-daemon disabled:
this will prevent from enabling the service when a
'.git-daemon' symlink exists at postinstall stage; also
this means that the '.git-daemon' symlink should be preserved
at prerm stage, but only if it was a local admin decision.
---
 debian/git-daemon-run.postinst | 10 ++++++----
 debian/git-daemon-run.postrm   |  1 +
 debian/git-daemon-run.prerm    | 10 ++++++++++
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/debian/git-daemon-run.postinst b/debian/git-daemon-run.postinst
index 00a4d38459..9ec0435f7d 100644
--- a/debian/git-daemon-run.postinst
+++ b/debian/git-daemon-run.postinst
@@ -17,7 +17,9 @@ test -z "$2" || dpkg --compare-versions "$2" gt '1:1.5.4.2-1' 
|| {
 }
 
 # enable git-daemon service
-update-service --add /etc/sv/git-daemon
-
-# restart git-daemon service if it was running
-test -z "$2" || sv -v term git-daemon || :
+# no-op if the admin set it as 'disabled'
+if [ ! -h /etc/service/.git-daemon ]; then
+  update-service --add /etc/sv/git-daemon
+  # restart git-daemon service if it was running
+  test -z "$2" || sv -v term git-daemon || :
+fi
diff --git a/debian/git-daemon-run.postrm b/debian/git-daemon-run.postrm
index f6aa282d05..f73b1d6bf1 100644
--- a/debian/git-daemon-run.postrm
+++ b/debian/git-daemon-run.postrm
@@ -16,6 +16,7 @@ for i in '@*' current config lock state; do
   rm -f /var/log/git-daemon/$i
 done
 rmdir /var/log/git-daemon || :
+rm -f /etc/service/.git-daemon
 
 getent passwd gitlog >/dev/null || exit 0
 ! deluser --version >/dev/null 2>&1 || exec deluser -f gitlog
diff --git a/debian/git-daemon-run.prerm b/debian/git-daemon-run.prerm
index 0685520903..ad8734a06d 100644
--- a/debian/git-daemon-run.prerm
+++ b/debian/git-daemon-run.prerm
@@ -6,4 +6,14 @@ set -e
 test "$1" = 'remove' || test "$1" = 'deconfigure' || \
   test "$1" = 'failed-upgrade' || exit 0
 
+disabled=0
+
+if [ -h /etc/service/.git-daemon ]; then
+  disabled=1
+fi
+
 update-service --remove /etc/sv/git-daemon || :
+
+if [ "$disabled" = 0 ]; then
+  rm -f /etc/service/.git-daemon
+fi
-- 
2.24.0.rc2

Reply via email to