On Fri, Aug 28, 2009 at 12:16:02AM +0700, Theppitak Karoonboonyanan wrote: > 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).
And here are the patches for debhelper and xfonts-utils. They have been tested by rebuilding thaixfonts (with package.alias) and thaifonts-scalable (without package.alias) and then emulating piuparts sequence against them in a chroot. -- Theppitak Karoonboonyanan http://linux.thai.net/~thep/
Index: debhelper-7.4.0+nmu1/autoscripts/postinst-xfonts =================================================================== --- debhelper-7.4.0+nmu1.orig/autoscripts/postinst-xfonts 2009-09-02 18:50:52.000000000 +0700 +++ debhelper-7.4.0+nmu1/autoscripts/postinst-xfonts 2009-09-02 19:23:36.000000000 +0700 @@ -1,3 +1,6 @@ +#ALIAS_BEGIN# +#ALIAS_BODY# +#ALIAS_END# if which update-fonts-dir >/dev/null 2>&1; then #CMDS# fi Index: debhelper-7.4.0+nmu1/autoscripts/postrm-xfonts =================================================================== --- debhelper-7.4.0+nmu1.orig/autoscripts/postrm-xfonts 2009-09-02 18:51:02.000000000 +0700 +++ debhelper-7.4.0+nmu1/autoscripts/postrm-xfonts 2009-09-02 19:24:06.000000000 +0700 @@ -1,3 +1,6 @@ +#ALIAS_BEGIN# +#ALIAS_BODY# +#ALIAS_END# if [ -x "`which update-fonts-dir 2>/dev/null`" ]; then #CMDS# fi Index: debhelper-7.4.0+nmu1/dh_installxfonts =================================================================== --- debhelper-7.4.0+nmu1.orig/dh_installxfonts 2009-09-02 18:50:35.000000000 +0700 +++ debhelper-7.4.0+nmu1/dh_installxfonts 2009-09-02 21:54:29.000000000 +0700 @@ -60,20 +60,36 @@ if (@fontdirs) { # Figure out what commands the postinst and postrm will need # to call. - my @cmds; + my @cmds, my @alias_postinst, my @alias_postrm; + my $alias_begin="/#ALIAS_BEGIN#/d"; + my $alias_postinst_body="/#ALIAS_BODY#/d"; + my $alias_postrm_body="/#ALIAS_BODY#/d"; + my $alias_end="/#ALIAS_END#/d"; + my $alias_exclude="/etc/fonts/excluded-aliases"; foreach my $f (@fontdirs) { # This must come before update-fonts-dir. push @cmds, "update-fonts-scale $f" if -f "$tmp/etc/X11/fonts/$f/$package.scale"; push @cmds, "update-fonts-dir --x11r7-layout $f"; - push @cmds, "update-fonts-alias $f" - if -f "$tmp/etc/X11/fonts/$f/$package.alias"; + if (-f "$tmp/etc/X11/fonts/$f/$package.alias") { + push @cmds, "update-fonts-alias $f"; + push @alias_postinst, "\tsed -i \'\\\\\\\\,/etc/X11/fonts/$f/$package.alias,d\' $alias_exclude"; + push @alias_postrm, "\tsed -i \'\\\\\\\\,/etc/X11/fonts/$f/$package.alias,d\' $alias_exclude"; + push @alias_postrm, "\techo /etc/X11/fonts/$f/$package.alias >> $alias_exclude"; + } + } + + if (@alias_postinst) { + $alias_begin="s:#ALIAS_BEGIN#:if [ -f $alias_exclude ]; then:"; + $alias_postinst_body="s:#ALIAS_BODY#:".join("\\\\n", @alias_postinst).":"; + $alias_postrm_body="s:#ALIAS_BODY#:".join("\\\\n", @alias_postrm).":"; + $alias_end="s:#ALIAS_END#:fi:"; } autoscript($package, "postinst", "postinst-xfonts", - "s:#CMDS#:".join(";", @cmds).":;"); + "s:#CMDS#:".join(";", @cmds).":;$alias_begin;$alias_postinst_body;$alias_end;"); autoscript($package, "postrm", "postrm-xfonts", - "s:#CMDS#:".join(";", @cmds).":;"); + "s:#CMDS#:".join(";", @cmds).":;$alias_begin;$alias_postrm_body;$alias_end;"); addsubstvar($package, "misc:Depends", "xfonts-utils"); }
Index: xfonts-utils-7.4+2/debian/local/update-fonts-alias =================================================================== --- xfonts-utils-7.4+2.orig/debian/local/update-fonts-alias 2009-09-02 22:11:23.000000000 +0700 +++ xfonts-utils-7.4+2/debian/local/update-fonts-alias 2009-09-02 22:21:28.000000000 +0700 @@ -129,30 +129,33 @@ 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 excluded aliases + grep $FILE /etc/fonts/excluded-aliases | grep -v '^!!' >/dev/null 2>&1 && 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 Index: xfonts-utils-7.4+2/debian/local/excluded-aliases =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xfonts-utils-7.4+2/debian/local/excluded-aliases 2009-09-02 22:17:50.000000000 +0700 @@ -0,0 +1 @@ +!! Excluded alias files to be ignored by update-fonts-alias(8) Index: xfonts-utils-7.4+2/debian/xfonts-utils.install =================================================================== --- xfonts-utils-7.4+2.orig/debian/xfonts-utils.install 2009-09-02 22:14:08.000000000 +0700 +++ xfonts-utils-7.4+2/debian/xfonts-utils.install 2009-09-02 22:17:03.000000000 +0700 @@ -10,6 +10,7 @@ usr/share/man/man1/ucs2any.1 usr/share/aclocal/fontutil.m4 usr/lib/pkgconfig/fontutil.pc +../local/excluded-aliases etc/fonts ../local/update-fonts-alias usr/sbin ../local/update-fonts-dir usr/sbin ../local/update-fonts-scale usr/sbin