~ubuntu-branches/ubuntu/jaunty/texlive-bin/jaunty-updates

« back to all changes in this revision

Viewing changes to debian/texlive-base-bin.root/usr/share/texmf-texlive/scripts/debian/debianize-updmap

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2006-05-11 00:12:10 UTC
  • Revision ID: james.westby@ubuntu.com-20060511001210-2p3y1ncrjg8a0ge9
Tags: 2005-2
* first upload to unstable, sponsored by 
  Frank Küster <frank@debian.org>
* texdoc support
  - let tetex texdoc find documentation of texlive (Closes: #364776)
  - include tetex texdoc patches (following of symlinks, security
    fixes) (Closes: #356390)
* texlive-lang-polish conflicts with octave-forge as both provide
  /usr/bin/mex, this is preliminary, a better solution must be
  sought (Closes: #364059)
* change shell for the reportbug script to bash (Closes: #356391)
* fix installation of thumbpdf and pdfcrop (Closes: #352092)
* improve various descriptions (Closes: #354964)
* call the update-* programs in all postinst scripts, so that the
  config files do not contain left-overs (Closes: #355266)
* fix creation of formats which in turn depend on the latex format
  (Closes: #351707)
* remap the ibycus4.map TeX/MF input file from the fonts/map location
  to the fonts/source location (Closes: #354652)
* depend on the updated lmodern package, thus making the fonts
  available for X (Closes: #351727)
* lots of internal changes, important ones being:
  - texlive packages now do not include files which have been
    packaged for Debian already (eg cm-super, lmodern, musixtex)
  - most packages can be used together with teTeX
  - fix several upstream bugs
  - generate license information for each file from the
    TeX Catalogue (ongoing work)
  for detailed changes see CHANGES.packaging in texlive-common

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
# $Id$
 
5
 
 
6
# This is the planned scheme how it works
 
7
 
8
# A for disableMap:
 
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
 
12
#
 
13
# B for enableMap:
 
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
 
22
#           appropriately
 
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
 
27
#
 
28
# C for syncwithtrees (and even more?)
 
29
# ?
 
30
#
 
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
 
35
# file per run.
 
36
 
 
37
###############################################################################
 
38
# DebianSyswideMode ()
 
39
#   determine whether we are running in syswide mode (or user-specific)
 
40
###############################################################################
 
41
DebianSyswideMode(){
 
42
  test "$(id -u)" -eq 0 && return 0 || return 1
 
43
}
 
44
 
 
45
###############################################################################
 
46
# FindDebianUserdir ()
 
47
#   find the directory containing user-specific updmap snippets
 
48
###############################################################################
 
49
FindDebianUserdir(){
 
50
  defaultuserdir=$HOME/.texmf-config/updmap.d
 
51
 
 
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
 
55
    echo $defaultuserdir
 
56
  fi
 
57
}
 
58
 
 
59
 
 
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'
 
68
  else
 
69
    debianuserdir=`FindDebianUserdir`
 
70
    if [ -n "$debianuserdir" ]; then
 
71
      find /etc/texmf/updmap.d "$debianuserdir" -maxdepth 1 -type f -name '*.cfg'
 
72
    else
 
73
      find /etc/texmf/updmap.d -maxdepth 1 -type f -name '*.cfg'
 
74
    fi
 
75
  fi
 
76
}
 
77
 
 
78
###############################################################################
 
79
# runUpdate
 
80
#   run update-updmap
 
81
###############################################################################
 
82
runUpdate(){
 
83
  updOptions=""
 
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"
 
91
#     fi
 
92
#     # here we could add support for an alternative output file
 
93
#   fi
 
94
 
 
95
  verboseMsg "Running update-updmap to merge the changed files"
 
96
  update-updmap --quiet
 
97
}
 
98
###############################################################################
 
99
# cleanupNoExit()
 
100
#   clean up the temp area, but don't exit
 
101
###############################################################################
 
102
cleanupNoExit()
 
103
{
 
104
  rc=$?
 
105
  $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
 
106
    && { cd / && rm -rf "$tmpdir"; }
 
107
}
 
108
 
 
109
###############################################################################
 
110
# reExecSelf
 
111
#   execute ourselves again - the confile has changed after an enable or disable
 
112
#   command has been processed
 
113
###############################################################################
 
114
reExecSelf(){
 
115
  # remove the temporary directory
 
116
  cleanupNoExit
 
117
  
 
118
  # if we need not remake map files, we are done here
 
119
  if [ "$mkmapEnabled" = "false" ]; then exit 0; fi
 
120
 
 
121
  # pass ourselves the right options.  
 
122
  repeatOptions=""
 
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`"
 
127
    fi
 
128
  done
 
129
  repeatOptions="$repeatOptions --cnffile=$orig"
 
130
  if [ "texhashEnabled" = "false" ]; then
 
131
    repeatOptions="$repeatOptions --nohash"
 
132
  fi
 
133
  if [ "$verbose" = "false" ]; then
 
134
    repeatOptions="$repeatOptions --quiet"
 
135
  fi
 
136
  
 
137
  verboseMsg "Now running $progname again to generate output files"
 
138
  echo $progname $repeatOptions
 
139
  exec $progname $repeatOptions
 
140
}
 
141
 
 
142
###############################################################################
 
143
# grepType (map,file)
 
144
#   grep in file for entry map, and return the mapType
 
145
###############################################################################
 
146
grepType()
 
147
{
 
148
  map=$1
 
149
  file="$2"
 
150
  egrep "^(MixedMap|Map)[       ]*$map( |       |$)" "$file" | awk '{print $1}' | sort | uniq
 
151
}
 
152
 
 
153
 
 
154
###############################################################################
 
155
# findUserfiles (filelist)
 
156
#   pick user-specific files out of a filelist of configuration files
 
157
###############################################################################
 
158
findUserfiles(){
 
159
  userfiles=""
 
160
  while [ $# -gt 0 ]; do
 
161
    file="$1"
 
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"
 
165
    fi
 
166
    shift;
 
167
  done
 
168
  echo $userfiles
 
169
}
 
170
 
 
171
###############################################################################
 
172
# findRightMatchfile (mapname,filelist)
 
173
#   find the right file from filelist to enable mapname 
 
174
###############################################################################
 
175
findRightMatchfile(){
 
176
  mapName=$1; shift
 
177
  matchfiles="$@"
 
178
  if [ $# -eq 1 ]; then
 
179
    # it is only one, enable map in it
 
180
    echo $matchfiles
 
181
    verboseMsg "Enabling map file in $matchfiles"
 
182
    return 0
 
183
  else
 
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
 
190
        echo $usermatchfiles
 
191
        verboseMsg "Enabling map file in user-specific file $matchfiles"
 
192
        return 0
 
193
      else
 
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
 
198
      fi
 
199
    fi
 
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
 
202
    # that hazzle.
 
203
    cat >&2 <<EOF
 
204
Entries for map file $mapName found in several files:
 
205
$matchfiles
 
206
 
 
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)
 
209
 
 
210
EOF
 
211
  fi
 
212
}
 
213
 
 
214
###############################################################################
 
215
# pickLocalFile (mapname,directory)
 
216
#   pick the right local file in directory
 
217
###############################################################################
 
218
pickLocalFile(){
 
219
  mapName=$1
 
220
  debDirname=$2
 
221
  debDirname=${debDirname%/}
 
222
  # Is there a file with "local" in the name?
 
223
  localfile=""
 
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
 
228
      # exactly one
 
229
      echo $localfile
 
230
      return 0
 
231
    else
 
232
      # more than one local file? Brrrr.
 
233
      cat >&2 <<EOF
 
234
While trying to enable $mapName locally, I found several user-specific map files:
 
235
$localfile
 
236
 
 
237
I don't know how to proceed here. Please refer to the manpage of update-upmdap(1)
 
238
 
 
239
EOF
 
240
    fi
 
241
  else
 
242
    # no user config file yet
 
243
    echo $debDirname/10local.cfg
 
244
    return 0
 
245
  fi
 
246
}
 
247
 
 
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(){
 
254
  mapName=$1
 
255
  # Do we know about a user-specific directory?
 
256
  DebianSyswideMode || debianuserdir=`FindDebianUserdir`
 
257
  if (! DebianSyswideMode) && [ -d "$debianuserdir" ]; then
 
258
      DebCnfFile=`pickLocalFile $mapName $debianuserdir`
 
259
  else
 
260
    DebCnfFile=`pickLocalFile $mapName /etc/texmf/updmap.d`
 
261
  fi
 
262
  # configReplace will try to grep in the file: touch it to prevent a error message
 
263
  touch $DebCnfFile
 
264
  echo $DebCnfFile
 
265
}
 
266
 
 
267
###############################################################################
 
268
# disableMapInner (map)
 
269
#   disables map in config file (any type) (real command)
 
270
###############################################################################
 
271
disableMapInner()
 
272
{
 
273
  map=$1
 
274
  local mapType
 
275
 
 
276
  if [ -z "$DebianConffilelist" ]; then
 
277
    DebianConffilelist=`createDebianConffilelist`
 
278
  fi
 
279
 
 
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"
 
286
      done
 
287
    fi
 
288
  done
 
289
}
 
290
 
 
291
###############################################################################
 
292
# disableMap (map)
 
293
#   disables map in config file (any type) (Debian wrapper)
 
294
###############################################################################
 
295
disableMap()
 
296
{
 
297
  disableMapInner $1
 
298
  runUpdate
 
299
  reExecSelf
 
300
}
 
301
###############################################################################
 
302
# enableMap (type, map)
 
303
#   enables an entry in the config file for map with a given type.
 
304
###############################################################################
 
305
enableMap()
 
306
{
 
307
  mapType=$1
 
308
  mapName=$2
 
309
  case $1 in
 
310
    Map|MixedMap)
 
311
      ;;
 
312
    *)
 
313
      abort "invalid mapType $mapType"
 
314
      ;;
 
315
  esac
 
316
 
 
317
  if [ -z "$DebianConffilelist" ]; then
 
318
    DebianConffilelist=`createDebianConffilelist`
 
319
  fi
 
320
 
 
321
  # a map can only have one type, so we carefully disable everything
 
322
  # about map here:
 
323
  disableMapInner "$mapName"
 
324
 
 
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?
 
328
  matchfiles=""
 
329
  for file in $DebianConffilelist; do
 
330
    if egrep "^#![[:blank:]]*(MixedMap|Map)[[:blank:]]*$map([[:blank:]]|$)" "$file" >/dev/null ; then
 
331
      matchfiles="$matchfiles $file"
 
332
    fi
 
333
  done
 
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"
 
338
  else
 
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"
 
343
  fi
 
344
 
 
345
  configReplace "$debCnfFile" "^#![     ]*$mapType[     ]*$mapName" "$mapType $mapName"
 
346
  runUpdate
 
347
  reExecSelf
 
348
}
 
349
 
 
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
###############################################################################
 
355
setOption()
 
356
{
 
357
  opt=$1
 
358
  val=$2
 
359
  case "$opt" in
 
360
    LW35)
 
361
      case "$val" in
 
362
        URWkb|URW|ADOBE|ADOBEkb)
 
363
          ;;
 
364
        *)
 
365
          abort "invalid value $val for option $opt"
 
366
          ;;
 
367
      esac
 
368
      ;;
 
369
    dvipsPreferOutline|dvipsDownloadBase35|pdftexDownloadBase14|dvipdfmDownloadBase14)
 
370
      case "$val" in
 
371
        true|false)
 
372
          ;;
 
373
        *)
 
374
          abort "invalid value $val for option $opt"
 
375
      esac
 
376
      ;;
 
377
    *)
 
378
      abort "unsupported option $opt"
 
379
      ;;
 
380
  esac
 
381
 
 
382
  DebNullCnfFile=""
 
383
  DebianSyswideMode || debianuserdir=`FindDebianUserdir`
 
384
  if (! DebianSyswideMode) && [ -f "$debianuserdir/00updmap.cfg" ]; then
 
385
    DebNullCnfFile=$debianuserdir/00updmap.cfg
 
386
  else
 
387
    DebNullCnfFile=/etc/texmf/updmap.d/00updmap.cfg
 
388
  fi
 
389
 
 
390
  configReplace "$DebNullCnfFile" "^$opt[       ]" "$opt $val"
 
391
  runUpdate
 
392
  reExecSelf
 
393
}
 
394