On Sat, Dec 22, 2007 at 03:41:53AM -0600, Ming Hua wrote: > > The fix is > also not very hard, the script just need to check the md5sum of the > conffile, something like the examples in [1]. > > 1. http://wiki.debian.org/DpkgConffileHandling
The attached patch is what I used in Ubuntu's 0.9.9-2ubuntu1 version, using the method in the example to handle deleted conffile. I tested in Ubuntu for both modified and unmodified conffile, and it seems to work as intended. I'll test it in Debian as well, if nobody beats me. The changelog entry for this change: * Move old conffile handling from postinst script to preinst script. Also check if the conffile is locally modified. If it is, back it up and tell the user to review the local changes and add it to the new conffile instead of just delete it. (Debian bug #457423) Ming 2008.01.01
--- xfonts-wqy-0.9.9/debian/postinst +++ xfonts-wqy-0.9.9/debian/postinst @@ -25,14 +25,6 @@ ln -s $CONFAVAIL/$wqy_conf $CONFDIR fi - # Clean up old config files - if dpkg --compare-versions "$2" lt-nl 0.9.9; then - rm -f $CONFDIR/wqy.conf - fi - if dpkg --compare-versions "$2" eq 0.9.9-1; then - rm -f $CONFAVAIL/85-xfonts-wqy.alias - fi - if [ -x /usr/bin/fc-cache ]; then echo -n "Regenerating fonts cache... " --- xfonts-wqy-0.9.9.orig/debian/preinst +++ xfonts-wqy-0.9.9/debian/preinst @@ -0,0 +1,38 @@ +#!/bin/sh + +set -e + +case "$1" in + install|upgrade) + if dpkg --compare-versions "$2" lt-nl 0.9.9; then + # handle removed conffile + CONFFILE=/etc/fonts/conf.d/wqy.conf + if [ -e $CONFFILE ]; then + md5sum=`md5sum $CONFFILE | sed -e "s/ .*//"` + old_md5sum=`dpkg-query -W -f '${Conffiles}' xfonts-wqy | sed -n -e "\\' $CONFFILE'{s/obsolete$//;s/.* //;p}"` + if [ $md5sum = $old_md5sum ]; then + rm -f $CONFFILE + echo "Removed obsolete conffile $CONFFILE." + else + mv -f $CONFFILE $CONFFILE.dpkg-bak + echo "Obsolete conffile $CONFFILE has been locally modified, saved as $CONFFILE.dpkg-bak." + echo "The new configuration file for xfonts-wqy is /etc/fonts/conf.avail/85-xfonts-wqy.conf, please review your local changes and add them to the new file." + fi + fi + fi + if dpkg --compare-versions "$2" eq 0.9.9-1; then + # unconditionally delete useless conffile introduced in 0.9.9-1 + rm -f /etc/fonts/conf.avail/85-xfonts-wqy.alias + fi + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER#