--- a/debian/postrm Thu Nov 12 11:24:50 2009 +0000
+++ b/debian/postrm Wed Dec 02 17:46:28 2009 +0000
@@ -1,28 +1,32 @@
#!/bin/sh
# postrm script for mercurial-server
-#
-# see: dh_installdeb(1)
set -e
-# summary of how this script can be called:
-# * <postrm> `remove'
-# * <postrm> `purge'
-# * <old-postrm> `upgrade' <new-version>
-# * <new-postrm> `failed-upgrade' <old-version>
-# * <new-postrm> `abort-install'
-# * <new-postrm> `abort-install' <old-version>
-# * <new-postrm> `abort-upgrade' <old-version>
-# * <disappearer's-postrm> `disappear' <overwriter>
-# <overwriter-version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
+# Load debconf
+. /usr/share/debconf/confmodule
+# Check if the user wants the repositories removed on purging
+remove_repositories_on_purge() {
+ db_get mercurial-server/purge_repositories || RET=false
+ if [ "$RET" = "true" ]; then
+ return 0
+ else
+ return 1
+ fi
+}
case "$1" in
purge)
- deluser --quiet --system hg > /dev/null || true
+ if remove_repositories_on_purge; then
+ echo -n "Removing hg user and purging data..."
+ deluser --remove-home --quiet --system hg > /dev/null || true
+ else
+ echo -n "Removing hg user..."
+ deluser --quiet --system hg > /dev/null || true
+ fi
delgroup --quiet --system hg > /dev/null || true
+ echo done
;;
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
@@ -41,4 +45,3 @@
exit 0
-