chiark / gitweb /
use template for confirm q
[xfonts-traditional.git] / debian / xfonts-traditional.prerm
old mode 100644 (file)
new mode 100755 (executable)
index a2786a6..7578f52
@@ -3,43 +3,49 @@ set -e
 
 . /usr/share/debconf/confmodule
 
+#DEBHELPER#
+
+/usr/share/xfonts-traditional/checkfiles prerm "$@"
+
 case "$1" in
 
 remove)
 
-       echo 'Checking that "fixed" is not from xfonts-traditional..."
+       echo 'Checking that "fixed" is not from xfonts-traditional...'
+
+       if grep '^fixed[         ][      ]*-trad-' \
+                       /etc/X11/fonts/misc/xfonts-base.alias \
+                       /usr/share/fonts/X11/misc/fonts.alias; then
+
+               RET=''
+               db_input critical xfonts-traditional/confirm-break-remove ||:
+               db_go ||:
+               db_get xfonts-traditional/confirm-break-remove ||:
+               if [ x$RET != xtrue ]; then
+                       db_fset xfonts-traditional/confirm-break-remove \
+                               seen false ||:
+                       echo 'Aborting to avoid breaking "fixed".' >&2
+                       exit 1
+               fi
+       fi
 
-       if grep '^fixed[         ][      ]*-trad-'; then
-               cat >&2 <<END
-Removing xfonts-traditional would probably your X server by removing "fixed".
+       for d in /usr/share/fonts/X11 /usr/local/share/fonts/X11; do
+               if ! test -e "$d"; then continue; fi
 
-You should not remove xfonts-traditional while "fixed" refers to one
-of its fonts.  You probably want to check the differences between
-/etc/X11/fonts/misc/xfonts-base.alias and xfonts-base.alias.not-trad,
-and probably replace the former with the latter, and retry the removal.
+               find "$d" \
+                          -type f \
+                       \( -name xfonts-traditional.log -o \
+                          -name xfonts-traditional.done -o \
+                          -name xfonts-traditional.done.new -o  \
+                          -name trad--\*.pcf.gz.new \) \
+                       -print0 | xargs -0r rm --
 
-END
-               printf 'Continue anyway ? [n/y] '
-               read x
-               case "$x" in
-               y*|Y*)  ;;
-               *)      exit 1 ;;
-               esac
-       fi
+               find "$d" \
+                          -type f \
+                          -name trad--\*.pcf.gz \
+                       -print0 | xargs -0r rm --
+       done
 
        ;;
 
-       find /usr/share/fonts/X11 /usr/local/share/fonts/X11 \
-                  -type f \
-               \( -name xfonts-traditional.log -o \
-                  -name xfonts-traditional.done -o 
-                  -name xfonts-traditional.done.new -o 
-                  -name trad--\*.pcf.gz.new \) \
-               -print0 | xargs -0r rm
-
-       find /usr/share/fonts/X11 /usr/local/share/fonts/X11 \
-                  -type f \
-                  -name trad--\*.pcf.gz \
-               -print0 | xargs -0r rm
-
 esac