Purge repositories if debconf says so. debian
authorPaul Crowley <paul@lshift.net>
Mon, 30 Nov 2009 15:20:34 +0000
branchdebian
changeset 224 caf9cb61f856
parent 223 eb8ec32583b0
child 228 f98f716b2ae8
Purge repositories if debconf says so.
debian/config
debian/postinst
debian/postrm
debian/templates
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/config	Mon Nov 30 15:20:34 2009 +0000
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -e
+
+# Load debconf
+. /usr/share/debconf/confmodule
+
+db_input medium mercurial-server/purge_repositories || true
+
+db_go || true
+
+exit 0
+
--- a/debian/postinst	Mon Nov 30 12:55:11 2009 +0000
+++ b/debian/postinst	Mon Nov 30 15:20:34 2009 +0000
@@ -1,25 +1,13 @@
 #!/bin/sh
 # postinst script for mercurial-server
-#
-# see: dh_installdeb(1)
 
 set -e
 
-# summary of how this script can be called:
-#        * <postinst> `configure' <most-recently-configured-version>
-#        * <old-postinst> `abort-upgrade' <new version>
-#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-#          <new-version>
-#        * <postinst> `abort-remove'
-#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-#          <failed-install-package> <version> `removing'
-#          <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
-
+# Load debconf
+. /usr/share/debconf/confmodule
 
 case "$1" in
-    configure)
+    configure|reconfigure)
         if ! getent passwd hg >/dev/null; then
             adduser --disabled-password --quiet --system \
                 --shell /bin/sh --group \
@@ -45,4 +33,3 @@
 
 exit 0
 
-
--- a/debian/postrm	Mon Nov 30 12:55:11 2009 +0000
+++ b/debian/postrm	Mon Nov 30 15:20:34 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
 
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/templates	Mon Nov 30 15:20:34 2009 +0000
@@ -0,0 +1,5 @@
+Template: mercurial-server/purge_repositories
+Type: boolean
+Default: false
+Description: Do you want the repositories to be removed when mercurial-server is purged?
+