diff --git a/debian/postrm.in b/debian/postrm.in
index 018dba855a061723925c455a5bc7a480d9abbf7e..b367ab5a99129274bd82d6c8136883c80b289779 100644
--- a/debian/postrm.in
+++ b/debian/postrm.in
@@ -3,16 +3,21 @@ set -e
 
 case "$1" in
   purge)
-    rm -f /etc/default/grub
+    if command -v ucfq > /dev/null ; then
+      package="$(ucfq --with-colons /etc/default/grub | cut -d : -f 2)"
+      case $package in
+        @PACKAGE@)
+          rm -f /etc/default/grub
 
-    if command -v ucf >/dev/null ; then
-	ucf --purge /etc/default/grub
-    fi
-    if command -v ucfr >/dev/null ; then
-	ucfr --purge @PACKAGE@ /etc/default/grub || true
+          if command -v ucf >/dev/null ; then
+	    ucf --purge /etc/default/grub
+          fi
+        if command -v ucfr >/dev/null ; then
+            ucfr --purge @PACKAGE@ /etc/default/grub || true
+        fi
+        rm -f /var/lib/grub/ucf/grub.previous
+      esac
     fi
-    rm -f /var/lib/grub/ucf/grub.previous
-
     case @PACKAGE@ in
       grub-pc)
         # debconf could have been purged