 configure                  |   13 +-
 texk/kpathsea/mktexlsr     |   19 +--
 texk/make/paths.mk         |    2 
 texk/tetex/Makefile.in     |   10 +-
 texk/tetex/fmtutil         |   53 +++++++++-
 texk/tetex/fmtutil-sys     |   10 +-
 texk/tetex/fmtutil.man     |   19 +++
 texk/tetex/texconfig       |    7 -
 texk/tetex/texconfig-sys   |    3 
 texk/tetex/texconfig.man   |  224 +++++++++++++++++++++++++++++++++++++++++++--
 texk/tetex/updmap          |   74 +++++++++++++-
 texk/tetex/updmap-sys      |    3 
 texk/tetex/updmap.man      |   35 +++++--
 texk/web2c/cwebdir/cweb.1  |   10 +-
 texk/web2c/fmtutil.in      |    2 
 texk/web2c/man/Makefile.in |    1 
 16 files changed, 417 insertions(+), 68 deletions(-)

Index: etch/configure
===================================================================
--- etch.orig/configure	2006-12-27 23:19:59.000000000 +0100
+++ etch/configure	2006-12-27 23:34:26.000000000 +0100
@@ -4213,12 +4213,13 @@
 
 
 # initialize texmf tree with fmtutil only for teTeX and TeX Live
-if test ! -d $srcdir/texk/tetex || test -n "$xdvik_standalone" || test "x$cross_compiling" = xyes; then
-  FMU=
-else
-  FMU='# '
-fi
-
+# if test ! -d $srcdir/texk/tetex || test -n "$xdvik_standalone" || test "x$cross_compiling" = xyes; then
+#   FMU=
+# else
+#   FMU='# '
+# fi
+# For Debian, we don't need this - we initialize in postinst
+FMU=
 
 # more customizations for standalone xdvik
 if test -z "$xdvik_standalone"; then
Index: etch/texk/kpathsea/mktexlsr
===================================================================
--- etch.orig/texk/kpathsea/mktexlsr	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/kpathsea/mktexlsr	2006-12-27 23:34:26.000000000 +0100
@@ -73,6 +73,9 @@
 '
   set x `kpsewhich --show-path=ls-R | tr : '
 ' | sort | uniq`; shift
+  if test "`id -u`" -eq 0; then
+      NOROOTHOME=true
+  fi
   IFS=$OIFS
 }
 
@@ -80,6 +83,10 @@
   # Prepend cwd if the directory was relative.
   case "$TEXMFLS_R" in
   "") continue ;;  # Strictly speaking, it is an error if this case is taken.
+  $HOME/*) if test -n "$NOROOTHOME"; then
+               tty -s && echo "$progname: Skipping $TEXMFLS_R" >&2
+               continue
+           fi ;;
   /* | [A-z]:/*) ;;
   *)  TEXMFLS_R="`pwd`/$TEXMFLS_R"
   esac
@@ -103,9 +110,9 @@
   db_dir=`echo "$db_file" | sed 's%/[^/][^/]*$%%'` # can't rely on dirname
 
   test -d "$db_dir" || continue
-  test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
 
   if test ! -f "$db_file"; then
+    test -w "$db_dir" || { echo "$progname: $db_dir: directory not writable. Skipping..." >&2; continue; }
     cp /dev/null "$db_file"
     # Use same permissions as parent directory, minus x,s, or t bits.
     chmod `kpsestat -xst "$db_dir"` "$db_file"
@@ -119,11 +126,8 @@
   # Skip if we cannot write the file:
   kpseaccess -w "$db_file" || { echo "$progname: $db_file: no write permission. Skipping..." >&2; continue; }
 
-  db_dir_tmp="$db_dir/lsR$$.tmp"
-  (umask 077 && mkdir "$db_dir_tmp" ) \
-    || { echo "$progname: could not create directory '$db_dir_tmp'. Skipping..." >&2; continue; }
-  db_file_tmp="$db_dir_tmp/lsR$$.tmp"
-  rm -f "$db_file_tmp"
+  db_file_tmp=`tempfile -p ls-R` \
+    || { echo "$progname: could not create temporary file for '$db_file'. Skipping..." >&2; continue; }
 
   tty -s && echo "$progname: Updating $db_file... " >&2
   echo "$ls_R_magic" >"$db_file_tmp"
@@ -137,12 +141,8 @@
   (cd "$TEXMFLS_R" && \ls -LRa 2>/dev/null) |
     sed '/^$/{n;s%^\./%%;s%^%./%;}; /^\.$/d; /^\.\.$/d; /^[\.\/]*lsR[0-9]*\.tmp:*$/d' >>"$db_file_tmp"
 
-  # To be really safe, a loop.
-  until PERMS=`kpsestat = "$db_file"`; do sleep 1; done
-  chmod $PERMS "$db_file_tmp"
-  rm -f "$db_file"
-  mv "$db_file_tmp" "$db_file"
-  rm -rf "$db_dir_tmp"
+  cat "$db_file_tmp" > "$db_file"
+  rm -f "$db_file_tmp"
 done
 tty -s && echo "$progname: Done." >&2
 exit 0
Index: etch/texk/make/paths.mk
===================================================================
--- etch.orig/texk/make/paths.mk	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/make/paths.mk	2006-12-27 23:34:26.000000000 +0100
@@ -47,7 +47,7 @@
 texmf = @texmfmain@
 
 # The directory used by varfonts.
-vartexfonts = /var/tmp/texfonts
+vartexfonts = /var/spool/texmf
 
 # Regular input files.
 texinputdir = $(texmf)/tex
Index: etch/texk/tetex/Makefile.in
===================================================================
--- etch.orig/texk/tetex/Makefile.in	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/Makefile.in	2006-12-27 23:34:26.000000000 +0100
@@ -35,7 +35,7 @@
 
 # Auxiliary files.
 install-data:: $(INFOFILES)
-	$(SHELL) $(top_srcdir)/../mkinstalldirs $(man1dir) $(man5dir) $(texpooldir) $(texmf)/doc/tetex
+	$(SHELL) $(top_srcdir)/../mkinstalldirs $(man1dir) $(man5dir) $(texpooldir) $(texmf)/../doc/tetex-doc/tetex
 	for p in $(manpgs); do \
 	  $(INSTALL_DATA) $(srcdir)/$$p.man $(man1dir)/$$p.$(manext); \
 	done
@@ -65,14 +65,14 @@
 	ln -s fmtutil.$(manext) $(man1dir)/fmtutil-sys.$(manext)
 	test -r ./latex.info || cd $(srcdir) && for i in latex.info*; do \
 	  $(INSTALL_DATA) $$i $(infodir)/$$i; done
-	if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
-	  install-info --info-dir=$(infodir) $(infodir)/latex.info; \
-	else true; fi
+# 	if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
+# 	  install-info --info-dir=$(infodir) $(infodir)/latex.info; \
+# 	else true; fi
 	for p in $(POOLFILES); do \
 	  $(INSTALL_DATA) $(srcdir)/$$p $(texpooldir)/$$p; \
 	done
 	for p in TETEXDOC.pdf TETEXDOC.ps TETEXDOC.dvi teTeX-FAQ; do \
-	  $(INSTALL_DATA) $(srcdir)/doc/$$p $(texmf)/doc/tetex; \
+	  $(INSTALL_DATA) $(srcdir)/doc/$$p $(texmf)/../doc/tetex-doc/tetex; \
 	done
 	$(SHELL) $(top_srcdir)/../mkinstalldirs $(texmf)/texconfig $(texmf)/texconfig/g $(texmf)/texconfig/v $(texmf)/texconfig/x
 	$(INSTALL_DATA) $(srcdir)/texmf/texconfig/g/generic $(texmf)/texconfig/g
Index: etch/texk/tetex/texconfig
===================================================================
--- etch.orig/texk/tetex/texconfig	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/texconfig	2006-12-27 23:34:26.000000000 +0100
@@ -883,8 +883,8 @@
 
     faq)
       setupTexmfmain
-      if test -f $MT_TEXMFMAIN/doc/tetex/teTeX-FAQ; then
-        <$MT_TEXMFMAIN/doc/tetex/teTeX-FAQ eval ${PAGER-more}
+      if test -f $MT_TEXMFDIST/doc/tetex/teTeX-FAQ.gz; then
+        <$MT_TEXMFDIST/doc/tetex/teTeX-FAQ.gz eval zcat | ${PAGER-sensible-pager}
       else
         echo "$progname: faq not found (usually in \$TEXMFMAIN/doc/tetex/teTeX-FAQ)" >&2
         rc=1
@@ -923,6 +923,7 @@
               if test -n "$tfc"; then
                 if test -w "$tfc"; then
                   configReplace "$tfc" '^VARTEXFONTS' "VARTEXFONTS  = $tcBatchFontVardir"
+ 		  /usr/sbin/update-texmf || true
                 else
                   echo "$progname: setting up vardir failed. Reason: no permission to write file \`$tfc'" >&2
                   rc=1
@@ -1067,7 +1068,7 @@
                 fi
                 ;;
             esac
-            ${VISUAL-${EDITOR-vi}} "$tcBatchHFEdit"
+            ${VISUAL:-${EDITOR:-sensible-editor}} "$tcBatchHFEdit"
             if cmp "$tcBatchHFEdit" "$tcBatchHFOrig" >/dev/null 2>&1; then
               echo "$progname: configuration unchanged." >&2
             else
Index: etch/texk/tetex/fmtutil
===================================================================
--- etch.orig/texk/tetex/fmtutil	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/fmtutil	2006-12-27 23:34:26.000000000 +0100
@@ -25,7 +25,13 @@
 #  --cnffile file             set configfile for fmtutil
 #  --fmtdir directory         set destination directory for format files
 ###############################################################################
-
+###############################################################################
+#
+# Debian-specific options:
+# --root-home                Don't use TEXMFSYSVAR, TEXMFSYSCONFIG even when
+#                            called by root
+#
+###############################################################################
 ###############################################################################
 # program history:
 #   Sa Jan 15 18:13:46 CET 2005 avoid multiple variable assignments in one statement
@@ -76,14 +82,40 @@
 # hack around a bug in zsh:
 test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
 
-progname=fmtutil
 argv0=$0
+export argv0
+progname=`basename $argv0`
+
 version=1105809354 # seconds since `00:00:00 1970-01-01 UTC'
                    # date '+%s' (with GNU date)
 
 cnf=fmtutil.cnf   # name of the config file
 
 ###############################################################################
+# Debian hack, needed until depending packages have switched to
+# calling fmtutil-sys
+###############################################################################
+if [ `id -u` -eq 0 ]; then
+  if [ "$1" = "--root-home" ]; then
+    shift
+    echo >&2
+    echo "$progname: Option --root-home given," >&2
+    echo "generating formats in /root/.texmf-var." >&2
+    echo >&2
+  else
+    if [ -z "$RUNNING_AS_SYS" ]; then
+      echo >&2
+      echo "Warning: $progname is being run as root; fmtutil-sys should probably be" >&2
+      echo "used instead.  If this is done by a Debian package upon installation," >&2
+      echo "upgrade, or removal, please file a bug against that package." >&2
+      echo >&2
+      export SHOW_UID_WARNING=true
+      exec fmtutil-sys ${1+"$@"}
+    fi
+  fi
+fi
+
+###############################################################################
 # cleanup()
 #   clean up the temp area and exit with proper exit status
 ###############################################################################
@@ -92,8 +124,21 @@
   rc=$?
   $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
     && { cd / && rm -rf "$tmpdir"; }
+
+  #############################################################################
+  # Debian hack, needed until depending packages have switched to
+  # calling fmtutil-sys
+  #############################################################################
+  if [ $SHOW_UID_WARNING ]; then
+      echo >&2
+      echo "Warning: $progname was run as root; fmtutil-sys was used instead." >&2
+      echo "If this was done by a Debian package upon installation," >&2
+      echo "upgrade, or removal, please file a bug against that package." >&2
+      echo >&2
+  fi
+
   (exit $rc); exit $rc
-}   
+}
 
 ###############################################################################
 # setupTmpDir()
@@ -435,7 +480,7 @@
       --test|--dolinks|--force)
           ;;
       "") break;;
-      *) abort "$progname: unknown option \`$1'. Try $progname --help for help";;
+      *) abort "unknown option \`$1'. Try $progname --help for help";;
     esac
   do test $# -gt 0 && shift; done
 
Index: etch/texk/tetex/fmtutil-sys
===================================================================
--- etch.orig/texk/tetex/fmtutil-sys	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/fmtutil-sys	2006-12-27 23:34:26.000000000 +0100
@@ -23,6 +23,12 @@
 
 TEXMFVAR="$v"
 TEXMFCONFIG="$c"
-export TEXMFVAR TEXMFCONFIG
+RUNNING_AS_SYS=true
+export TEXMFVAR TEXMFCONFIG RUNNING_AS_SYS
 
-exec fmtutil ${1+"$@"}
+case $argv0 in
+  mktexfmt|*/mktexfmt)
+    exec mktexfmt ${1+"$@"} ;;
+  *)
+    exec fmtutil ${1+"$@"} ;;
+esac
Index: etch/texk/tetex/fmtutil.man
===================================================================
--- etch.orig/texk/tetex/fmtutil.man	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/fmtutil.man	2006-12-27 23:34:26.000000000 +0100
@@ -1,4 +1,4 @@
-.TH "fmtutil" "8" "February 2005" "teTeX" "teTeX" 
+.TH "fmtutil" "1" "February 2005" "teTeX" "teTeX"
 .PP 
 .SH "NAME" 
 fmtutil \- utility for maintaining TeX format files
@@ -41,6 +41,14 @@
 .IP "\fB--cnffile\fP \fIfile\fP" 
 specify the configuration
 \fIfile\fP \fBfmtutil\fP should use
+.IP "\fB--root-home\FP"
+(Debian-specific, transitional):
+Unless this option is given, \fBfmtutil\fP will refuse to generate
+formats in \fI/root/.texmf-var/\fP if called by root, and execute
+\fBfmtutil-sys\fP instead.  This is needed until packages that call
+\fBfmtutil\fP in their maintainer scripts have switched to
+\fBfmtutil-sys\fP, and will then be removed.
+.IP
 .IP "\fB--dolinks\fP" 
 (not implemented, just for compatibility)
 .IP "\fB--fmtdir\fP \fIdirectory\fP" 
@@ -53,6 +61,15 @@
 (not implemented, just for compatibility)
 .IP "\fB--test\fP" 
 (not implemented, just for compatibility)
+.PP
+.SH "DEBIAN-SPECIFIC CHANGES"
+.PP
+In Debian. \fBfmtutil\fP acts on the system-wide format files if it is
+called by root (actually, by numerical UID 0).  If you want to create
+user-specific formats for root, use
+.PP
+.IP "\fB\-\-root\-home\fP"
+Don't use TEXMFSYSVAR, TEXMFSYSCONFIG even when called by root.
 .PP 
 .SH "FILES" 
 .PP 
Index: etch/texk/web2c/fmtutil.in
===================================================================
--- etch.orig/texk/web2c/fmtutil.in	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/web2c/fmtutil.in	2006-12-27 23:34:26.000000000 +0100
@@ -55,7 +55,7 @@
 
 # Change "amstex.ini -> bamstex.ini" and "- -> language.dat"
 # if you want babel support in amstex:
-#! amstex	pdfetex		-		-translate-file=cp227.tcx *amstex.ini
+amstex	pdfetex		-		-translate-file=cp227.tcx *amstex.ini
 
 # Change "pdfamstex.ini -> pdfbamstex.ini" and "- -> language.dat"
 # if you want babel support in pdfamstex:
Index: etch/texk/web2c/cwebdir/cweb.1
===================================================================
--- etch.orig/texk/web2c/cwebdir/cweb.1	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/web2c/cwebdir/cweb.1	2006-12-27 23:34:26.000000000 +0100
@@ -100,19 +100,19 @@
 .
 .SH FILES
 .TP
-/usr/local/lib/tex/inputs/cwebmac.tex
+/usr/share/texmf/tex/plain/base/cwebmac.tex
 TeX macros used by cweave output.
 .TP
-/usr/local/src/cweb/cwebman.tex
+/usr/share/doc/texmf/programs/cwebman.dvi.gz
 The user manual.
 .TP
-/usr/local/src/cweb/examples/wc.w
+/usr/share/doc/texmf/programs/cweb-examples/wc.w.gz
 An introductory example.
 .TP
-/usr/local/src/cweb/examples/wmerge.w
+/usr/share/doc/texmf/programs/cweb-examples/wmerge.w.gz
 Patch program based on CWEB-style change files.
 .TP
-/usr/local/lib/cweb
+/usr/share/texmf/cweb
 Directory for cweb "include" files.
 .
 .SH "SEE ALSO"
Index: etch/texk/tetex/updmap.man
===================================================================
--- etch.orig/texk/tetex/updmap.man	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/updmap.man	2006-12-27 23:34:26.000000000 +0100
@@ -32,11 +32,20 @@
 line, \fBupdmap\fP will write generated map files to a directory of
 your choosing (via one of the \fB--*outputdir\fP options), or automatically
 determine where to place the files\&.  In the latter case, it tries to
-use the tree where the variable TEXMFVAR points to.
+use the tree where the variable TEXMFVAR -- or TEXMFSYSVAR if called
+as \fBupdmap-sys\fP -- points to.
+.PP
 When used with the options \fB--edit\fP, \fB--setoption\fP,
-\fB--enable\fP, \fB--disable\fP, or \fB--syncwithtrees\fP, \fBupdmap\fP will first write
-\fBupdmap\&.cfg\fP(5) and regenerate the map files only if this file
-has been changed\&.
+\fB--enable\fP, \fB--disable\fP, or \fB--syncwithtrees\fP,
+\fBupdmap\fP will first write \fBupdmap\&.cfg\fP(5) and regenerate the
+map files only if this file has been changed\&.  In Debian, updmap has
+been adapted so that \fB--enable\fP and \fB--disable\fP do the "right
+thing": change the configuration snippets in \fIupdmap.d\fP instead,
+call \fBupdate-updmap\fP(1) to regenerate \fBupdmap\&.cfg\fP(5) and
+regenerate the map files afterwards.  There are some limitations,
+though: \fBupdmap\fP will regenerate the map files even if
+\fBupdmap\&.cfg\fP(5) has not been changed, and \fB--edit\fP and
+\fB--syncwithtrees\fP cannot be used.
 .PP
 .SH "OPTIONS"
 .PP
@@ -45,6 +54,14 @@
 .IP "\fB--cnffile\fP \fIfile\fP"
 Specify a configuration \fIfile\fP\&.
 .IP
+.IP "\fB--root-home\FP"
+(Debian-specific, transitional):
+Unless this option is given, \fBupdmap\fP will refuse to generate
+files in \fI/root/.texmf-var/\fP if called by root, and execute
+\fBupdmap-sys\fP instead.  This is needed until packages that call
+\fBupdmap\fP in their maintainer scripts have switched to
+\fBupdmap-sys\fP, and will then be removed.
+.IP
 .IP "\fB--dvipsoutputdir\fP \fIdirectory\fP"
 Specify the output
 \fIdirectory\fP for map files generated with dvips syntax\&.
@@ -98,10 +115,10 @@
 \fBdvipdfmDownloadBase14\fP
 .IP
 .IP "\fB--enable\fP \fImaptype\fP \fImapfile\fP"
-Add or enable a \fBMap\fP or \fBMixedMap\fP for \fImapfile\fP\&.
+Permanently add or enable a \fBMap\fP or \fBMixedMap\fP for \fImapfile\fP\&.
 .IP
 .IP "\fB--enable Map=\fImapfile\fP"
-Add or enable a Map for \fImapfile\fP\&.
+Permanently add or enable a Map for \fImapfile\fP\&.
 .IP
 .IP "\fB--enable MixedMap=\fP\fImapfile\fP"
 Add or enable a MixedMap for \fImapfile\fP\&.
@@ -126,7 +143,9 @@
 .IP "\fIupdmap\&.cfg\fP"
 Main configuration file\&.  In
 \fItexmf/web2c\fP by default, but may be located elsewhere
-depending on your distribution\&.
+depending on your distribution\&. \fBNote for Debian\fP: On Debian
++ that file is generated out of files in \fI/etc/texmf/updmap.d\fP.
++ See \fBupdate-updmap\fP(8) or \fIREADME.Debian\fP.
 .IP
 .IP "\fIdvips35\&.map\fP"
 Map file for standard 35 PostScript fonts for
@@ -240,7 +259,7 @@
 .PP
 .SH "SEE ALSO"
 .PP
-\fBupdmap\&.cfg\fP(5), \fBdvipdfm\fP(1), \fBdvips\fP(1),
+\fBupdmap\&.cfg\fP(5), \fBupdate-updmap\fP(8), \fBdvipdfm\fP(1), \fBdvips\fP(1),
 \fBgsftopk\fP(1), \fBpdftex\fP(1), \fBps2pk\fP(1),
 \fBtexhash\fP(1), \fBxdvi\fP(1)\&.
 .PP
Index: etch/texk/tetex/updmap
===================================================================
--- etch.orig/texk/tetex/updmap	2006-12-27 23:34:26.000000000 +0100
+++ etch/texk/tetex/updmap	2006-12-27 23:34:26.000000000 +0100
@@ -15,6 +15,8 @@
 #   --nohash                   do not run texhash
 #   --nomkmap                  do not recreate map files
 #   --quiet                    reduce verbosity
+#   --root-home                (Debian specific) create files in root's homedir
+#                              must be the first option!
 #
 # Valid commands:
 #   --edit                     edit $cnfFileShort file
@@ -112,9 +114,40 @@
 test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
 
 # the version string
-version=1107552857 # seconds since `00:00:00 1970-01-01 UTC'
+version=1107552857-debian # seconds since `00:00:00 1970-01-01 UTC'
                    # date '+%s' (with GNU date)
 
+case $RUNNING_AS_SYS in
+  "") progname=updmap ;;
+  *)  progname=updmap-sys ;;
+esac
+
+###############################################################################
+# Debian hack, needed until depending packages have switched to
+# calling updmap-sys
+###############################################################################
+if [ `id -u` -eq 0 ]; then
+  if [ "$1" = "--root-home" ]; then
+    shift
+    echo >&2
+    echo "$progname: Option --root-home given," >&2
+    echo "generating font configuration in /root/.texmf-var." >&2
+    echo >&2
+  else
+    if [ ! "$progname" = "updmap-sys" ]; then
+      echo >&2
+      echo "Warning: updmap is being run as root; updmap-sys should probably be" >&2
+      echo "used instead.  If this is done by a Debian package upon installation," >&2
+      echo "upgrade, or removal, please file a bug against that package." >&2
+      echo >&2
+      export SHOW_UID_WARNING=true
+      exec updmap-sys ${1+"$@"}
+    fi
+  fi
+fi
+
+
+
 ###############################################################################
 # help()
 #   display help message and exit
@@ -317,6 +350,8 @@
 #   sets option to value in the config file (replacing the existing setting
 #   or by adding a new line to the config file).
 ###############################################################################
+# for Debian, this is superseded by a function defined in debianize-updmap
+# (see below)
 setOption()
 {
   opt=$1
@@ -351,6 +386,8 @@
 # enableMap (type, map)
 #   enables an entry in the config file for map with a given type.
 ###############################################################################
+# for Debian, this is superseded by a function defined in debianize-updmap
+# (see below)
 enableMap()
 {
   case $1 in
@@ -373,6 +410,8 @@
 # disableMap (map)
 #   disables map in config file (any type)
 ###############################################################################
+# for Debian, this is superseded by a function defined in debianize-updmap
+# (see below)
 disableMap()
 {
   #mapType=`awk '($1 == "MixedMap" || $1 == "Map") && $2 == map { print $1 }' \
@@ -735,12 +774,8 @@
 !!! ERROR! The map file \`$2' has not been found at all.
 
     Either put this file into the right place or remove the
-    reference from the configuration file. An automatic way
-    to disable unavailable map files is to call
-      $progname --syncwithtrees
-
-    For manual editing, call
-      $progname --edit
+    reference from the configuration files - see
+    update-updmap(1).
 "
 
     false; return 1
@@ -757,6 +792,19 @@
   rc=$?
   $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
     && { cd / && rm -rf "$tmpdir"; }
+
+  #############################################################################
+  # Debian hack, needed until depending packages have switched to
+  # calling updmap-sys
+  #############################################################################
+  if [ $SHOW_UID_WARNING ]; then
+      echo >&2
+      echo "Warning: updmap was run as root; updmap-sys was used instead." >&2
+      echo "If this was done by a Debian package upon installation," >&2
+      echo "upgrade, or removal, please file a bug against that package." >&2
+      echo >&2
+  fi
+
   (exit $rc); exit $rc
 }
 
@@ -1038,6 +1086,8 @@
 #   update the config file: uncomment all lines which refer to map files that
 #   are unavailabe in the texmf trees
 ###############################################################################
+# for Debian, this is superseded by a function defined in debianize-updmap
+# (see below)
 syncWithTrees()
 {
   for i in `egrep '^(Mixed)?Map' "$cnfFile" | sed 's@.* @@'`; do
@@ -1051,6 +1101,11 @@
 }
 
 ###############################################################################
+# source Debian-specific changes, superseding some functions
+###############################################################################
+. /usr/share/tex-common/debianize-updmap
+
+###############################################################################
 # normalizeLines()
 #   remove comments, whitespace is exactly one space, no empty lines,
 #   no whitespace at end of line, one space before and after "
@@ -1274,7 +1329,8 @@
 main()
 {
   # initialize global variables
-  progname=updmap
+  # progname is needed earlier in Debian
+  # progname=updmap
   cmd=
   log=
 
@@ -1333,7 +1389,7 @@
 
     case "$cmd" in
       edit)
-        ${VISUAL-${EDITOR-vi}} $cnfFile;;
+	debianEditWarnAndShow;;
       setoption)
         setOption "$setoptionOpt" "$setoptionVal";;
       enable)
Index: etch/texk/tetex/updmap-sys
===================================================================
--- etch.orig/texk/tetex/updmap-sys	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/updmap-sys	2006-12-27 23:34:26.000000000 +0100
@@ -23,6 +23,7 @@
 
 TEXMFVAR="$v"
 TEXMFCONFIG="$c"
-export TEXMFVAR TEXMFCONFIG
+RUNNING_AS_SYS=true
+export TEXMFVAR TEXMFCONFIG RUNNING_AS_SYS
 
 exec updmap ${1+"$@"}
Index: etch/texk/tetex/texconfig-sys
===================================================================
--- etch.orig/texk/tetex/texconfig-sys	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/texconfig-sys	2006-12-27 23:34:26.000000000 +0100
@@ -23,6 +23,7 @@
 
 TEXMFVAR="$v"
 TEXMFCONFIG="$c"
-export TEXMFVAR TEXMFCONFIG
+RUNNING_AS_SYS=true
+export TEXMFVAR TEXMFCONFIG RUNNING_AS_SYS
 
 exec texconfig ${1+"$@"}
Index: etch/texk/web2c/man/Makefile.in
===================================================================
--- etch.orig/texk/web2c/man/Makefile.in	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/web2c/man/Makefile.in	2006-12-27 23:34:26.000000000 +0100
@@ -38,7 +38,6 @@
 	dvicopy.1	\
 	dvitomp.1	\
 	dvitype.1	\
-	eplain.1	\
 	etex.1		\
 	gftodvi.1	\
 	gftopk.1	\
Index: etch/texk/tetex/texconfig.man
===================================================================
--- etch.orig/texk/tetex/texconfig.man	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/tetex/texconfig.man	2006-12-27 23:34:26.000000000 +0100
@@ -6,22 +6,230 @@
 .SH SYNOPSIS
 .B texconfig
 .LP
+.B texconfig
+[\fB commands\fR ...]
+.LP
 .B texconfig-sys
 .SH DESCRIPTION
 .I texconfig
-allows to configure and maintain
+allows one to configure and maintain
+.I teTeX
+in an easy and convenient manner, offering a series of dialog boxes to
+the user. After choosing settings or options, the appropriate files
+are changed automatically and the new settings are applied for the
+user.  If needed, copies of files in 
+.I TEXMFDIST
+or
+.I TEXMFMAIN
+will be made in the user's 
+.I TEXMFCONFIG
+tree.
+.PP
+.I texconfig
+uses either the
+.IR whiptail (1)
+or
+.IR dialog (1)
+program to communicate with the user, so must be run in a terminal.
+.PP
+For making system-wide changes, which will apply to all users of
 .I teTeX
-in an easy and convenient manner. It uses the
-.I dialog
-program to draw nice input boxes. After answering the dialoges, the
-appropriate files are changed automatically and all necessary
-steps are involved to apply the new settings.
+(for example, default paper size and so on), run
+.I texconfig-sys
+instead.  Changed or generated files will be placed in
+.I TEXMFSYSCONFIG.
+(You may need ot be root to do this.)
+.PP
+Note that on a Debian system, changes to formats, font setup,
+hyphenation for different languages, etc. should not be done with
+texconfig, because
+.B fmtutil.cnf(5), updmap.cfg(5), texmf.cnf
+and
+.B language.dat
+are generated files in Debian.  See 
+.I TeX-on-Debian.pdf, TeX-on-Debian.txt.gz
+or
+.I TeX-on-Debian.hmlt/index.html
+in 
+.I /usr/share/doc/tex-common/
+for alternatives.
+.PP
+.I texconfig
+also offers a non-interactive batch mode which can be accessed with
+the following commands
+.SH COMMANDS
+Commands that accept further options usually display available options
+if called without them.  For example, 
+.B texconfig dvipdfm paper
+will inform about valid paper settings.
+.PP
+.B
+.IP conf
+Display the system configuration.  Note that some of the files listed
+as configuration files are generated files on a Debian system.
+.PP
+.TP
+.B dvipdfm paper [letter|legal|ledger|tabloid|a4|a3]
+Set up dvipdfm to use papersize PAPER by default.
+.TP
+.B dvips add PRINTERNAME
+Create a new (empty) configuration file
+.I TEXMFCONFIG/dvips/config/config.PRINTERNAME.
+This file can later be filled with the 
+.B mode, offset
+or
+.B printcmd
+options
+.TP
+.B dvips del PRINTERNAME
+Remove
+.I config.PRINTERNAME
+.TP 
+.B dvips mode
+List available MetaFont modes.
+.TP
+.B dvips [-P PRINTER] mode MODE
+Change the MetaFont mode to 
+.I MODE
+for
+.I PRINTER
+or for all output files
+.I (config.ps),
+if no
+.B -P
+option is given.
+.TP
+.B dvips [-P PRINTER] offset x-OFFSET,y-OFFSET
+Set printer offset for
+.I PRINTER
+or for all output files
+.I (config.ps),
+if no
+.B -P
+option is given.  Offsets must be given with units, e.g.
+.I 0pt,10pt
+You can use testpage.tex from the LaTeX distribution to find these
+numbers.
+.TP
+.B dvips [-P PRINTER] printcmd CMD
+Set the printing command for 
+.I PRINTER
+or for all output files
+.I (config.ps),
+if no
+.B -P
+option is given.  Commands might be
+.B lp
+or
+.B lpr.
+See the description of the
+.I o
+option in
+.B info dvips
+or the 
+.I -O
+option in
+.B dvips(1).
+.TP
+.B faq
+Display the list of Frequently Asked Questions about
+.B teTeX
+(and their answers).
+.TP
+.B font vardir DIR, font ro, font ro
+These options should not be used on a Debian system unless you really
+know what you are doing.  For details, look at the output of
+.B texconfig fonts
+and read section 2.5, font caching, in the TeX-on-Debian documentation
+in
+.I /usr/share/doc/tex-common/.
+.TP 
+.B formats
+This command allows to edit
+.B fmtutil.cnf(5)
+and (re)creates any new or changed formats afterwards.  It should not
+be used on Debian systems, unless you want to temporarily create and
+test a specific format, because
+.B fmtutil.cnf(5)
+is a generated file in Debian, and changes will be overwritten.  See
+.B update-fmtutil
+for details.
+.TP
+.B hyphen FORMAT
+This command allows to edit the hyphenation configuration file for
+formats that support this, and recreates the formats afterwards to
+enable the new languages.  Available formats are shown when no 
+.I FORMAT
+is given.
+.IP
+Note that for formats that use LaTeX's 
+.I language.dat,
+ e.g.
+.I (pdf)jadetex
+and
+.I latex
+itself, this change is not persistent, since this file is a generated
+file.  You should not use this command in these cases, read
+.B update-language(1)
+for alternatives.
+.TP
+.B init [format]
+Recreate
+.I format
+or all formats if none is given, and the font information.  This is
+the same as calling
+.B fmtutil --byfmt format
+or
+.B fmtutil --all,
+respectively, followed by
+.B updmap.
+.TP
+.B mode-list
+List available printer modes, together with the printers they were
+developed for, and their DPI resolution
+.TP
+.B mode MODE
+Set the default printer mode in 
+.I /etc/texmf/web2c/mktex.cnf
+or the respective user file in
+.I $TEXMFCONFIG/web2c
+to 
+.B MODE.
+.TP
+.B paper [a4|letter]
+Set the default papersize for 
+.B dvips, dvipdfm, pdftex
+and
+.B xdvi.
+The set is restricted because not all programs understand all sizes.
+.TP
+.B pdftex paper [a4|letter]
+Set the default paper size for 
+.B pdftex.
+.TP
+.B rehash
+Call
+.B mktexlsr.
+.TP
+.B xdvi paper PAPER
+Set the default paper size for 
+.B xdvi.
+The (long) list is available with
+.B texconfig xdvi paper.
+
+.SH ENVIRONMENT
+To let you change files,
+.B texconfig
+will open the editor specified in the VISUAL or EDITOR variables, or
+.B sensible-editor
+if both are unset.
 .SH "SEE ALSO"
+.IR whiptail (1),
 .IR dialog (1),
-.IR initex (1),
+.IR tex (1),
 .IR mf (1),
 .IR vi (1),
 .IR EDITOR
-environment-variable.
+environment variable.
 .SH AUTHOR
 Thomas Esser <te@dbs.uni-hannover.de>
Index: etch/texk/kpathsea/mktexlsr.man
===================================================================
--- etch.orig/texk/kpathsea/mktexlsr.man	2006-12-27 23:19:59.000000000 +0100
+++ etch/texk/kpathsea/mktexlsr.man	2006-12-27 23:35:05.000000000 +0100
@@ -1,4 +1,4 @@
-.TH MKTEXLSR 1 "4 January 1998" "Kpathsea @VERSION@"
+.TH MKTEXLSR 1 "27 December 2006" "Kpathsea @VERSION@"
 .\"=====================================================================
 .if n .ds MP MetaPost
 .if t .ds MP MetaPost
@@ -44,3 +44,12 @@
 .B --version
 .rb
 Print version information and exit.
+.\"=====================================================================
+.SH NOTES
+When called by root with no arguments, \fBmktexlsr\fP in Debian ignores
+TEXMF trees under \fI$HOME\fP. This is to avoid creating undesirable files
+such as \fI/root/texmf/ls-R\fP when doing usual maintainance (it is generally
+a bad idea to work with TeX as root, therefore having a file such as
+\fI/root/texmf/ls-R\fP in the first place is rather pointless). If you really
+want to update the ls-R databases for such TEXMF trees, simply list them
+explicitely on the command-line.
