On Sat, Oct 17, 2009 at 5:27 AM, Julien Cristau <jcris...@debian.org> wrote: > On Sat, Sep 5, 2009 at 11:00:54 +0700, Theppitak Karoonboonyanan wrote: > >> +INCLUDE_ALIAS= >> +EXCLUDE_ALIAS= >> +EXCLUDE_CONF=/etc/fonts/excluded-aliases > > Should this one be somewhere in /etc/X11 instead? /etc/fonts has the > fontconfig stuff, I'd rather not hijack it.
Oops. Yes, I meant to put it there. But as said below, we're moving it somewhere else, anyway. >> +# Remove aliases to be included from exclude list >> +for f in $INCLUDE_ALIAS; do >> + sed -i "\\,$f,d" $EXCLUDE_CONF >> +done >> +# Add aliases to be excluded to exclude list >> +for f in $EXCLUDE_ALIAS; do >> + sed -i "\\,$f,d" $EXCLUDE_CONF >> + echo "$f" >> $EXCLUDE_CONF >> +done >> + > > If possible, I think it'd be better if we didn't modify a configuration > file. Can we keep this file for the admin (read-only for > update-fonts-alias), and have something under /var/lib/ for package > bookkeeping? (that's assuming we do need a config file for this; if > not, we can just move the exclude list to /var/lib/xfonts) I initially intended to put it under the same root as the alias files to prevent too much surprise to users who investigate this. But, sure, one can still figure it out by reading the update-fonts-alias script. For simplicity, I just move it to /var/lib/xfonts, without additional config file. > ... and now I wonder if the foo.alias files really need to stay in /etc, > or if we can move them somewhere else where they'll be removed with the > corresponding package. oh well... Yeah, as I mentioned in the last part of message #48, this would require a lot of updates on font packages, but results in a cleaner system. > In any case the sed regexps should be anchored here. OK. >> + grep -v '^!!' /etc/fonts/excluded-aliases | grep $FILE >> >/dev/null 2>&1 && continue > > grep -q ^"$FILE"$ $EXCLUDE_CONF && continue Ah, yes. Thanks for the suggestion. Updated patch attached. Regards, -- Theppitak Karoonboonyanan http://linux.thai.net/~thep/
Index: xfonts-utils-7.4+2.1/debian/local/update-fonts-alias =================================================================== --- xfonts-utils-7.4+2.1.orig/debian/local/update-fonts-alias 2009-09-02 22:11:23.000000000 +0700 +++ xfonts-utils-7.4+2.1/debian/local/update-fonts-alias 2009-10-17 09:36:11.000000000 +0700 @@ -43,7 +43,7 @@ message "usage error: $*" fi cat <<EOF -Usage: $PROGNAME DIRECTORY ... +Usage: $PROGNAME [OPTIONS] DIRECTORY ... $PROGNAME { -h | --help } This program combines X font alias information from several packages into a single file that is placed in each specified X font directory DIRECTORY. This @@ -51,35 +51,68 @@ update-fonts-alias(8) for more information. Options: -h, --help display this usage message and exit + -i, --include ALIAS-FILE drop ALIAS-FILE from exlude list if any + -x, --exclude ALIAS-FILE add ALIAS-FILE to exclude list EOF } X11R7_LAYOUT= - -# Validate arguments. -case "$1" in - -h|--help) - usage - exit 0 - ;; - -7|--x11r7-layout) - X11R7_LAYOUT=true - shift - ;; -esac - -case "$1" in - -*) - usage "unrecognized option" >&2 - exit 2 - ;; -esac +INCLUDE_ALIAS= +EXCLUDE_ALIAS= +EXCLUDE_CONF=/var/lib/xfonts/excluded-aliases + +# Validate options. +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + usage + exit 0 + ;; + -7|--x11r7-layout) + X11R7_LAYOUT=true + shift + ;; + -i|--include) + if [ $# -lt 2 ]; then + usage "alias file to include is missing" >&2 + exit 2 + fi + INCLUDE_ALIAS="$INCLUDE_ALIAS $2" + shift 2 + ;; + -x|--exclude) + if [ $# -lt 2 ]; then + usage "alias file to exclude is missing" >&2 + exit 2 + fi + EXCLUDE_ALIAS="$EXCLUDE_ALIAS $2" + shift 2 + ;; + -*) + usage "unrecognized option" >&2 + exit 2 + ;; + *) + break + ;; + esac +done if [ $# -eq 0 ]; then usage "one or more font directories must be specified" >&2 exit 2 fi +# Remove aliases to be included from exclude list +for f in $INCLUDE_ALIAS; do + sed -i "\\,^$f$,d" $EXCLUDE_CONF +done +# Add aliases to be excluded to exclude list +for f in $EXCLUDE_ALIAS; do + sed -i "\\,^$f$,d" $EXCLUDE_CONF + echo "$f" >> $EXCLUDE_CONF +done + while [ -n "$1" ]; do # Try to be clever about the argument; were we given an absolute path? if expr "$1" : "/.*" >/dev/null 2>&1; then @@ -129,30 +162,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 -q "^$FILE$" $EXCLUDE_CONF && 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.1/debian/local/excluded-aliases =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ xfonts-utils-7.4+2.1/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.1/debian/xfonts-utils.install =================================================================== --- xfonts-utils-7.4+2.1.orig/debian/xfonts-utils.install 2009-09-02 22:14:08.000000000 +0700 +++ xfonts-utils-7.4+2.1/debian/xfonts-utils.install 2009-10-17 08:55:22.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 var/lib/xfonts ../local/update-fonts-alias usr/sbin ../local/update-fonts-dir usr/sbin ../local/update-fonts-scale usr/sbin