tags 607243 + patch
quit

How about this?

-- 8< --
Subject: debian/git-daemon-run: allow package to be removed and purged in one 
step

Suppose I install git-daemon-run, wait a while, and then decide
to remove it (with "apt-get --purge remove git-daemon-run" or
"dpkg --purge git-daemon-run").

 - prerm remove runs "update-service --remove /etc/sv/git-daemon".
   This removes the git-daemon symlink from /etc/service, providing an
   asynchronous signal to the supervisor to shut down git-daemon and
   its logging process.

 - non-conffiles (in /usr/share/doc) are removed by dpkg.  postrm
   remove is invoked and does nothing.  conffiles ("run" scripts under
   /etc/sv/git-daemon) are removed by dpkg.  /etc/sv/git-daemon/log,
   /var/lib/supervise/git-daemon, etc remain.

 - postrm purge runs "sv force-stop git-daemon", in case runit is
   still installed.  This would kill the service and wait for it to
   die if /etc/service/git-daemon still existed.

 - postrm purge removes its state and tries to remove the gitlog user.
   Unfortunately if we were too quick, then the gitlog user is still
   in use, as the owner of the logging process for git-daemon.  postrm
   fails.

Yagh.  Luckily the fixes are simple:

As the update-service manual explains, sv(8) does not control a
removed service unless we pass it the full path /etc/sv/git-daemon.
Pass such a full path.

The force-stop command does not stop the logging service --- one needs
to use force-shutdown to request that.  Do so.

This patch does not affect the rapid-fire sequence

 * install git-daemon-run
 * remove git-daemon-run
 * remove runit
 * purge git-daemon-run

which seems by chance to work already (probably because removal of
runit takes long enough to avoid the race window).

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 debian/changelog             |    8 ++++++++
 debian/git-daemon-run.postrm |    2 +-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 83290f5..4b2dfac 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,12 @@
 git (1:1.7.4.1-6~exp0) experimental; urgency=low
 
+  * git-daemon-run.postrm: reliably stop git-daemon if runit is
+    running (closes: #610099).
+    * pass the full path /etc/sv/git-daemon to sv.  Otherwise the
+      supervisor looks for metadata in /etc/service and cannot find
+      it because prerm already removed the symlink there.
+    * pass force-shutdown, not force-stop, to sv so that both
+      git-daemon and its logging service get a chance to terminate.
   * debian/diff/0037..0199: new from the upstream 'master' branch
     (see RelNotes/1.7.5.txt for details):
     * repo-config: add deprecation warning
diff --git a/debian/git-daemon-run.postrm b/debian/git-daemon-run.postrm
index 6151b52..5e77e4d 100644
--- a/debian/git-daemon-run.postrm
+++ b/debian/git-daemon-run.postrm
@@ -3,7 +3,7 @@ set -e
 
 test "$1" = 'purge' || exit 0
 
-sv force-stop git-daemon 2>/dev/null || :
+sv force-shutdown /etc/sv/git-daemon 2>/dev/null || :
 rm -rf /etc/sv/git-daemon/supervise /etc/sv/git-daemon/log/supervise
 rm -rf /var/lib/supervise/git-daemon /var/lib/supervise/git-daemon.log
 
-- 
1.7.4.1.643.g28c43.dirty




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to