1
# This file, debianize-updmap, is meant to be sourced by updmap and
2
# enhance the --enable and --disable options with the functionality
3
# needed to deal with Debian's generated updmap.cfg.
6
# This is the planned scheme how it works
9
# 1. create a list of files to act on (either in sysconfdir only, or in user dirs too)
10
# 2. grep for not-commented lines in these files that contain $map
11
# 3. for each of these files, run configReplace appropriately
14
# 1. create a list of files to act on (either in sysconfdir only, or in user dirs too)
15
# 2. grep for commented lines in these files that contain $map
16
# 2.1. if any are found, check whether it is only one
17
# 2.1.1 if there is only one, run configReplace on that file appropriately
18
# 2.1.2 if there is more than one, the precedence is
19
# 20tetex-extra.cfg > XX*local*.cfg > 10tetex-base.cfg > any
20
# (extra has maximum priority because
21
# 2.1.2.1 if it's clear on which file to act, run configReplace on that file
23
# 2.1.2.2 if unclear (i.e. only "any"), exit with an error
24
# 2.2 if none are found, act on 10local.cfg (could be made configurable)
25
# - if 10local.cfg does not exist, create it (with an explanatory comment)
26
# - run configReplace on it appropriately
28
# C for syncwithtrees (and even more?)
31
# After that, update-updmap must be run (in the appropriate mode!), and then updmap
32
# must reexecute itself. Since disableMap is called by enableMap, we need a wrapper
33
# for it. An alternative would be to do this just before the creation of the output
34
# files, but I think it's easier this way, and currently updmap only enables one Map
37
###############################################################################
38
# DebianSyswideMode ()
39
# determine whether we are running in syswide mode (or user-specific)
40
###############################################################################
42
test "$(id -u)" -eq 0 && return 0 || return 1
45
###############################################################################
46
# FindDebianUserdir ()
47
# find the directory containing user-specific updmap snippets
48
###############################################################################
50
defaultuserdir=$HOME/.texmf-config/updmap.d
52
# this should read a config item in updmap.cfg, but for now we just
53
# check whether the default exists
54
if [ -d $defaultuserdir ]; then
60
###############################################################################
61
# createDebianConffilelist
62
# create a list of configuration files containing updmap snippets;
63
# we are going to act on these
64
###############################################################################
65
createDebianConffilelist(){
66
if DebianSyswideMode; then
67
find /etc/texmf/updmap.d -maxdepth 1 -type f -name '*.cfg'
69
debianuserdir=`FindDebianUserdir`
70
if [ -n "$debianuserdir" ]; then
71
find /etc/texmf/updmap.d "$debianuserdir" -maxdepth 1 -type f -name '*.cfg'
73
find /etc/texmf/updmap.d -maxdepth 1 -type f -name '*.cfg'
78
###############################################################################
81
###############################################################################
84
# here we could check for an alternative user dir, or output file
85
# but as long as FindDebianUserdir only reports the default location,
86
# it doesn't make sense
87
# if ! DebianSyswideMode; then
88
# debianuserdir=`FindDebianUserdir`
89
# if [ -n "$debianuserdir" ]; then
90
# updOptions="--conf-dir $debianuserdir"
92
# # here we could add support for an alternative output file
95
verboseMsg "Running update-updmap to merge the changed files"
98
###############################################################################
100
# clean up the temp area, but don't exit
101
###############################################################################
105
$needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
106
&& { cd / && rm -rf "$tmpdir"; }
109
###############################################################################
111
# execute ourselves again - the confile has changed after an enable or disable
112
# command has been processed
113
###############################################################################
115
# remove the temporary directory
118
# if we need not remake map files, we are done here
119
if [ "$mkmapEnabled" = "false" ]; then exit 0; fi
121
# pass ourselves the right options.
123
for option in dvipsoutputdir pdftexoutputdir dvipdfmoutputdir; do
124
# strange that I can't do the same with eval test -n
125
if eval [ ! -z "\$$option" ]; then
126
repeatOptions="$repeatOptions `eval echo --$option \\$$option`"
129
repeatOptions="$repeatOptions --cnffile=$orig"
130
if [ "texhashEnabled" = "false" ]; then
131
repeatOptions="$repeatOptions --nohash"
133
if [ "$verbose" = "false" ]; then
134
repeatOptions="$repeatOptions --quiet"
137
verboseMsg "Now running $progname again to generate output files"
138
echo $progname $repeatOptions
139
exec $progname $repeatOptions
142
###############################################################################
143
# grepType (map,file)
144
# grep in file for entry map, and return the mapType
145
###############################################################################
150
egrep "^(MixedMap|Map)[ ]*$map( | |$)" "$file" | awk '{print $1}' | sort | uniq
154
###############################################################################
155
# findUserfiles (filelist)
156
# pick user-specific files out of a filelist of configuration files
157
###############################################################################
160
while [ $# -gt 0 ]; do
162
if [ "$file" = "${file#/etc/texmf/updmap.d}" ]; then
163
# doesn't start with /etc/texmf/updmap.d: must be user-specific
164
userfiles="$userfiles $file"
171
###############################################################################
172
# findRightMatchfile (mapname,filelist)
173
# find the right file from filelist to enable mapname
174
###############################################################################
175
findRightMatchfile(){
178
if [ $# -eq 1 ]; then
179
# it is only one, enable map in it
181
verboseMsg "Enabling map file in $matchfiles"
184
# there are more than one;
185
if ! DebianSyswideMode; then
186
# a file in the user's dir takes precedence
187
usermatchfiles=`findUserfiles $matchfiles`
188
if [ `(set $usermatchfiles; echo $#)` -eq 1 ]; then
189
# exactly one of them is a user-specific file
191
verboseMsg "Enabling map file in user-specific file $matchfiles"
194
# two files in the user directory (as bad as two in the site-wide
195
# dir), or no user-specific files. If there are two user-specific
196
# files, report about them:
197
test -n "$usermatchfiles" && matchfiles="$usermatchfiles" || true
200
# for now, we exit with an error. Any sensible choice would have to
201
# check whether teTeX or texlive is installed, and I want to save me
204
Entries for map file $mapName found in several files:
207
Since updmap.cfg is a generated file in Debian, I don't know how to proceed.
208
Please refer to the manpage of update-updmap(1)
214
###############################################################################
215
# pickLocalFile (mapname,directory)
216
# pick the right local file in directory
217
###############################################################################
221
debDirname=${debDirname%/}
222
# Is there a file with "local" in the name?
224
localfile="`ls $debDirname/*local*cfg 2>/dev/null`"
225
if [ -n "$localfile" ]; then
226
# there is at least one
227
if [ `(set $localfile; echo $#)` -eq 1 ]; then
232
# more than one local file? Brrrr.
234
While trying to enable $mapName locally, I found several user-specific map files:
237
I don't know how to proceed here. Please refer to the manpage of update-upmdap(1)
242
# no user config file yet
243
echo $debDirname/10local.cfg
248
###############################################################################
249
# findRightLocalfile (mapname)
250
# find the right file to enable mapname, site-wide or user-specific
251
# mapname is only needed for the error message
252
###############################################################################
253
findRightLocalfile(){
255
# Do we know about a user-specific directory?
256
DebianSyswideMode || debianuserdir=`FindDebianUserdir`
257
if (! DebianSyswideMode) && [ -d "$debianuserdir" ]; then
258
DebCnfFile=`pickLocalFile $mapName $debianuserdir`
260
DebCnfFile=`pickLocalFile $mapName /etc/texmf/updmap.d`
262
# configReplace will try to grep in the file: touch it to prevent a error message
267
###############################################################################
268
# disableMapInner (map)
269
# disables map in config file (any type) (real command)
270
###############################################################################
276
if [ -z "$DebianConffilelist" ]; then
277
DebianConffilelist=`createDebianConffilelist`
280
# act on all files that contain an entry
281
for debCnfFile in $DebianConffilelist; do
282
if mapType=`grepType $map "$debCnfFile"`; then
283
# although it's a bug, there might be two types enabled - we disable both
284
for type in $mapType; do
285
configReplace "$debCnfFile" "^$type[ ]*$1" "#! $type $1"
291
###############################################################################
293
# disables map in config file (any type) (Debian wrapper)
294
###############################################################################
301
###############################################################################
302
# enableMap (type, map)
303
# enables an entry in the config file for map with a given type.
304
###############################################################################
313
abort "invalid mapType $mapType"
317
if [ -z "$DebianConffilelist" ]; then
318
DebianConffilelist=`createDebianConffilelist`
321
# a map can only have one type, so we carefully disable everything
323
disableMapInner "$mapName"
325
# now enable with the right type.
326
# But we have to determine where to enable.
327
# is there already a file that contains a (commented) entry?
329
for file in $DebianConffilelist; do
330
if egrep "^#![[:blank:]]*(MixedMap|Map)[[:blank:]]*$map([[:blank:]]|$)" "$file" >/dev/null ; then
331
matchfiles="$matchfiles $file"
334
if [ -n "$matchfiles" ]; then
335
# there is already (at least) one file that has a commented entry for our map
336
debCnfFile=`findRightMatchfile $mapName $matchfiles`
337
test -n "$debCnfFile" || abort "Cannot proceed. Exiting"
339
# there is no (commented) entry yet.
340
debCnfFile=`findRightLocalfile $mapName`
341
test -n "$debCnfFile" || abort "Cannot proceed. Exiting"
342
verboseMsg "Creating new entry for map file $mapName in $debCnfFile"
345
configReplace "$debCnfFile" "^#![ ]*$mapType[ ]*$mapName" "$mapType $mapName"
350
###############################################################################
351
# setOption (option, value)
352
# sets option to value in the config file (replacing the existing setting
353
# or by adding a new line to the config file).
354
###############################################################################
362
URWkb|URW|ADOBE|ADOBEkb)
365
abort "invalid value $val for option $opt"
369
dvipsPreferOutline|dvipsDownloadBase35|pdftexDownloadBase14|dvipdfmDownloadBase14)
374
abort "invalid value $val for option $opt"
378
abort "unsupported option $opt"
383
DebianSyswideMode || debianuserdir=`FindDebianUserdir`
384
if (! DebianSyswideMode) && [ -f "$debianuserdir/00updmap.cfg" ]; then
385
DebNullCnfFile=$debianuserdir/00updmap.cfg
387
DebNullCnfFile=/etc/texmf/updmap.d/00updmap.cfg
390
configReplace "$DebNullCnfFile" "^$opt[ ]" "$opt $val"