[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

X Strike Force XFree86 SVN commit: r1228 - in trunk/debian: . local



Author: branden
Date: 2004-04-11 18:30:03 -0500 (Sun, 11 Apr 2004)
New Revision: 1228

Modified:
   trunk/debian/changelog
   trunk/debian/local/update-fonts-scale
   trunk/debian/local/update-fonts-scale.8
Log:
Fix update-fonts-scale to not attempt to manipulate temporary files that
do not exist.  (Closes: #243127)

Enhance update-fonts-scale in several small ways:
+ Improve comments.
+ Update copyright notice.
+ Add SVN Id keyword and set corresponding property.
+ On startup, Query the terminal with stty if $COLUMNS is not set.
+ Send all diagnostic messages to standard error output in message()
  function.
+ Add observe() function for debugging diagnostics.
+ Rename error() to die() and update invocations of it accordingly.
+ Quote shell variables more religiously when expanding them.
+ Use consistent syntax style.
+ Update Vim modeline.

Improve update-fonts-scale(8) manual page:
+ Update copyright notice.
+ Fix minor wording issues.
+ Add "ENVIRONMENT section documenting effects of $COLUMNS and $DEBUG.
+ Add a preface to the "DIAGNOSTICS" section.
+ Document the new "index references nonexistent font file" diagnostic.


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2004-04-10 18:16:35 UTC (rev 1227)
+++ trunk/debian/changelog	2004-04-11 23:30:03 UTC (rev 1228)
@@ -110,8 +110,31 @@
 
   * Add Fabio Massimo Di Nitto to list of package uploaders.
 
- -- Branden Robinson <branden@debian.org>  Tue,  6 Apr 2004 04:49:19 -0500
+  * Fix update-fonts-scale to not attempt to manipulate temporary files that
+    do not exist.  (Closes: #243127)
 
+  * Enhance update-fonts-scale in several small ways:
+    + Improve comments.
+    + Update copyright notice.
+    + Add SVN Id keyword and set corresponding property.
+    + On startup, Query the terminal with stty if $COLUMNS is not set.
+    + Send all diagnostic messages to standard error output in message()
+      function.
+    + Add observe() function for debugging diagnostics.
+    + Rename error() to die() and update invocations of it accordingly.
+    + Quote shell variables more religiously when expanding them.
+    + Use consistent syntax style.
+    + Update Vim modeline.
+
+  * Improve update-fonts-scale(8) manual page:
+    + Update copyright notice.
+    + Fix minor wording issues.
+    + Add "ENVIRONMENT section documenting effects of $COLUMNS and $DEBUG.
+    + Add a preface to the "DIAGNOSTICS" section.
+    + Document the new "index references nonexistent font file" diagnostic.
+
+ -- Branden Robinson <branden@debian.org>  Sun, 11 Apr 2004 18:21:09 -0500
+
 xfree86 (4.3.0-7) unstable; urgency=medium
 
   * Urgency due to fix for FTBFS.  Yes -- I too am begging for it to stop.

Modified: trunk/debian/local/update-fonts-scale
===================================================================
--- trunk/debian/local/update-fonts-scale	2004-04-10 18:16:35 UTC (rev 1227)
+++ trunk/debian/local/update-fonts-scale	2004-04-11 23:30:03 UTC (rev 1228)
@@ -1,52 +1,70 @@
 #!/bin/sh
-# update-fonts-scale
-# compiles fonts.scale files for X font directories
-# see mkfontdir(1) for a description of the format of fonts.scale files
-# Copyright 1999,2001,2002 Branden Robinson.
+#
+# This program generates fonts.scale files for X font directories.  See
+# mkfontdir(1x) for a description of the format of fonts.scale files.
+#
+# Copyright 1999--2002, 2004 Branden Robinson.
 # Licensed under the GNU General Public License, version 2.  See the file
 # /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
 
+# $Id$
+
 PROGNAME=${0##*/}
 
-# display a message, wrapping lines at the terminal width
+# Query the terminal to establish a default number of columns to use for
+# displaying messages to the user.  This is used only as a fallback in the
+# event the COLUMNS variable is not set.  ($COLUMNS can react to SIGWINCH while
+# the script is running, and this cannot, only being calculated once.)
+DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true
+if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then
+  DEFCOLUMNS=80
+fi
+
 message () {
-  echo "$PROGNAME: $*" | fold -s -w ${COLUMNS:-80};
+  # pretty-print messages of arbitrary length
+  echo "$*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} >&2
 }
 
+observe () {
+  if [ -n "$DEBUG" ]; then
+    message "note: $*"
+  fi
+}
+
 warn () {
-  echo "$(message "warning: $*")" >&2;
+  message "warning: $*"
 }
 
-error () {
-  echo "$(message "error: $*")" >&2
-  exit 1;
+die () {
+  message "error: $*"
+  exit 1
 }
 
 if [ $# -eq 0 ]; then
-  error "one or more font directories must be provided"
+  die "one or more font directories must be provided"
 fi
 
 while [ -n "$1" ]; do
   # try to be clever about the arguments
-  if expr "$1" : "/.*" > /dev/null 2>&1; then
+  if expr "$1" : "/.*" >/dev/null 2>&1; then
     # absolute path to X font directory was provided
     XDIR=$1
     ETCDIR=/etc/X11/fonts/${XDIR##*/}
     if [ "$XDIR" = "$ETCDIR" ]; then
       # they gave us an /etc directory as the argument
-      error "path to X font directory must be used"
+      die "path to X font directory must be used"
     else
       warn "absolute path $XDIR was provided"
     fi
   else
     # assume they just gave us the basename
-    XDIR=/usr/lib/X11/fonts/$1
-    ETCDIR=/etc/X11/fonts/$1
+    XDIR="/usr/lib/X11/fonts/$1"
+    ETCDIR="/etc/X11/fonts/$1"
   fi
   # confirm that the directories to be operated on exist
-  for DIR in $XDIR $ETCDIR; do
+  for DIR in "$XDIR" "$ETCDIR"; do
     VALID=yes
-    if [ ! -d $DIR ]; then
+    if [ ! -d "$DIR" ]; then
       warn "$DIR does not exist or is not a directory"
       VALID=
     fi
@@ -54,31 +72,38 @@
   if [ -n "$VALID" ]; then
     # are there any files to process?
     if [ "$(echo $ETCDIR/*.scale)" != "$ETCDIR/*.scale" ]; then
-      for file in $ETCDIR/*.scale; do
-        # only write fonts to the .scale file that actually exist, so that
+      for SCALEFILE in "$ETCDIR"/*.scale; do
+        # Only write fonts to the .scale file that actually exist, so that
         # removed-but-not-purged scalable font packages do not register
         # nonexistent fonts; this has the desirable side effect that the count
-        # at the top of the file is also omitted
-        # XXX: this technique will be tricked into yielding false negatives if
-        # the font filename has whitespace in it
-        while read FILENAME FONTNAME; do
-          if [ -f "$XDIR/$FILENAME" ]; then
-            echo "$FILENAME $FONTNAME" >> $XDIR/fonts.scale.update-tmp
+        # at the top of the file is also omitted.
+        #
+        # XXX: This technique will be tricked into yielding false negatives if
+        # the font filename has whitespace in it.
+        while read FONTFILE FONTNAME; do
+          if [ -f "$XDIR/$FONTFILE" ]; then
+            echo "$FONTFILE $FONTNAME" >>"$XDIR/fonts.scale.update-tmp"
+          else
+            observe "$SCALEFILE references nonexistent font file $FONTFILE;" \
+              "skipping"
           fi
-        done < $file
+        done < $SCALEFILE
       done
-      # write new scale file in case we are interrupted
-      # write new count to top of file
-      # cat and pipe to wc so wc doesn't spew the filename
-      cat $XDIR/fonts.scale.update-tmp | wc -l | tr -d '[:blank:]' > $XDIR/fonts.scale.update-new
-      cat $XDIR/fonts.scale.update-tmp >> $XDIR/fonts.scale.update-new
-      mv $XDIR/fonts.scale.update-new $XDIR/fonts.scale
-      rm $XDIR/fonts.scale.update-tmp
+      if [ -e "$XDIR/fonts.scale.update-tmp" ]; then
+        # Write new scale file to .update-new in case we are interrupted.
+        # Write the new count to the top of file.  Use cat and pipe to wc so wc
+        # doesn't report the filename.
+        cat "$XDIR/fonts.scale.update-tmp" | wc -l | tr -d '[:blank:]' \
+          >"$XDIR/fonts.scale.update-new"
+        cat "$XDIR/fonts.scale.update-tmp" >>"$XDIR/fonts.scale.update-new"
+        mv "$XDIR/fonts.scale.update-new" "$XDIR/fonts.scale"
+        rm "$XDIR/fonts.scale.update-tmp"
+      fi
     else
       # no files to process, remove the one in the font dir
-      rm -f $XDIR/fonts.scale
+      rm -f "$XDIR/fonts.scale"
       # remove the font dir if it is empty
-      rmdir $XDIR > /dev/null 2>&1 || true
+      rmdir "$XDIR" >/dev/null 2>&1 || true
     fi
   fi
   shift
@@ -86,4 +111,4 @@
 
 exit 0
 
-# vim:ai:et:sts=2:sw=2:tw=0:
+# vim:set ai et sts=2 sw=2 tw=80:


Property changes on: trunk/debian/local/update-fonts-scale
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/debian/local/update-fonts-scale.8
===================================================================
--- trunk/debian/local/update-fonts-scale.8	2004-04-10 18:16:35 UTC (rev 1227)
+++ trunk/debian/local/update-fonts-scale.8	2004-04-11 23:30:03 UTC (rev 1228)
@@ -1,5 +1,7 @@
-.\" This manpage is copyright 1999,2002 Branden Robinson <branden@debian.org>.
+.\" $Id$
 .\"
+.\" Copyright 1999,2002,2004 Branden Robinson <branden@debian.org>.
+.\"
 .\" This is free software; you can redistribute it and/or modify it under
 .\" the terms of the GNU General Public License as published by the Free
 .\" Software Foundation, version 2.
@@ -13,9 +15,9 @@
 .\" the Debian operating system, in /usr/share/common-licenses/GPL;  if
 .\" not, write to the Free Software Foundation, Inc., 59 Temple Place,
 .\" Suite 330, Boston, MA 02111-1307 USA
-.TH update\-fonts\-scale 8 "2003\-08\-05" "Debian Project"
+.TH update\-fonts\-scale 8 "2004\-04\-11" "Debian Project"
 .SH NAME
-update\-fonts\-scale \- compile fonts.scale files
+update\-fonts\-scale \- generate fonts.scale files
 .SH SYNOPSIS
 .B update\-fonts\-scale
 .I directory ...
@@ -27,11 +29,9 @@
 subdirectory of
 .IR /etc/X11/fonts/ .
 It is typically invoked only from the post\-installation and post\-removal
-scripts of a
-.I package
-containing scalable fonts usable by the X Window System whose X LFD font
-names are not in the font files themselves, but may be invoked at any time
-to reconstruct
+scripts of a package containing scalable fonts usable by the X Window
+System whose X LFD font names are not in the font files themselves, but may
+be invoked at any time to reconstruct
 .I fonts.scale
 files.  For each
 .IR directory ,
@@ -41,8 +41,11 @@
 .B update\-fonts\-scale
 will assemble
 .IR /usr/lib/X11/fonts/ directory /fonts.scale
-from the files found in
-.IR /etc/X11/fonts/ directory / package .scale .
+from the index files found at
+.IR /etc/X11/fonts/ directory / package .scale ,
+where
+.I package
+is the name of the package installing the fonts.
 .PP
 This enables multiple packages to provide names for fonts in the same
 directory.  No font package actually provides the
@@ -88,7 +91,25 @@
 and
 .RB \(oq "update\-fonts\-scale /usr/lib/X11/fonts/75dpi" \(cq
 are not.
+.SH ENVIRONMENT
+.TP
+.B COLUMNS
+This variable is used to format diagnostic messages so that they fit the
+width of the terminal.  If not set, a terminal width of 80 columns is
+assumed.
+.TP
+.B DEBUG
+This variable determines whether low\-level diagnostic messages are issued
+to standard error output.  A null (empty) or unset value indicates that
+they are not, and a non\-null value indicates that they are.
 .SH DIAGNOSTICS
+.B update\-fonts\-scale
+reports three types of diagnostics; errors, which are fatal and cause the
+command to abort processing; warnings, which are errors that the program
+attempts to recover from; and notes, which are only visible if the
+environment variable
+.B DEBUG
+is set to a non\-null value.
 .SS Errors
 .TP
 .B error: one or more font directories must be provided
@@ -112,6 +133,18 @@
 was invalid.
 .B update\-fonts\-scale
 skipped it.
+.SS Notes
+.TP
+.BI "note: " index " references nonexistent font file " filename
+The index file
+.IR /etc/X11/fonts/ directory / package .scale ,
+refers to a nonexistent font file,
+.IR filename .
+This is normal when
+.I package
+has been removed, but not purged from the system.  In other circumstances,
+it likely indicates an error in
+.IR package .
 .SH "EXIT STATUS"
 .TP
 0


Property changes on: trunk/debian/local/update-fonts-scale.8
___________________________________________________________________
Name: svn:keywords
   + Id



Reply to: