]> git.pld-linux.org Git - packages/t1lib.git/blame - t1libconfig
- added CVE-2010-2642 patch from t1lib-5.1.2-10.1.src.rpm (OpenSuSE), rel. 4
[packages/t1lib.git] / t1libconfig
CommitLineData
d470d1c2
TP
1#!/bin/sh -e
2
3# to test POSIX-correctness, change hash-bang to /bin/bash and uncomment
4# the following line:
5
6# set -o posix
7
8# Very simple configuration script for t1lib. Checks system font
9# directory and adds anything ending in .pfa or pfb to the font
10# database. A few things borrowed from paperconfig, (C) 1996, Yves
11# Arrouye <arrouye@debian.org>
12
13# Based on script written by David Huggins-Daines <dhd@debian.org>
14
15usage() {
16 cat <<EOF
17
18Usage: `basename $0` [ -v, --version ] [ -h, --help ] [ --force ]
19 [ fontdirs... ]
20
21Options: -v, --version print version information and exit
22 -h, --help print this help and exit
23 --force force configuration
24EOF
25 exit 0
26}
27
28version=0.3
29confdir=/etc/t1lib
30conffile=$confdir/t1lib.config
31dbase=$confdir/FontDatabase
32temp=$confdir/FontDatabase.tmp
33force=0
34fontdirs="/usr/share/fonts/Type1"
35
36while [ $# -ne 0 ]
37do
38 case "$1" in
39 -v|--version)
40 echo "`basename $0` version $version"
41 exit 0
42 ;;
43 -h|--help)
44 usage
45 ;;
46 --force)
47 force=1
48 ;;
49 *)
50 pat=${1%/}
df1e8eac 51 if ! grep -q -x $pat <<EOF 2>/dev/null
d470d1c2
TP
52$fontdirs
53EOF
54 then
55 fontdirs="$fontdirs $1"
56 fi
57 ;;
58 esac
59 shift
60done
61
62# We presume that if the database exists, then so does the
63# configuration file. Hopefully this won't break anything.
64
65if [ $force -ne 1 ] && [ -e $dbase ]; then
66 echo "Configuration and font database files already exist."
c3400054 67 echo "Run $0 --force to rebuild them."
d470d1c2
TP
68 exit 0
69fi
70
71fontpath=""
72afmpath=""
73mkdir -p $confdir || true
74echo -n "Searching for Type 1 fonts and AFM files..."
75
76for i in $fontdirs
77do
78 if [ ! -d $i ] || [ "`echo $i/*.pf[ab]`" = "$i/*.pf[ab]" ]; then
79 continue
80 fi
81 fontpath="$fontpath$i:"
82
157eb7d5 83 for j in `find $i -mindepth 1 -maxdepth 2 -name "*.afm" -type f -printf "%h\n" | sort | uniq`; do
d470d1c2
TP
84 afmpath="$afmpath$j:"
85 done
86
87 # get a listing of all the fonts in each dir
157eb7d5 88 find $i -maxdepth 1 -name "*.pf[ab]" -type f -printf '%f\n' >> $temp
d470d1c2
TP
89done
90fontpath=${fontpath%:}
91afmpath=${afmpath%:}
92
93if [ -z "$fontpath" ]; then
94 cat <<EOF
95
96
97No Type 1 fonts were found in the expected locations.
98If you want t1lib to be aware of your fonts, you should run
99$0 with the names of your local font directories as
100arguments, or you should edit the $dbase file manually.
101See the FontDatabase(5) manual page for more information.
102
103EOF
104 rm -f $temp
105else
106 echo " done."
107 echo -n "Building font database..."
108 fontcount=`cat $temp | wc -l || true`
109 echo $fontcount > $dbase
110 cat $temp >> $dbase
111 rm -f $temp
112 echo " done."
113fi
114
115# now set the paths in the config file
116cat <<EOF >$conffile
117t1lib.config - global configuration file for t1lib.
118It was created automatically on `date`
119by the t1libconfig script.
120
121Run $0 --force to rebuild it.
122
123ENCODING=$confdir/enc
124AFM=$afmpath
125TYPE1=$fontpath
126FONTDATABASE=$dbase
127EOF
128
129exit 0
This page took 0.0456530000000001 seconds and 4 git commands to generate.