Debian Codegraph @

debian/local/update-fonts-dir

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # $Id: update-fonts-dir 189 2005-06-11 00:04:27Z branden $
4
5 # This program compiles fonts.dir files for X font directories; see
6 # mkfontdir(1x) for a description of the format of fonts.dir files.
7
8 # Copyright 1999, 2001, 2002, 2004 Branden Robinson.
9 # Licensed under the GNU General Public License, version 2. See the file
10 # /usr/share/common-licenses/GPL or <https://www.gnu.org/copyleft/gpl.txt>.
11
12 PROGNAME=${0##*/}
13 ENCDIR=/usr/share/fonts/X11/encodingsscip-shell filesystem . . `/usr/share/fonts/X11/encodings`.
14
15 # Query the terminal to establish a default number of columns to use for
16 # displaying messages to the user. This is used only as a fallback in the event
17 # the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the
18 # script is running, and this cannot, only being calculated once.)
19 DEFCOLUMNS=$(sttyscip-shell system . . stty. size 2>/dev/nullscip-shell filesystem . . `/dev/null`. | awkscip-shell system . . awk. '{print $2}') || truescip-shell system . . true.
20 if ! exprscip-shell system . . expr. "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
21 DEFCOLUMNS=80
22 fi
23
24 # Display a message, wrapping lines at the terminal width.
25 messagescip-shell shell xfonts-utils 1:7.7+7 message(). () {
26 echoscip-shell system . . echo. "$*" | fmtscip-shell system . . fmt. -t -w ${COLUMNS:-$DEFCOLUMNS}
27 }
28
29 # Display a warning message.
30 warnscip-shell shell xfonts-utils 1:7.7+7 warn(). () {
31 messagescip-shell shell xfonts-utils 1:7.7+7 message(). "warning: $*" >&2
32 }
33
34 # Display an error message and exit.
35 diescip-shell shell xfonts-utils 1:7.7+7 die(). () {
36 messagescip-shell shell xfonts-utils 1:7.7+7 message(). "fatal error: $*" >&2
37 exit 1
38 }
39
40 # Display a usage message.
41 usagescip-shell shell xfonts-utils 1:7.7+7 usage(). () {
42 if [scip-shell system . . `[`. -n "$*" ]; then
43 messagescip-shell shell xfonts-utils 1:7.7+7 message(). "usage error: $*"
44 fi
45 catscip-shell system . . cat. <<EOF
46 Usage: $PROGNAME DIRECTORY ...
47 $PROGNAME { -7 | --x11r7-layout } DIRECTORY ...
48 $PROGNAME { -h | --help }
49 This program combines X font alias information from several packages into a
50 single file that is placed in each specified X font directory DIRECTORY. This
51 utility is primarily useful to Debian package maintainer scripts. See
52 update-fonts-dir(8) for more information.
53 Options:
54 -h, --help display this usage message and exit
55 -7, --x11r7-layout use new font layout introduced with X11R7
56 EOF
57 }
58
59 X11R7_LAYOUT=
60
61 # Validate arguments.
62 case "$1" in
63 -h|--help)
64 usagescip-shell shell xfonts-utils 1:7.7+7 usage().
65 exit 0
66 ;;
67 -7|--x11r7-layout)
68 X11R7_LAYOUT=true
69 shift
70 ;;
71 esac
72
73 case "$1" in
74 -*)
75 usagescip-shell shell xfonts-utils 1:7.7+7 usage(). "unrecognized option" >&2
76 exit 2
77 ;;
78 esac
79
80
81 if [scip-shell system . . `[`. $# -eq 0 ]; then
82 usagescip-shell shell xfonts-utils 1:7.7+7 usage(). "one or more font directories must be specified" >&2
83 exit 2
84 fi
85
86 while [scip-shell system . . `[`. -n "$1" ]; do
87 # Try to be clever about the argument; were we given an absolute path?
88 if exprscip-shell system . . expr. "$1" : "/.*" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
89 # Yes; an absolute path to an X font directory was provided.
90 XDIRS=$1
91 if [scip-shell system . . `[`. -n "$X11R7_LAYOUT" ]; then
92 ETCDIR=/etc/X11/fonts/X11R7/${XDIRS##*/}
93 else
94 ETCDIR=/etc/X11/fonts/${XDIRS##*/}
95 fi
96 if [scip-shell system . . `[`. "$XDIRS" = "$ETCDIR" ]; then
97 # We were given an /etc directory as an argument.
98 diescip-shell shell xfonts-utils 1:7.7+7 die(). "path to X font directory must be used"
99 else
100 warnscip-shell shell xfonts-utils 1:7.7+7 warn(). "absolute path $XDIRS was provided"
101 fi
102 else
103 # No; a relative path was provided -- assume we were given just the
104 # basename.
105 XDIRS="/usr/share/fonts/X11/$1"
106 fi
107 # Confirm that the directories to be operated on exist.
108 for XDIR in $XDIRS; do
109 VALID=yes
110 if ! [scip-shell system . . `[`. -d "$XDIR" ]; then
111 warnscip-shell shell xfonts-utils 1:7.7+7 warn(). "$XDIR does not exist or is not a directory"
112 VALID=
113 fi
114 if [scip-shell system . . `[`. -n "$VALID" ]; then
115 # Use encoding directories if they are available.
116 if [scip-shell system . . `[`. -d "$ENCDIR" ] && [scip-shell system . . `[`. -d "$ENCDIR/large" ]; then
117 mkfontdir -e "$ENCDIR" -e "$ENCDIR/large" "$XDIR"
118 else
119 mkfontdir "$XDIR"
120 fi
121 # Are there any fonts in the font directory?
122 if [scip-shell system . . `[`. "$(headscip-shell system . . head. -n 1 "$XDIR/fonts.dir")" = "0" ]; then
123 # There are no files to process; remove any generated files already
124 # in the font directory.
125 rmscip-shell system . . rm. -f "$XDIR/fonts.dir" "$XDIR/encodings.dir"
126 # Remove the font dirextory if it is empty.
127 rmdirscip-shell system . . rmdir. "$XDIR" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1 || truescip-shell system . . true.
128 fi
129 fi
130 done
131 shift
132 done
133
134 exit 0
135
136 # vim:set ai et sts=4 sw=4 tw=80: