+#!/bin/sh
+# run from the prerm and postinst
+set -e
+
+install=$1
+
+check_file () {
+ dckey=$1; regexp=$2; file=$3
+
+ if ! test -f $file; then return; fi
+
+ if $install; then
+ if test -e $file.not-trad; then return; fi
+ before=misc
+ after=trad
+ newfile=$file.trad
+ oldfile=$file.not-trad
+ else
+ if ! test -e $file.not-trad; then return; fi
+ before=trad
+ after=misc
+ newfile=$file.undo-trad
+ oldfile=$file.trad
+ fi
+
+ perl -pe '
+ s/^('"$regexp"'\s+)\-'$before'\-(fixed-medium-r-semicondensed)/$1-'$after'-$2/
+ ' <$file >$file
+ if cmp -s $file $newfile; then
+ rm $newfile
+ return
+ fi
+
+ db_get $dckey
+ if [ $RET != true ]; then return; fi
+
+ if $install; then
+ db_get $dckey-done || true
+ if [ $RET = true ]; then return; fi
+
+ echo "Updating $file to use traditional fixed..."
+ else
+ echo "Restoring $file with nontraditional fixed..."
+ fi
+ rm -f $oldfile
+ ln $file $oldfile
+ mv -f $newfile $file
+
+ case "$file" in
+ *.alias) update-fonts-alias misc ;;
+ esac
+
+ db_set $dckey-done $install
+ # only ever do this once, unless we've actually undone it since
+}
+
+echo "Checking configuration..."
+
+check_file reconfigure-xterm '\*VT100\.utf8Fonts\.font\:' \
+ /etc/X11/app-defaults/XTerm
+
+check_file remap-fixed 'fixed' \
+ /etc/X11/fonts/misc/xfonts-base.alias
+