xfonts-utils: Changes to 'debian-unstable'
debian/changelog | 8 ++
debian/local/update-fonts-alias | 118 ++++++++++++++++++++++++++--------------
debian/xfonts-utils.postinst.in | 22 +++++++
debian/xfonts-utils.postrm.in | 22 +++++++
4 files changed, 129 insertions(+), 41 deletions(-)
New commits:
commit 6c9954c869ef8960790cfcb63a30200c0390689f
Author: Theppitak Karoonboonyanan <thep@debian.org>
Date: Wed Dec 9 14:30:57 2009 +0100
update-fonts-alias: add an exclude file
Use an exclude file in /var/lib/xfonts/ listing alias files we need to
ignore, which is to be used when font packages are removed.
Signed-off-by: Julien Cristau <jcristau@debian.org>
diff --git a/debian/changelog b/debian/changelog
index c82dca7..13b6aa7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+xfonts-utils (1:7.5+2) UNRELEASED; urgency=low
+
+ * update-font-alias: use an exclude file listing alias files we need to
+ ignore, which is to be used when font packages are removed
+ (closes: #543512).
+
+ -- Theppitak Karoonboonyanan <thep@debian.org> Wed, 09 Dec 2009 15:04:53 +0700
+
xfonts-utils (1:7.5+1) unstable; urgency=low
[ Julien Cristau ]
diff --git a/debian/local/update-fonts-alias b/debian/local/update-fonts-alias
index 508e313..a344542 100644
--- a/debian/local/update-fonts-alias
+++ b/debian/local/update-fonts-alias
@@ -43,7 +43,7 @@ usage () {
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 @@ utility is primarily useful to Debian package maintainer scripts. See
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 @@ while [ -n "$1" ]; do
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
diff --git a/debian/xfonts-utils.postinst.in b/debian/xfonts-utils.postinst.in
new file mode 100644
index 0000000..d4695c8
--- /dev/null
+++ b/debian/xfonts-utils.postinst.in
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+THIS_PACKAGE=xfonts-utils
+THIS_SCRIPT=postinst
+
+#INCLUDE_SHELL_LIB#
+
+EXCLUDE_DIR=/var/lib/xfonts
+EXCLUDE=$EXCLUDE_DIR/excluded-aliases
+
+if [ "$1" = "configure" ]; then
+ if ! [ -f $EXCLUDE ]; then
+ [ -d $EXCLUDE_DIR ] || mkdir -m 755 -p $EXCLUDE_DIR
+ echo '!! Excluded alias files to be ignored by update-fonts-alias(8)' > $EXCLUDE
+ fi
+fi
+
+#DEBHELPER#
+
+# vim:set ai et sw=4 ts=4 tw=80:
diff --git a/debian/xfonts-utils.postrm.in b/debian/xfonts-utils.postrm.in
new file mode 100644
index 0000000..756f938
--- /dev/null
+++ b/debian/xfonts-utils.postrm.in
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+THIS_PACKAGE=xfonts-utils
+THIS_SCRIPT=postrm
+
+#INCLUDE_SHELL_LIB#
+
+EXCLUDE_DIR=/var/lib/xfonts
+EXCLUDE=$EXCLUDE_DIR/excluded-aliases
+
+if [ "$1" = purge ]; then
+ if [ -d $EXCLUDE_DIR ]; then
+ rm -f $EXCLUDE
+ rmdir --ignore-fail-on-non-empty $EXCLUDE_DIR
+ fi
+fi
+
+#DEBHELPER#
+
+# vim:set ai et sw=4 ts=4 tw=80:
Reply to: