[subversion-commit] SVN tetex commit + diffs: r149 - tetex-bin/trunk/debian

Frank Küster frank at costa.debian.org
Fri Aug 19 18:29:36 UTC 2005


Author: frank
Date: 2005-08-19 18:29:35 +0000 (Fri, 19 Aug 2005)
New Revision: 149

Added:
   tetex-bin/trunk/debian/debianize-updmap
Log:
add a updmap add-on that enables to use --enable and --disable, yes, actually

Added: tetex-bin/trunk/debian/debianize-updmap
===================================================================
--- tetex-bin/trunk/debian/debianize-updmap	2005-08-19 12:45:06 UTC (rev 148)
+++ tetex-bin/trunk/debian/debianize-updmap	2005-08-19 18:29:35 UTC (rev 149)
@@ -0,0 +1,128 @@
+# This file is meant to be sourced by updmap and enhance the --enable and
+# --disable options with the functionality needed to deal with Debian's
+# generated updmap.cfg.
+
+# This is the planned scheme how it works
+# 
+# A for disableMap:
+#   1. create a list of files to act on (either in sysconfdir only, or in user dirs too)
+#   2. grep for not-commented lines in these files that contain $map
+#   3. for each of these files, run configReplace appropriately
+#
+# B for enableMap:
+#   1. create a list of files to act on (either in sysconfdir only, or in user dirs too)
+#   2. grep for commented lines in these files that contain $map
+#   2.1. if any are found, check whether it is only one
+#   2.1.1 if there is only one, run configReplace on that file appropriately
+#   2.1.2 if there is more than one, the precedence is 
+#         XX*local*.cfg > 10tetex-base.cfg > 20tetex-extra.cfg > any
+#   2.1.2.1 if it's clear on which file to act, run configReplace on that file
+#           appropriately
+#   2.1.2.2 if unclear (i.e. only "any"), exit with an error
+#   2.2 if none are found, act on 99local.cfg (could be made configurable)
+#       - if 99local.cfg does not exist, create it (with an explanatory comment)
+#       - run configReplace on it appropriately
+#
+# After that, update-updmap must be run (in the appropriate mode!), and then updmap
+# must reexecute itself.  Since disableMap is called by enableMap, we need a wrapper
+# for it.  An alternative would be to do this just before the creation of the output
+# files, but I think it's easier this way, and currently updmap only enables one Map
+# file per run.
+
+###############################################################################
+# disableMap (map)
+#   disables map in config file (any type) (Debian wrapper)
+###############################################################################
+disableMap()
+{
+  disableMapInner $1
+  runUpdate
+  reExecSelf
+}
+###############################################################################
+# grepType (map,file)
+#   grep in file for entry map, and return the mapType
+###############################################################################
+grepType()
+{
+  map=$1
+  file="$2"
+  egrep "^(MixedMap|Map)[ 	]*$map( |	|$)" "$file" | awk '{print $1}' | sort | uniq
+}
+
+###############################################################################
+# disableMapInner (map)
+#   disables map in config file (any type) (real command)
+###############################################################################
+disableMapInner()
+{
+  #mapType=`awk '($1 == "MixedMap" || $1 == "Map") && $2 == map { print $1 }' \
+  #           map=$1 <"$cnfFile" | sort | uniq`
+  map=$1
+
+  if [ -z "$DebianConffilelist" ]; then
+    createDebianConffilelist
+  fi
+
+  # act on all files that contain an entry
+  for file in $DebianConffilelist; do
+    if mapType=`grepType $map "$cnfFile"`; then
+      # although it's a bug, there might be two types enabled - we disable both
+      for type in $mapType; do
+	configReplace "$cnfFile" "^$type[ 	]*$1" "#! $type $1"
+      done
+    fi
+  done
+}
+
+
+###############################################################################
+# enableMap (type, map)
+#   enables an entry in the config file for map with a given type.
+###############################################################################
+enableMap()
+{
+  mapType=$1
+  mapName=$2
+  case $1 in
+    Map|MixedMap)
+      ;;
+    *)
+      abort "invalid mapType $mapType"
+      ;;
+  esac
+
+  if [ -z "$DebianConffilelist" ]; then
+    createDebianConffilelist
+  fi
+
+  # a map can only have one type, so we carefully disable everything
+  # about map here:
+  disableMapInner "$mapName"
+
+  # now enable with the right type.
+  # But we have to determine where to enable.
+  # is there already a file that contains a (commented) entry?
+  matchfiles=""
+  for file in $DebianConffilelist; do
+    if egrep "^#![[:blank:]]*(MixedMap|Map)[[:blank:]]*$map([[:blank:]]|$)" "$file"  ; then
+      matchfiles="$matchfiles $file"
+    fi
+  done
+  if [ -z "$matchfiles" ]; then
+    # there is already (at least) one file that has a commented entry for our map
+    if [ `(set $matchfiles; echo $#)` -eq 1 ]; then
+      # it is only one, enable map in it
+      configReplace "$file" "^#![ 	]*$mapType[ 	]*$mapName" "$mapType $mapName"
+      # from here we go directly to runUpdate!
+    else
+      # there are more than one
+    fi
+  else
+  fi
+
+  configReplace "$cnfFile" "^#![ 	]*$mapType[ 	]*$mapName" "$mapType $mapName"
+  runUpdate
+  reExecSelf
+}
+




More information about the Pkg-tetex-commits mailing list