monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] org.debian.monotone: 60ad112b749eb7ca1911855720


From: code
Subject: [Monotone-commits-diffs] org.debian.monotone: 60ad112b749eb7ca1911855720dbc2adfee88968
Date: Mon, 11 Mar 2013 21:54:06 +0100 (CET)

revision:            60ad112b749eb7ca1911855720dbc2adfee88968
date:                2010-06-14T11:53:26
author:              address@hidden
branch:              org.debian.monotone
changelog:
- Attempt to make monotone-server delete auto-generated key correctly on purge.
- Make monotone-server purge script more robust in the event of missing files/
  folders.

manifest:
format_version "1"

new_manifest [646407441fb9f26881e9a61a4fbabf893aee314c]

old_revision [f5fa4837d8931197708e8770830bcd1f708a5b90]

patch "monotone-server.postrm"
 from [8bd9ca557becb519bc67515dfafead77b97120e2]
   to [22cbf57558b8bd4b613f82a965d8081fcf5e8d5d]
============================================================
--- monotone-server.postrm	8bd9ca557becb519bc67515dfafead77b97120e2
+++ monotone-server.postrm	22cbf57558b8bd4b613f82a965d8081fcf5e8d5d
@@ -18,6 +18,37 @@ set -e
 # for details, see http://www.debian.org/doc/debian-policy/ or
 # the debian-policy package
 
+MTN_HOME="/var/lib/monotone"
+MTN_KEY_DIR="${MTN_HOME}/keys"
+
+locate_key()
+{
+  # This function attempts to locate the auto-generated keypair for the monotone-server.
+  # It may list multiple filenames, or none at all.
+  # Filenames are printed to standard out.
+  db_get monotone-server/key
+
+  if [ -d ${MTN_KEY_DIR} ]; then
+    find ${MTN_KEY_DIR} -type f -regextype posix-egrep -regex "${MTN_KEY_DIR}/${RET}(\.[0-9a-f]{40})?"
+  fi
+}
+
+delete_key()
+{
+  local KEY
+  local KEY_COUNT
+
+  KEY=`locate_key`
+  KEY_COUNT=`echo ${KEY} | wc -w`
+
+  if [ ${KEY_COUNT} -gt 1 ]; then
+    echo "Unable to determine auto-generated monotone-server keypair." >&2
+    echo "Please delete it manually from ${MTN_KEY_DIR}." >&2
+  elif [ ${KEY_COUNT} -eq 1 ]; then
+    rm -f "${KEY}"
+  fi
+}
+
 case "$1" in
     purge)
        # note: when executing in this mode, this script cannot assume
@@ -55,33 +86,39 @@ case "$1" in
 
 	   db_get monotone-server/manage-db
 	   if [ "$RET" = true ]; then
-	       db_get monotone-server/key
-	       rm -f /var/lib/monotone/keys/"$RET"
+	       delete_key
+               rm -f ${MTN_HOME}/default.mtn
+               rm -f ${MTN_HOME}/default.mtn~
+               rm -f ${MTN_HOME}/default.mtn-journal
 
-	       rm -f /var/lib/monotone/default.mtn
-	       rm -f /var/lib/monotone/default.mtn~
-	       rm -f /var/lib/monotone/default.mtn-journal
-
-	       grep -v "$RET" /etc/monotone/passphrases \
-	                    > /etc/monotone/passphrases.dpkg-new || true
-	       if [ -s /etc/monotone/passphrases.dpkg-new ]; then
-		   mv -f /etc/monotone/passphrases.dpkg-new \
-		         /etc/monotone/passphrases
-	       else
-		   rm -f /etc/monotone/passphrases.dpkg-new \
-		         /etc/monotone/passphrases
+               if [ -f /etc/monotone/passphrases ]; then
+                 db_get monotone-server/key
+	         grep -v "$RET" /etc/monotone/passphrases \
+	                      > /etc/monotone/passphrases.dpkg-new || true
+	         if [ -s /etc/monotone/passphrases.dpkg-new ]; then
+	  	     mv -f /etc/monotone/passphrases.dpkg-new \
+		           /etc/monotone/passphrases
+	         else
+		     rm -f /etc/monotone/passphrases.dpkg-new \
+		           /etc/monotone/passphrases
+	         fi
 	       fi
-
 	   fi
 	   # do not stop debconf, the debhelper additions will need it.
        fi
-       rmdir --ignore-fail-on-non-empty /var/lib/monotone/keys
-       rmdir --ignore-fail-on-non-empty /var/lib/monotone
 
+       if [ -d ${MTN_KEY_DIR} ]; then
+         rmdir --ignore-fail-on-non-empty ${MTN_KEY_DIR}
+       fi
+
+       if [ -d ${MTN_HOME} ]; then
+         rmdir --ignore-fail-on-non-empty ${MTN_HOME}
+       fi
+
        # if deluser/delgroup exist, remove the server user and group.
        # do not do this if /var/lib/monotone still exists (so that it
        # will still have a named user owning it).
-       if which deluser > /dev/null && [ ! -e /var/lib/monotone ]; then
+       if which deluser > /dev/null && [ ! -e ${MTN_HOME} ]; then
 	   if [ -n "`id -u monotone 2>/dev/null`" ]; then
                deluser --quiet monotone 2>/dev/null >/dev/null
 	   fi
@@ -90,8 +127,8 @@ case "$1" in
                delgroup --quiet monotone 2>/dev/null >/dev/null
 	   fi
        else
-	   if [ -e /var/lib/monotone ]; then
-	       reason="/var/lib/monotone still exists"
+	   if [ -e ${MTN_HOME} ]; then
+	       reason="${MTN_HOME} still exists"
 	   else
 	       reason="deluser is not available"
 	   fi

reply via email to

[Prev in Thread] Current Thread [Next in Thread]