On Thu, Aug 27, 2009 at 11:03 PM, Julien Cristau<jcris...@debian.org> wrote:

> update-fonts-* shouldn't need to know about dpkg, IMO.  Any way we can
> avoid this?

Exclude list, probably:

- /etc/fonts/excluded-aliases lists *.alias files to be excluded.
- Patch update-fonts-alias to filter out the exclude list.
- Patch dh_installxfonts so that:
  - package.postrm adds its *.alias to excluded-aliases
  - package.postinst removes its *.alias from excluded-aliases if any.

This requires font packages to be rebuilt with the updated debhelper
to take effect. Unupdated packages still work as usual, just fail piuparts,
and get listed in fonts.alias even after they are removed (but not purged).


Alternatively, move packages' fonts.alias to /usr/share.
/etc may still be read for user-defined aliases and for old packages.

- Patch update-fonts-alias to also read from /usr/share.
- Font packages install package.alias in /usr/share instead, and clean
  their obsolete conffiles on upgrade, to pass piuparts.

This pushes the job to font packages instead. It will require heavy
sourceful uploads for piuparts-cleanness, but, IMO, results in a
cleaner system.


Any other ideas?

BTW, I update the dpkg-based patch to be a bit more robust.
It shouldn't fail if some *.alias files are not from packages.

Regards,
-- 
Theppitak Karoonboonyanan
http://linux.thai.net/~thep/
--- update-fonts-alias.orig	2009-08-27 22:15:55.000000000 +0700
+++ update-fonts-alias	2009-08-27 23:19:25.000000000 +0700
@@ -129,30 +129,35 @@
         continue
     fi
 
-    # Are there any files to process?
-    if [ "$(echo "$ETCDIR"/*.alias "$ETC7DIR"/*.alias)" != "$ETCDIR/*.alias $ETC7DIR/*.alias" ]
-    then
-        if [ -n "$X11R7DIR" ] && [ -d "$X11R7DIR" ]; then
-            # Write the new alias file in a temporary location in case we are
-            # interrupted.
-            cat >"$X11R7DIR/fonts.alias.update-new" <<EOF
+    if [ -n "$X11R7DIR" ] && [ -d "$X11R7DIR" ]; then
+        # Write the new alias file in a temporary location in case we are
+        # interrupted.
+        cat >"$X11R7DIR/fonts.alias.update-new" <<EOF
 !! fonts.alias -- automatically generated file.  DO NOT EDIT.
 !! To modify, see update-fonts-alias(8).
 EOF
-            for FILE in "$ETCDIR"/*.alias "$ETC7DIR"/*.alias; do
-                [ -e "$FILE" ] || continue
-                echo "!! $FILE" >>"$X11R7DIR/fonts.alias.update-new"
-                cat "$FILE" >>"$X11R7DIR/fonts.alias.update-new"
-            done
-            mv "$X11R7DIR/fonts.alias.update-new" "$X11R7DIR/fonts.alias"
-        fi
-    else
-        if [ -n "$X11R7DIR" ] && [ -d "$X11R7DIR" ]; then
-            # There are no files to process; remove any alias file already in
-            # the font directory.
-            rm -f "$X11R7DIR/fonts.alias"
-            # Remove the font directory if it is empty.
-            rmdir "$X11R7DIR" >/dev/null 2>&1 || true
+        has_data=0
+        for FILE in "$ETCDIR"/*.alias "$ETC7DIR"/*.alias; do
+            [ -e "$FILE" ] || continue
+
+            # Skip conffiles left over by removed packages
+            pkg=`basename $FILE | sed 's/.alias$//'`
+            inst_status=`dpkg-query -W -f='${Status}' $pkg 2>/dev/null | cut -d' ' -f1`
+            [ "$inst_status" == "deinstall" ] && continue
+
+            echo "!! $FILE" >>"$X11R7DIR/fonts.alias.update-new"
+            cat "$FILE" >>"$X11R7DIR/fonts.alias.update-new"
+            has_data=1
+        done
+        if [ $has_data -eq 1 ]; then
+          mv "$X11R7DIR/fonts.alias.update-new" "$X11R7DIR/fonts.alias"
+        else
+          rm -f "$X11R7DIR/fonts.alias.update-new"
+          # There are no files to process; remove any alias file already in
+          # the font directory.
+          rm -f "$X11R7DIR/fonts.alias"
+          # Remove the font directory if it is empty.
+          rmdir "$X11R7DIR" >/dev/null 2>&1 || true
         fi
     fi
 done

Reply via email to