From 4bbdb7af7704d712bc0aac08bc8d02709336bfd8 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 8 Apr 2013 15:51:20 +0000 Subject: move runtime tetex/ scripts to texlive/ , etc. git-svn-id: svn://tug.org/texlive/trunk@29739 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/chktex/chkweb.sh | 56 + Master/texmf-dist/scripts/psutils/getafm.sh | 358 +++ Master/texmf-dist/scripts/psutils/showchar.sh | 118 + Master/texmf-dist/scripts/tetex/allcm.sh | 118 - Master/texmf-dist/scripts/tetex/allneeded.sh | 46 - Master/texmf-dist/scripts/tetex/dvi2fax.sh | 41 - Master/texmf-dist/scripts/tetex/dvired.sh | 98 - Master/texmf-dist/scripts/tetex/e2pall.pl | 89 - Master/texmf-dist/scripts/tetex/fmtutil-sys.sh | 29 - Master/texmf-dist/scripts/tetex/fmtutil.sh | 1017 --------- Master/texmf-dist/scripts/tetex/fontinst.sh | 16 - Master/texmf-dist/scripts/tetex/kpsetool.sh | 118 - Master/texmf-dist/scripts/tetex/kpsewhere.sh | 63 - Master/texmf-dist/scripts/tetex/ps2frag.sh | 11 - Master/texmf-dist/scripts/tetex/pslatex.sh | 46 - Master/texmf-dist/scripts/tetex/rubibtex.sh | 110 - Master/texmf-dist/scripts/tetex/rumakeindex.sh | 77 - .../texmf-dist/scripts/tetex/texconfig-dialog.sh | 486 ----- Master/texmf-dist/scripts/tetex/texconfig-sys.sh | 31 - Master/texmf-dist/scripts/tetex/texconfig.sh | 1432 ------------ Master/texmf-dist/scripts/tetex/texdoctk.pl | 1857 ---------------- Master/texmf-dist/scripts/tetex/texlinks.sh | 335 --- Master/texmf-dist/scripts/tetex/updmap-sys.sh | 30 - Master/texmf-dist/scripts/tetex/updmap.pl | 2306 -------------------- Master/texmf-dist/scripts/texdoctk/texdoctk.pl | 1857 ++++++++++++++++ Master/texmf-dist/scripts/texlive/allcm.sh | 118 + Master/texmf-dist/scripts/texlive/allneeded.sh | 46 + Master/texmf-dist/scripts/texlive/dvi2fax.sh | 41 + Master/texmf-dist/scripts/texlive/dvired.sh | 98 + Master/texmf-dist/scripts/texlive/e2pall.pl | 89 + Master/texmf-dist/scripts/texlive/fmtutil-sys.sh | 29 + Master/texmf-dist/scripts/texlive/fmtutil.sh | 1017 +++++++++ Master/texmf-dist/scripts/texlive/fontinst.sh | 16 + Master/texmf-dist/scripts/texlive/kpsetool.sh | 118 + Master/texmf-dist/scripts/texlive/kpsewhere.sh | 63 + Master/texmf-dist/scripts/texlive/ps2frag.sh | 11 + Master/texmf-dist/scripts/texlive/pslatex.sh | 46 + Master/texmf-dist/scripts/texlive/rubibtex.sh | 110 + Master/texmf-dist/scripts/texlive/rumakeindex.sh | 77 + .../texmf-dist/scripts/texlive/texconfig-dialog.sh | 486 +++++ Master/texmf-dist/scripts/texlive/texconfig-sys.sh | 31 + Master/texmf-dist/scripts/texlive/texconfig.sh | 1432 ++++++++++++ Master/texmf-dist/scripts/texlive/texlinks.sh | 335 +++ Master/texmf-dist/scripts/texlive/updmap-sys.sh | 30 + Master/texmf-dist/scripts/texlive/updmap.pl | 2306 ++++++++++++++++++++ 45 files changed, 8888 insertions(+), 8356 deletions(-) create mode 100755 Master/texmf-dist/scripts/chktex/chkweb.sh create mode 100755 Master/texmf-dist/scripts/psutils/getafm.sh create mode 100755 Master/texmf-dist/scripts/psutils/showchar.sh delete mode 100755 Master/texmf-dist/scripts/tetex/allcm.sh delete mode 100755 Master/texmf-dist/scripts/tetex/allneeded.sh delete mode 100755 Master/texmf-dist/scripts/tetex/dvi2fax.sh delete mode 100755 Master/texmf-dist/scripts/tetex/dvired.sh delete mode 100755 Master/texmf-dist/scripts/tetex/e2pall.pl delete mode 100755 Master/texmf-dist/scripts/tetex/fmtutil-sys.sh delete mode 100755 Master/texmf-dist/scripts/tetex/fmtutil.sh delete mode 100755 Master/texmf-dist/scripts/tetex/fontinst.sh delete mode 100755 Master/texmf-dist/scripts/tetex/kpsetool.sh delete mode 100755 Master/texmf-dist/scripts/tetex/kpsewhere.sh delete mode 100755 Master/texmf-dist/scripts/tetex/ps2frag.sh delete mode 100755 Master/texmf-dist/scripts/tetex/pslatex.sh delete mode 100755 Master/texmf-dist/scripts/tetex/rubibtex.sh delete mode 100755 Master/texmf-dist/scripts/tetex/rumakeindex.sh delete mode 100755 Master/texmf-dist/scripts/tetex/texconfig-dialog.sh delete mode 100755 Master/texmf-dist/scripts/tetex/texconfig-sys.sh delete mode 100755 Master/texmf-dist/scripts/tetex/texconfig.sh delete mode 100755 Master/texmf-dist/scripts/tetex/texdoctk.pl delete mode 100755 Master/texmf-dist/scripts/tetex/texlinks.sh delete mode 100755 Master/texmf-dist/scripts/tetex/updmap-sys.sh delete mode 100755 Master/texmf-dist/scripts/tetex/updmap.pl create mode 100755 Master/texmf-dist/scripts/texdoctk/texdoctk.pl create mode 100755 Master/texmf-dist/scripts/texlive/allcm.sh create mode 100755 Master/texmf-dist/scripts/texlive/allneeded.sh create mode 100755 Master/texmf-dist/scripts/texlive/dvi2fax.sh create mode 100755 Master/texmf-dist/scripts/texlive/dvired.sh create mode 100755 Master/texmf-dist/scripts/texlive/e2pall.pl create mode 100755 Master/texmf-dist/scripts/texlive/fmtutil-sys.sh create mode 100755 Master/texmf-dist/scripts/texlive/fmtutil.sh create mode 100755 Master/texmf-dist/scripts/texlive/fontinst.sh create mode 100755 Master/texmf-dist/scripts/texlive/kpsetool.sh create mode 100755 Master/texmf-dist/scripts/texlive/kpsewhere.sh create mode 100755 Master/texmf-dist/scripts/texlive/ps2frag.sh create mode 100755 Master/texmf-dist/scripts/texlive/pslatex.sh create mode 100755 Master/texmf-dist/scripts/texlive/rubibtex.sh create mode 100755 Master/texmf-dist/scripts/texlive/rumakeindex.sh create mode 100755 Master/texmf-dist/scripts/texlive/texconfig-dialog.sh create mode 100755 Master/texmf-dist/scripts/texlive/texconfig-sys.sh create mode 100755 Master/texmf-dist/scripts/texlive/texconfig.sh create mode 100755 Master/texmf-dist/scripts/texlive/texlinks.sh create mode 100755 Master/texmf-dist/scripts/texlive/updmap-sys.sh create mode 100755 Master/texmf-dist/scripts/texlive/updmap.pl diff --git a/Master/texmf-dist/scripts/chktex/chkweb.sh b/Master/texmf-dist/scripts/chktex/chkweb.sh new file mode 100755 index 00000000000..8d6361d1097 --- /dev/null +++ b/Master/texmf-dist/scripts/chktex/chkweb.sh @@ -0,0 +1,56 @@ +#! /bin/sh + +# ChkWEB v1.0, runs the LaTeX parts of a CWEB file through ChkTeX. +# Copyright (C) 1996 Jens T. Berger Thielemann +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Contact the author at: +# Jens Berger +# Spektrumvn. 4 +# N-0666 Oslo +# Norway +# E-mail: + + +params= + +for p +do + case $p in + --) break + ;; + -*) params="$params $p" + shift + ;; + *) break + ;; + esac +done + + +if test "$1" = ""; then + deweb | chktex -v3 $params +else + for file + do + if test -f $file; then + deweb $file | chktex -p $file -v3 $params + else + deweb $file.w | chktex -p $file.w -v3 $params + fi + done +fi + diff --git a/Master/texmf-dist/scripts/psutils/getafm.sh b/Master/texmf-dist/scripts/psutils/getafm.sh new file mode 100755 index 00000000000..1c6cd21cf77 --- /dev/null +++ b/Master/texmf-dist/scripts/psutils/getafm.sh @@ -0,0 +1,358 @@ +#!/bin/sh + +if [ $# -ne 1 ]; then + echo "usage: $0 font-name | gsnd - >font-name.afm" >&2 + exit 1 +fi + +cat << EOF +%! +% produce .afm for $1 +% (c) 1993 by Robert Joop +% inspired by two other versions of this theme which are +% getafm 1.00 (c) AJCD +% and getafm.ps by an unknown author, +% modified by J. Daniel Smith + +% Metrics dictionary code added by AJCD, 7/6/93 + +/getafmdict 100 dict dup begin + + /buf 256 string def + /buf2 16 string def + + /prany % dict dictname printname -> dict + { + 2 index 2 index cvn known + { + print % printname + ( ) print + 1 index exch cvn get = + } + { + (Comment /FontInfo contains no /) print + 2 copy eq + { + = % printname + pop % dictname + } + { + exch + print % dictname + (, therefore no ) print + = % printname + } + ifelse + } + ifelse + } + bind def + + /printfontname + { + (FontName)dup prany + } + bind def + + /printfontinfo + { + dup /FontInfo known + { + dup /FontInfo get + (FullName)dup prany + (FamilyName)dup prany + (Weight)dup prany + (ItalicAngle)dup prany + (isFixedPitch)(IsFixedPitch) prany + (UnderlinePosition)dup prany + (UnderlineThickness)dup prany + (Version)(version) prany + (Notice)dup prany + pop + } + { + (Comment Font lacks a /FontInfo!)= + } + ifelse + } + bind def + + /prbbox % llx lly urx ury -> - + { + 4 1 roll 3 1 roll exch % swap top 4 elements + 4 { ( ) print buf cvs print } repeat + } + bind def + + /getbbox % fontdict chardict character -> fontdict chardict llx lly urx ury + { + gsave + 2 index setfont 0 0 moveto + false charpath flattenpath pathbbox + grestore + } + bind def + + /printmiscinfo + { + dup /FontBBox known + { + (FontBBox) print + dup /FontBBox get aload pop prbbox ()= + } + { + (Comment missing required /FontBBox)= + quit + } + ifelse + 2 copy exch get + dup /H known + 1 index /x known and + 1 index /d known and + 1 index /p known and + dup /looksRoman exch def + { + (CapHeight ) print + (H) getbbox + ceiling cvi = pop pop pop + (XHeight ) print + (x) getbbox + ceiling cvi = pop pop pop + (Ascender ) print + (d) getbbox + ceiling cvi = pop pop pop + (Descender ) print + (p) getbbox + pop pop floor cvi = pop + } + { + (Comment font doesn't contain H, x, d and p; therefore no CapHeight, XHeight, Ascender and Descender)= + } + ifelse + pop + dup /Encoding get + [ + [ (ISOLatin1Encoding) /ISOLatin1Encoding ] + [ (AdobeStandardEncoding) /StandardEncoding ] + ] + { + aload pop dup where + { + exch get 2 index eq + { + (EncodingScheme ) print + buf cvs = + } + { + pop + } + ifelse + } + { + pop pop + } + ifelse + } + forall + pop + } + bind def + + /printcharmetric + { + % chardictname fontdict charnamedict encoding charindex charname + + 4 index dup length dict dup begin exch + { + 1 index /FID ne + 2 index /UniqueID ne + and + { + 1 index /Encoding eq { 256 array copy } if + def + } + { pop pop } + ifelse + } + forall + end + dup /Encoding get 32 3 index put + /f2 exch definefont + setfont + + (C ) print + 1 index buf cvs print + + ( ; WX ) print +% Metrics entries are: +% 1 number: which is the character width +% an array of 2 numbers: which are the left sidebearing and width +% an array of 4 numbers: x & y left sidebearing, width and height + dup 5 index % /charname fontdict + dup /Metrics known { + /Metrics get exch 2 copy known { + get dup type /arraytype eq { + dup length 2 eq + {1 get} {2 get} ifelse + } if + round cvi buf cvs print + } { + pop pop ( ) stringwidth pop round cvi buf cvs print + } ifelse + } { + pop pop ( ) stringwidth pop round cvi buf cvs print + } ifelse + + ( ; N ) print + dup buf cvs print + + ( ; B) print + gsave + newpath 0 0 moveto + ( ) true charpath flattenpath pathbbox + grestore + 2 { ceiling cvi 4 1 roll } repeat + 2 { floor cvi 4 1 roll } repeat + prbbox + + looksRoman + { + [ + [ /f [ /i /f /l ] ] + [ /ff [ /i /l ] ] + ] + { + aload pop 1 index 3 index eq + { + { + 1 index buf cvs + length + 1 index buf2 cvs dup length + 2 index add + buf + 4 2 roll putinterval + buf 0 + 3 -1 roll getinterval + dup cvn + 7 index + exch known + { + exch + ( ; L ) print + buf2 cvs print + ( ) print + print + } + { + pop pop + } + ifelse + } + forall + pop + } + { + pop pop + } + ifelse + } + forall + } + if + pop + + ( ;)= + } + bind def + + /printcharmetrics + { + (StartCharMetrics ) print + 2 copy exch get length 1 sub buf cvs = + + 256 dict dup begin + 1 index /Encoding get + { null def } + forall + end + % chardictname fontdict charnamedict + 1 index /Encoding get + 0 1 255 + { + % encoding index + 2 copy get + dup /.notdef eq { pop } { printcharmetric } ifelse + pop % index + } for + + -1 + 3 index 5 index get + { + pop + dup /.notdef eq + { pop } + { + % chardictname fontdict charnamedict encoding charindex charname + dup 4 index exch known + { pop } + { printcharmetric } + ifelse + } + ifelse + } + forall + % charnamedict encoding index + pop pop pop + + (EndCharMetrics)= + } + bind def + + /printfontmetrics + { + (StartFontMetrics 3.0)= + (Comment Produced by getafm 3.0 (which is by rj@rainbow.in-berlin.de))= + + printfontname + printfontinfo + printmiscinfo + printcharmetrics + + (EndFontMetrics)= + } + bind def + +end def + +/getafm +{ + getafmdict begin + save exch + findfont 1000 scalefont + + null + [ /CharDefs /CharData /CharProcs /CharStrings ] + { + 2 index 1 index known { exch } if + pop + } + forall + dup null eq + { + (can't find dictionary with character data!)= + quit + } + if + exch % dictname fontdict + + printfontmetrics + + pop pop + restore + end +} +bind def + +/$1 getafm + +EOF diff --git a/Master/texmf-dist/scripts/psutils/showchar.sh b/Master/texmf-dist/scripts/psutils/showchar.sh new file mode 100755 index 00000000000..e685e99ae8c --- /dev/null +++ b/Master/texmf-dist/scripts/psutils/showchar.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# showchar: show character with information +# usage: +# showchar Font-Name Char-Name | lpr -Pprinter + +if [ $# != 2 ]; then + echo "Usage: `basename $0` Font-Name Char-Name" >&2 + exit 1 +fi + +cat </dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -progname=`basename $0` -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ - -case "$progname" in - allec) - encoding=T1;; - *) - encoding=OT1;; -esac - -case "$1" in - -r) - DVIPS=dvired - shift - ;; - *) - DVIPS=dvips - ;; -esac - -body() -{ - cat <<-'eof' - \pagestyle{empty} - \parindent0in - \hfuzz=\maxdimen - \hbadness=10000 - \textheight9.5in - \textwidth6.5in - \newcommand{\myformula}{\sum a_{b_{c_d}} = c} - \newcommand{\mytext}{text $\mathcal{\myformula}\mathrm{\myformula} - \mathbf{\myformula}\mathsf{\myformula}\mathtt{\myformula} - \mathnormal{\myformula}\mathit{\myformula}$} - - \newcommand{\TestSizes}{{% - \tiny \mytext\scriptsize \mytext\footnotesize \mytext\small \mytext - \normalsize \mytext - \large \mytext\Large \mytext\LARGE \mytext\huge \mytext\Huge \mytext}} - \newcommand{\TestRM}{rm-family: {\rmfamily\TestSizes}\newline} - \newcommand{\TestSF}{sf-family: {\sffamily\TestSizes}\newline} - \newcommand{\TestTT}{tt-family: {\ttfamily\TestSizes}\newline} - \newcommand{\TestFamilies}{\TestRM\TestSF\TestTT\newline} - \newcommand{\TestMD}{md-series: {\mdseries\TestFamilies}} - \newcommand{\TestBF}{bf-series: {\bfseries\TestFamilies}} - \newcommand{\TestSeries}{\TestBF\TestMD\par} - \newcommand{\TestUP}{up-shape: {\upshape\TestSeries}\par} - \newcommand{\TestIT}{it-shape: {\itshape\TestSeries}\par} - \newcommand{\TestSL}{sl-shape: {\slshape\TestSeries}\par} - \newcommand{\TestSC}{sc-shape: {\scshape\TestSeries}\par} - \newcommand{\TestShapes}{\TestUP\TestIT\TestSL\TestSC} - \begin{document} - \TestShapes - \end{document} -eof -} - -head() -{ - echo '\documentclass['$1'pt]{article}' - echo '\usepackage['$encoding']{fontenc}' -} - -# before we create the tmpdir, set trap for cleanup -trap ' - rm -rf $tmpdir - exit 1 -' 1 2 3 7 13 15 - -(umask 077; mkdir "$tmpdir") || { - echo "$progname: failed to create temp directory." >&2 - exit 1 -} - -cd $tmpdir || exit 1 -echo >&2 -echo "---------------------------------------------------------------------" >&2 -echo ">>>>>>>>>>> Generating testfiles for 10pt, 11pt and 12pt. <<<<<<<<<<" >&2 -echo "---------------------------------------------------------------------" >&2 -head 10 > allcm10.tex -head 11 > allcm11.tex -head 12 > allcm12.tex -body >> allcm10.tex -body >> allcm11.tex -body >> allcm12.tex - -echo >&2 -echo "---------------------------------------------------------------------" >&2 -echo ">>>>>>>>>>> Calling latex... <<<<<<<<<<" >&2 -echo "---------------------------------------------------------------------" >&2 -latex allcm10 >/dev/null -latex allcm11 >/dev/null -latex allcm12 >/dev/null - -echo >&2 -echo "---------------------------------------------------------------------" >&2 -echo ">>>>>>>>>>> Now, calling $DVIPS to make missing fonts... <<<<<<<<<<" >&2 -echo "---------------------------------------------------------------------" >&2 -$DVIPS ${1+"$@"} -V -f allcm10 > /dev/null -$DVIPS ${1+"$@"} -V -f allcm11 > /dev/null -$DVIPS ${1+"$@"} -V -f allcm12 > /dev/null - -cd / -rm -rf $tmpdir diff --git a/Master/texmf-dist/scripts/tetex/allneeded.sh b/Master/texmf-dist/scripts/tetex/allneeded.sh deleted file mode 100755 index 15c62c84adb..00000000000 --- a/Master/texmf-dist/scripts/tetex/allneeded.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -progname=`basename $0` -dvired=false - -case $1 in --r) DVIPS="dvips -x707" - shift;; -*) DVIPS=dvips;; -esac - -case $# in -0) echo "Usage: $progname [-r] files ..." >&2 - exit ;; -esac - -findopt= -dvipsopt= - -for i -do - if [ -f $i ] || [ -d $i ]; then - findopt="$findopt $i" - else - dvipsopt="$dvipsopt $i" - fi -done - -find $findopt -name \*.dvi -type f -print | - while true; do - read i - test -z "$i" && exit - echo "processing file '$i' ..." - $DVIPS $dvipsopt -f "$i" >/dev/null - echo - done diff --git a/Master/texmf-dist/scripts/tetex/dvi2fax.sh b/Master/texmf-dist/scripts/tetex/dvi2fax.sh deleted file mode 100755 index fdfa83211eb..00000000000 --- a/Master/texmf-dist/scripts/tetex/dvi2fax.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -# options for dvips are passwd down - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -progname=`basename "$0"` -help() -{ - echo "Usage: $progname [-hi|-lo] file[.dvi] [options for dvips]" - echo " -hi: use high fax resolution (204x196) (default)" - echo " -lo: use low fax resolution (204x98)" - echo - echo "Example: $progname foo -l 2" -} - -dvipsconf=dfaxhigh; gsdev=dfaxhigh -case $1 in - -hi) gsdev=dfaxhigh; shift;; - -lo) gsdev=dfaxlow; shift;; -esac - -case $# in - 0) help >&2 - exit 1 - ;; -esac - -NAME=`basename "$1" .dvi` -dvips "$@" -P$dvipsconf -f | - gs -q -dSAFER -sDEVICE=$gsdev -sOutputFile="$NAME-%03d.fax" -sNOPAUSE - diff --git a/Master/texmf-dist/scripts/tetex/dvired.sh b/Master/texmf-dist/scripts/tetex/dvired.sh deleted file mode 100755 index 4eb3586119d..00000000000 --- a/Master/texmf-dist/scripts/tetex/dvired.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh -#============================================================================== -# Version: 0.3 -# Module: dvired -# Purpose: Translate dvi-file into postscript with reduced output size. -# Two logical pages will be put on onto each physical sheet of -# paper. -# System: Linux. UNIX(tm) systems may work as well :-) -# Requires: pstops (http://www.dcs.ed.ac.uk/home/ajcd/psutils/), dvips -# Created: 19.11.1992 -# Last Change: 13.08.1999 -# Language: sh -# Author: Thomas Esser -# Address: te@dbs.uni-hannover.de -# Copyright: (c) 1994, 1999 by Thomas Esser -# Copying: GNU GENERAL PUBLIC LICENSE -#============================================================================== - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -help() -{ - cat < "$of" - ;; -esac diff --git a/Master/texmf-dist/scripts/tetex/e2pall.pl b/Master/texmf-dist/scripts/tetex/e2pall.pl deleted file mode 100755 index 2997f8b1102..00000000000 --- a/Master/texmf-dist/scripts/tetex/e2pall.pl +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env perl - -# Author: Jody Klymak , publisted by a posting -# to the pdftex mailinglist. - -# recursively finds all your eps files. Looks down \input{fname}. -# CAVEATS: -# 1) cannot handle \input{fname} split over more than one line. -# 1.5) cannot handle multiple \input{} or \includegraphics{} on one line. -# 2) Must be run from same directory as the Latex file. -# 3) Does not look down $TEXINPUTS or anything fancy like that... -# 4) Handling of \include is untested (though I guess its trivial) -# 5) Assumes *all* your graphics inclusions are [e]ps. But don't -# fret, because if they are not epstopdf dies anyhow.... -# 6) Does not distinguish between percent (\%) and comment (%). - -# Changelog: -# 20030103 -- Lachlan Andrew -# * Only append '.tex' if $fname doesn't exist. -# * Correctly handle lines with '}' after the \includegraphics{} -# * Allow multiple extensions for graphics files. .eps -> .ps -> none -# (Should try them in the same order as \includegraphics does -# -- given by \DeclareGraphicsExtensions{}?) -# * Allow \include the same way as \input -# * Allow \includegraphics{} to be split over multiple lines -# * Check that commands begin with '\', and allow spaces before arguments - -# EDIT these two lines for your system.... - -$Eps2PdfCom = "epstopdf"; -$ThisFunCom = "e2pall"; - -$fname=$ARGV[0]; - -# check for a *.tex at the end... -if ((-f "$fname")=="" && $fname !~ /.tex$/){ - $fname = "$fname.tex"; -} - -open(TEXFILE,$fname) or die "Cannot open file $fname"; -# print "Finding *.eps files in $fname\n"; - -$seekingArg = 0; -while($line=){ - # truncate $line after % sign.... - $line=~s/%.*//; - # check for /input.... - if ($line=~/\\input *{([^}]*)}/){ - print `$ThisFunCom $1`; - } - # check for /include.... - if ($line=~/\\include *{([^}]*)}/){ - print `$ThisFunCom $1`; - } - - $base = ""; - if ($line=~/\\includegraphics.*{([^}]*)}/){ - $base = $1; - } - elsif ($seekingArg==1 && ($line=~/{([^}]*)}/)){ - $base = $1; - } - elsif ($line=~/\\includegraphics/){ - $seekingArg = 1; - } - - if ($base ne "") { - $seekingArg = 0; - if ((-f "$base.eps")!="") { - $srcfile = "$base.eps"; - } - elsif ((-f "$base.ps")!=""){ - $srcfile = "$base.ps"; - } - else { - $srcfile = $base; - } - # check that the [e]ps version is newer than the pdf version.... - if ((-M "$base.pdf")=="" || (-M "$base.pdf") >= (-M "$srcfile")){ - print "Constructing \t $base.pdf from $srcfile\n"; - print `$Eps2PdfCom $srcfile`; - } - else{ - print "$base.pdf \t is up to date with $srcfile\n"; - } - - }; -} -close(TEXFILE); diff --git a/Master/texmf-dist/scripts/tetex/fmtutil-sys.sh b/Master/texmf-dist/scripts/tetex/fmtutil-sys.sh deleted file mode 100755 index bfb52f94e1f..00000000000 --- a/Master/texmf-dist/scripts/tetex/fmtutil-sys.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -# fmtutil-sys: Thomas Esser, public domain. - -# wrapper script for fmtutil with TEXMFVAR and TEXMFCONFIG set to -# TEXMFSYSVAR / TEXMFSYSCONFIG - -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' -export PATH - -v=`kpsewhich -var-value TEXMFSYSVAR` -c=`kpsewhich -var-value TEXMFSYSCONFIG` - -TEXMFVAR="$v" -TEXMFCONFIG="$c" -export TEXMFVAR TEXMFCONFIG - -exec fmtutil ${1+"$@"} diff --git a/Master/texmf-dist/scripts/tetex/fmtutil.sh b/Master/texmf-dist/scripts/tetex/fmtutil.sh deleted file mode 100755 index 06ef11380b4..00000000000 --- a/Master/texmf-dist/scripts/tetex/fmtutil.sh +++ /dev/null @@ -1,1017 +0,0 @@ -#!/bin/sh -# fmtutil - utility to maintain format files. -# Public domain. Originally written by Thomas Esser. -# Run with --help for usage. - -# program history: -# further changes in texk/tetex/ChangeLog. -# 2007-01-04 patch by JK to support $engine subdir (enabled by default) -# Fr Apr 8 19:15:05 CEST 2005 cleanup now has an argument for the return code -# Do Mar 02 10:42:31 CET 2006 add tmpdir to TEXFORMATS -# So Ma 27 18:52:06 CEST 2005 honor $TMPDIR, $TEMP and $TMP, not just $TMP -# Sa Jan 15 18:13:46 CET 2005 avoid multiple variable assignments in one statement -# Di Jan 11 11:42:36 CET 2005 fix --byhyphen with relative hyphenfile -# Fr Dez 31 16:51:29 CET 2004 option catcfg added (for being called by texconfig) -# Do Dez 30 21:53:27 CET 2004 rename variable verbose to verboseFlag -# Sa Dez 25 12:44:23 CET 2004 implementation adopted for teTeX-3.0 (tcfmgr) -# Do Okt 28 11:09:36 CEST 2004 added --refresh -# Fr Sep 17 19:25:28 CEST 2004 save $0 in a variable before calling a function -# Sun May 9 23:24:06 CEST 2004 changes for new web2c: format names -# are now *.fmt, nothing else, disable -# "plain" symlinks -# Thu May 6 14:16:19 CEST 2004: "mv .../dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -progname=fmtutil -argv0=$0 -version='$Id: fmtutil 25899 2012-04-09 23:09:26Z karl $' - -cnf=fmtutil.cnf # name of the config file -export PATH - -############################################################################### -# cleanup() -# clean up the temp area and exit with proper exit status -############################################################################### -cleanup() -{ - rc=$1 - # for debugging, exit $rc here so $tmpdir with its logs sticks around. - $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ - && { cd / && rm -rf "$tmpdir"; } - (exit $rc); exit $rc -} - -############################################################################### -# help() and version() -# display help (or version) message and exit -############################################################################### -help() -{ - cat < -eof - cleanup 0 -} - -versionfunc() -{ - cat </dev/null; then - ed "$file" >/dev/null 2>&1 <<-eof - /$pat/ - c - $line - . - w - q -eof - else - echo "$line" >> $file - fi -} - -############################################################################### -# setmatch(match) -# setting the "match state" to true or false. Used to see if there was at -# least one match. -############################################################################### -setmatch() -{ - match=$1 -} - -############################################################################### -# getmatch() -# return success if there was at least one match. -############################################################################### -getmatch() -{ - test "x$match" = xtrue -} - -############################################################################### -# initTexmfMain() -# get $MT_TEXMFMAIN from $TEXMFMAIN -############################################################################### -initTexmfMain() -{ - case $MT_TEXMFMAIN in - "") MT_TEXMFMAIN=`kpsewhich --var-value=TEXMFMAIN`;; - esac - export MT_TEXMFMAIN -} - -############################################################################### -# cache_vars() -# locate files / kpathsea variables and export variables to environment -# this speeds up future calls to e.g. mktexupd -############################################################################### -cache_vars() -{ - : ${MT_VARTEXFONTS=`kpsewhich --expand-var='$VARTEXFONTS' | sed 's%^!!%%'`} - : ${MT_MKTEXNAM=`kpsewhich --format='web2c files' mktexnam`} - : ${MT_MKTEXNAM_OPT=`kpsewhich --format='web2c files' mktexnam.opt`} - : ${MT_MKTEXDIR=`kpsewhich --format='web2c files' mktexdir`} - : ${MT_MKTEXDIR_OPT=`kpsewhich --format='web2c files' mktexdir.opt`} - : ${MT_MKTEXUPD=`kpsewhich --format='web2c files' mktexupd`} - : ${MT_MKTEX_CNF=`kpsewhich --format='web2c files' mktex.cnf`} - : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`} - export MT_VARTEXFONTS MT_MKTEXNAM MT_MKTEXNAM_OPT MT_MKTEXDIR - export MT_MKTEXDIR_OPT MT_MKTEXUPD MT_MKTEX_CNF MT_MKTEX_OPT -} - -############################################################################### -# abort(errmsg) -# print `errmsg' to stderr and exit with error code 1 -############################################################################### -abort() -{ - echo "$progname: $1." >&2 - cleanup 1 -} - -############################################################################### -# maybe_abort(errmsg) -# print `errmsg' to stderr and -# unless noAbortFlag is set exit with error code 1 -############################################################################### -maybe_abort() -{ - echo "$progname: $1." >&2 - $noAbortFlag || cleanup 1 -} - -############################################################################### -# verboseMsg(msg) -# print `msg' to stderr is $verbose is true -############################################################################### -verboseMsg() { - $verboseFlag && verbose echo ${1+"$@"} -} - -############################################################################### -# byebye() -# report any failures and exit the program -############################################################################### -byebye() -{ - if $has_warnings; then - { - cat <&2 - fi - - if $has_errors; then - { - cat <&2 - cleanup 1 - else - cleanup 0 - fi -} - -############################################################################### -# init_log_warning() -# reset the list of warning messages -############################################################################### -init_log_warning() -{ - log_warning_msg= - has_warnings=false -} - -############################################################################### -# init_log_failure() -# reset the list of failure messages -############################################################################### -init_log_failure() -{ - log_failure_msg= - has_errors=false -} - -############################################################################### -# log_warning(errmsg) -# report and save warning message `errmsg' -############################################################################### -log_warning() -{ - echo "Warning: $@" >&2 - if test -z "$log_warning_msg"; then - log_warning_msg="$@" - else - OLDIFS=$IFS; IFS= - log_warning_msg="$log_warning_msg -$@" - IFS=$OLDIFS - fi - has_warnings=true -} - -############################################################################### -# log_failure(errmsg) -# report and save failure message `errmsg' -############################################################################### -log_failure() -{ - echo "Error: $@" >&2 - if test -z "$log_failure_msg"; then - log_failure_msg="$@" - else - OLDIFS=$IFS; IFS= - log_failure_msg="$log_failure_msg -$@" - IFS=$OLDIFS - fi - has_errors=true -} - -############################################################################### -# verbose (cmd) -# execute cmd. Redirect output depending on $mktexfmtMode. -############################################################################### -verbose() -{ - $mktexfmtMode && ${1+"$@"} >&2 || ${1+"$@"} -} - -############################################################################### -# mktexdir(args) -# call mktexdir script, disable all features (to prevent sticky directories) -############################################################################### -mktexdir() -{ - initTexmfMain - MT_FEATURES=none "$MT_TEXMFMAIN/web2c/mktexdir" "$@" >&2 -} - -############################################################################### -# tcfmgr(args) -# call tcfmgr script -############################################################################### -tcfmgr() -{ - initTexmfMain - "$MT_TEXMFMAIN/texconfig/tcfmgr" "$@" -} - -############################################################################### -# mktexupd(args) -# call mktexupd script -############################################################################### -mktexupd() -{ - initTexmfMain - "$MT_TEXMFMAIN/web2c/mktexupd" "$@" -} - -############################################################################### -# main() -# parse commandline arguments, initialize variables, -# switch into temp. direcrory, execute desired command -############################################################################### -main() -{ - destdir= # global variable: where do we put the format files? - cnf_file= # global variable: full name of the config file - cmd= # desired action from command line - needsCleanup=false - need_find_hyphenfile=false - cfgparam= - cfgmaint= - verboseFlag=true - noAbortFlag=false - # eradicate double slashes to avoid kpathsea expansion. - tmpdir=`echo ${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ | sed s,//,/,g` - - # mktexfmtMode: if called as mktexfmt, set to true. Will echo the - # first generated filename after successful generation to stdout then - # (and nothing else), since kpathsea can only deal with one. - mktexfmtMode=false - case $argv0 in - mktexfmt|*/mktexfmt) - mktexfmtMode=true - fullfmt=$1; shift - case $fullfmt in - ""|--help) help ;; - --version) versionfunc ;; - --*) abort "unknown option $fullfmt, try --help" ;; - *.fmt|*.mem|*.base) - set x --byfmt `echo $fullfmt | sed 's@\.[a-z]*$@@'` ${1+"$@"} - shift - ;; - *.*) abort "unknown format type: $fullfmt" ;; - *) set x --byfmt $fullfmt; shift ;; - esac - ;; - esac - - use_engine_dir=true # whether to use web2c/$engine subdirs - while - case $1 in - --cnffile) - shift; cnf_file=$1; cfgparam=1;; - --cnffile=*) - cnf_file=`echo "$1" | sed 's/--cnffile=//'`; cfgparam=1; shift ;; - --fmtdir) - shift; destdir=$1;; - --fmtdir=*) - destdir=`echo "$1" | sed 's/--fmtdir=//'`; shift ;; - --no-engine-subdir) - use_engine_dir=false;; - --all|-a) - cmd=all;; - --edit|-e) - cmd=edit; cfgmaint=1;; - --missing|-m) - cmd=missing;; - --refresh|-r) - cmd=refresh;; - --byengine) - shift; cmd=byengine; arg=$1;; - --byengine=*) - cmd=byengine; arg=`echo "$1" | sed 's/--byengine=//'`; shift ;; - --byfmt|-f) - shift; cmd=byfmt; arg=$1;; - --byfmt=*) - cmd=byfmt; arg=`echo "$1" | sed 's/--byfmt=//'`; shift ;; - --byhyphen|-h) - shift; cmd=byhyphen; arg=$1;; - --byhyphen=*) - cmd=byhyphen; arg=`echo "$1" | sed 's/--byhyphen=//'`; shift ;; - --showhyphen|-s) - shift; cmd=showhyphen; arg=$1;; - --showhyphen=*) - cmd=showhyphen; arg=`echo "$1" | sed 's/--showhyphen=//'`; shift ;; - --help|-help) - cmd=help;; - --version) - cmd=version;; - --enablefmt) - shift; cmd=enablefmt; arg=$1; cfgmaint=1;; - --enablefmt=*) - cmd=enablefmt; arg=`echo "$1" | sed 's/--enablefmt=//'`; cfgmaint=1; shift;; - --disablefmt) - shift; cmd=disablefmt; arg=$1; cfgmaint=1;; - --disablefmt=*) - cmd=disablefmt; arg=`echo "$1" | sed 's/--disablefmt=//'`; cfgmaint=1; shift;; - --catcfg) - cmd=catcfg;; - --listcfg) - cmd=listcfg;; - --no-error-if-no-format) - noAbortFlag=true;; - --quiet|-q|--silent) - verboseFlag=false;; - --test|--dolinks|--force) - ;; - "") break;; - *) abort "unknown option \`$1'; try $progname --help if you need it";; - esac - do test $# -gt 0 && shift; done - - case "$cmd" in - "") abort "missing command; try $progname --help if you need it";; - help) help;; - version) versionfunc;; - esac - - if test -n "$cfgparam"; then - test -f "$cnf_file" || abort "config file \`$cnf_file' not found (ls-R missing?)" - fi - - if test -n "$cfgmaint"; then - if test -z "$cfgparam"; then - setupTmpDir - co=`tcfmgr --tmp $tmpdir --cmd co --file $cnf` - test $? = 0 || cleanup 1 - set x $co; shift - id=$1; cnf_file=$3; orig=$4 - verboseMsg "$progname: initial config file is \`$orig'" - fi - else - if test -z "$cfgparam"; then - cnf_file=`tcfmgr --cmd find --file $cnf` - test -f "$cnf_file" || abort "config file \`$cnf' not found" - fi - fi - - # these commands need no temp directory, so do them here: - case "$cmd" in - catcfg) - grep -v '^ *#' "$cnf_file" | sed 's@^ *@@; s@ *$@@' | grep . | sort - cleanup $? ;; - edit) - echo "$0: fmtutil --edit is disabled in TeX Live;" >&2 - echo "$0: use a file fmtutil-local.cnf instead." >&2 - echo "$0: See tlmgr --help or http://tug.org/texlive/doc/tlmgr.html." >&2 - cleanup 0 ;; - enablefmt|disablefmt) - $cmd $arg ;; # does not return - listcfg) - listcfg_loop - cleanup $? ;; - showhyphen) - show_hyphen_file "$arg" - cleanup $? ;; - esac - - if test -n "$cfgmaint"; then - if test -z "$cfgparam"; then - ci=`tcfmgr --tmp $tmpdir --cmd ci --id $id` - if test $? = 0; then - if test -n "$ci"; then - verboseMsg "$progname: configuration file updated: \`$ci'" - else - verboseMsg "$progname: configuration file unchanged." - fi - else - abort "failed to update configuration file." - fi - fi - cleanup $? - fi - - # set up destdir: - if test -z "$destdir"; then - : ${MT_TEXMFVAR=`kpsewhich -var-value=TEXMFVAR`} - destdir=$MT_TEXMFVAR/web2c - fi - test -d "$destdir" || mktexdir "$destdir" >/dev/null 2>&1 - test -d "$destdir" || abort "format directory \`$destdir' does not exist" - test -w "$destdir" || abort "format directory \`$destdir' is not writable" - - thisdir=`pwd` - - : ${KPSE_DOT=$thisdir} - export KPSE_DOT - - # due to KPSE_DOT, we don't search the current directory, so include - # it explicitly for formats that \write and later on \read - TEXINPUTS="$tmpdir:$TEXINPUTS"; export TEXINPUTS - # for formats that load other formats (e.g., jadetex loads latex.fmt), - # add the current directory to TEXFORMATS, too. Currently unnecessary - # for MFBASES and MPMEMS. - TEXFORMATS="$tmpdir:$TEXFORMATS"; export TEXFORMATS - - setupTmpDir - cd "$tmpdir" || cleanup 1 - - # make local paths absolute: - case "$destdir" in - /*) ;; - *) destdir="$thisdir/$destdir";; - esac - case "$cnf_file" in - /*) ;; - *) cnf_file="$thisdir/$cnf_file";; - esac - - cache_vars - init_log_failure - init_log_warning - # execute the desired command: - case "$cmd" in - all) - recreate_all;; - missing) - create_missing;; - refresh) - recreate_existing;; - byengine) - recreate_by_engine "$arg";; - byfmt) - recreate_by_fmt "$arg";; - byhyphen) - recreate_by_hyphenfile "$arg";; - esac - - byebye -} - -############################################################################### -# parse_line(config_line) sets global variables: -# format: name of the format, e.g. pdflatex -# engine: name of the TeX engine, e.g. tex, etex, pdftex -# texargs: flags for initex and name of the ini file (e.g. -mltex frlatex.ini) -# fmtfile: name of the format file (without directory, but with extension) -# -# Support for building internationalized formats sets: -# pool: base name of pool file (to support translated pool files) -# tcx: translation file used when creating the format -# -# Example (for fmtutil.cnf): -# mex-pl tex mexconf.tex nls=tex-pl,il2-pl mex.ini -# -# The nls parameter (pool,tcx) can only be specified as the first argument -# inside the 4th field in fmtutil.cnf. -# -# exit code: returns error code if the ini file is not installed -############################################################################### -parse_line() -{ - case $1 in - '#!') disabled=true; shift;; - *) disabled=false;; - esac - format=$1 - engine=$2 - hyphenation=$3 - shift; shift; shift - - # handle nls support: pool + tcx - pool=; tcx= - case $1 in - nls=*) - pool=`echo $1 | sed 's@nls=@@; s@,.*@@'` - tcx=`echo $1 | sed 's@nls=[^,]*@@; s@^,@@'` - shift # nls stuff is not handled by the engine directly, - # so we shift this away - ;; - esac - - texargs="$@" - - case "$engine" in - mpost) fmtfile="$format.mem"; kpsefmt=mp; texengine=metapost;; - mf|mfw|mf-nowin) fmtfile="$format.base"; kpsefmt=mf; texengine=metafont;; - *) fmtfile="$format.fmt"; kpsefmt=tex; texengine=$engine;; - esac - - # remove any * for the sake of the kpsewhich lookup. - eval lastarg=\$$# - inifile=`echo $lastarg | sed 's%^\*%%'` - - # See if we can find $inifile for return code: - kpsewhich -progname=$format -format=$kpsefmt $inifile >/dev/null 2>&1 -} - -############################################################################### -# find_hyphenfile(format, hyphenation) searches for hyphenation along -# searchpath of format -# exit code: returns error is file is not found -############################################################################### -find_hyphenfile() -{ - format="$1"; hyphenation="`echo $2 | sed 's/,/ /g'`" - case $hyphenation in - -) ;; - *) kpsewhich -progname="$format" -format=tex $hyphenation;; - esac -} - -############################################################################### -# find_info_for_name(format) -# Look up the config line for format `format' and call parse_line to set -# global variables. -############################################################################### -find_info_for_name() -{ - format="$1" - - # set x `awk '$1 == format {print; exit}' format="$format" "$cnf_file"`; shift - set x `egrep "^$format( | )" "$cnf_file" | sed q`; shift - test $# = 0 && abort "no info for format \`$format'" - parse_line "$@" -} - -############################################################################### -# run_initex() -# Calls initex. Assumes that global variables are set by parse_line. -############################################################################### -run_initex() -{ - - # install a pool file and set tcx flag if requested in lang= option: - rm -f *.pool - poolfile= - tcxflag= - test -n "$pool" \ - && poolfile=`(kpsewhich -progname=$engine $pool.pool) 2>/dev/null` - if test -n "$poolfile" && test -f "$poolfile"; then - verboseMsg "$progname: attempting to create localized format using pool=$pool and tcx=$tcx." - cp "$poolfile" $engine.pool - test -n "$tcx" && tcxflag=-translate-file=$tcx - localpool=true - else - localpool=false - fi - - jobswitch="-jobname=$format" - case "$format" in - metafun) prgswitch=-progname=mpost;; - mptopdf|cont-??) prgswitch=-progname=context;; - *) prgswitch=-progname=$format;; - esac - - rm -f $fmtfile - - # Check for infinite recursion before running the iniTeX: - # We do this check only if we are running in mktexfmt mode - # otherwise double format definitions will create an infinite loop, too - $mktexfmtMode || mktexfmt_loop= - case :$mktexfmt_loop: in - *:"$format/$engine":*) - abort "Infinite recursion detected, giving up!" ;; - esac - mktexfmt_loop=$mktexfmt_loop:$format/$engine - export mktexfmt_loop - - verboseMsg "$progname: running \`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' ..." - - # run in a subshell to get a local effect of TEXPOOL manipulation: - ( - # If necessary, set TEXPOOL. Use absolute path, because of KPSE_DOT. - $localpool && { TEXPOOL="`pwd`:$TEXPOOL"; export TEXPOOL; } - verbose $engine -ini $tcxflag $jobswitch $prgswitch $texargs - ) /dev/null 2>&1 && - log_warning "\`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' possibly failed." - - # We don't want user-interaction for the following "mv" commands: - mv "$format.log" "$fulldestdir/$format.log" /dev/null" - - # No match before the loop: - setmatch false - - recreate_loop - - # Now check if there was at least one match: - getmatch || maybe_abort "no format depends on hyphen file \`$hyphenfile'" -} - -############################################################################### -# recreate_by_engine(enginename) -# recreate all formats that are based on enginename -############################################################################### -recreate_by_engine() -{ - enginename=$1 - - match_cmd="test x\$engine = x$enginename" - - # No match before the loop: - setmatch false - - recreate_loop - - # Now check if there was at least one match: - getmatch || maybe_abort "no format depends on engine \`$enginename'" -} - - - -############################################################################### -# show_hyphen_file(format) -# prints full name of the hyphenfile for format -# -# exit code: returns error code if the ini file is not installed or if -# the hyphen file cannot be found -############################################################################### -show_hyphen_file() -{ - fmtname=$1 - - find_info_for_name "$fmtname" || abort "no info for format \`$fmtname'" - if test "x$hyphenation" = x-; then - echo - - cleanup 0 - fi - find_hyphenfile "$format" "$hyphenation" \ - || abort "hyphenfile \`$hyphenation' not found" -} - -############################################################################### -# disablefmt(format) -# disables format in configuration file -############################################################################### -disablefmt() -{ - grep "^$1[ ]" $cnf_file >/dev/null || { (exit 0); return 0; } - - ed $cnf_file >/dev/null 2>&1 <<-eof - g/^$1[ ]/s/^/#! / - w - q -eof - (exit 0); return 0 -} - -############################################################################### -# enablefmt(format) -# enables format in configuration file -############################################################################### -enablefmt() -{ - grep "^#![ ]*$1[ ]" $cnf_file >/dev/null || { (exit 0); return 0; } - ed $cnf_file >/dev/null 2>&1 <<-eof - g/^#![ ]*$1[ ]/s/..[ ]*// - w - q -eof - (exit 0); return 0 -} - -main ${1+"$@"} -cleanup 0 diff --git a/Master/texmf-dist/scripts/tetex/fontinst.sh b/Master/texmf-dist/scripts/tetex/fontinst.sh deleted file mode 100755 index 7d1271517ad..00000000000 --- a/Master/texmf-dist/scripts/tetex/fontinst.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -tex -progname=fontinst \&tex ${1+"$@"} diff --git a/Master/texmf-dist/scripts/tetex/kpsetool.sh b/Master/texmf-dist/scripts/tetex/kpsetool.sh deleted file mode 100755 index 463097fd4a9..00000000000 --- a/Master/texmf-dist/scripts/tetex/kpsetool.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh - -# kpsetool. Script to make teTeX-style kpsetool, kpsexpand and kpsepath -# available. Web2C's kpsewhich offers a superset of the functionality. -# For compatibilty with old versions of teTeX, this script provides the -# old command line interface of kpsetool, kpsexpand and kpsepath. All the -# real work is done inside Web2C's kpsewhich. -# Thomas Esser , Mar 1997, public domain. - -export PATH - -usage=" -Usage: kpsexpand [options] string -Usage: kpsetool -w [options] pathtype filename -Usage: kpsepath [options] pathtype - -Valid options are the following: - -n progname : pretend to be progname to kpathsea - -m mode : set Metafont mode - -w : locate files (similar to kpsewhich) - -p : act like kpsepath - -v : act like kpsexpand - -Valid pathtypes are: - gf : generic font bitmap - pk : packed bitmap font - base : Metafont memory dump - bib : BibTeX bibliography source - bst : BibTeX style files - cnf : Kpathsea runtime configuration files - fmt : TeX memory dump - mem : MetaPost memory dump - mf : Metafont source - mfpool : Metafont program strings - mp : MetaPost source - mppool : MetaPost program strings - mpsupport : MetaPost support files - pict : Other kinds of figures - tex : TeX source - texpool : TeX program strings - tfm : TeX font metrics - vf : virtual font - dvips_config : dvips config files - dvips_header : dvips header files - troff_font : troff fonts -" - -action=kpsexpand -case $0 in - */kpsewhich) action=kpsewhich;; - */kpsepath) action=kpsepath;; -esac - -progname=`echo $0 | sed 's@.*/@@'` -flags='' - -while true; do - case x"$1" in - x-n) - if test $# = 1; then - echo "$progname: missing argument for -n." - echo "$usage"; exit 1 - else - flags="$flags -progname=$2"; shift; shift - fi;; - x-m) - if test $# = 1; then - echo "$progname: missing argument for -m." - echo "$usage"; exit 1 - else - flags="$flags -mode=$2"; shift; shift - fi;; - x-w) action=kpsewhich; shift;; - x-p) action=kpsepath; shift;; - x-v) action=kpsexpand; shift;; - *) break;; - esac -done - -case "$action" in - kpsewhich|kpsepath) - case "$1" in - gf) format='gf';; - pk) format='pk';; - base) format='.base';; - bib) format='.bib';; - bst) format='.bst';; - cnf) format='.cnf';; - fmt) format='.fmt';; - mem) format='.mem';; - mf) format='.mf';; - mfpool) format='.pool';; - mp) format='.mp';; - mppool) format='.pool';; - mpsupport) format='MetaPost support';; - pict) format='.eps';; - tex) format='.tex';; - texpool) format='.pool';; - tfm) format='.tfm';; - vf) format='.vf';; - dvips_config) format='dvips config';; - dvips_header) format='.pro';; - troff_font) format='Troff fonts';; - *) echo "$progname: $1: unknown format"; echo "$usage"; exit 1;; - esac - shift;; -esac - -case "$action" in - kpsewhich) - test $# = 1 || { echo "$progname: missing filename"; echo "$usage"; exit 1; } - kpsewhich $flags -format="$format" "$1";; - kpsepath) - kpsewhich $flags -show-path="$format";; - kpsexpand) - test $# = 1 || { echo "$progname: missing string"; echo "$usage"; exit 1; } - kpsewhich $flags -expand-var="$1";; -esac diff --git a/Master/texmf-dist/scripts/tetex/kpsewhere.sh b/Master/texmf-dist/scripts/tetex/kpsewhere.sh deleted file mode 100755 index 51088ee80d6..00000000000 --- a/Master/texmf-dist/scripts/tetex/kpsewhere.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# -# Thomas Esser, Hans Fredrik Nordhaug, 2003, 2004. -# Public domain. -# -# kpsewhere is an extension to kpsewhich (as where is for which in tcsh). -# The intention is to provide a way to check for conflicts/shadowed -# files. -# -# Original version by Hans Fredrik Nordhaug -# -# Bugs / limitations: -# conflicts/shadowed files whithin each texmf tree are not found. -# - - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -export PATH - -help='Usage: kpsewhere [OPTION]... [FILENAME]... - Expanding kpsewhich to iterate over each texmf tree listed in $TEXMF - separately. - - See kpsewhich for help on options. - - --help show this help' - -options= -while - case $1 in - -h|-help|--help) - echo "$help" >&2 - exit 0;; - -*) options="${options} '${1}'";; - *) break;; - esac -do shift; done - -case $# in - 0) - echo "$help" >&2 - exit 1 - ;; -esac - -IFS=':' -for file -do - for path in `kpsewhich --expand-path='$TEXMF'` - do - eval TEXMF=\$path kpsewhich $options \"\$file\" - done -done -exit 0 diff --git a/Master/texmf-dist/scripts/tetex/ps2frag.sh b/Master/texmf-dist/scripts/tetex/ps2frag.sh deleted file mode 100755 index b8e673be087..00000000000 --- a/Master/texmf-dist/scripts/tetex/ps2frag.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -tty -s && { - echo - echo "Warning: the ps2frag script is not needed with this version of psfrag." - echo "Please read the manpage ps2frag(1) and the documentation of the" - echo "psfrag package." - echo -} >&2 - -exit 0 diff --git a/Master/texmf-dist/scripts/tetex/pslatex.sh b/Master/texmf-dist/scripts/tetex/pslatex.sh deleted file mode 100755 index 4badef0ec12..00000000000 --- a/Master/texmf-dist/scripts/tetex/pslatex.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -# Copyright 1994 David Carlisle -# This file may be redistributed and/or modified under the terms of the -# LaTeX Project Public License distributed from CTAN archives in directory -# macros/latex/base/lppl.txt; either version 1 of the License, or (at -# your option) any later version. - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -# we want to be able to use options to latex: -while :; do - case $1 in - -*) - latexoptions="$latexoptions \"$1\"" - shift;; - *) - break;; - esac -done - -echo -echo "*************************************" -echo "* Using LaTeX, with pslatex package *" -echo "*************************************" -echo - -# messing around with \PSLATEXTMP is for AUCTeX which calls -# documents via latex \nonstopmode \input{file} - -latex $latexoptions \ - "\AtBeginDocument{\RequirePackage{pslatex}}"\ - "\def\PSLATEXTMP{\futurelet\PSLATEXTMP\PSLATEXTMPB}"\ - "\def\PSLATEXTMPB{\ifx\PSLATEXTMP\nonstopmode\else\input\fi}"\ - "\PSLATEXTMP" ${1+"$@"} diff --git a/Master/texmf-dist/scripts/tetex/rubibtex.sh b/Master/texmf-dist/scripts/tetex/rubibtex.sh deleted file mode 100755 index 373e6e1194d..00000000000 --- a/Master/texmf-dist/scripts/tetex/rubibtex.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh - -# rubibtex, based on the original version contained in the t2 bundle. -# Thomas Esser, Public Domain. - -progname=rubibtex -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ -job=$1 -backup="$tmpdir/orig.aux" - -case $job in - "") - echo "usage: $progname file" >&2 - exit 1 -esac - -if test ! -f "$job.aux"; then - echo "$progname: file \`$job.aux' does not exist." >&2 - exit 1 -fi - -trap ' - rm -rf "$tmpdir" - exit 1 -' 1 2 3 7 13 15 -(umask 077; mkdir "$tmpdir") \ - || { echo "$progname: could not create directory \`$tmpdir'" >&2; exit 1; } - -cat <"$job.aux" >"$backup" || { - echo "$progname: could not create backup of file \`$job.aux' as \`$backup'." >&2 - rm -rf "$tmpdir" - exit 1 -} - -sed ' - /^\\citation/ { - s/\\IeC {\\CYRA }/á/g - s/\\IeC {\\CYRB }/â/g - s/\\IeC {\\CYRV }/÷/g - s/\\IeC {\\CYRG }/ç/g - s/\\IeC {\\CYRD }/ä/g - s/\\IeC {\\CYRE }/å/g - s/\\IeC {\\CYRYO }/³/g - s/\\IeC {\\CYRZH }/ö/g - s/\\IeC {\\CYRZ }/ú/g - s/\\IeC {\\CYRI }/é/g - s/\\IeC {\\CYRISHRT }/ê/g - s/\\IeC {\\CYRK }/ë/g - s/\\IeC {\\CYRL }/ì/g - s/\\IeC {\\CYRM }/í/g - s/\\IeC {\\CYRN }/î/g - s/\\IeC {\\CYRO }/ï/g - s/\\IeC {\\CYRP }/ð/g - s/\\IeC {\\CYRR }/ò/g - s/\\IeC {\\CYRS }/ó/g - s/\\IeC {\\CYRT }/ô/g - s/\\IeC {\\CYRU }/õ/g - s/\\IeC {\\CYRF }/æ/g - s/\\IeC {\\CYRH }/è/g - s/\\IeC {\\CYRC }/ã/g - s/\\IeC {\\CYRCH }/þ/g - s/\\IeC {\\CYRSH }/û/g - s/\\IeC {\\CYRSHCH }/ý/g - s/\\IeC {\\CYRHRDSN }/ÿ/g - s/\\IeC {\\CYRERY }/ù/g - s/\\IeC {\\CYRSFTSN }/ø/g - s/\\IeC {\\CYREREV }/ü/g - s/\\IeC {\\CYRYU }/à/g - s/\\IeC {\\CYRYA }/ñ/g - s/\\IeC {\\cyra }/Á/g - s/\\IeC {\\cyrb }/Â/g - s/\\IeC {\\cyrv }/×/g - s/\\IeC {\\cyrg }/Ç/g - s/\\IeC {\\cyrd }/Ä/g - s/\\IeC {\\cyre }/Å/g - s/\\IeC {\\cyryo }/£/g - s/\\IeC {\\cyrzh }/Ö/g - s/\\IeC {\\cyrz }/Ú/g - s/\\IeC {\\cyri }/É/g - s/\\IeC {\\cyrishrt }/Ê/g - s/\\IeC {\\cyrk }/Ë/g - s/\\IeC {\\cyrl }/Ì/g - s/\\IeC {\\cyrm }/Í/g - s/\\IeC {\\cyrn }/Î/g - s/\\IeC {\\cyro }/Ï/g - s/\\IeC {\\cyrp }/Ð/g - s/\\IeC {\\cyrr }/Ò/g - s/\\IeC {\\cyrs }/Ó/g - s/\\IeC {\\cyrt }/Ô/g - s/\\IeC {\\cyru }/Õ/g - s/\\IeC {\\cyrf }/Æ/g - s/\\IeC {\\cyrh }/È/g - s/\\IeC {\\cyrc }/Ã/g - s/\\IeC {\\cyrch }/Þ/g - s/\\IeC {\\cyrsh }/Û/g - s/\\IeC {\\cyrshch }/Ý/g - s/\\IeC {\\cyrhrdsn }/ß/g - s/\\IeC {\\cyrery }/Ù/g - s/\\IeC {\\cyrsftsn }/Ø/g - s/\\IeC {\\cyrerev }/Ü/g - s/\\IeC {\\cyryu }/À/g - s/\\IeC {\\cyrya }/Ñ/g - } -' <"$backup" >"$job.aux" - -bibtex "$job" - -cat "$backup" > "$job.aux" -rm -rf "$tmpdir" -exit 0 diff --git a/Master/texmf-dist/scripts/tetex/rumakeindex.sh b/Master/texmf-dist/scripts/tetex/rumakeindex.sh deleted file mode 100755 index b7b0c072729..00000000000 --- a/Master/texmf-dist/scripts/tetex/rumakeindex.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh - -BASE=`basename "$1" .idx` -IDX=$BASE.idx -IND=$BASE.ind -ILG=$BASE.ilg - -sed ' -/^\\indexentry{/ { -s/\\IeC {\\CYRA }/¾/g -s/\\IeC {\\cyra }/¿/g -s/\\IeC {\\CYRB }/À/g -s/\\IeC {\\cyrb }/Á/g -s/\\IeC {\\CYRV }/Â/g -s/\\IeC {\\cyrv }/Ã/g -s/\\IeC {\\CYRG }/Ä/g -s/\\IeC {\\cyrg }/Å/g -s/\\IeC {\\CYRD }/Æ/g -s/\\IeC {\\cyrd }/Ç/g -s/\\IeC {\\CYRE }/È/g -s/\\IeC {\\cyre }/É/g -s/\\IeC {\\CYRYO }/Ê/g -s/\\IeC {\\cyryo }/Ë/g -s/\\IeC {\\CYRZH }/Ì/g -s/\\IeC {\\cyrzh }/Í/g -s/\\IeC {\\CYRZ }/Î/g -s/\\IeC {\\cyrz }/Ï/g -s/\\IeC {\\CYRI }/Ð/g -s/\\IeC {\\cyri }/Ñ/g -s/\\IeC {\\CYRISHRT }/Ò/g -s/\\IeC {\\cyrishrt }/Ó/g -s/\\IeC {\\CYRK }/Ô/g -s/\\IeC {\\cyrk }/Õ/g -s/\\IeC {\\CYRL }/Ö/g -s/\\IeC {\\cyrl }/×/g -s/\\IeC {\\CYRM }/Ø/g -s/\\IeC {\\cyrm }/Ù/g -s/\\IeC {\\CYRN }/Ú/g -s/\\IeC {\\cyrn }/Û/g -s/\\IeC {\\CYRO }/Ü/g -s/\\IeC {\\cyro }/Ý/g -s/\\IeC {\\CYRP }/Þ/g -s/\\IeC {\\cyrp }/ß/g -s/\\IeC {\\CYRR }/à/g -s/\\IeC {\\cyrr }/á/g -s/\\IeC {\\CYRS }/â/g -s/\\IeC {\\cyrs }/ã/g -s/\\IeC {\\CYRT }/ä/g -s/\\IeC {\\cyrt }/å/g -s/\\IeC {\\CYRU }/æ/g -s/\\IeC {\\cyru }/ç/g -s/\\IeC {\\CYRF }/è/g -s/\\IeC {\\cyrf }/é/g -s/\\IeC {\\CYRH }/ê/g -s/\\IeC {\\cyrh }/ë/g -s/\\IeC {\\CYRC }/ì/g -s/\\IeC {\\cyrc }/í/g -s/\\IeC {\\CYRCH }/î/g -s/\\IeC {\\cyrch }/ï/g -s/\\IeC {\\CYRSH }/ð/g -s/\\IeC {\\cyrsh }/ñ/g -s/\\IeC {\\CYRSHCH }/ò/g -s/\\IeC {\\cyrshch }/ó/g -s/\\IeC {\\CYRHRDSN }/ô/g -s/\\IeC {\\cyrhrdsn }/õ/g -s/\\IeC {\\CYRERY }/ö/g -s/\\IeC {\\cyrery }/÷/g -s/\\IeC {\\CYRSFTSN }/ø/g -s/\\IeC {\\cyrsftsn }/ù/g -s/\\IeC {\\CYREREV }/ú/g -s/\\IeC {\\cyrerev }/û/g -s/\\IeC {\\CYRYU }/ü/g -s/\\IeC {\\cyryu }/ý/g -s/\\IeC {\\CYRYA }/þ/g -s/\\IeC {\\cyrya }/ÿ/g -}' $IDX | makeindex -t $ILG | tr '¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ' \ - 'áÁâÂ÷×çÇäÄåų£öÖúÚéÉêÊëËìÌíÍîÎïÏðÐòÒóÓôÔõÕæÆèÈãÃþÞûÛýÝÿßùÙøØüÜàÀñÑ' > $IND diff --git a/Master/texmf-dist/scripts/tetex/texconfig-dialog.sh b/Master/texmf-dist/scripts/tetex/texconfig-dialog.sh deleted file mode 100755 index e1868d91574..00000000000 --- a/Master/texmf-dist/scripts/tetex/texconfig-dialog.sh +++ /dev/null @@ -1,486 +0,0 @@ -#!/bin/sh - -# TeX-Config version 3.0 -# Thomas Esser, te@dbs.uni-hannover.de. Public domain. - -# invoke the right shell: - -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -export PATH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -# the version string -version='$Id: texconfig-dialog 23826 2011-09-05 17:59:15Z karl $' - -: ${PAGER=more} -progname=texconfig-dialog -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/tcdtmp.$$ -log=$tmpdir/log -tmpmenu=$tmpdir/tmpmenu -needsCleanup=false - -############################################################################### -# cleanup() -# clean up the temp area and exit with proper exit status -############################################################################### -cleanup() -{ - rc=$1 - $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ - && { cd / && rm -rf "$tmpdir"; } - termCtl reset - (exit $rc); exit $rc -} - -############################################################################### -# setupTmpDir() -# set up a temp directory and a trap to remove it -############################################################################### -setupTmpDir() -{ - case $needsCleanup in - true) return;; - esac - - trap 'cleanup 1' 1 2 3 7 13 15 - needsCleanup=true - (umask 077; mkdir "$tmpdir") \ - || abort "could not create directory \`$tmpdir'" -} - -############################################################################### -# abort(errmsg) -# print `errmsg' to stderr and exit with error code 1 -############################################################################### -abort() -{ - echo "$progname: $1." >&2 - cleanup 1 -} - -logexec() -{ - (echo; echo ">>> Executing \`$@' <<<") >> $log - "$@" 2>&1 | tee -a $log -} - -############################################################################### -# runDialog(args, ...) -# execute the right dialog program with the right default parameters -############################################################################### -runDialog() -{ - if test -n "$DIALOG_PROG"; then - termCtl clear - $DIALOG_PROG --title "TeX setup utility" ${1+"$@"} - runDialogRc=$? - termCtl clear - else - abort "could not find dialog or whiptail program to run" - fi - (exit $runDialogRc) - return $runDialogRc -} - -############################################################################### -# findDialog(void) -# set DIALOG_PROG to the system dialog program, or the empty string. -############################################################################### -findDialog() -{ - for bin in whiptail dialog - do - binLoc=`texconfig findprog $bin` - case $binLoc in - "") DIALOG_PROG="";; - *) DIALOG_PROG=$binLoc; break;; - esac - done -} - -############################################################################### -# mktexdir(args) -# call mktexdir script, disable all features (to prevent sticky directories) -############################################################################### -mktexdir() -{ - MT_FEATURES=none "$TEXMFMAIN/web2c/mktexdir" "$@" >&2 -} - -############################################################################### -# termCtl(arg) -# some convenience utilities for terminal control -############################################################################### -termCtl() -{ - case $1 in - clear) - test -n "$NO_CLEAR" && return - tty >/dev/null 2>&1 && clear - ;; - reset) - test -n "$NO_CLEAR" && return - reset 2>/dev/null - stty sane 2>/dev/null - reset 2>/dev/null - termCtl clear - ;; - readln) - echo - echo "press return to continue..." - read a - ;; - esac -} - -############################################################################### -# menuMain(void) -# the main menu -############################################################################### -menuMain() -{ - cat <<-'eof' - The interactive texconfig utility will be started now. Make sure - your screen has at least 24 rows and 80 columns. If texconfig - crashes now, you can still set up your teTeX system using the - batch mode of texconfig. Try 'texconfig help' to get a list - of options. - - The interactive mode works best with a real vt100 terminal or - inside an xterm window. -eof - termCtl readln - - while :; do - logMessage='view logfile' - - runDialog \ - --menu " -Hint: all output of external commands (e.g. tex) is logged into -a file. You can look at this file using "LOG". If cursor keys make -trouble, you may have more luck with +/- and TAB. -" \ - 23 80 14 \ - EXIT 'exit' \ - PAPER 'default paper: A4 or letter (us)' \ - MODE 'default metafont mode and resolution' \ - REHASH 'rebuild filename databases' \ - FORMATS 'edit format definitions' \ - HYPHENATION 'customize hyphenation' \ - DVIPS 'dvips configuration' \ - FAQ 'view frequently asked questions + answers' \ - CONF 'show configuration' \ - LOG "$logMessage" \ - 2>"$tmpmenu" || break - - case `cat "$tmpmenu"` in - EXIT) - break - ;; - PAPER) - menuPaper - ;; - MODE) - menuMode - ;; - REHASH) - logexec texconfig rehash - termCtl readln - ;; - FORMATS) - texconfig formats - termCtl readln - ;; - HYPHENATION) - menuHyphenation - ;; - DVIPS) - menuDvips - ;; - FAQ) - texconfig faq - termCtl readln - ;; - CONF) - logexec texconfig conf - termCtl readln - ;; - LOG) - <"$log" eval $PAGER - termCtl readln - ;; - esac - done -} - -menuGetMode() -{ - # we need eval to get the command line right... :-( - eval \ - runDialog \ - --menu \"" -Chosse a mode to be used when metafont generates font bitmaps. The resolution is the most important point, but there might -be differences between modes of the same resolution. See the comments in the file modes.mf for more details. -\"" \ - 23 80 14 \ - `texconfig mode-list` 2>"$tmpmenu" -} - -menuMode() -{ - menuGetMode - mode=`cat "$tmpmenu"` - - if test -n "$mode"; then - logexec texconfig mode "$mode" - termCtl readln - fi -} - -menuDvips() -{ - menuDvipsDest=ps - - while :; do - case $menuDvipsDest in - ps) - menuDvipsPrinterOpt= - menuDvipsMsg=" -dvips GLOBAL section. Define the most common default settings (config.ps). -To define settings for a specific printer, first ADD a printer definition, -then CHANGE it. -" - ;; - *) - menuDvipsPrinterOpt="-P $menuDvipsDest" - menuDvipsMsg=" -dvips settings for printer $menuDvipsDest (config.$menuDvipsDest). Define -local settings for this printer. To switch back to global settings mode, -select GLOBAL. -" - ;; - esac - - runDialog \ - --menu "$menuDvipsMsg -You can use dvips for non PostScript printers, if you can setup your -printing system to convert PostScript to a format that your printer can -handle. Maybe, you can use GhostScript to do the conversion (if your -printer is supported)." \ - 23 80 9 \ - RETURN 'back to the main menu' \ - DEST 'define default destination of the generated Postscript' \ - MODE 'change metafont mode/resolution' \ - OFFSET 'shift output by some offset' \ - PAPER 'define the default paper' \ - GLOBAL 'change global settings (config.ps)' \ - CHANGE 'change printer settings (config.$PRINTER)' \ - ADD 'add a printer configuration' \ - DEL 'remove a printer configuration' \ - 2>"$tmpmenu" || break - - menuDvipsAns=`cat "$tmpmenu"` - case $menuDvipsAns in - RETURN) - break - ;; - DEST) - runDialog --inputbox "Enter the command to print. - -In general, you need a command like 'lpr' or 'lpr -Pfoo'. - -NOTE: If you just press return, printing will be disabled and the output saved to a file by default. -" 23 80 2>"$tmpmenu" - if test $? = 0; then - menuDvipsAns=`cat "$tmpmenu"` - case $menuDvipsAns in - "") - menuDvipsPrintOpt=- - ;; - *) - menuDvipsPrintOpt=$menuDvipsAns - ;; - esac - logexec texconfig dvips $menuDvipsPrinterOpt printcmd "$menuDvipsPrintOpt" - termCtl readln - fi - ;; - MODE) - menuGetMode - mode=`cat "$tmpmenu"` - - if test -n "$mode"; then - logexec texconfig dvips $menuDvipsPrinterOpt mode "$mode" - termCtl readln - fi - ;; - OFFSET) - runDialog --inputbox "Enter a dimension pair (a rightwards offset and a downwards -offset), e.g. 2mm,-0.5in (right 2mm and up .5in):" 23 80 2>"$tmpmenu"; menuDvipsAns=`cat "$tmpmenu"` - case $menuDvipsAns in - "") : ;; - *) - logexec texconfig dvips $menuDvipsPrinterOpt offset "$menuDvipsAns" - termCtl readln - ;; - esac - ;; - PAPER) - eval runDialog \ - --menu \'\\n\\nChoose the default papersize definition for dvips.\\n\\n\' \ - 23 80 8 `texconfig dvips paper-list` \ - 2>"$tmpmenu" - paper=`cat "$tmpmenu"` - if test -n "$paper"; then - logexec texconfig dvips paper "$paper" - termCtl readln - fi - ;; - GLOBAL) - menuDvipsDest=ps - ;; - CHANGE) - runDialog --inputbox "Printer name (for future settings of DEST / MODE / OFFSET)" 23 80 2>"$tmpmenu" - menuDvipsAns=`cat $tmpmenu` - case $menuDvipsAns in - "") : ;; - *) menuDvipsDest=$menuDvipsAns;; - esac - ;; - ADD) - runDialog --inputbox "Printer name (for printer to add)" 23 80 2>"$tmpmenu" - menuDvipsAns=`cat $tmpmenu` - case $menuDvipsAns in - "") : ;; - *) - logexec texconfig dvips add $menuDvipsAns - termCtl readln - ;; - esac - ;; - DEL) - runDialog --inputbox "Printer name (for printer to delete)" 23 80 2>"$tmpmenu" - menuDvipsAns=`cat $tmpmenu` - case $menuDvipsAns in - "") : ;; - *) - logexec texconfig dvips del $menuDvipsAns - termCtl readln - ;; - esac - ;; - esac - done -} - -menuPaper() -{ - runDialog \ - --menu " -Select your default paper format. -" \ - 23 80 14 \ - RETURN 'return to the main menu' \ - A4 'ISO A4 (210x297mm)' \ - LETTER 'US (8.5x11in)' 2>"$tmpmenu" - - p=`cat "$tmpmenu"` - case $p in - A4) - logexec texconfig paper a4 - termCtl readln - ;; - LETTER) - logexec texconfig paper letter - termCtl readln - ;; - esac -} - -menuHyphenation() -{ - runDialog \ - --menu " -Choose format to set up hyphenation for. -" \ - 23 80 14 \ - `texconfig hyphen-list | sed 's@\(.*\)@\1 \1@'` 2>"$tmpmenu" - p=`cat "$tmpmenu"` - case $p in - "") - return - ;; - *) - texconfig hyphen "$p" - termCtl readln - esac -} - -# main() - -case $1 in - help|--help) - cat <<-eof - Usage: $progname [--help|--version] -eof - exit 0 - ;; - --version) - cat <<-eof - $progname version $version. -eof - exit 0 - ;; -esac - - -: ${TEXMFCONFIG=`kpsewhich -var-value=TEXMFCONFIG`} -: ${TEXMFVAR=`kpsewhich -var-value=TEXMFVAR`} -: ${TEXMFMAIN=`kpsewhich -var-value=TEXMFMAIN`} -export TEXMFCONFIG TEXMFVAR TEXMFMAIN - -setupTmpDir -echo "$progname: started `date`" > $log -findDialog - -test -d "$TEXMFCONFIG" \ - || mktexdir "$TEXMFCONFIG" >/dev/null 2>&1 \ - || echo "$progname: directory \`$TEXMFCONFIG' (from TEXMFCONFIG variable) does not exist and cannot be created" >&2 - -canWriteConfig=false -if test -d "$TEXMFCONFIG"; then - if test -w "$TEXMFCONFIG"; then - canWriteConfig=true - else - echo "$progname: directory \`$TEXMFCONFIG' (from TEXMFCONFIG variable) is not writable." - echo "$progname: configuration data cannot be changed." >&2 - fi -fi - -test -d "$TEXMFVAR" \ - || mktexdir "$TEXMFVAR" >/dev/null 2>&1 \ - || echo "$progname: directory \`$TEXMFVAR' (from TEXMFVAR variable) does not exist and cannot be created" >&2 - -canWriteVardata=false -if test -d "$TEXMFVAR"; then - if test -w "$TEXMFVAR"; then - canWriteVardata=true - else - echo "$progname: directory \`$TEXMFVAR' (from TEXMFVAR variable) is not writable." - echo "$progname: cached variable runtime data files cannot be written." >&2 - fi -fi - -menuMain -cleanup 0 diff --git a/Master/texmf-dist/scripts/tetex/texconfig-sys.sh b/Master/texmf-dist/scripts/tetex/texconfig-sys.sh deleted file mode 100755 index ff549003ad2..00000000000 --- a/Master/texmf-dist/scripts/tetex/texconfig-sys.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# $Id: texconfig-sys 20962 2011-01-07 11:45:38Z peter $ - -# texconfig-sys: Thomas Esser, public domain. - -# wrapper script for texconfig with TEXMFVAR and TEXMFCONFIG set to -# TEXMFSYSVAR / TEXMFSYSCONFIG - -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -export PATH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -v=`kpsewhich -var-value TEXMFSYSVAR` -c=`kpsewhich -var-value TEXMFSYSCONFIG` - -TEXMFVAR="$v" -TEXMFCONFIG="$c" -export TEXMFVAR TEXMFCONFIG - -exec texconfig ${1+"$@"} diff --git a/Master/texmf-dist/scripts/tetex/texconfig.sh b/Master/texmf-dist/scripts/tetex/texconfig.sh deleted file mode 100755 index c9cc73c8305..00000000000 --- a/Master/texmf-dist/scripts/tetex/texconfig.sh +++ /dev/null @@ -1,1432 +0,0 @@ -#!/bin/sh - -# TeXConfig version 3.0 -# Originally written by Thomas Esser. Public domain. -# Now maintained as part of TeX Live; correspondence to tex-live@tug.org. - -# invoke the right shell: - -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -export PATH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -# initializations... -progname=texconfig - -# the version string -version='$Id$' - -envVars=" - AFMFONTS BIBINPUTS BSTINPUTS CMAPFONTS CWEBINPUTS ENCFONTS GFFONTS - GLYPHFONTS INDEXSTYLE LIGFONTS MFBASES MFINPUTS MFPOOL MFTINPUTS - MISCFONTS MPINPUTS MPMEMS MPPOOL MPSUPPORT OCPINPUTS OFMFONTS - OPENTYPEFONTS OPLFONTS OTPINPUTS OVFFONTS OVPFONTS PDFTEXCONFIG PKFONTS - PSHEADERS SFDFONTS T1FONTS T1INPUTS T42FONTS TEXBIB TEXCONFIG TEXDOCS - TEXFONTMAPS TEXFONTS TEXFORMATS TEXINDEXSTYLE TEXINPUTS TEXMFCNF - TEXMFDBS TEXMFINI TEXMFSCRIPTS TEXPICTS TEXPKS TEXPOOL TEXPSHEADERS - TEXSOURCES TFMFONTS TRFONTS TTFONTS VFFONTS WEB2C WEBINPUTS -" -tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/tctmp.$$ -needsCleanup=false -lastUpdatedFile= - -# -############################################################################### -# setupFMT(void) - find a suitable version of fmt / adjust -# -setupFMT() -{ - case $FMT in - "") - FMT=fmt - test ! -x /bin/fmt && test ! -f /usr/bin/fmt && - { test -x /bin/adjust || test -x /usr/bin/adjust; } && FMT=adjust - ;; - *) - return - ;; - esac -} - -############################################################################### -# myFmt(args) - run $FMT -# -myFmt() -{ - setupFMT - $FMT ${1+"$@"} -} - -############################################################################### -# echoShowVariable(args ...) -# show environment variables which names are as args and their values -# -echoShowVariable() -{ - for esv - do - var=$esv - eval val=\"\${$var+=}\${$var- is unset}\" - echo "$var$val" - done | grep -v 'is unset$' -} - -############################################################################### -# echoShowKpseVariable(args ...) -# show kpathsea variables which names are as args and their values -# -echoShowKpseVariable() -{ - for eskv - do - var=$eskv - val=`kpsewhich -var-value="$eskv"` - echo "$var=$val" - done -} - -############################################################################### -# echoLocateBinary(args ...) - show where programs actually exist -# -echoLocateBinary() -{ - for elb - do - elbLoc=`checkForBinary "$elb"` - if test -n "$ELB_PATH_ONLY"; then - test -n "$elbLoc" && echo "$elbLoc" - else - case $elbLoc in - "") echo "$elb: not found";; - *) echo "$elb: $elbLoc";; - esac - fi - done -} - -############################################################################### -# echoLocateCfgfile(args ...) - show where files actually exist -# -echoLocateCfgfile() -{ - for elc - do - case $elc in - texmf.cnf) elcLoc=`kpsewhich $elc`;; - *) elcLoc=`tcfmgr --cmd find --file "$elc"`;; - esac - case $elcLoc in - "") echo "$elc: not found";; - *) echo "$elcLoc";; - esac - done -} - -############################################################################### -# checkForBinary(prog) - echo full path of prog -# -checkForBinary() -{ - cfbBinary=$1 - - OLDIFS=$IFS - IFS=: - set x `echo "$PATH" | sed 's/^:/.:/; s/:$/:./; s/::/:.:/g'`; shift - found=false - for pathElem - do - case $pathElem in - "") continue;; - *) test -f "$pathElem/$cfbBinary" && { echo "$pathElem/$cfbBinary"; found=true; break; } - esac - done - IFS=$OLDIFS - case $found in - true) (exit 0); return 0;; - false) (exit 1); return 1;; - esac -} - -############################################################################### -# cleanup() - clean up the temp area and exit with proper exit status -# -cleanup() -{ - rc=$1 - $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ - && { cd / && rm -rf "$tmpdir"; } - (exit $rc); exit $rc -} - -############################################################################### -# setupTmpDir() - set up a temp directory and a trap to remove it -# -setupTmpDir() -{ - case $needsCleanup in - true) return;; - esac - - trap 'cleanup 1' 1 2 3 7 13 15 - needsCleanup=true - (umask 077; mkdir "$tmpdir") \ - || abort "could not create directory \`$tmpdir'" -} - -############################################################################### -# setupTexmfmain() - get value for MT_TEXMFMAIN (with caching) -# -setupTexmfmain() -{ - case $MT_TEXMFMAIN in - "") MT_TEXMFMAIN=`kpsewhich -var-value=TEXMFMAIN`;; - *) return;; - esac -} - -############################################################################### -# setupTexmfmain() - get value for MT_TEXMFDIST (with caching) -# -setupTexmfdist() -{ - case $MT_TEXMFDIST in - "") MT_TEXMFDIST=`kpsewhich -var-value=TEXMFDIST`;; - *) return;; - esac -} - -############################################################################### -# setupTexmfvar() - get value for MT_TEXMFVAR (with caching) -# -setupTexmfvar() -{ - case $MT_TEXMVAR in - "") MT_TEXMVAR=`kpsewhich -var-value=TEXMFVAR`;; - *) return;; - esac -} - -############################################################################### -# setupSystexmf() - get value for MT_SYSTEXMF (with caching) -# -setupSystexmf() -{ - case $MT_SYSTEXMF in - "") MT_SYSTEXMF=`kpsewhich -var-value=SYSTEXMF`;; - *) return;; - esac -} - -############################################################################### -# abort(errmsg) -# print `errmsg' to stderr and exit with error code 1 -# -abort() -{ - echo "$progname: $1." >&2 - cleanup 1 -} - -############################################################################### -# mktexdir(args) -# call mktexdir script, disable all features (to prevent sticky directories) -# -mktexdir() -{ - setupTexmfmain - MT_FEATURES=none "$MT_TEXMFMAIN/web2c/mktexdir" "$@" >&2 -} - -############################################################################### -# tcfmgr(args) - call tcfmgr script -# -tcfmgr() -{ - setupTexmfmain - "$MT_TEXMFMAIN/texconfig/tcfmgr" "$@" -} - -############################################################################### -# mktexupd(args) - call mktexupd script -# -mktexupd() -{ - setupTexmfmain - "$MT_TEXMFMAIN/web2c/mktexupd" "$@" -} - -############################################################################### -# getRelDir(file) -# matches file against SYSTEXMF. Returns relative directory of file within -# a texmf tree in variable relPart. -# -getRelDir() -{ - file=$1 - relPart= - - setupSystexmf - OLDIFS=$IFS - IFS=' -' - set x `echo "$MT_SYSTEXMF" | tr : ' -'`; shift - IFS=$OLDIFS - - # now loop over all components of SYSTEXMF - for dir - do - test -n "$dir" || continue - case "$file" in - $dir/*) - relPart=`echo "$file" | sed "s%$dir/*%%"` - break - ;; - esac - done - - # now check for success / failure - case $relPart in - ""|$file) - # empty or full filename -> getRelDir failed! - (exit 1); return 1 - ;; - *) - # relPart should just have the "dirname" part: - relPart=`echo "$relPart" | sed 's%/*[^/]*$%%'` - (exit 0); return 0 - ;; - esac -} - -############################################################################### -# configReplace(file pattern line) -# The first line in file that matches pattern gets replaced by line. -# line will be added at the end of the file if pattern does not match. -# -configReplace() -{ - configReplaceFile=$1; configReplacePat=$2; configReplaceLine=$3 - - if grep "$configReplacePat" "$configReplaceFile" >/dev/null; then - ed "$configReplaceFile" >/dev/null 2>&1 <<-eof - /$configReplacePat/c - $configReplaceLine - . - w - q -eof - else - echo "$configReplaceLine" >> $configReplaceFile - fi -} - -############################################################################### -# fmgrConfigReplace (file regex value) -# replaces line matching regex by value in file -# -fmgrConfigReplace() -{ - fmgrConfigReplaceChanged=false - - moreArgs="" - while - case $1 in - --*) moreArgs="$moreArgs $1 $2";; - *) break;; - esac - do shift; shift; done - fmgrConfigReplaceFile=$1 - fmgrConfigReplaceRegex=$2 - fmgrConfigReplaceValue=$3 - - setupTmpDir - co=`tcfmgr $moreArgs --tmp $tmpdir --cmd co --file $fmgrConfigReplaceFile` - if test $? != 0; then - echo "$progname: fmgrConfigReplace co failed for \`$fmgrConfigReplaceFile'" >&2 - (exit 1); return 1 - fi - set x $co; shift - fmgrConfigReplaceID=$1; fmgrConfigReplaceCfgFile=$3; fmgrConfigReplaceOrigFile=$4 - configReplace "$fmgrConfigReplaceCfgFile" "$fmgrConfigReplaceRegex" "$fmgrConfigReplaceValue" - ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$fmgrConfigReplaceID"` - if test $? != 0; then - echo "$progname: fmgrConfigReplace ci failed for \`$fmgrConfigReplaceFile'" >&2 - (exit 1); return 1 - fi - case $ci in - "") :;; - $lastUpdatedFile) - fmgrConfigReplaceChanged=true;; - *) echo "$progname: updated configuration saved as file \`$ci'" >&2 - fmgrConfigReplaceChanged=true - lastUpdatedFile=$ci;; - esac - (exit 0); return 0 -} - -############################################################################### -# setupDvipsPaper(paper) -# rearranges config.ps to make paper the first paper definition -# -setupDvipsPaper() -{ - setupDvipsPaperChanged=false - setupDvipsPaperFile=config.ps - setupDvipsPaperDftPaper=$1 - - setupTmpDir - co=`tcfmgr --tmp $tmpdir --cmd co --file $setupDvipsPaperFile` - if test $? != 0; then - echo "$progname: setupDvipsPaper co failed for \`$setupDvipsPaperFile'" >&2 - (exit 1); return 1 - fi - set x $co; shift - setupDvipsPaperID=$1; setupDvipsPaperCfgFile=$3; setupDvipsPaperOrigFile=$4 - - ed "$setupDvipsPaperCfgFile" > /dev/null 2>&1 <<-eof - /@ /ka - \$a - @ - . - /@ $setupDvipsPaperDftPaper /;/@ /-1m'a-1 - \$d - w - q -eof - - ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$setupDvipsPaperID"` - if test $? != 0; then - echo "$progname: setupDvipsPaper ci failed for \`$setupDvipsPaperFile'" >&2 - (exit 1); return 1 - fi - case $ci in - "") :;; - $lastUpdatedFile) - setupDvipsPaperChanged=true;; - *) echo "$progname: updated configuration saved as file \`$ci'" >&2 - setupDvipsPaperChanged=true - lastUpdatedFile=$ci;; - esac - (exit 0); return 0 -} - -############################################################################### -# setupModesMfFile(void) - find modes.mf file (with caching) -# -setupModesMfFile() -{ - case $modesMfFile in - "") - modesMfFile=`tcfmgr --cmd find --file modes.mf` - ;; - *) - return - ;; - esac -} - -############################################################################### -# locateConfigPsFile(void) - find config.ps file (with caching) -# -locateConfigPsFile() -{ - case $configPsFile in - "") - configPsFile=`tcfmgr --cmd find --file config.ps` - ;; - *) - return - ;; - esac -} - -############################################################################### -# listMfModes(file) - list modes from modes.mf file -# -listMfModes() -{ - grep mode_def "$modesMfFile" | - sed -e "s/mode_def //" \ - -e "s/ .*%[^ ]* / '/" \ - -e "s/\$/' /" | - egrep -v "^(help|%)" | sort -} - -############################################################################### -# listDvipsPapers(void) - list paper definitions from config.ps -# -listDvipsPapers() -{ - grep '@ ' $configPsFile | sed "s/..//;s/ / '/;s/\$/' /" -} - -############################################################################### -# getFormatsForHyphen(void) -# list all formats which have customizable hyphenation -# -getFormatsForHyphen() -{ - fmtutil --catcfg | awk '$3 != "-" {print $1}' | sort -} - -############################################################################### -# getRes(mode) - print resolution (both X and Y axis) to metafont mode -# -getRes() -{ - getResMode=$1 - ( - cd $tmpdir - cat >mftmp.mf <<-'eof' - let myexit = primitive_end_; - mode_setup; - string xdpi; - xdpi := decimal round pixels_per_inch; - message "XDPI = " & xdpi; - string ydpi; - ydpi := decimal round (pixels_per_inch * aspect_ratio); - message "YDPI = " & ydpi; - fontmaking := 0; - myexit; -eof - mf '\mode='"$getResMode"'; \input ./mftmp' &2; rc=1;; - *) - echo "$progname: unknown PAPER \`$3' given as argument for \`$progname dvipdfm paper'" >&2 - echo "$progname: try \`$progname dvipdfm paper' for help" >&2 - rc=1 ;; - esac ;; - # texconfig dvipdfm "" - "") - echo "$help" >&2; rc=1 ;; - # texconfig dvipdfm - *) - echo "$progname: unknown option \`$2' given as argument for \`$progname dvipdfm'" >&2 - echo "$progname: try \`$progname dvipdfm' for help" >&2 - rc=1 - ;; - esac - ;; - - # texconfig dvipdfmx - dvipdfmx) - help="Usage: $progname dvipdfmx paper PAPER - -Valid PAPER settings: - letter legal ledger tabloid a4 a3" - case $2 in - # texconfig dvipdfmx paper - paper-list) - for p in letter legal ledger tabloid a4 a3; do echo $p; done - ;; - paper) - case $3 in - letter|legal|ledger|tabloid|a4|a3) - fmgrConfigReplace dvipdfmx.cfg '^p' "p $3";; - "") echo "$help" >&2; rc=1;; - *) - echo "$progname: unknown PAPER \`$3' given as argument for \`$progname dvipdfmx paper'" >&2 - echo "$progname: try \`$progname dvipdfmx paper' for help" >&2 - rc=1 ;; - esac ;; - # texconfig dvipdfmx "" - "") - echo "$help" >&2; rc=1 ;; - # texconfig dvipdfmx - *) - echo "$progname: unknown option \`$2' given as argument for \`$progname dvipdfmx'" >&2 - echo "$progname: try \`$progname dvipdfmx' for help" >&2 - rc=1 - ;; - esac - ;; - - # texconfig dvips - dvips) - shift - help="Usage: $progname dvips add PRINTER - $progname dvips del PRINTER - $progname dvips paper PAPER - $progname dvips [-P PRINTER] mode MODE - $progname dvips [-P PRINTER] offset OFFSET - $progname dvips [-P PRINTER] printcmd CMD" - case $1 in - -P) - case $2 in - "") - echo "$progname: missing arg for parameter -P" >&2 - rc=1; (exit $rc); return $rc - ;; - *) - otherPrinter=true - otherPrinterName=$2 - otherPrinterFile=`kpsewhich -format='dvips config' "config.$otherPrinterName"` - case $otherPrinterFile in - "") - echo "$progname: configuration file \`config.$otherPrinterName' for printer \`$otherPrinterName' not found" >&2 - rc=1; (exit $rc); return $rc - ;; - *) shift; shift;; - esac - ;; - esac - ;; - *) - otherPrinter=false - ;; - esac - case $otherPrinter in - true) - tcBatchDvipsPrinter=$otherPrinterName - moreFmgrArgs="--reldir dvips/config --infile $otherPrinterFile" - ;; - *) - tcBatchDvipsPrinter=ps - ;; - esac - case $1 in - add) - case $2 in - "") - echo "Usage: $progname dvips add PRINTER" >&2 - rc=1 - ;; - *) - printerName=$2 - pFile=`kpsewhich -format='dvips config' "config.$printerName"` - case $pFile in - "") - setupTmpDir - tcfRet=`tcfmgr --emptyinfile --reldir dvips/config --cmd co --tmp $tmpdir --file "config.$printerName"` - if test $? != 0; then - echo "$progname: failed to add new configuration file \`config.$printerName'" >&2 - rc=1 - else - set x $tcfRet; shift - tcBatchDvipsAddID=$1; tcBatchDvipsAddFile=$3 - echo "% file config.$printerName; added by texconfig" > "$tcBatchDvipsAddFile" - tcfRet=`tcfmgr --tmp $tmpdir --id "$tcBatchDvipsAddID" --cmd ci` - if test $? != 0; then - echo "$progname: failed to add new configuration file \`config.$printerName'" >&2 - rc=1 - else - echo "$progname: file $tcfRet added" >&2 - fi - fi - ;; - *) - echo "$progname: configuration file for printer \`$printerName' already exists (\`$pFile')" >&2 - rc=1 - ;; - esac - ;; - esac - ;; - del) - case $2 in - "") - echo "Usage: $progname dvips del PRINTER" >&2 - rc=1 - ;; - *) - printerName=$2 - pFile=`kpsewhich -format='dvips config' "config.$printerName"` - case $pFile in - "") - echo "$progname: configuration file for printer \`$printerName' (config.$printerName) not found" >&2 - rc=1 - ;; - *) - if rm "$pFile"; then - echo "$progname: file \`$pFile' removed" >&2 - else - echo "$progname: failed to remove file \`$pFile'" >&2 - rc=1 - fi - ;; - esac - ;; - esac - ;; - paper-list) - locateConfigPsFile - listDvipsPapers - ;; - paper) - case $2 in - "") - echo "Usage: $progname dvips paper PAPER" >&2 - echo >&2; echo "Valid PAPER settings:" >&2 - locateConfigPsFile - listDvipsPapers | sed 's@ .*@@; s@^@ @' | myFmt - rc=1 - ;; - *) - tcBatchDvipsPaper=$2 - locateConfigPsFile - case "$configPsFile" in - "") - echo "$progname: file config.ps not found" >&2; rc=1 - ;; - *) - if grep "@ $tcBatchDvipsPaper " $configPsFile >/dev/null 2>&1; then - setupDvipsPaper "$tcBatchDvipsPaper" - else - echo "$progname: paper \`$tcBatchDvipsPaper' not found in file \`$configPsFile'" >&2; rc=1 - fi - ;; - esac - ;; - esac - ;; - mode) - case $2 in - "") - echo "Usage: $progname dvips mode MODE - -Valid MODE settings:" - setupModesMfFile - listMfModes | sed 's@ .*@@; s@^@ @' | myFmt - rc=1 - ;; - *) - tcBatchDvipsMode=$2 - setupTmpDir - setupModesMfFile - if checkElemInList "$tcBatchDvipsMode" `listMfModes | sed 's@ .*@@'`; then - set x `getRes "$tcBatchDvipsMode"`; shift - resX=$1; resY=$2 - fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^M' "M $tcBatchDvipsMode" - fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^D' "D $resX" - fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^X' "X $resX" - fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^Y' "Y $resY" - else - echo "$progname: unknown MODE \`$tcBatchDvipsMode' given as argument for \`$progname dvips mode'" >&2 - echo "$progname: try \`$progname dvips mode' for help" >&2 - rc=1 - fi - ;; - esac - ;; - offset) - offset=$2 - case $offset in - "") - echo "Usage: $progname dvips offset OFFSET" - rc=1 - ;; - *) - fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^O' "O $offset" - esac - ;; - printcmd) - printcmd=$2 - case $printcmd in - "") - echo "Usage: $progname dvips printcmd CMD" - rc=1 - ;; - -) - fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^o' o - ;; - *) - fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^o' "o |$printcmd" - ;; - esac - ;; - "") - echo "$help" >&2; rc=1 - ;; - *) - echo "$progname: unknown option \`$1' given as argument for \`$progname dvips'" >&2 - echo "$progname: try \`$progname dvips' for help" >&2 - rc=1 - ;; - esac - ;; - - faq) - setupTexmfmain - if test -f $MT_TEXMFMAIN/doc/tetex/teTeX-FAQ; then - <$MT_TEXMFMAIN/doc/tetex/teTeX-FAQ eval ${PAGER-more} - else - echo "$progname: faq not found (usually in \$TEXMFMAIN/doc/tetex/teTeX-FAQ)" >&2 - rc=1 - fi - ;; - - findprog) - shift - ELB_PATH_ONLY=1 echoLocateBinary "$@" - ;; - - # handle "texconfig font" - font) - help="Usage: $progname font vardir DIR - $progname font ro - $progname font rw - -The vardir option changes the VARTEXFONTS variable in the texmf.cnf file. - -The rw option makes the VARTEXFONTS directory (and subtrees pk, tfm, -source) world writable and sets the features appendonlydir:varfonts -in mktex.cnf. - -The ro option makes the VARTEXFONTS directory (and subtrees pk, tfm, -source) writable for the owner only and sets the feature texmfvar in -mktex.cnf. - -For more information about these \`features', consult the teTeX manual -(e.g. by running \`texdoc TETEXDOC')." - - case $2 in - vardir) - case $3 in - "") - echo "$help" >&2 - rc=1 - ;; - *) - tcBatchFontVardir=$3 - tfc=`kpsewhich texmf.cnf` - if test -n "$tfc"; then - if test -w "$tfc"; then - configReplace "$tfc" '^VARTEXFONTS' "VARTEXFONTS = $tcBatchFontVardir" - else - echo "$progname: setting up vardir failed. Reason: no permission to write file \`$tfc'" >&2 - rc=1 - fi - else - echo "$progname: setting up vardir failed. Reason: failed to find file texmf.cnf" >&2 - rc=1 - fi - ;; - esac - ;; - rw) - MT_VARTEXFONTS=`kpsewhich -var-value VARTEXFONTS` - if test -z "$MT_VARTEXFONTS"; then - echo "$progname: failed to set \`font rw'; reason: could not determine VARTEXFONTS variable." >&2; rc=1 - return - fi - test -d "$MT_VARTEXFONTS" || mktexdir "$MT_VARTEXFONTS" - if test ! -d "$MT_VARTEXFONTS"; then - echo "$progname: failed to set \`font rw'; reason: directory \`$MT_VARTEXFONTS' does not exist." >&2; rc=1 - return - fi - chmod 1777 "$MT_VARTEXFONTS" || { - echo "$progname: failed to modify permissions in \`$MT_VARTEXFONTS'." >&2; rc=1 - return; - } - ( - cd "$MT_VARTEXFONTS" || exit - echo "$progname: modifying permissions in \`$MT_VARTEXFONTS' ..." >&2 - for d in pk tfm source; do - test -d "$d" && find $d -type d -exec chmod 1777 '{}' \; - done - echo "$progname: all permissions set." >&2 - ) - setupTmpDir - fmgrConfigReplace mktex.cnf '^: ..MT_FEATURES=' ": \${MT_FEATURES=appendonlydir:varfonts}" - ;; - ro) - MT_VARTEXFONTS=`kpsewhich -var-value VARTEXFONTS` - if test -z "$MT_VARTEXFONTS"; then - echo "$progname: failed to set \`font ro'; reason: could not determine VARTEXFONTS variable." >&2; rc=1 - return - fi - test -d "$MT_VARTEXFONTS" || mktexdir "$MT_VARTEXFONTS" - if test ! -d "$MT_VARTEXFONTS"; then - echo "$progname: failed to set \`font ro'; reason: directory \`$MT_VARTEXFONTS' does not exist." >&2; rc=1 - return - fi - chmod 755 "$MT_VARTEXFONTS" || { - echo "$progname: failed to modify permissions in \`$MT_VARTEXFONTS'." >&2; rc=1 - return; - } - ( - cd "$MT_VARTEXFONTS" || exit - echo "$progname: modifying permissions in \`$MT_VARTEXFONTS' ..." >&2 - for d in pk tfm source; do - test -d "$d" && find "$d" -type d -exec chmod 755 '{}' \; - done - echo "$progname: all permissions set." >&2 - ) - setupTmpDir - fmgrConfigReplace mktex.cnf '^: ..MT_FEATURES=' ": \${MT_FEATURES=texmfvar}" - ;; - "") echo "$help" >&2; rc=1;; - *) echo "$progname: unknown option \`$2' given as argument for \`$progname font'" >&2 - echo "$progname: try \`$progname font' for help" >&2 - rc=1 - ;; - esac - ;; - - formats) - cat >&2 <&2 - fmtutil --catcfg > $tmpdir/pre - fmtutil --edit - echo "$progname: analyzing new configuration..." >&2 - fmtutil --catcfg > $tmpdir/post - - if cmp $tmpdir/pre $tmpdir/post >/dev/null 2>&1; then - echo "$progname: no new/updated formats available ..." >&2 - else - echo "$progname: updating formats ..." >&2 - comm -13 $tmpdir/pre $tmpdir/post > $tmpdir/addOrChange - for i in `awk '{print $1}' $tmpdir/addOrChange`; do - fmtutil --byfmt "$i" || rc=1 - done - texlinks --multiplatform || rc=1 - fi - ;; - - help|--help|-h) - echo "$help" - ;; - - # "hyphen FORMAT" - hyphen) - cat >&2 <&2; rc=1 - ;; - *) - if checkElemInList "$tcBatchHyphenFormat" $formatsForHyphen; then - - tcBatchHyphenFile=`fmtutil --showhyphen "$tcBatchHyphenFormat"` - case $tcBatchHyphenFile in - "") - echo "$progname: could not find hyphen setup file for format \`$tcBatchHyphenFormat'" >&2 - rc=1 - return - ;; - esac - - getRelDir "$tcBatchHyphenFile" - case $relPart in - "") - # edit tcBatchHyphenFile directly - tcBatchHFID= - setupTmpDir - tcBatchHFEdit=$tcBatchHyphenFile - tcBatchHFOrig=$tmpdir/hforig - cp "$tcBatchHyphenFile" "$tcBatchHFOrig" - ;; - *) - # use tcfmgr - tcBatchHyphenFileBasename=`echo "$tcBatchHyphenFile" | sed 's@.*/@@'` - setupTmpDir - co=`tcfmgr --tmp $tmpdir --cmd co --file "$tcBatchHyphenFileBasename" --reldir "$relPart" --infile "$tcBatchHyphenFile"` - if test $? != 0; then - echo "$progname: failed to check out file \`$tcBatchHyphenFile'" >&2 - rc=1 - return 1 - else - set x $co; shift - tcBatchHFID=$1; tcBatchHFEdit=$3; tcBatchHFOrig=$4 - fi - ;; - esac - ${VISUAL-${EDITOR-vi}} "$tcBatchHFEdit" - if cmp "$tcBatchHFEdit" "$tcBatchHFOrig" >/dev/null 2>&1; then - echo "$progname: configuration unchanged." >&2 - else - case $tcBatchHFID in - "") - tcBatchHFOut=$tcBatchHFEdit - echo "$progname: updated configuration saved as file \`$tcBatchHFOut'" >&2 - lastUpdatedFile=$ci - ;; - *) - ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$tcBatchHFID"` - if test $? != 0; then - echo "$progname: failed to check in file \`$tcBatchHyphenFileBasename'" >&2 - rc=1 - return - else - tcBatchHFOut=$ci - echo "$progname: updated configuration saved as file \`$tcBatchHFOut'" >&2 - lastUpdatedFile=$ci - fi - ;; - esac - fmtutil --byhyphen "$tcBatchHFOut" - fi - else - echo "$progname: invalid format \`$tcBatchHyphenFormat' specified as argument for \`$progname hyphen'" >&2 - echo "$progname: for getting help, try \`$progname hyphen'" >&2 - rc=1 - fi - ;; - esac - ;; - - hyphen-list) - getFormatsForHyphen - ;; - - init) - case $2 in - "") - if fmtutil --all \ - && texlinks --multiplatform \ - && updmap; then - : - else - rc=1 - fi - ;; - *) - shift 1 - for i in "$@"; do - fmtutil --byfmt "$i" || rc=1 - done - ;; - esac - ;; - - mode-list) - setupModesMfFile - listMfModes - ;; - - mode) - case $2 in - "") - echo "Usage: $progname mode MODE - -Valid MODE settings:" - setupModesMfFile - listMfModes | sed 's@ .*@@; s@^@ @' | myFmt - rc=1 - ;; - *) - tcBatchMode=$2 - setupModesMfFile - if checkElemInList $tcBatchMode `listMfModes | sed 's@ .*@@'`; then - - # modify mktex.cnf - setupTmpDir - fmgrConfigReplace mktex.cnf '^: ..MODE=' ": \${MODE=$tcBatchMode}" - set x `getRes "$tcBatchMode"`; shift - tcBatchRes=$1 - fmgrConfigReplace mktex.cnf '^: ..BDPI=' ": \${BDPI=$tcBatchRes}" - - if checkForBinary dvips >/dev/null && tcfmgr --cmd find --file config.ps >/dev/null 2>&1; then - tcBatch dvips mode "$tcBatchMode" - fi - if checkForBinary pdftex >/dev/null && tcfmgr --cmd find --file pdftexconfig.tex >/dev/null 2>&1; then - tcBatch pdftex mode "$tcBatchMode" - fi - else - echo "$progname: unknown mode \`$tcBatchMode' specified as argument for \`$progname mode'" >&2; rc=1 - fi - ;; - esac - ;; - - paper) - help="Usage: $progname paper PAPER - -Valid PAPER settings: - letter a4" - - p=$2; pXdvi=$2; pDvips=$2 - case $2 in - letter) - pXdvi=us;; - a4) - pXdvi=a4;; - "") echo "$help" >&2; rc=1; return;; - *) - echo "$progname: unknown PAPER \`$2' given as argument for \`$progname paper'" >&2 - echo "$progname: try \`$progname paper' for help" >&2 - rc=1 - return;; - esac - if checkForBinary dvips >/dev/null && tcfmgr --cmd find --file config.ps >/dev/null 2>&1; then - tcBatch dvips paper $pDvips - fi - if checkForBinary dvipdfm >/dev/null && tcfmgr --cmd find --file config >/dev/null 2>&1; then - tcBatch dvipdfm paper $p - fi - if checkForBinary dvipdfmx >/dev/null && tcfmgr --cmd find --file dvipdfmx.cfg >/dev/null 2>&1; then - tcBatch dvipdfmx paper $p - fi - if checkForBinary xdvi >/dev/null && tcfmgr --cmd find --file XDvi >/dev/null 2>&1; then - tcBatch xdvi paper $pXdvi - fi - if checkForBinary pdftex >/dev/null && tcfmgr --cmd find --file pdftexconfig.tex >/dev/null 2>&1; then - tcBatch pdftex paper $p - fi - ;; - - pdftex) - help="Usage: $progname pdftex paper PAPER - -Valid PAPER settings: - a4 letter" - case $2 in - - mode) - case $3 in - "") - echo "Usage: $progname pdftex mode MODE" - rc=1 - ;; - *) - tcBatchPdftexMode=$3 - setupTmpDir - setupModesMfFile - if checkElemInList "$tcBatchPdftexMode" `listMfModes | sed 's@ .*@@'`; then - set x `getRes "$tcBatchPdftexMode"`; shift - fmgrConfigReplace pdftexconfig.tex 'pdfpkresolution' "\\pdfpkresolution=$1" - if $fmgrConfigReplaceChanged; then - fmtutil --refresh - fi - else - echo "$progname: unknown MODE \`$tcBatchPdftexMode' given as argument for \`$progname pdftex mode'" >&2 - rc=1 - fi - ;; - esac - ;; - - paper) - case $3 in - letter) - w="8.5 true in"; h="11 true in" - setupTmpDir - fmgrConfigReplace pdftexconfig.tex pdfpagewidth '\pdfpagewidth='"$w" - wChanged=$fmgrConfigReplaceChanged - fmgrConfigReplace pdftexconfig.tex pdfpageheight '\pdfpageheight='"$h" - if $wChanged || $fmgrConfigReplaceChanged; then - fmtutil --refresh - fi - ;; - a4) - w="210 true mm"; h="297 true mm" - fmgrConfigReplace pdftexconfig.tex pdfpagewidth '\pdfpagewidth='"$w" - wChanged=$fmgrConfigReplaceChanged - fmgrConfigReplace pdftexconfig.tex pdfpageheight '\pdfpageheight='"$h" - if $wChanged || $fmgrConfigReplaceChanged; then - fmtutil --refresh - fi - ;; - "") echo "$help" >&2; rc=1;; - *) - echo "$progname: unknown PAPER \`$3' given as argument for \`$progname pdftex paper'" >&2 - echo "$progname: try \`$progname pdftex paper' for help" >&2 - rc=1 ;; - esac ;; - "") - echo "$help" >&2; rc=1;; - *) - echo "$progname: unknown option \`$2' given as argument for \`$progname pdftex'" >&2 - echo "$progname: try \`$progname pdftex' for help" >&2 - rc=1 - ;; - esac - ;; - - rehash) - mktexlsr - ;; - - # - version|--version) - echo "$progname version $version" - setupTexmfmain - setupTexmfdist - showDistVersionInfo - (exit 0); exit 0;; - - # handle "xdvi paper PAPER" - xdvi) - tcBatchXdviPapers='us "8.5x11" -usr "11x8.5" -legal "8.5x14" -foolscap "13.5x17.0" -a1 "59.4x84.0cm" -a2 "42.0x59.4cm" -a3 "29.7x42.0cm" -a4 "21.0x29.7cm" -a5 "14.85x21.0cm" -a6 "10.5x14.85cm" -a7 "7.42x10.5cm" -a1r "84.0x59.4cm" -a2r "59.4x42.0cm" -a3r "42.0x29.7cm" -a4r "29.7x21.0cm" -a5r "21.0x14.85cm" -a6r "14.85x10.5cm" -a7r "10.5x7.42cm" -b1 "70.6x100.0cm" -b2 "50.0x70.6cm" -b3 "35.3x50.0cm" -b4 "25.0x35.3cm" -b5 "17.6x25.0cm" -b6 "13.5x17.6cm" -b7 "8.8x13.5cm" -b1r "100.0x70.6cm" -b2r "70.6x50.0cm" -b3r "50.0x35.3cm" -b4r "35.3x25.0cm" -b5r "25.0x17.6cm" -b6r "17.6x13.5cm" -b7r "13.5x8.8cm" -c1 "64.8x91.6cm" -c2 "45.8x64.8cm" -c3 "32.4x45.8cm" -c4 "22.9x32.4cm" -c5 "16.2x22.9cm" -c6 "11.46x16.2cm" -c7 "8.1x11.46cm" -c1r "91.6x64.8cm" -c2r "64.8x45.8cm" -c3r "45.8x32.4cm" -c4r "32.4x22.9cm" -c5r "22.9x16.2cm" -c6r "16.2x11.46cm" -c7r "11.46x8.1cm"' - help="Usage: $progname xdvi paper PAPER - -Valid PAPER settings: - a1 a1r a2 a2r a3 a3r a4 a4r a5 a5r a6 a6r a7 a7r - b1 b1r b2 b2r b3 b3r b4 b4r b5 b5r b6 b6r b7 b7r - c1 c1r c2 c2r c3 c3r c4 c4r c5 c5r c6 c6r c7 c7r - foolscap legal us usr" - case $2 in - paper-list) - echo "$tcBatchXdviPapers" - ;; - paper) - case $3 in - a1|a1r|a2|a2r|a3|a3r|a4|a4r|a5|a5r|a6|a6r|a7|a7r|b1|b1r|b2|b2r|b3|b3r|b4|b4r|b5|b5r|b6|b6r|b7|b7r|c1|c1r|c2|c2r|c3|c3r|c4|c4r|c5|c5r|c6|c6r|c7|c7r|foolscap|legal|us|usr) - fmgrConfigReplace XDvi paper: "*paper: $3" - ;; - "") echo "$help" >&2; rc=1;; - *) - echo "$progname: unknown PAPER \`$3' given as argument for \`$progname xdvi paper'" >&2 - echo "$progname: try \`$progname xdvi paper' for help" >&2 - rc=1 ;; - esac ;; - "") - echo "$help" >&2; rc=1;; - *) - echo "$progname: unknown option \`$2' given as argument for \`$progname xdvi'" >&2 - echo "$progname: try \`$progname xdvi' for help" >&2 - rc=1 - ;; - esac - ;; - *) - echo "$progname: unknown option \`$1' given as argument for \`$progname'" >&2 - echo "$progname: try \`$progname help' for help" >&2 - rc=1 - esac -} - -############################################################################### -# tcInteractive(void) -# handle interactive mode -############################################################################### -tcInteractive() -{ - texconfig-dialog -} - -############################################################################### -# main() -############################################################################### -rc=0 -case $# in - 0) tcInteractive;; - *) tcBatch "$@";; -esac - -cleanup $rc diff --git a/Master/texmf-dist/scripts/tetex/texdoctk.pl b/Master/texmf-dist/scripts/tetex/texdoctk.pl deleted file mode 100755 index 36497183e3b..00000000000 --- a/Master/texmf-dist/scripts/tetex/texdoctk.pl +++ /dev/null @@ -1,1857 +0,0 @@ -#! /usr/bin/env perl -############################################################################### -# texdoctk - GUI for TeX documentation access -# Copyright (C) 2000-2004 Thomas Ruedas -# Updated in 2010 by Manuel Pegourie-Gonnard -# This program is provided under the GNU Public License; see the file -# README.texdoctk for details about requirements, installation, configuration, -# and the full disclaimer. -############################################################################### -my ($version, $date) = ("0.6.1", "2004-11-05"); -use strict; -use Tk; -use Getopt::Long; -Getopt::Long::config('bundling'); -use File::Basename; - -BEGIN { - Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow; -} - -my $IsWin32 = ($^O =~ /MSWin32/i); - -if ($IsWin32) { - require Win32::API; -# Win32::API->import( qw( -# &something -# )); -} - -# initialization of some internal variables -$|=1; -my $quiet=1; -my $autoview; -my $xfmt_viewer=1, -my @tdcolors; -my %butcol; -my $srchentry; -my $srchflag=0; -my $srchtype; # 0 = database, 1 = texdoc -my $tmpfno; -# system variables -my ($texmfmain,$texmfdist,$texmfdoc,$texmflocal,$texmfhome, - $texdocpath,$distdocpath,$docdocpath,$localdocpath,$homedocpath, - $datadir, - $dvi_viewer,$dvips_conv,$ps_viewer,$pdf_viewer, - $pdfps_conv,$html_viewer,$htmlps_conv,$htmlps_redir, - $txt_viewer,$txtps_conv,$txtps_redir,$print_cmd); - -# defaults: unix values -my $qq="'"; -my $HomeEnv=$ENV{HOME}; -my $TeXDocRcDefaults="texdocrc.defaults"; -my $TempDir; $TempDir=$ENV{TMPDIR} or $TempDir="/tmp"; -my $CmdConsole="xterm -e "; - -if ($IsWin32) { - $qq = "\""; - $HomeEnv = $ENV{'USERPROFILE'}; - chomp $HomeEnv; - $TeXDocRcDefaults = "texdocrc-win32.defaults"; - $TempDir = &GetTempPath; - $CmdConsole = "cmd /c "; -} - -my $myrc="${HomeEnv}/.texdocrc"; # optional personal settings file - -my ($line,@dummy); -my @tmpfiles; -# read system-wide defaults from texdocrc.defaults -my $sysrc=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} ${TeXDocRcDefaults}`; -my $database=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk.dat`; -my $locdatabase=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk-local.dat`; -my $homedatabase=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk-pers.dat`; -chomp $locdatabase; -chomp $homedatabase; -chomp $sysrc; -&readrc($sysrc,1); -@dummy=split("/",$sysrc); -pop @dummy; -$datadir=join('/',@dummy); -# possibly use personal settings instead of defaults -if (-e $myrc) { &readrc($myrc,2); } -# command line options -GetOptions('v'=>\$quiet,'a'=>\$autoview); -my $special=0; -my @button; -$button[17]="Miscellaneous"; -my (@packname,@topic,@doc,@keywords,@maxind,%stydoc); -# read database file -my $i=-1; -my $j; -open(DATABASE,"$database") || &fatalmsg("Couldn't open database $database.\n"); -while ($line = ) { - LINETYPE: { - ($line =~ /^\@/) && do { # category - ++$i; - if ($i == $#button) { - pop @button; - push @button,(substr($line,1,-1)); - $special=1; - } else { - $button[$i]=substr($line,1,-1); - } - $j=0; - last LINETYPE; - }; - ($line =~ /^(#|$)/) && do { # comment or empty line - last LINETYPE; - }; -# list item - @dummy=split(";",$line); - $packname[$i][$j]=$dummy[0]; - $topic[$i][$j]=$dummy[1]; - $doc[$i][$j]=$dummy[2]; - $keywords[$i][$j]=$dummy[3]; - if ($doc[$i][$j] =~ /sty$/ && $keywords[$i][$j]) { - $stydoc{"$doc[$i][$j]"}=substr($keywords[$i][$j],1,1); - unless ($stydoc{"$doc[$i][$j]"} =~ /^\d$/) { - $stydoc{"$doc[$i][$j]"}=0; - } - } - $maxind[$i]=$j; - ++$j; - }; -} -close(DATABASE); -# Read site-local and user's database(s) if it/they exist(s) -foreach my $dbfile ($locdatabase,$homedatabase) { - if (-e "$dbfile") { - open(DATABASE,"$dbfile") || - print "Couldn't open additional database $dbfile.\n"; - $i=17; # local/user: if no category is specified in database, add to "Misc" - while ($line = ) { - LINETYPE: { - ($line =~ /^\@/) && do { # category - $i=&arrindex(@button,substr($line,1,-1)); - if ($i >= $#button) { - $i=$#button; - pop @button; - push @button,(substr($line,1,-1)); - $special=1; - } - last LINETYPE; - }; - ($line =~ /^(#|$)/) && do { # comment or empty line - last LINETYPE; - }; -# list item - @dummy=split(";",$line); - $j=&arrindex(@{$packname[$i]},$dummy[0]); - if ($j > $#{$packname[$i]}) { - $packname[$i][$j]=$dummy[0]; - $topic[$i][$j]=$dummy[1]; - $doc[$i][$j]=$dummy[2]; - $keywords[$i][$j]=$dummy[3]; - if ($doc[$i][$j] =~ /sty$/ && $keywords[$i][$j]) { - $stydoc{"$doc[$i][$j]"}=substr($keywords[$i][$j],1,1); - unless ($stydoc{"$doc[$i][$j]"} =~ /^\d$/) { - $stydoc{"$doc[$i][$j]"}=0; - } - } - $maxind[$i]=$j; - ++$j; - } - }; - } - close(DATABASE); - $special=1 if ($i == 17 && $j > 0); - } -} - -# Tk -# hash table for toplevel windows; used to avoid multiple calls of same window -my %tlwins; -my %buttonlist; -# create frames for main window: commands on top, frame for buttons below -my $main=new MainWindow; -$tlwins{'mainwindow'}{'addr'}=$main; -$main->resizable(0,0); -$main->title("TeX Documentation Browser"); -$main->bind('all',''=>\&clean_exit); -$main->bind('all',''=>sub { $main->raise(); }); -$main->bind('all',''=>\&helptext); -$main->bind('all',''=>sub { $main->raise(); &mksrch; }); -$main->bind('all',''=>\&settings); -my $cmdframe=$main->Frame(-background=>"#ffcc99"); -my $buttonframe=$main->Frame; -$cmdframe->pack(-side=>'top',-fill=>'x'); -$buttonframe->pack(-side=>'bottom'); -# normal cursor -my $defcursor=$main->cget(-cursor); -# make buttons for command frame -my $Qbut=$cmdframe->Button(-text=>'Quit',%butcol, - -command=>\&clean_exit)->pack(-side=>'left'); -$tlwins{'mainwindow'}{'buttons'}[0]=$Qbut; -# define common default font for labels and text explicitly -my $deffont=$Qbut->cget(-font); -# ensure readability on high-res screens (suggested by R.Kotucha) -$deffont='Helvetica -16 bold' if &x_resolution > 1200; -$Qbut->configure(-font=>$deffont); -$tlwins{'mainwindow'}{'buttons'}[1]=$cmdframe->Button( - -text=>'Database search', - -font=>$deffont,%butcol, - -command=>[\&mksrch, 0] - )->pack(-side=>'left'); -$tlwins{'mainwindow'}{'buttons'}[2]=$cmdframe->Button( - -text=>'File search', - -font=>$deffont,%butcol, - -command=>[\&mksrch, 1] - )->pack(-side=>'left'); -$tlwins{'mainwindow'}{'buttons'}[3]=$cmdframe->Button(-text=>'Help/About', - -font=>$deffont,%butcol, - -command=>\&helptext - )->pack(-side=>'right'); -$tlwins{'mainwindow'}{'buttons'}[4]=$cmdframe->Button(-text=>'Settings', - -font=>$deffont,%butcol, - -command=>\&settings - )->pack(-side=>'right'); -# make buttons for category button frame -my $lbut=0; -my $l; -foreach (@button) { $l=length $_; $lbut=$l if ( $l > $lbut) } -my @catg; -my ($i2,$i3); -my $nbutt=scalar @button; -my $ncols=$nbutt/3-1; -foreach (0..$ncols) { - $i=$_; - $i2=$i+$nbutt/3; - $i3=$i+2*$nbutt/3; - $catg[$i]=$buttonframe->Button(-text=>$button[$i], - -font=>$deffont,%butcol, - -width=>$lbut, - -command=>[\&tpslct,$i,\@dummy])->grid - ($catg[$i2]=$buttonframe->Button(-text=>$button[$i2], - -font=>$deffont,%butcol, - -width=>$lbut, - -command=>[\&tpslct,$i2,\@dummy]), - $catg[$i3]=$buttonframe->Button(-text=>$button[$i3], - -font=>$deffont,%butcol, - -width=>$lbut, - -command=>[\&tpslct,$i3,\@dummy])); -} -# disable last button (lower right) if no local specials are found in list -my $ncat; -if ($special == 0) { - $catg[$#button]->configure(-state=>'disabled'); - $ncat=$nbutt-1; -} else { - $ncat=$nbutt; -} -for ($i=0,$j=5; $i<@catg; ++$i,++$j) { - $tlwins{'mainwindow'}{'buttons'}[$j]=$catg[$i]; -} -MainLoop; - -########## SUBROUTINES ######################################################## -# toplevel for selecting a topic of a category for viewing or printing -sub tpslct { - my($opt,@srchitems)=@_; - my (@lbitems,@lbdocs,$dspselect,$docselect,$wtitle); - if ($opt >= 0) { -# main window buttons -# see if toplevel window is already there - if (Exists($tlwins{$opt}{'addr'})) { - $tlwins{$opt}{'addr'}->deiconify(); - $tlwins{$opt}{'addr'}->raise(); - return; - } - for ($j=0; $j <= $maxind[$opt]; ++$j) { - push @lbitems,$topic[$opt][$j]; - push @lbdocs,$doc[$opt][$j]; - } - $wtitle=$button[$opt]; - } else { -# search results - my $spec_wtitle=shift @srchitems; - for ($j=0; $j < $#srchitems; $j+=2) { - my $k=$j+1; - push @lbitems,$topic[$srchitems[$j]][$srchitems[$k]]; - push @lbdocs,$doc[$srchitems[$j]][$srchitems[$k]]; - } - $wtitle = ($srchtype ? "File" : "Database") - . " search results for $spec_wtitle"; - } -# toplevel window of category $opt with two frames - my $tpwin=$main->Toplevel(-title=>$wtitle); - $tlwins{$opt}{'addr'}=$tpwin; - my $tpdsp=$tpwin->Frame(-relief=>'groove')->pack(-side=>'top'); - my $tpslc=$tpwin->Frame()->pack(-side=>'top'); -# selection frame with listbox and buttons -# label for listbox - my $tplabel=$tpslc->Label(-text=>($srchtype ? "Files" : "Topics"), - -font=>$deffont)->pack(-anchor=>'w', - -side=>'top'); -# listbox with optional scrollbar - my $tplist=$tpslc->Scrolled("Listbox", - -font=>$deffont, - -scrollbars=>'osoe', -# -height=>0, - -width=>0, - -selectmode=>'single', - -exportselection=>0, - -cursor=>'hand2')->pack(-side=>'left', - -fill=>'y', - -expand=>1); - $tplist->insert('end',@lbitems); # fill topics into listbox -# buttons frame - my $tpbframe=$tpslc->Frame(-borderwidth=>8); - $tpbframe->pack(-side=>'right'); -# make buttons for command frame - my $n_buttons = 0; - $tlwins{$opt}{'buttons'}[$n_buttons++]= - $tpbframe->Button(-text=>'View', - -font=>$deffont,%butcol, - -command=>sub{ &viewslc($docselect,$tpbframe);}, - -width=>6)->pack(-side=>'top'); - if (! $IsWin32) { - $tlwins{$opt}{'buttons'}[$n_buttons++]= - $tpbframe->Button(-text=>'Print', - -font=>$deffont,%butcol, - -command=>sub{ &prtslc($docselect,$tpbframe);}, - -width=>6)->pack(-side=>'top'); - } - $tlwins{$opt}{'buttons'}[$n_buttons++]= - $tpbframe->Button(-text=>'Cancel', - -font=>$deffont,%butcol, - -command=>sub{ destroy $tpwin; undef $tlwins{$opt};}, - -width=>6)->pack(-side=>'bottom'); -# if only 1 item is in the list (most likely in search results), select it - if (scalar @lbitems == 1) { - $tplist->selectionSet(0); - $dspselect=$lbitems[0]; - $docselect=$lbdocs[0]; - &viewslc($docselect,$tpbframe) - if ($autoview && $wtitle =~ /^Search results/); - } -# display frame - my $dsplabel=$tpdsp->Label(-text=>'Selection:', - -font=>$deffont)->pack(-anchor=>'w',, - -fill=>'x', - -side=>'left'); - my $dspslc=$tpdsp->Label(-textvariable=>\$dspselect, - -font=>$deffont, - -borderwidth=>2)->pack(-anchor=>'w', - -fill=>'x', - -side=>'right'); -# handle selection; only one selection possible - $tplist->bind(''=>sub{my ($slctind)=$tplist->curselection(); - $dspselect=$lbitems[$slctind]; - $docselect=$lbdocs[$slctind];}); -# key bindings - $tplist->bind(''=>sub{ - &viewslc($docselect,$tpbframe);}); - $tpwin->bind(''=>sub{ - &viewslc($docselect,$tpbframe);}); - $tpwin->bind(''=>sub{ - &prtslc($docselect,$tpbframe);}); - $tpwin->bind(''=>sub{destroy $tpwin; undef $tlwins{$opt};}); - $tplist->bind(''=>sub{ - if ($docselect) { - &showpath($docselect,$tpbframe); - } else { - &popmsg(2,"No selection;\nuse left mouse button.",$tpbframe); - }}); -} - -# view document selected in listbox -sub viewslc { - my($slc,$parframe)=@_; - my $viewer; - my $itype=-1; - my $browser=0; - my $styflag=0; - unless (defined $slc) { - &popmsg(2,"No selection was made.",$parframe); - return; - } - $parframe->configure(-cursor=>'watch'); - chomp $slc; - my @dummy=split('\.',$slc); - DOC_FORMAT: { # determine document type - ($dummy[-1] =~ /dvi/) && do { $viewer=$dvi_viewer; last DOC_FORMAT; }; - ($dummy[-1] =~ /ps/) && do { $viewer=$ps_viewer; last DOC_FORMAT; }; - ($dummy[-1] =~ /pdf/) && do { $viewer=$pdf_viewer; last DOC_FORMAT; }; - ($dummy[-1] =~ /txt/ || $dummy[-1] =~ /faq$/) && do { - $viewer=($txt_viewer eq "TDK_OWN" || - $txt_viewer =~ /xterm/) ? - $txt_viewer : "${CmdConsole} $txt_viewer"; - last DOC_FORMAT; - }; - ($dummy[-1] =~ /README/i || $dummy[-2] =~ /\/README$/i) && do { - $viewer=($txt_viewer eq "TDK_OWN" || - $txt_viewer =~ /xterm/) ? - $txt_viewer : "${CmdConsole} $txt_viewer"; - last DOC_FORMAT; - }; - ($dummy[-1] =~ /htm/) && do { - $viewer=$html_viewer; - if ($html_viewer =~ /netscape/i) { # check if Netscape is open - my $lockfile="${HomeEnv}/.netscape/lock"; - $browser=1 if (-e $lockfile || -l $lockfile); - } elsif ($html_viewer =~ /mozilla/i) { # check if Mozilla is open - my $mozcheck= - `mozilla -remote 'openFile($texmfmain/doc/index.html)'`; - $browser=1 unless ($?); - } - last DOC_FORMAT; - }; -# some packages have no normal documentation but useful info in the .sty - ($dummy[-1] =~ /sty$/) && do { - $viewer=($txt_viewer eq "TDK_OWN" || - $txt_viewer =~ /xterm/) ? - $txt_viewer : "${CmdConsole} $txt_viewer"; - $slc="../tex/$slc"; # .sty files are in ${tex,local}docpath/../tex/ - $styflag=1; - last DOC_FORMAT; - }; - $parframe->configure(-cursor=>$defcursor); - if ($xfmt_viewer != 1) { - &popmsg(2,"$dummy[-1]: not a known document format",$parframe); - return; - } - }; - if ($viewer eq "") { - if ($xfmt_viewer == 1) { - &popmsg(-1,'Unknown format; assuming plain text.',$parframe); - $viewer=($txt_viewer eq "TDK_OWN" || - $txt_viewer =~ /xterm/) ? - $txt_viewer : "${CmdConsole} $txt_viewer"; - } else { - &popmsg(2,"$dummy[-1]: no viewer available/specified for this format", - $parframe); - $parframe->configure(-cursor=>$defcursor); - return; - } - } -# build complete path and start viewer if file exists - my $slcdoc; - $slcdoc=&finddoc($slcdoc,$slc,$parframe); - if ($slcdoc ne "") { -# change to doc directory in case there are pictures - my $docpath=substr($slcdoc,0,(rindex($slcdoc,'/',(length $slcdoc)))); - chomp $slcdoc; - chdir ($docpath); -# try to get doc out of .sty file - if ($styflag) { - &popmsg(-1,'Trying to extract documentation out of .sty file; -might be cluttered with program comments.', - $parframe); - $slcdoc=&stripsty($slcdoc,substr($slc,7)); - } -# for text files use built-in text viewer if set - if ($IsWin32) { - if ($viewer eq "TDK_OWN") { - &ShellExecute('open', $slcdoc); - $parframe->configure(-cursor=>$defcursor); - return; - } - else { - system("$viewer $slcdoc"); - } - } - else { - if ($viewer eq "TDK_OWN") { - &textview($slcdoc); - $parframe->configure(-cursor=>$defcursor); - return; - } - if ($quiet == 0) { # show messages - if ($browser == 0) { # normal viewers or new Netscape/Mozilla - system("$viewer $slcdoc &"); - } else { # open doc in existing Netscape/Mozilla window - system("$viewer -remote 'openFile($slcdoc)' &"); - &popmsg(-1,"Opening document in existing $viewer window.", - $parframe); - } - } else { # viewer messages written to /dev/null instead of terminal - if ($browser == 0) { # normal viewers or new Netscape/Mozilla - system("perl -we 'use strict; \ -my \$dump=\"\"; \ -open(NULL,\">/dev/null\"); \ -open (VIEWQ,\"$viewer $slcdoc |\"); \ -while (\$dump=) { print NULL \$dump; } \ -close(VIEWQ); \ -close(NULL);' &"); - } else { # open doc in existing window (Netscape or Mozilla) - # not quiet; I didn't get an inline perl call like in - # the other branch working - system("$viewer -remote 'openFile($slcdoc)' &"); - &popmsg(-1,"Opening document in existing $viewer window.", - $parframe); - } - } - } - } - $parframe->configure(-cursor=>$defcursor); -} - -# Tk widget for text document -sub textview { - my($txtfile)=@_; -# see if toplevel window with this file is already there - if (Exists($tlwins{$txtfile}{'addr'})) { - $tlwins{$txtfile}{'addr'}->deiconify(); - $tlwins{$txtfile}{'addr'}->raise(); - return; - } - my $tfv_tk=$main->Toplevel(-title=>"Text file viewer"); - $tfv_tk->resizable(0,1); - $tlwins{$txtfile}{'addr'}=$tfv_tk; - $tfv_tk->Label(-text=>"File: $txtfile", - -font=>$deffont, - -relief=>'ridge', - -borderwidth=>3)->pack(-side=>'top', - -fill=>'x', - -ipady=>10, - -anchor=>'s'); - my $txtbody=$tfv_tk->Scrolled("Text", - -relief=>'flat', - -font=>$deffont, - -height=>20, - -width=>80, - -scrollbars=>"e")->pack(-side=>'top', - -fill=>'y', - -expand=>1); - open(TXTFILE,"$txtfile"); - while () { $txtbody->insert('end',$_); } - close(TXTFILE); - $txtbody->configure(-state=>'disabled'); - $tlwins{$txtfile}{'buttons'}[0]= - $tfv_tk->Button(-text=>'Close', - -font=>$deffont,%butcol, - -command=>sub{ destroy $tfv_tk; - undef $tlwins{$txtfile}; - })->pack(-side=>'bottom', - -fill=>'x'); - $tfv_tk->bind(''=>sub{destroy $tfv_tk; - undef $tlwins{$txtfile}; - }); -} - -# print document selected in listbox -sub prtslc { - my($slc,$parframe)=@_; - $tmpfno=&randname; - my $pstmpfile="${TempDir}/texdoc_$tmpfno.ps"; - push @tmpfiles,$pstmpfile; - my $status; - chomp $slc; - unless (defined $slc) { - &popmsg(2,"No selection was made.",$parframe); - return; - } - if ($print_cmd eq "") { - &popmsg(2,"No printer specified.",$parframe); - return; - } -# build complete path and check existence of file - my @dummy=split('\.',$slc); - if ($dummy[-1] =~ /sty$/) { - $slc="../tex/$slc"; # .sty files are in ${tex,local,home}docpath/../tex - } - my $slcdoc; - $slcdoc=&finddoc($slcdoc,$slc,$parframe); - return if ($slcdoc eq ""); -# change to doc directory in case there are pictures - my $docpath=substr($slcdoc,0,(rindex($slcdoc,'/',(length $slcdoc)))); - chdir ($docpath); - DOC_FORMAT: { # determine document type -# convert dvi files to ps before printing - ($dummy[-1] =~ /dvi/) && do { - if ($dvips_conv eq "") { - &popmsg(2,"No converter available for dvi->ps conversion.", - $parframe); - return; - } - &popmsg(-1,"Converting dvi to ps for printing and sending file to print...",$parframe); - $status=system("$dvips_conv $slcdoc -o $pstmpfile"); - if ($status != 0) { - &popmsg(2,"Error: Conversion dvi->ps failed!",$parframe); - } - last DOC_FORMAT; - }; -# PostScript is printed directly - ($dummy[-1] =~ /ps/) && do { - &popmsg(-1,"Sending file to $print_cmd...",$parframe); - $pstmpfile=$slcdoc; - last DOC_FORMAT; - }; -# convert pdf files to ps before printing - ($dummy[-1] =~ /pdf/) && do { - if ($pdfps_conv eq "") { - &popmsg(2,"No converter available for pdf->ps conversion.", - $parframe); - return; - } - &popmsg(-1,"Converting pdf to ps for printing and sending file to print...",$parframe); - system("$pdfps_conv $slcdoc $pstmpfile"); - last DOC_FORMAT; - }; -# convert html files to ps before printing - ($dummy[-1] =~ /htm/) && do { - if ($htmlps_conv eq "") { - &popmsg(2,"No converter available for html->ps conversion.", - $parframe); - return; - } - &popmsg(-1,"Converting html to ps for printing and sending file to print...",$parframe); - my $htmlps_redir_sign=($htmlps_redir == 1) ? ">" :""; - system("$htmlps_conv $slcdoc $htmlps_redir_sign $pstmpfile"); - last DOC_FORMAT; - }; -# convert txt files to ps before printing - ($dummy[-1] =~ /txt/ || $dummy[-1] =~ /faq$/ - || $dummy[-1] =~ /README/i) && do { - if ($txtps_conv eq "") { - &popmsg(2,"No converter available for txt->ps conversion.", - $parframe); - return; - } - &popmsg(-1,"Converting txt to ps for printing and sending file to print...",$parframe); - my $txtps_redir_sign=($txtps_redir == 1) ? ">" :""; - system("$txtps_conv $slcdoc $txtps_redir_sign $pstmpfile"); - last DOC_FORMAT; - }; -# convert extracted comments from sty files to ps before printing - ($dummy[-1] =~ /sty$/) && do { - if ($txtps_conv eq "") { - &popmsg(2,"No converter available for sty(txt)->ps conversion.", - $parframe); - return; - } - &popmsg(-1,"Converting sty(txt) to ps for printing and sending file to print...",$parframe); -# try to get doc out of .sty file - &popmsg(-1,'Trying to extract documentation out of .sty file; -might be cluttered with program comments.', - $parframe); - $slcdoc=&stripsty($slcdoc,substr($slc,7)); - my $txtps_redir_sign=($txtps_redir == 1) ? ">" :""; - system("$txtps_conv $slcdoc $txtps_redir_sign $pstmpfile"); - last DOC_FORMAT; - }; - &popmsg(2,"$dummy[-1]: cannot print document format",$parframe); - return; - }; - system("$print_cmd $pstmpfile"); -} - -# test existence and search a documentation which is not in specified place -sub finddoc { - my($slcdoc,$slc,$parframe)=@_; - my ($dummy,$status); - SLCDOCFIND: foreach ($texdocpath,$distdocpath,$docdocpath) { - $slcdoc="$_/$slc"; - if (-e $slcdoc) { -# found where it should be - return $slcdoc; - } else { -# see if the documentation file is in the local doc tree... - my @srchslcdoc=($slcdoc); - if ($localdocpath) { - push @srchslcdoc,"$localdocpath/$slc"; - return $srchslcdoc[-1] if (-e $srchslcdoc[-1]); - } -# ... or the user's doc tree... - if ($homedocpath) { - push @srchslcdoc,"$homedocpath/$slc"; - return $srchslcdoc[-1] if (-e $srchslcdoc[-1]); - } -# ... otherwise proceed with searching - $status=-1; -# see if the documentation file is compressed - CMPREND: foreach my $cmprtype ("gz","bz2","zip") { - foreach (@srchslcdoc) { - $dummy="$_.$cmprtype"; - if (-e $dummy) { # yes, it is compressed - $tmpfno=&randname; - my $rawname=basename($slc,""); - $slcdoc="${TempDir}/texdoc_$tmpfno$rawname"; - push @tmpfiles,$slcdoc; - my ($dcmp,$dcmp_opt); - COMPRESS: { # determine compression type - ($cmprtype eq "gz") && do { - $dcmp="gzip"; - $dcmp_opt="-cd"; - last COMPRESS; - }; - ($cmprtype eq "bz2") && do { - $dcmp="bzip2"; - $dcmp_opt="-cd"; - last COMPRESS; - }; - ($cmprtype eq "zip") && do { - $dcmp="zip"; - $dcmp_opt="-p"; - last COMPRESS; - }; - }; -# try to decompress - $status=system("$dcmp $dcmp_opt $dummy > $slcdoc"); - if ($status != 0) { # failure - &popmsg(2, - "$dcmp: Couldn't decompress file, cancelling.", - $parframe); - $slcdoc=""; - return $slcdoc; - } -# last CMPREND; does not work, what we need is: - return $slcdoc; - } - } - } - } - } - if ($status != 0) { - $parframe->configure(-cursor=>'watch'); -# try to find it elsewhere with kpsewhich - my $rawname=basename($slc,""); - $slcdoc=($slcdoc =~ /\.sty$/) ? - `kpsewhich $rawname` : - `kpsewhich --format=${qq}TeX system documentation${qq} $rawname`; - if ($slcdoc eq "") { # nothing found; cancel - &popmsg(2,"$rawname not found, cancelling.",$parframe); - $slcdoc=""; - } - $parframe->configure(-cursor=>$defcursor); - } - return $slcdoc; -} - -# determine existence and show paths of files (Button-3) -sub showpath { - my ($docselect,$tpbframe)=@_; - my $found=0; - if ($docselect =~ /\.sty$/) { - STYPATH: foreach my $fullpath ("$texmfmain/tex/$docselect", - "$texmfdist/tex/$docselect", - "$texmflocal/tex/$docselect", - "$texmfhome/tex/$docselect") { - if (-e $fullpath) { - &popmsg(0,"Selected file:\n$fullpath",$tpbframe); - $found=1; - last STYPATH; - } - } - if (!$found) { - &popmsg(2,"Selected file:\n$docselect\ndoes not exist.",$tpbframe) } - } else { - DOCPATH: foreach my $fullpath ("$texdocpath/$docselect", - "$distdocpath/$docselect", - "$docdocpath/$docselect", - "$localdocpath/$docselect", - "$homedocpath/$docselect") { - foreach ('','.gz','.bz2','.zip') { - my $fullpathext="$fullpath$_"; - if (-e $fullpathext) { - &popmsg(0,"Selected file:\n$fullpathext",$tpbframe); - $found=1; - last DOCPATH; - } - } - } - if (!$found) { - &popmsg(2,"Selected file:\n$docselect\ndoes not exist (neither in normal form nor compressed).",$tpbframe) } - } -} - -# make or destroy search entry widget -sub mksrch { - my ($type) = @_; - if ($srchflag == 1) { - if ($type == $srchtype) { - destroy $srchentry; - $srchflag=0; - } else { - $srchtype = $type; - } - } else { - $srchtype = $type; -# get the search string - $srchentry=$cmdframe->Entry(-cursor=>'xterm', - -font=>$deffont, - -width=>20, - -takefocus=>1)->pack(-side=>'left'); - $srchentry->focus(); - $srchentry->bind(''=>[\&srchstr, $srchentry]); - $srchflag=1; -# key binding - $srchentry->bind(''=>sub{destroy $srchentry; $srchflag=0;}); - $srchentry->bind(''=>sub{destroy $srchentry; $srchflag=0;}); - } -} - -# call search routine and display results -sub srchstr { - my $string; - my @reslist; - $string=$srchentry->get(); -# search - $main->Busy(-recurse => 1); - if ($srchtype == 0) { - @reslist = &srchdb($string); - } else { - @reslist = &srchtd($string); - } - $main->Unbusy(); -# destroy entry widget and show results - destroy $srchentry; - $srchflag=0; - if (scalar @reslist == 0) { - &popmsg(0, ($srchtype == 0 ? 'Database' : 'File'). - " search for $string: no matches found.\n". - "You may want to try a ". - ($srchtype == 0 ? 'File' : 'Databse') . " search.\n\n". - "If nothing else works, CTAN offers an online search form:\n". - "http://ctan.org/search.html\n", - $cmdframe); - } else { - &tpslct(-1, $string, @reslist); - } -} - -# search using texdoc -sub srchtd { - my ($string) = @_; - my @res; - my $tdout = `texdoc -M -l $string`; - if ($?) { - &popmsg(0,"texdoc failed, sorry: $!\n". - "Please report this problem on the texlive mailing list.\n"); - return; - } else { - my $i = 0; - for my $line (split /\n/, $tdout) { - my @fields = split /\t/, $line; - $doc[$ncat][$i] = $fields[2]; - $topic[$ncat][$i] = basename($fields[2]); - $packname[$ncat][$i] = "no package name"; - push @res, ($ncat, $i++); - } - return @res; - } -} - -# search a string in @packname, @topic and @keywords -sub srchdb { - my ($string) = @_; - my (@results, @reslist); - if ($string) { - for ($i=0; $i<$ncat; ++$i) { - for ($j=0; $j<$maxind[$i]+1; ++$j) { - SRCH: { - ($topic[$i][$j] =~ /$string/i) && do { - push @results,($i,$j); - last SRCH; - }; - (defined $keywords[$i][$j]) && do { - if ($keywords[$i][$j] =~ /$string/i) { - push @results,($i,$j); - last SRCH; - } - }; - ($packname[$i][$j] =~ /$string/i) && do { - push @results,($i,$j); - last SRCH; - }; - }; - } - } - } else { # return full database - $string='all database entries'; - for ($i=0; $i<$ncat; ++$i) { - for ($j=0; $j<$maxind[$i]+1; ++$j) { push @results,($i,$j); } - } - } - unless (scalar @results == 0) { -# cancel multiple entries - my ($omit,$pack1,$pack2); - @reslist=($results[0],$results[1]); - for ($i=0; $i<$#results; $i+=2) { - $omit=0; - $pack1=$packname[$results[$i]][$results[$i+1]]; - for ($j=0; $j<$#reslist; $j+=2) { - $pack2=$packname[$reslist[$j]][$reslist[$j+1]]; - if ($pack1 eq $pack2) { $omit=1; last; } - } - if ($omit == 0) { push @reslist,($results[$i],$results[$i+1]); } - } - } - return @reslist; -} - -# extract documentation of .sty files; a flag in the @keywords array shows -# where the doc is located: -# -0-: no specific place; -1-: at end, behind \endinput; -2-: at beginning, -# terminated by %%%%%%; -3-: at beginning, terminated with blank line -sub stripsty { - my ($slcdoc,$slc)=@_; - my @stydoc; - $tmpfno=&randname; - my $tmpslcdoc="${TempDir}/texdoc_$tmpfno.txt"; - push @tmpfiles,$tmpslcdoc; - open (STY,"$slcdoc"); - LOC: { - ($stydoc{$slc} == 0) && do { # no specific place, suck in everything :-( - while ($line = ) { push @stydoc,$line if ($line =~ /^%/); } - last LOC; - }; - ($stydoc{$slc} == 1) && do { # at end, behind \endinput - while ($line = ) { - last if ($line =~ /^\s*\\endinput/ && !($line =~ /^%/)); - } - while ($line = ) { push @stydoc,$line; } - last LOC; - }; - ($stydoc{$slc} == 2) && do { # up to a certain %%%%%%%, hopefully the 1st - for (my $i=0; $i<9; ++$i) { $stydoc[$i]=; } # after the 8th line - while ($line = ) { - last if ($line =~ /^%{4,}/); - push @stydoc,$line; - } - last LOC; - }; - ($stydoc{$slc} == 3) && do { # up to 1st blank/apparently empty line - while ($line = ) { - last if ($line =~ /^\s*$/); - push @stydoc,$line; - } - last LOC; - }; - }; - close(STY); - open(TMPSTY,">$tmpslcdoc"); - foreach (@stydoc) { print TMPSTY $_; } - close(TMPSTY); - return $tmpslcdoc; -} - -# pop up a note or an error or warning message toplevel window -sub popmsg { - my($level,$msg,$parframe)=@_; - my $degree; - LEVEL: { - ($level == -1) && do { $degree="Info"; last LEVEL; }; - ($level == 0) && do { $degree="Note"; last LEVEL; }; - ($level == 1) && do { - return if ($quiet == 1); - $degree="Warning"; - last LEVEL - }; - ($level == 2) && do { $degree="Error"; last LEVEL; }; - }; - my $msgwin=$parframe->Toplevel(-title=>$degree); - my $lbl=$msgwin->Label(-text=>uc($degree), - -font=>$deffont)->pack(-side=>'top', -fill=>'x'); -# get size of message text - my @dummy=split("\n",$msg); - my $nline=scalar @dummy; - my $msgwidth=0; - my $lline; - foreach (@dummy) { - $lline=length $_; - if ($lline > $msgwidth) { $msgwidth=$lline; } - } - my $message=$msgwin->Text(-relief=>'flat', - -font=>$deffont, - -height=>$nline, - -width=>$msgwidth)->pack(-side=>'top'); - $message->insert('end',$msg); - $message->configure(-state=>'disabled'); - if ($level < 0) { # transient message window - $msgwin->after(3000,sub{destroy $msgwin}); - } else { # persistent message window - $msgwin->Button(-text=>'Close', - -font=>$deffont,%butcol, - -command=>sub{destroy $msgwin})->pack(-side=>'bottom', - -fill=>'x'); - $msgwin->bind(''=>sub{destroy $msgwin}); - } -} - -# show/change settings (don't show this to an expert :-/ ) -sub settings { - my ($homedocpath_tmp,$quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, - $dvi_viewer_tmp,$dvips_conv_tmp, - $ps_viewer_tmp,$pdf_viewer_tmp,$pdfps_conv_tmp, - $html_viewer_tmp,$htmlps_conv_tmp,$htmlps_redir_tmp, - $txt_viewer_tmp,$txtps_conv_tmp,$txtps_redir_tmp,$print_cmd_tmp)= - ($homedocpath,$quiet,$autoview,$xfmt_viewer, - $dvi_viewer,$dvips_conv,$ps_viewer, - $pdf_viewer,$pdfps_conv,$html_viewer, - $htmlps_conv,$htmlps_redir,$txt_viewer, - $txtps_conv,$txtps_redir,$print_cmd); - my @tdcolors_tmp=@tdcolors; -# see if toplevel window is already there - if (Exists($tlwins{"setmenu"}{'addr'})) { - $tlwins{"setmenu"}{'addr'}->deiconify(); - $tlwins{"setmenu"}{'addr'}->raise(); - return; - } - my $setmenu=$main->Toplevel(-title=>'Settings'); - $setmenu->resizable(0,0); - $tlwins{"setmenu"}{'addr'}=$setmenu; -# documentation path - my $datlabel; - $datlabel="Database file(s) used: teTeX"; - $datlabel.=", local database" if (-e $locdatabase); - $datlabel.=", user database" if (-e $homedatabase); - my $docframe=$setmenu->Frame(-relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -expand=>1); - my $docframestring="\nDistribution documentation root path(s):\n$texdocpath"; - $docframestring.=", $distdocpath" if (-e $distdocpath); - $docframestring.=", $docdocpath" if (length $docdocpath); - if ($localdocpath && $localdocpath ne $texdocpath) { - $docframestring.="\nLocal documentation root path: $localdocpath\n"; - } - $docframe->Label(-text=>"$docframestring", - -font=>$deffont)->pack(-side=>'top', - -anchor=>'w', - -fill=>'x', - -expand=>1); - if (defined $texmfhome && -d $texmfhome) { - $homedocpath_tmp=basename($homedocpath_tmp,""); - my $usrdocframe=$docframe->Frame(-relief=>'flat')->pack(-side=>'top', - -fill=>'x'); - my $usrdoclabel=$usrdocframe->Label(-text=>"User's documentation root path: $texmfhome/", - -font=>$deffont)->pack(-side=>'left'); - my $usrdocentry=$usrdocframe->Entry(-textvariable=>\$homedocpath_tmp, - -font=>$deffont)->pack(-side=>'left'); - } - $docframe->Label(-text=>"$datlabel.", - -font=>$deffont)->pack(-side=>'top', - -anchor=>'w', - -ipady=>2, - -fill=>'x', - -expand=>1); -# General viewer behaviour - my $genvframe=$setmenu->Frame(-label=>'General viewer behaviour', - -relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -ipady=>6, - -expand=>1); - my $genvframe1=$genvframe->Frame()->pack(-side=>'left'); - my $genvsub1=$genvframe1->Frame()->pack(-side=>'top', - -anchor=>'w', - -ipady=>3); - my $genvecbut=$genvsub1-> - Checkbutton(-variable=>\$quiet_tmp)->pack(-side=>'left', - -anchor=>'sw'); - my $genvelabel=$genvsub1->Label(-text=>'Suppress error messages', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $genvsub2=$genvframe1->Frame()->pack(-side=>'top', - -anchor=>'w'); - my $genvscbut=$genvsub2-> - Checkbutton(-variable=>\$autoview_tmp)->pack(-side=>'left', - -anchor=>'sw'); - my $genvslabel=$genvsub2->Label(-text=>'Autostart viewer for one-item listboxes', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $genvsub3=$genvframe1->Frame()->pack(-side=>'top', - -anchor=>'w'); - my $genvxcbut=$genvsub3-> - Checkbutton(-variable=>\$xfmt_viewer_tmp)->pack(-side=>'left', - -anchor=>'sw'); - my $genvxlabel=$genvsub3->Label(-text=>'Use text viewer for unknown file format', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); -# colours of GUI - my @tdcolors_d=@tdcolors_tmp; - $tlwins{'setmenu'}{'buttons'}[0]= - $genvframe->Button(-text=>'Change viewer colours', - -command=>sub { - @tdcolors_tmp=&popcolor($setmenu,@tdcolors_tmp); - @tdcolors_d=@tdcolors_tmp; - }, - -font=>$deffont,%butcol)->pack(-side=>'right'); -# DVI - my $dviframe=$setmenu->Frame(-label=>'DVI', - -relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -ipady=>6, - -expand=>1); - my $dvisub1=$dviframe->Frame()->pack(-side=>'top', - -anchor=>'w'); - my $dvisub2=$dviframe->Frame()->pack(-side=>'top', - -anchor=>'w', - -ipady=>6); - my $dvivlabel=$dvisub1->Label(-text=>'Viewer command', - -anchor=>'w', - -font=>$deffont)->pack(-side=>'left'); - my $dviventry=$dvisub1->Entry(-textvariable=>\$dvi_viewer_tmp, - -font=>$deffont)->pack(-side=>'left'); - my $dviclabel=$dvisub2->Label(-text=>'DVI->PS converter command', - -anchor=>'w', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $dvilbwidth=length 'DVI->PS converter command'; - $dvivlabel->configure(-width=>1.1*$dvilbwidth); - $dviclabel->configure(-width=>1.1*$dvilbwidth); - my $dvicentry=$dvisub2->Entry(-textvariable=>\$dvips_conv_tmp, - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); -# PostScript - my $psframe=$setmenu->Frame(-label=>'PostScript', - -relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -ipady=>10, - -expand=>1); - my $psvlabel=$psframe->Label(-text=>'Viewer command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'w'); - my $psventry=$psframe->Entry(-textvariable=>\$ps_viewer_tmp, - -font=>$deffont)->pack(-side=>'left'); -# PDF - my $pdfframe=$setmenu->Frame(-label=>'PDF', - -relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -ipady=>6, - -expand=>1); - my $pdfsub1=$pdfframe->Frame()->pack(-side=>'top', - -anchor=>'w'); - my $pdfsub2=$pdfframe->Frame()->pack(-side=>'top', - -anchor=>'w', - -ipady=>6); - my $pdfvlabel=$pdfsub1->Label(-text=>'Viewer command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'w'); - my $pdfventry=$pdfsub1->Entry(-textvariable=>\$pdf_viewer_tmp, - -font=>$deffont)->pack(-side=>'left'); - my $pdfclabel=$pdfsub2->Label(-text=>'PDF->PS converter command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $pdfcentry=$pdfsub2->Entry(-textvariable=>\$pdfps_conv_tmp, - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); -# HTML - my $htmlframe=$setmenu->Frame(-label=>'HTML', - -relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -ipady=>6, - -expand=>1); - my $htmlsub1=$htmlframe->Frame()->pack(-side=>'top', - -anchor=>'w'); - my $htmlsub2=$htmlframe->Frame()->pack(-side=>'top', - -anchor=>'w', - -ipady=>6); - my $htmlvlabel=$htmlsub1->Label(-text=>'Viewer command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'w'); - my $htmlventry=$htmlsub1->Entry(-textvariable=>\$html_viewer_tmp, - -font=>$deffont)->pack(-side=>'left'); - my $htmlclabel=$htmlsub2->Label(-text=>'HTML->PS converter command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $htmlcentry=$htmlsub2->Entry(-textvariable=>\$htmlps_conv_tmp, - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $htmlrlabel=$htmlsub2->Label(-text=>'Output redirect needed', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $htmlrcbut=$htmlsub2-> - Checkbutton(-variable=>\$htmlps_redir_tmp)->pack(-side=>'left', - -anchor=>'sw'); -# plain text - my $txtframe=$setmenu->Frame(-label=>'Plain text', - -relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -ipady=>6, - -expand=>1); - my $txtsub1=$txtframe->Frame()->pack(-side=>'top', - -anchor=>'w'); - my $txtsub2=$txtframe->Frame()->pack(-side=>'top', - -anchor=>'w', - -ipady=>6); - my $txtvlabel=$txtsub1->Label(-text=>'Viewer command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'w'); - my $txtventry=$txtsub1->Entry(-textvariable=>\$txt_viewer_tmp, - -font=>$deffont)->pack(-side=>'left'); - my $txt_view_flag; - if ($txt_viewer_tmp eq "TDK_OWN") { - $txt_view_flag=1; - $txtventry->configure(-state=>'disabled'); - } else { - $txt_view_flag=0; - $txtventry->configure(-state=>'normal'); - } - my $txtvilabel=$txtsub1->Label(-text=>"\tUse texdoctk\'s own viewer", - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $txtvcbut=$txtsub1-> - Checkbutton(-variable=>\$txt_view_flag, - -command=>sub { - if ($txt_view_flag == 1) { - $txt_viewer_tmp="TDK_OWN"; - $txtventry->configure(-state=>'disabled'); - } else { - $txt_viewer_tmp=$txt_viewer; - $txtventry->configure(-state=>'normal'); - $txtventry->focus(); - } - })->pack(-side=>'left', - -anchor=>'sw'); - my $txtclabel=$txtsub2->Label(-text=>'Text->PS converter command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $txtcentry=$txtsub2->Entry(-textvariable=>\$txtps_conv_tmp, - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $txtrlabel=$txtsub2->Label(-text=>'Output redirect needed', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'sw'); - my $txtrcbut=$txtsub2-> - Checkbutton(-variable=>\$txtps_redir_tmp)->pack(-side=>'left', - -anchor=>'sw'); -# printer - my $prtframe=$setmenu->Frame(-label=>'Printer', - -relief=>'groove', - -borderwidth=>2)->pack(-side=>'top', - -fill=>'x', - -ipady=>10, - -expand=>1); - my $prtclabel=$prtframe->Label(-text=>'Command', - -font=>$deffont)->pack(-side=>'left', - -anchor=>'w'); - my $prtcentry=$prtframe->Entry(-textvariable=>\$print_cmd_tmp, - -font=>$deffont)->pack(-side=>'left'); -# buttons and key bindings - my $setbfr=$setmenu->Frame()->pack(-side=>'bottom'); - $tlwins{'setmenu'}{'buttons'}[1]= - $setbfr->Button(-text=>'OK', - -font=>$deffont,%butcol, - -command=>sub{ - $homedocpath="$texmfhome/$homedocpath_tmp"; - ($quiet,$autoview,$xfmt_viewer, - $dvi_viewer,$dvips_conv, - $ps_viewer,$pdf_viewer, - $pdfps_conv,$html_viewer, - $htmlps_conv,$htmlps_redir, - $txt_viewer,$txtps_conv,$txtps_redir,$print_cmd)= - ($quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, - $dvi_viewer_tmp,$dvips_conv_tmp, - $ps_viewer_tmp, - $pdf_viewer_tmp,$pdfps_conv_tmp, - $html_viewer_tmp, - $htmlps_conv_tmp,$htmlps_redir_tmp, - $txt_viewer_tmp,$txtps_conv_tmp, - $txtps_redir_tmp,$print_cmd_tmp); - @tdcolors=@tdcolors_tmp; - %butcol=('-background'=>$tdcolors[0], - '-foreground'=>$tdcolors[1], - '-activebackground'=>$tdcolors[2], - '-activeforeground'=>$tdcolors[3]); - foreach my $tlkey (keys %tlwins) { - foreach (@{$tlwins{$tlkey}{'buttons'}}) { - $_->configure(%butcol); - } - } - if ($txt_viewer eq "" && - defined $ENV{PAGER}) { - $txt_viewer=$ENV{PAGER}; - } - destroy $setmenu}, - -width=>6)->pack(-side=>'left', - -padx=>10, - -pady=>10); - $tlwins{'setmenu'}{'buttons'}[2]= - $setbfr->Button(-text=>'Save', - -font=>$deffont,%butcol, - -command=>sub{ - $setmenu->configure(-cursor=>'watch'); - &popmsg(-1,"Writing settings to $myrc",$setmenu); - my $tdcolors_tmp=join(' ',@tdcolors_tmp); - &writerc($homedocpath_tmp, - $quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, - $tdcolors_tmp, - $dvi_viewer_tmp,$dvips_conv_tmp, - $ps_viewer_tmp, - $pdf_viewer_tmp,$pdfps_conv_tmp, - $html_viewer_tmp, - $htmlps_conv_tmp,$htmlps_redir_tmp, - $txt_viewer_tmp,$txtps_conv_tmp, - $txtps_redir_tmp,$print_cmd_tmp,$setmenu); - $setmenu->configure(-cursor=>$defcursor); - })->pack(-side=>'left', - -padx=>10); - $tlwins{'setmenu'}{'buttons'}[3]= - $setbfr->Button(-text=>'Cancel', - -font=>$deffont,%butcol, - -command=>sub{destroy $setmenu; - undef $tlwins{"setmenu"}; - })->pack(-side=>'left', - -padx=>10); - $setmenu->bind(''=>sub{destroy $setmenu; - undef $tlwins{"setmenu"};}); -} - -# dialog toplevel for color settings -sub popcolor { - my ($parframe,@entryvar)=@_; -# see if toplevel window is already there - if (Exists($tlwins{'chngcol'}{'addr'})) { - $tlwins{'chngcol'}{'addr'}->deiconify(); - $tlwins{'chngcol'}{'addr'}->raise(); - return; - } - my $dlgwin=$parframe->Toplevel(-title=>'Change colours'); - $dlgwin->resizable(0,0); - $tlwins{'chngcol'}{'addr'}=$dlgwin; -# entry widgets for default/active back/foreground - $dlgwin->Label(-text=>'Enter colours as names or RGB #xxxxxx values', - -font=>$deffont)->pack(-side=>'top'); - my $dlgdef=$dlgwin->Frame()->pack(-side=>'top'); - my $dlgact=$dlgwin->Frame()->pack(-side=>'top'); - my $dlgdef1=$dlgdef->Frame()->pack(-side=>'left'); - my $dlgtfr0=$dlgdef1->Frame()->pack(-side=>'top'); - my $dlgtfr1=$dlgdef1->Frame()->pack(-side=>'top'); - my $dlgact1=$dlgact->Frame()->pack(-side=>'left'); - my $dlgtfr2=$dlgact1->Frame()->pack(-side=>'top'); - my $dlgtfr3=$dlgact1->Frame()->pack(-side=>'top'); - $dlgtfr0->Label(-text=>"Default background", - -anchor=>'w', - -width=>18, - -font=>$deffont)->pack(-side=>'left'); - $dlgtfr0->Entry(-textvariable=>\$entryvar[0], - -font=>$deffont)->pack(-side=>'left'); - $dlgtfr1->Label(-text=>"Default foreground", - -anchor=>'w', - -width=>18, - -font=>$deffont)->pack(-side=>'left'); - $dlgtfr1->Entry(-textvariable=>\$entryvar[1], - -font=>$deffont)->pack(-side=>'left'); - my $deflabel=$dlgdef->Label(-text=>'Default', - -relief=>'ridge', - -width=>10, - -height=>2)->pack(-side=>'right', - -padx=>7); - $dlgtfr2->Label(-text=>"Active background", - -anchor=>'w', - -width=>18, - -font=>$deffont)->pack(-side=>'left'); - $dlgtfr2->Entry(-textvariable=>\$entryvar[2], - -font=>$deffont)->pack(-side=>'left'); - $dlgtfr3->Label(-text=>"Active foreground", - -anchor=>'w', - -width=>18, - -font=>$deffont)->pack(-side=>'left'); - $dlgtfr3->Entry(-textvariable=>\$entryvar[3], - -font=>$deffont)->pack(-side=>'left'); - my $actlabel=$dlgact->Label(-text=>'Active', - -background=>$entryvar[2], - -foreground=>$entryvar[3], - -relief=>'ridge', - -width=>10, - -height=>2)->pack(-side=>'right', - -padx=>7); -# buttons - my $setbfr=$dlgwin->Frame()->pack(-side=>'bottom'); - my $chngflag=0; - $tlwins{'chngcol'}{'buttons'}[0]= - $setbfr->Button(-text=>'OK', - -font=>$deffont,%butcol, - -command=>sub { - foreach (@entryvar) { # RGB form with leading # - $_="#$_" if (/^[A-Fa-f0-9]{6}$/); - } - $chngflag=1 if (&colcheck($dlgwin,@entryvar)); - }, - -width=>6)->pack(-side=>'left', - -padx=>5, - -pady=>10); - $tlwins{'chngcol'}{'buttons'}[1]= - $setbfr->Button(-text=>'Preview', - -font=>$deffont,%butcol, - -command=>sub { - foreach (@entryvar) { # RGB form with leading # - $_="#$_" if (/^[A-Fa-f0-9]{6}$/); - } - if (&colcheck($dlgwin,@entryvar)) { - $deflabel-> - configure(-background=>$entryvar[0], - -foreground=>$entryvar[1]); - $actlabel-> - configure(-background=>$entryvar[2], - -foreground=>$entryvar[3]); - } - }, - -width=>6)->pack(-side=>'left', - -padx=>5, - -pady=>10); - $tlwins{'chngcol'}{'buttons'}[2]= - $setbfr->Button(-text=>'Cancel', - -font=>$deffont,%butcol, - -command=>sub{destroy $dlgwin; - undef $tlwins{'chngcol'}; - })->pack(-side=>'right', - -padx=>5, - -pady=>10); - $dlgwin->bind(''=>sub{destroy $dlgwin; - undef $tlwins{'chngcol'}; }); - $dlgwin->waitVariable(\$chngflag); - destroy $dlgwin; - undef $tlwins{'chngcol'}; - return @entryvar; -} - -# check colours set in popcolor; relies on the existence of X11's showrgb -sub colcheck { - my ($dlgwin,@entryvar)=@_; - my $ecnt=0; - foreach (@entryvar) { # all colours defined? - last unless ($_); - ++$ecnt; - } - &popmsg(2,'Some colours undefined.',$dlgwin) if ($ecnt != 4); - my $defcol=0; - if (`which showrgb`) { # test for proper name - my @rgb=`showrgb`; - my @norgb; - foreach my $colour (@entryvar) { - if ($colour =~ /^#[A-Fa-f0-9]{6}$/ || grep /\b$colour\b/i,@rgb) { - ++$defcol; - } else { - push @norgb,$colour; - } - } - if ($defcol != 4) { - my $norgb=join("\n",@norgb); - &popmsg(2,"Some colours invalid:\n$norgb",$dlgwin); - } - } else { $defcol=4; } - return ($ecnt == 4 && $defcol == 4) ? 1 : 0; -} - -# write user's ~/.texdocrc -sub writerc { - use File::Copy qw/cp mv/; - my ($homedocpath_tmp,$quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, - $tdcolors_tmp, - $dvi_viewer_tmp,$dvips_conv_tmp, - $ps_viewer_tmp, - $pdf_viewer_tmp,$pdfps_conv_tmp, - $html_viewer_tmp, - $htmlps_conv_tmp,$htmlps_redir_tmp, - $txt_viewer_tmp,$txtps_conv_tmp, - $txtps_redir_tmp,$print_cmd_tmp,$parframe)=@_; - my $err=0; - mv $myrc,"$myrc.save" if (-e $myrc); - open(MYRC,">$myrc"); - print MYRC "# user's .texdocrc, generated by program\n -# root of user's doc directory (from \$HOMETEXMF) -# can be left empty if \$TEXMFHOME is undefined -HOMEDOCPATH=$homedocpath_tmp -# general viewer behaviour (y or yes to make active) -QUIET=$quiet_tmp -AUTOVIEW=$autoview_tmp -XFMT_VIEWER=$xfmt_viewer_tmp -# button colours: default and active back-/foreground -# names and RGB values are both allowed; use the form #xxxxxx for RGB -TDCOLORS=$tdcolors_tmp -# the following variables contain whole commands, i.e. options can be given -# DVI settings -DVI_VIEWER=$dvi_viewer_tmp -DVIPS_CONV=$dvips_conv_tmp -# PostScript handling -PS_VIEWER=$ps_viewer_tmp -# PDF handling -PDF_VIEWER=$pdf_viewer_tmp -PDFPS_CONV=$pdfps_conv_tmp -# HTML handling -HTML_VIEWER=$html_viewer_tmp -HTMLPS_CONV=$htmlps_conv_tmp -# HTMLPS_REDIR must be on, if the html->ps converter normally writes its output -# to stdout instead of a file (e.g. as html2ps) (y or yes to make active) -HTMLPS_REDIR=$htmlps_redir_tmp -# Plain text handling -# TDK_OWN is texdoctk's own text file viewer -TXT_VIEWER=$txt_viewer_tmp -TXTPS_CONV=$txtps_conv_tmp -# TXTPS_REDIR must be on, if the txt->ps converter normally writes its output -# to stdout instead of a file (e.g. as a2ps) (y or yes to make active) -TXTPS_REDIR=$txtps_redir_tmp -# printer -PRINT_CMD=$print_cmd_tmp -\n# end of config\n"; - close(MYRC); -} - -# help window (toplevel) -sub helptext { -# see if toplevel window is already there - if (Exists($tlwins{"helptext"}{'addr'})) { - $tlwins{"helptext"}{'addr'}->deiconify(); - $tlwins{"helptext"}{'addr'}->raise(); - return; - } - my $help=$main->Toplevel(-title=>'Help/About'); - $help->resizable(0,1); - $tlwins{'helptext'}{'addr'}=$help; - $help->Label(-text=>"texdoctk -TeX documentation browser -v$version ($date)", - -font=>$deffont)->pack(-side=>'top', - -ipady=>10, - -anchor=>'s'); - my $helpbody=$help->Scrolled("Text", - -relief=>'flat', - -font=>$deffont, - -height=>20, - -width=>60, - -scrollbars=>"e")->pack(-side=>'top', - -fill=>'y', - -expand=>1); - my $pos=tell DATA; - while () { - $_ =~ s/\$sysrc/$sysrc/; - last if (/^#/); - $helpbody->insert('end',$_); - } - seek(DATA,$pos,0); - $helpbody->configure(-state=>'disabled'); - $tlwins{'helptext'}{'buttons'}[0]= - $help->Button(-text=>'Close', - -font=>$deffont,%butcol, - -command=>sub{destroy $help; - undef $tlwins{"helptext"}; - })->pack(-side=>'bottom', - -fill=>'x'); - $help->bind(''=>sub{destroy $help; undef $tlwins{"helptext"};}); -} - -# read config file; personal settings override the default settings -sub readrc { - my($rcfile,$icall)=@_; - my ($var,$val); - my $pathflag=0; - my $pathflagl=0; - my $pathflagh=0; - my $tdcolors=''; -# for backward compatibility of converter/printer options - my ($dvips_opts,$pdfps_opts,$print_opts); -# read defaults resp. local/personal settings - CALL: { - ($icall == 1) && do { - open (RC,"$rcfile") || - &fatalmsg("Couldn't open system-wide default config file ${TeXDocRcDefaults}.\n"); - last CALL; - }; - ($icall == 2) && do { - open (RC,"$rcfile") || - &fatalmsg("Couldn't open personal config file ~/.texdocrc.\n"); - last CALL; - }; - }; - while ($line = ) { - next if ($line =~ /^($|#)/); - chomp $line; - ($var,$val)=split("=",$line,2); - RCVARS: { - ($var =~ /texdocpath/i) && do { # TEXDOCPATH - if (length $val > 0) { - $pathflag=1; - eval(join("",("\$",lc($var),"=\$val"))); - } - last RCVARS; - }; - ($var =~ /localdocpath/i) && do { # LOCALDOCPATH - if (length $val > 0) { - $pathflagl=1; - eval(join("",("\$",lc($var),"=\$val"))); - } - last RCVARS; - }; - ($var =~ /homedocpath/i) && do { # HOMEDOCPATH - if ($icall == 2 && length $val > 0) { # set only in ~/.texdocrc - $pathflagh=1; - eval(join("",("\$",lc($var),"=\$val"))); - } - last RCVARS; - }; - # other variables - eval(join("",("\$",lc($var),"=\$val"))); - }; - } - close(RC); -# find texmf/doc, and possibly other distribution texmf trees - if ($rcfile eq $sysrc || $pathflag == 1) { - $texmfmain=`kpsewhich --expand-path=${qq}\$TEXMFMAIN${qq}`; - chomp $texmfmain; - $texdocpath="$texmfmain/$texdocpath"; - $texmfdist=`kpsewhich --expand-path=${qq}\$TEXMFDIST${qq}`; - chomp $texmfdist; - $distdocpath=join('/',"$texmfdist",basename($texdocpath,"")) - if (length $texmfdist); - # TeXLive has this texmf-doc - $texmfdoc=join('/',"$texmfmain-doc",basename($texdocpath,"")); - if (-e $texmfdoc) { - chomp $texmfdoc; - $docdocpath="$texmfdoc/$docdocpath"; - } - } -# find texmf-local/doc, if there is one - if ($rcfile eq $sysrc || $pathflagl == 1) { - $texmflocal=`kpsewhich --expand-path=${qq}\$TEXMFLOCAL${qq}`; - chomp $texmflocal; - if (length $texmflocal) { - # if LOCALDOCPATH is not explicitly defined, it equals TEXDOCPATH - unless (defined $localdocpath) { - $localdocpath=basename($texdocpath,""); - } - $localdocpath="$texmflocal/$localdocpath"; - } - } -# find user's $HOMETEXMF/doc, if there is one - if ($icall == 2 || $pathflagh == 1) { - $texmfhome=`kpsewhich --expand-path=${qq}\$HOMETEXMF${qq}`; - chomp $texmfhome; - if (length $texmfhome) { - # if HOMEDOCPATH is not explicitly defined, it equals TEXDOCPATH - unless (defined $homedocpath) { - $homedocpath=basename($texdocpath,""); - } - $homedocpath="$texmfhome/$homedocpath"; - } - } -# colours: create array - @tdcolors=split(' ',$tdcolors); - if (scalar @tdcolors != 4) { # if old texdocrc file is used - if (!(-e $myrc) || (-e $myrc && $icall == 2)) { - print "NOTE: Button colours not set in $rcfile; using defaults.\n"; - @tdcolors=('#d9d9d9','Black','#ececec','red'); - } - } - %butcol=('-background'=>$tdcolors[0], - '-foreground'=>$tdcolors[1], - '-activebackground'=>$tdcolors[2], - '-activeforeground'=>$tdcolors[3]); -# viewer: suppress viewer warnings/use $PAGER if no $txt_viewer is defined - $quiet=($quiet =~ /y/i || $quiet eq "1") ? 1 : 0; - if (!(defined $txt_viewer) && defined $ENV{PAGER}) { - $txt_viewer=$ENV{PAGER}; - } -# viewer: autostart viewer if listbox of search results contains only 1 item - $autoview=($autoview =~ /y/i || $autoview eq "1") ? 1 : 0; -# viewer: use text viewer to open files with unrecognized format - $xfmt_viewer=($xfmt_viewer =~ /y/i || $xfmt_viewer eq "1") ? 1 : 0; -# converter: output redirection flags for HTML/Text->PS converters - $htmlps_redir=($htmlps_redir =~ /(y|1)/i) ? 1 : 0; - $txtps_redir=($txtps_redir =~ /(y|1)/i) ? 1 : 0; -# for backward compatibility of converter/printer options - $dvips_conv.=" $dvips_opts" if ($dvips_opts); - $pdfps_conv.=" $pdfps_opts" if ($pdfps_opts); - $print_cmd.=" $print_opts" if ($print_opts); -} - -# determine resolution if xwininfo is available -# slightly modified from a patch contributed by Reinhard Kotucha -sub x_resolution { - my $x_res; - if ($IsWin32) { - $x_res = &GetScreenWidth; - } - else { - open(XINF,"xwininfo -root|") or return 1200; - while () { - chop; - if (/Width:/) { ($x_res=$_)=/Width:\s+(\d+)/; last; } - } - close(XINF); - } - return $x_res; -} - -# generate a random name for temporary files -sub randname { - my $namestr; - my @chars=("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); - my $time=time; - my $maxcnt=3+substr($time,-1); - for (my $i=0; $i<=$maxcnt; $i++) { $namestr.=$chars[rand(51)] } - my @tmp=split(/./,$time/$$); - $namestr.=$tmp[1]; - until (length($namestr) > 16) { $namestr.=int(rand(1000000)) } - return $namestr; -} - -# find index of an array entry -sub arrindex { - my @array=@_; - my $item=pop @array; - my $i=0; - foreach (@array) { - last if ($_ eq $item); - ++$i; - } - return $i; -} - -# clean up and exit -sub clean_exit { - foreach (@tmpfiles) { if (-e $_) { unlink $_; } } - exit; -} - -# alternative main window, launched for fatal error messages on startup -sub fatalmsg { - my($msg)=@_; - print STDERR $msg; # also print to stderr -# create frame for main window - my $main=new MainWindow; - $main->resizable(0,0); - $main->title("TeX Documentation Browser"); - $main->bind(''=>sub { exit }); - $main->bind(''=>sub { exit }); - my $msgframe=$main->Frame(-background=>"#ffcc99"); - my $cmdframe=$main->Frame; - $msgframe->pack(-side=>'top'); - $cmdframe->pack(-side=>'bottom',-fill=>'x'); -# make buttons for command frame - my $Qbut=$cmdframe->Button(-text=>'Kill',%butcol, - -command=>sub { exit })->pack(-fill=>'x'); -# define common default font for labels and text explicitly - my @deffont=$Qbut->configure(-font); -# ensure readability on high-res screens (suggested by R.Kotucha) - $deffont='Helvetica -16 bold' if &x_resolution > 1200; - $Qbut->configure(-font=>$deffont); - $msgframe->Label(-text=>'FATAL ERROR', - -font=>$deffont)->pack(-side=>'top', -fill=>'x'); -# get size of message text - my @dummy=split("\n",$msg); - my $nline=scalar @dummy; - my $msgwidth=0; - my $lline; - foreach (@dummy) { - $lline=length $_; - if ($lline > $msgwidth) { $msgwidth=$lline; } - } - my $message=$msgframe->Text(-relief=>'flat', - -font=>$deffont, - -height=>$nline, - -width=>$msgwidth)->pack(-side=>'top'); - $message->insert('end',$msg); - $message->configure(-state=>'disabled'); - MainLoop; -} - -if ($IsWin32) { - sub GetScreenWidth { - my $GetDeviceCaps = new Win32::API('gdi32', 'GetDeviceCaps', 'NN', 'N'); - my $HORZRES = 8; # from WinGDI.h - if(not defined $GetDeviceCaps) { - die "Can't import API GetDeviceCaps: $!\n"; - } - return $GetDeviceCaps->Call(0, $HORZRES); - } - - sub GetTempPath { - my $GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', 'N'); - if(not defined $GetTempPath) { - die "Can't import API GetTempPath: $!\n"; - } - my $lpBuffer = " " x 260; - - $GetTempPath->Call(80, $lpBuffer); - } - - sub ShellExecute { - my ($command, $file) = @_; - my $ShellExecute = new Win32::API('shell32', 'ShellExecute', 'NPPPPN', 'N'); - if(not defined $ShellExecute) { - die "Can't import API ShellExecute: $!\n"; - } - $ShellExecute->Call(0, $command, $file, '', '', 0); - } - - sub GetHomeDir { - my $home = $ENV{'HOME'}; - # Should check for CSIDL_... - return $home; - } -} -__END__ -Many TeX programmers provide more or less detailed manuals for -their programs or packages. They are usually available as .dvi, -.ps, .pdf, .html or plain text files (sometimes included in the -.sty files instead of a separate documentation file) and can be -accessed with this browser, which is simply an interface to find a -documentation more easily. It starts the respective viewer for -reading the selected documentation making use of a database file -which contains the path entries according to the current teTeX -texmf/doc structure; additional usage of a system-wide local and -of individual user texmf trees with corresponding databases is also -possible. -The documentations are grouped in several categories shown in the -main window; pressing one of its buttons lists all documentations -belonging to this topic. -The topic window lets you select one documentation file, view or -send it to the default printer. By right-clicking on the selected -item you get the complete path of the file. -The search button of the main window allows you to search the -database for a string; it does not search file names. Enter the -string and hit to start the search or to -cancel. Just hitting without typing something in will -show the full list of files in the database. -Defaults for the documentation root directory, the viewers, the -converters, certain options and the printer are set in the global -configuration file $sysrc. -However, each user can put a copy of it as .texdocrc into his home -directory to modify them according to his needs; modification or -generation of ~/.texdocrc can also be done with the Settings menu. -Additionally, the settings can be changed temporarily with this -menu. - -The following key shortcuts are defined for use with the browser: - Quit browser - Raise the Main window to the foreground - Search a keyword in database (case insensitive) - Cancel/close subwindow or search entry widget - View selected document (topic windows) - Print selected document (topic windows) - Open settings menu - Kill fatal error message window (same as - ) - Open this help - Equivalent to button press; - OK in selection menu and search - Next/previous widget - -There are the following command line options: - -a autostart viewer if a listbox of search results - contains only one item; can also be set in a - configuration file - -v disable suppression of viewer messages sent to - stderr and of certain permanent message popup - windows, in case this was not set in a - configuration file; default: off - -Some more information is available in the manpage of texdoctk. - -Comments and suggestions to: -Thomas Ruedas -tr@dlc.ku.dk or tex-k@tug.org -# Local Variables: -# mode: perl -# auto-fill-hook: do-auto-fill -# End: -# vim: ts=8 sw=4 noexpandtab diff --git a/Master/texmf-dist/scripts/tetex/texlinks.sh b/Master/texmf-dist/scripts/tetex/texlinks.sh deleted file mode 100755 index 09b3488d263..00000000000 --- a/Master/texmf-dist/scripts/tetex/texlinks.sh +++ /dev/null @@ -1,335 +0,0 @@ -#!/bin/sh -# $Id: texlinks 18035 2010-04-28 17:41:52Z mpg $ - -# Thomas Esser, 1999, 2002, 2003. public domain. - -# texlinks: script to maintain symlinks from format to engine. Interprets -# the lines given in fmtutil.cnf. - -# History: -# (Further changes in ChangeLog.) -# Tue Oct 9 14:23:01 BST 2007 -# Added unlink option (-u) to aid OpenBSD package uninstall -# Edd Barrett -# Sun Aug 28 21:41:06 CEST 2005 -# remove special cases for csplain,cslatex,pdfcslatex,pdfcsplain -# Fr Apr 8 19:15:05 CEST 2005 -# cleanup now has an argument for the return code -# So Mar 27 18:52:06 CEST 2005 -# honor $TMPDIR, $TEMP and $TMP, not just $TMP -# Mon May 10 20:52:48 CEST 2004 -# kpseaccess instead of access -# Thu Dec 25 22:11:53 CET 2003, te: -# add version string -# Tue Apr 9 22:46:34 CEST 2002, te: -# do not create symlinks for cont-??, metafun and mptopdf - -test -f /bin/sh5 && test -z "$RUNNING_SH5" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } -unset RUNNING_SH5 - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -export PATH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -version='$Id: texlinks 18035 2010-04-28 17:41:52Z mpg $' -progname=texlinks -cnf=fmtutil.cnf # name of the config file - -usage='Usage: texlinks [OPTION]... [DIRECTORY]... - -Create symbolic links format -> engine according to fmtutil setup. - -Mandatory arguments to long options are mandatory for short options too. - -e, --exeext EXT append EXT to symlink targets (default: none) - -f, --cnffile FILE use FILE as config file (default: fmtutil.cnf) - -m, --multiplatform operate in all platform specific directories - (default: operate only in directory for this platform) - -q, --quiet silently skip existing scripts / binaries - (default: issue warning) - -s, --silent same as -q - -u, --unlink remove symlinks created by texlinks - -v, --verbose enable verbose messages (default: off) - -h, --help show this help text - --version show version string - -The DIRECTORY arguments are an optional list of directories in which to -operate. If no directories are specified and --multiplatform is -likewise not specified, the directory of this script itself is used. -With --multiplatform, all child dirs of an upper-level bin/ dir are used. - -Report bugs to: tex-k@tug.org -TeX Live home page: -' - -############################################################################### -# abort(errmsg) -# print `errmsg' to stderr and exit with error code 1 -############################################################################### -abort() { errmsg "texlinks: $1."; cleanup 1; } - -# error message to stderr: -errmsg() { echo "$@" >&2; } - -# give message to stderr only if "verbose" mode is on: -verbose_echo() { $verbose && errmsg "$@"; } - -# in verbose mode: show command that is executed: -verbose_do() { verbose_echo "$@"; "$@"; } - -############################################################################### -# cleanup() -# clean up the temp area and exit with proper exit status -############################################################################### -cleanup() -{ - rc=$1 - $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ - && { rm -f "$tmpdir"/*; cd /; rmdir "$tmpdir"; } - exit $rc -} - -############################################################################### -# setupTmpDir() -# set up a temp directory and a trap to remove it -############################################################################### -setupTmpDir() -{ - $needsCleanup && return - - trap 'cleanup 1' 1 2 3 7 13 15 - needsCleanup=true - (umask 077; mkdir "$tmpdir") \ - || abort "could not create directory \`$tmpdir'" -} - - -# search a binary along $PATH: -check_for_binary() -{ - testbin=$1 - set x `echo "$PATH" | sed 's/^:/.:/; s/:$/:./; s/::/:.:/g; s/:/ /g'`; shift - for i - do - if [ -x "$i/$testbin" ]; then - echo "$i/$testbin" - return 0 - fi - done - return 1 -} - - -############################################################################### -# install_link(dest src) -# create a symlink like ln -s dest src, but make sure that src is not -# an existing binary, possibly adding the executable extension if -# passed on the command. -############################################################################### -install_link() -{ - # make symlink src -> dest - dest=$1; src=$2 - - case $src in - */mf) - if test "$dest" = mf-nowin; then - if test -f $selfautoloc/mfw; then - dest=mfw # name for windows-enabled mf, once upon a time - verbose_echo "both mfw and mf-nowin exists, $src linked to $dest" - fi - if test -f $selfautoloc/mf && test -f $selfautoloc/mf-nowin; then - # have both mf and mf-nowin binaries. no link. - verbose_echo "skipped metafont symlink $src -> $dest (special case)" - return - fi - fi - ;; - esac - - # append .exe if supplied (for cygwin). - test -n "$exeext" && dest="$dest$exeext" - - case $src in - */cont-??|*/mptopdf) - # context includes wrapper scripts that create/run these. - verbose_echo "skipped ConTeXtish symlink $src -> $dest (special case)" - ;; - *) - test "x$src" != "x`(ls -ld $src | awk '{print $NF}') 2>/dev/null`" && - rm -f "$src" - - if test -f "$src"; then - case $silent in - true) - ;; - *) - errmsg "install_link $src -> $dest failed: file already exists." - ;; - esac - else - verbose_do ln -s "$dest" "$src" - fi - ;; - esac -} - -############################################################################### -# search_symlinkdir() -# look if $PATH has only symlinks to the real binaries and find that -# directory. Also check if this directory is writable. -############################################################################### -search_symlinkdir() -{ - kpsewhich=`check_for_binary kpsewhich` - test -z "$kpsewhich" && return 1 - symlinkdir=`echo $kpsewhich | sed 's@/*kpsewhich$@@'` - kpseaccess -w "$symlinkdir" || return 1 - touch "$symlinkdir/tl$$" - if test -f "$selfautoloc/tl$$"; then - rm -f "$symlinkdir/tl$$" - return 1 - else - rm -f "$symlinkdir/tl$$" - return 0 - fi -} - -############################################################################### -# upd_symlinkdir() -# if $PATH has only symlinks to the real binaries, update that directory -# that holds the symlinks -############################################################################### -upd_symlinkdir() -{ - search_symlinkdir || return 0 - for i in `sed 's@ .*@@' cnf_file_ln.$$`; do - install_link "$selfautoloc/$i" "$symlinkdir/$i" - done -} - -############################################################################### -# rm_link() -# Delete a previously installed link -############################################################################### -rm_link() -{ - link=$1; - if test -e $link; then - if test -h $link; then - verbose_do rm -Rf $link - else - verbose_echo "kept $link, since not a symlink" - fi - else - verbose_echo "skipped $link, non-existent" - fi -} - -############################################################################### -# main() -# parse commandline arguments, initialize variables, -# switch into temp. direcrory, execute desired command -############################################################################### -main() -{ - cnf_file= # global variable: full name of the config file - dirs= - needsCleanup=false - - exeext= - multiplatform=false - verbose=false - unlink=false - silent=false - thisdir=`pwd` - : ${KPSE_DOT=$thisdir}; export KPSE_DOT - selfautoloc=`kpsewhich --expand-var='$SELFAUTOLOC'` - while - case $1 in - --h*|-h) - echo "$usage"; exit 0;; - --version) - echo "$progname version $version"; exit 0;; - --cnffile|-f) - shift; cnf_file=$1;; - --e*|-e) shift; exeext=$1;; - --m*|-m) multiplatform=true;; - --s*|-s|--q*|-q) silent=true;; - --u*|-u) unlink=true;; - --v*|-v) verbose=true;; - -*) errmsg "fmtutil: unknown option \`$1' ignored.";; - *) break;; - esac - do test $# -gt 0 && shift; done - dirs="$*" - - # if no cnf_file from command-line, look it up with kpsewhich: - test -z "$cnf_file" && cnf_file=`kpsewhich --format='web2c files' $cnf` - test -f "$cnf_file" || abort "config file \`$cnf' not found" - - - tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/texlinks.$$ - setupTmpDir - cd "$tmpdir" || cleanup 1 - - sed '/^[ ]*#/d; /^[ ]*$/d' $cnf_file \ - | awk '{print $1, $2}' > cnf_file_ln.$$ - - if test -z "$dirs"; then - if test $multiplatform = true; then - case $selfautoloc in - */bin) dirs=$selfautoloc;; - *) parent=`kpsewhich --expand-var='$SELFAUTODIR'` - dirs=`find $parent -type f -name kpsewhich -print \ - | sed 's@/kpsewhich$@@'`;; - esac - else - dirs=$selfautoloc - fi - fi - - for d in $dirs; do - kpseaccess -w $d \ - || { errmsg "$d: no write permissions. Skipping..."; continue; } - # cnf_file_ln.$$ has lines with "format engine" pairs - set x `cat cnf_file_ln.$$`; shift - while test $# != 0; do - fmt=$1; engine=$2; shift; shift - - # Some broken shells destroy the positional arguments when calling a - # shellfunction. Therefore, we save and restore them "by hand" in the - # main_args_while variable. - main_args_while="$@" - - test "x$fmt" = "x$engine" && continue - if test -f "$d/$engine$exeext"; then - case $unlink in - true) - rm_link "$d/$fmt";; - *) - install_link "$engine" "$d/$fmt";; - esac - else - verbose_echo "skipped $d/$engine, engine does not exist" - fi - - # restore positional arguments: - set x $main_args_while; shift - - done - done - upd_symlinkdir -} - -main ${1+"$@"} - -# set successful return code -cleanup 0 diff --git a/Master/texmf-dist/scripts/tetex/updmap-sys.sh b/Master/texmf-dist/scripts/tetex/updmap-sys.sh deleted file mode 100755 index 6f3c8365658..00000000000 --- a/Master/texmf-dist/scripts/tetex/updmap-sys.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -# updmap-sys: Thomas Esser, public domain. - -# wrapper script for updmap with TEXMFVAR and TEXMFCONFIG set to -# TEXMFSYSVAR / TEXMFSYSCONFIG - -test -f /bin/ksh && test -z "$RUNNING_KSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ - && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } -unset RUNNING_KSH - -test -f /bin/bsh && test -z "$RUNNING_BSH" \ - && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ - && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } -unset RUNNING_BSH - -export PATH - -# hack around a bug in zsh: -test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' - -v=`kpsewhich -var-value TEXMFSYSVAR` -c=`kpsewhich -var-value TEXMFSYSCONFIG` - -TEXMFVAR="$v" -TEXMFCONFIG="$c" -export TEXMFVAR TEXMFCONFIG - -exec updmap ${1+"$@"} diff --git a/Master/texmf-dist/scripts/tetex/updmap.pl b/Master/texmf-dist/scripts/tetex/updmap.pl deleted file mode 100755 index c87e7d09b7f..00000000000 --- a/Master/texmf-dist/scripts/tetex/updmap.pl +++ /dev/null @@ -1,2306 +0,0 @@ -#!/usr/bin/env perl -# mupdmap: utility to maintain map files for outline fonts. -# $Id: updmap.pl 27264 2012-07-31 05:10:29Z preining $ -# -# Copyright 2011, 2012 Norbert Preining -# This file is licensed under the GNU General Public License version 2 -# or any later version. -# -# History: -# Original shell script (C) 2002 Thomas Esser -# first perl variant (C) Fabrice Popineau -# later adaptions by Reinhard Kotucha and Karl Berry -# the original versions were licensed under the following agreement: -# Anyone may freely use, modify, and/or distribute this file, without -# limitation. -# -# TODO -# - check all other invocations -# - after TL2012? Maybe remove support for reading updmap-local.cfg -# - -my $TEXMFROOT; - -BEGIN { - $^W=1; - $TEXMFROOT = `kpsewhich -var-value=TEXMFROOT`; - if ($?) { - print STDERR "updmap: Cannot find TEXMFROOT, aborting!\n"; - exit 1; - } - chomp($TEXMFROOT); - unshift (@INC, "$TEXMFROOT/tlpkg"); -} - - -my $version = '$Id: updmap.pl 27264 2012-07-31 05:10:29Z preining $'; - -use Getopt::Long qw(:config no_autoabbrev ignore_case_always); -use strict; -use TeXLive::TLUtils qw(mkdirhier mktexupd win32 basename dirname - sort_uniq member); - -#use Data::Dumper; -#$Data::Dumper::Indent = 1; - -(my $prg = basename($0)) =~ s/\.pl$//; - -# sudo sometimes does not reset the home dir of root, check on that -# see more comments at the definition of the function itself -# this function checks by itself whether it is running on windows or not -reset_root_home(); - -chomp(my $TEXMFMAIN = `kpsewhich --var-value=TEXMFMAIN`); -chomp(my $TEXMFVAR = `kpsewhich -var-value=TEXMFVAR`); -chomp(my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`); -chomp(my $TEXMFHOME = `kpsewhich -var-value=TEXMFHOME`); - -# make sure that on windows *everything* is in lower case for comparison -if (win32()) { - $TEXMFMAIN = lc($TEXMFMAIN); - $TEXMFVAR = lc($TEXMFVAR); - $TEXMFCONFIG = lc($TEXMFCONFIG); - $TEXMFROOT = lc($TEXMFROOT); - $TEXMFHOME = lc($TEXMFHOME); -} - - -my %opts = ( quiet => 0, nohash => 0, nomkmap => 0 ); -my $alldata; -my $updLSR; - -my @cmdline_options = ( - "listfiles", - "cnffile=s@", - "copy", - "disable=s@", - "dvipdfmoutputdir=s", - "dvipdfmxoutputdir=s", - "dvipsoutputdir=s", - # the following does not work, Getopt::Long looses the first - # entry in a multi setting, treat it separately in processOptions - # furthermore, it is not supported by older perls, so do it differently - #"enable=s{1,2}", - "edit", - "force", - "listavailablemaps", - "listmaps|l", - "nohash", - "nomkmap", - "dry-run|n", - "outputdir=s", - "pdftexoutputdir=s", - "pxdvioutputdir=s", - "quiet|silent|q", - # the following is a correct specification of an option according - # to the manual, but it does not work! - # we will treat that option by itself in processOptions - # furthermore, it is not supported by older perls, so do it differently - #"setoption=s@{1,2}", - "showoptions=s@", - "showoption=s@", - "syncwithtrees", - "version", - "help|h", - # some debugging invocations - "_readsave=s", - ); - -my %settings = ( - dvipsPreferOutline => { - type => "binary", - default => "true", - }, - LW35 => { - type => "string", - possible => [ qw/URW URWkb ADOBE ADOBEkb/ ], - default => "URWkb", - }, - dvipsDownloadBase35 => { - type => "binary", - default => "true", - }, - pdftexDownloadBase14 => { - type => "binary", - default => "true", - }, - dvipdfmDownloadBase14 => { - type => "binary", - default => "true", - }, - pxdviUse => { - type => "binary", - default => "false", - }, - kanjiEmbed => { - type => "any", - default => "noEmbed", - }, - kanjiVariant => { - type => "any", - default => "", - }, -); - -&main(); - -############### - -sub main { - processOptions(); - - help() if $opts{'help'}; - - if ($opts{'version'}) { - print version(); - exit (0); - } - - if ($opts{'dvipdfmoutputdir'} && !defined($opts{'dvipdfmxoutputdir'})) { - $opts{'dvipdfmxoutputdir'} = $opts{'dvipdfmoutputdir'}; - printf STDERR "Using --dvipdfmoutputdir options for dvipdfmx, but please use --dvipdfmxoutputdir\n"; - } - - if ($opts{'dvipdfmoutputdir'} && $opts{'dvipdfmxoutputdir'} && - $opts{'dvipdfmoutputdir'} ne $opts{'dvipdfmxoutputdir'}) { - printf STDERR "Options for --dvipdfmoutputdir and --dvipdfmxoutputdir do not agree\nplease use only --dvipdfmxoutputdir. Exiting.\n"; - exit(1); - } - - if ($opts{'_readsave'}) { - read_updmap_files($opts{'_readsave'}); - merge_settings_replace_kanji(); - print "READING DONE ============================\n"; - #print Dumper($alldata); - $alldata->{'updmap'}{$opts{'_readsave'}}{'changed'} = 1; - save_updmap($opts{'_readsave'}); - exit 0; - } - - if ($opts{'showoptions'}) { - for my $o (@{$opts{'showoptions'}}) { - if (defined($settings{$o})) { - if ($settings{$o}{'type'} eq "binary") { - print "true false\n"; - } elsif ($settings{$o}{'type'} eq "string") { - print "@{$settings{$o}{'possible'}}\n"; - } elsif ($settings{$o}{'type'} eq "any") { - print "(any string)\n"; - } else { - print "strange: unknown type of option $o\nplease report\n"; - } - } else { - print "$prg: unknown option: $o\n"; - } - } - exit 0; - } - - # config file for changes - my $changes_config_file; - - # determine which config files should be used - # replaces the former "setupCfgFile" - # - # we also determine here where changes will be saved to - if ($opts{'cnffile'}) { - my @tmp; - for my $f (@{$opts{'cnffile'}}) { - if (! -f $f) { - die "$prg: Config file \"$f\" not found."; - } - push @tmp, (win32() ? lc($f) : $f); - } - @{$opts{'cnffile'}} = @tmp; - # in case that config files are given on the command line, the first - # in the list is the one where changes will be written to. - ($changes_config_file) = @{$opts{'cnffile'}}; - } else { - my @all_files = `kpsewhich -all updmap.cfg`; - chomp(@all_files); - my @used_files; - for my $f (@all_files) { - push @used_files, (win32() ? lc($f) : $f); - } - # - my $TEXMFLOCALVAR; - my @TEXMFLOCAL; - if (win32()) { - chomp($TEXMFLOCALVAR =`kpsewhich --expand-path=\$TEXMFLOCAL`); - @TEXMFLOCAL = map { lc } split(/;/ , $TEXMFLOCALVAR); - } else { - chomp($TEXMFLOCALVAR =`kpsewhich --expand-path='\$TEXMFLOCAL'`); - @TEXMFLOCAL = split /:/ , $TEXMFLOCALVAR; - } - # - # search for TEXMFLOCAL/web2c/updmap.cfg - # check for compatibility with old updmap-local.cfg - my @tmlused; - for my $tml (@TEXMFLOCAL) { - my $TMLabs = Cwd::abs_path($tml); - next if (!$TMLabs); - my $oldfound = 0; - if (-r "$TMLabs/web2c/updmap-local.cfg") { - push @tmlused, "$TMLabs/web2c/updmap-local.cfg"; - warning("Old configuration file\n $TMLabs/web2c/updmap-local.cfg\nfound! "); - $oldfound = 1; - } - if (-r "$TMLabs/web2c/updmap.cfg") { - if ($oldfound) { - warning("Will read it *instead* of\n $TMLabs/web2c/updmap.cfg\n"); - } else { - push @tmlused, "$TMLabs/web2c/updmap.cfg"; - } - } - warning("Please consider moving the information from updmap-local.cfg to\n $TMLabs/web2c/updmap.cfg\n") - if ($oldfound); - } - # - # reorder used files: we move TEXMFLOCAL (if used) just above TEXMFMAIN - # as sysadmins will probably adjust values there - # - # updmap (user): - # ============== - # as found: - # TEXMFCONFIG $HOME/.texliveYYYY/texmf-config/web2c/updmap.cfg - # TEXMFVAR $HOME/.texliveYYYY/texmf-var/web2c/updmap.cfg - # TEXMFHOME $HOME/texmf/web2c/updmap.cfg - # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg - # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg - # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg - # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg - # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg - # - # as used: - # TEXMFCONFIG $HOME/.texliveYYYY/texmf-config/web2c/updmap.cfg - # TEXMFVAR $HOME/.texliveYYYY/texmf-var/web2c/updmap.cfg - # TEXMFHOME $HOME/texmf/web2c/updmap.cfg - # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg - # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg - # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg - # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg - # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg - # - # updmap-sys (root): - # ================== - # as found: - # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg - # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg - # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg - # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg - # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg - # - # as used: - # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg - # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg - # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg - # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg - # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg - # - if (@tmlused) { - my @tmp; - for my $f (@used_files) { - if ($f =~ m!\Q$TEXMFMAIN/\E!) { - push @tmp, @tmlused; - push @tmp, $f; - } else { - my $pushit = 1; - for my $tml (@TEXMFLOCAL) { - if ($f =~ m!\Q$tml\E!) { - $pushit = 0; - last; - } - } - push @tmp, $f if ($pushit); - } - } - @used_files = @tmp; - } - @{$opts{'cnffile'}} = @used_files; - # - # determine the config file that we will use for changes - # if in the list of used files contains either one from - # TEXMFHOME or TEXMFCONFIG (which is TEXMFSYSCONFIG in the -sys case) - # then use the *top* file (which will be either one of the two), - # if none of the two exists, create a file in TEXMFCONFIG and use it - my $use_top = 0; - for my $f (@used_files) { - if ($f =~ m!(\Q$TEXMFHOME\E|\Q$TEXMFCONFIG\E)/web2c/updmap.cfg!) { - $use_top = 1; - last; - } - } - if ($use_top) { - ($changes_config_file) = @used_files; - } else { - # add the empty config file - my $dn = "$TEXMFCONFIG/web2c"; - $changes_config_file = "$dn/updmap.cfg"; - } - } - if (!$opts{'quiet'}) { - print "$prg is using the following updmap.cfg files (in precedence order):\n"; - for my $f (@{$opts{'cnffile'}}) { - print " $f\n"; - } - print "$prg is using the following updmap.cfg file for writing changes:\n"; - print " $changes_config_file\n"; - } - if ($opts{'listfiles'}) { - # we listed it above, so be done - exit 0; - } - - $alldata->{'changes_config'} = $changes_config_file; - - read_updmap_files(@{$opts{'cnffile'}}); - - if ($opts{'showoption'}) { - merge_settings_replace_kanji(); - for my $o (@{$opts{'showoption'}}) { - if (defined($settings{$o})) { - my ($v, $vo) = get_cfg($o); - $v = "\"$v\"" if ($v =~ m/\s/); - print "$o=$v ($vo)\n"; - } else { - printf STDERR "$prg: unknown option: $o\n"; - } - } - exit 0; - } - - if ($opts{'listmaps'}) { - merge_settings_replace_kanji(); - for my $m (keys %{$alldata->{'maps'}}) { - my $origin = $alldata->{'maps'}{$m}{'origin'}; - print $alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'}, " $m ", - $alldata->{'updmap'}{$origin}{'maps'}{$m}{'status'}, " in $origin\n"; - } - exit 0; - } - - # we do changes always in the used config file with the highest - # priority - my $bakFile = $changes_config_file; - $bakFile =~ s/\.cfg$/.bak/; - my $changed = 0; - - if ($opts{'syncwithtrees'}) { - merge_settings_replace_kanji(); - my @missing = read_map_files(); - if (@missing) { - print "Missing map files found, disabling\n"; - for my $m (@missing) { - my $orig = $alldata->{'maps'}{$m}{'origin'}; - print "\t$m (in $orig)\n"; - } - print "in $changes_config_file\n"; - print "Do you really want to continue (y/N)? "; - my $answer = ; - $answer = "n" if !defined($answer); - chomp($answer); - print "answer =$answer=\n"; - if ($answer ne "y" && $answer ne "Y") { - print "Please fix manually before running updmap(-sys) again!\n"; - exit 0; - } - $changed ||= enable_disable_maps(@missing); - print "finished.\n"; - # the original script did not run any update of the map files here, - # should we do that? - } - exit 0; - } - - $updLSR = &mktexupd(); - $updLSR->{mustexist}(0); - - my $cmd; - if ($opts{'edit'}) { - if ($opts{"dry-run"}) { - printf STDERR "No, are you joking, you want to edit with --dry-run?\n"; - exit 1; - } - # it's not a good idea to edit updmap.cfg manually these days, - # but for compatibility we'll silently keep the option. - $cmd = 'edit'; - my $editor = $ENV{'VISUAL'} || $ENV{'EDITOR'}; - $editor ||= (&win32 ? "notepad" : "vi"); - if (-r $changes_config_file) { - ©File($changes_config_file, $bakFile); - } else { - touch($bakFile); - touch($changes_config_file); - } - system($editor, $changes_config_file); - $changed = files_are_different($bakFile, $changes_config_file); - } elsif ($opts{'setoption'}) { - $cmd = 'setOption'; - $changed = setOptions (@{$opts{'setoption'}}); - } elsif ($opts{'enable'} || $opts{'disable'}) { - $cmd = 'enableMap'; - $changed ||= enable_disable_maps(@{$opts{'enable'}}, @{$opts{'disable'}}); - } - - - if ($cmd && !$opts{'force'} && !$changed) { - print "$changes_config_file unchanged. Map files not recreated.\n" - if !$opts{'quiet'}; - } else { - if (!$opts{'nomkmap'}) { - # before we continue we have to make sure that a newly created config - # file is acually used. So we have to push the $changes_config_file - # onto the list of available files. Since it is already properly - # initialized and the merging is done later, all settings should be - # honored - my @aaa = @{$alldata->{'order'}}; - unshift @aaa, $changes_config_file; - $alldata->{'order'} = [ @aaa ]; - # - setupOutputDir("dvips"); - setupOutputDir("pdftex"); - setupOutputDir("dvipdfmx"); - setupOutputDir("pxdvi"); - merge_settings_replace_kanji(); - my @missing = read_map_files(); - if (@missing) { - print STDERR "\nERROR: The following map file(s) couldn't be found:\n"; - for my $m (@missing) { - my $orig = $alldata->{'maps'}{$m}{'origin'}; - print STDERR "\t$m (in $orig)\n"; - } - print STDERR "\n\tDid you run mktexlsr?\n\n" . - "\tYou can disable non-existent map entries using the option\n". - "\t --syncwithtrees.\n\n"; - exit 1; - } - merge_data(); - # for inspecting the output - #print STDERR Data::Dumper->Dump([$alldata], [qw(mapdata)]); - #print Dumper($alldata); - mkMaps(); - } - unlink ($bakFile) if (-r $bakFile); - } - - if (!$opts{'nohash'}) { - print "$prg: Updating ls-R files.\n" if !$opts{'quiet'}; - $updLSR->{exec}() unless $opts{"dry-run"}; - } - - return 0; -} - -################################################################## -# -# - -sub getFonts { - my ($first, @rest) = @_; - my $getall = 0; - my @maps = (); - return if !defined($first); - if ($first eq "-all") { - $getall = 1; - @maps = @rest; - } else { - @maps = ($first, @rest); - } - my @lines = (); - for my $m (@maps) { - if (defined($alldata->{'maps'}{$m})) { - print LOG "\n" . $alldata->{'maps'}{$m}{'fullpath'} . ":\n" unless $opts{'dry-run'}; - push @lines, "% $m"; - for my $k (sort keys %{$alldata->{'maps'}{$m}{'fonts'}}) { - if ($getall || $alldata->{'fonts'}{$k}{'origin'} eq $m) { - if (defined($alldata->{'maps'}{$m}{'fonts'}{$k})) { - push @lines, "$k " . $alldata->{'maps'}{$m}{'fonts'}{$k}; - } else { - print "undefined fonts for $k in $m ?!?!?\n"; - } - print LOG "$k\n" unless $opts{'dry-run'}; - } - } - } - } - chomp @lines; - return @lines; -} - -############################################################################### -# writeLines() -# write the lines in $filename -# -sub writeLines { - my ($fname, @lines) = @_; - return if $opts{"dry-run"}; - map { ($_ !~ m/\n$/ ? s/$/\n/ : $_ ) } @lines; - open FILE, ">$fname" or die "$prg: can't write lines to $fname: $!"; - print FILE @lines; - close FILE; -} - -############################################################################### -# to_pdftex() -# if $pdftexStripEnc is set, strip "PS_Encoding_Name ReEncodeFont" -# from map entries; they are ignored by pdftex. But since the sh -# incarnation of updmap included them, and we want to minimize -# differences, this is not done by default. -# -sub to_pdftex { - my $pdftexStripEnc = 0; - return @_ unless $pdftexStripEnc; - my @in = @_; - my @out; - foreach my $line (@in) { - if ($line =~ /^(.*\s+)(\S+\s+ReEncodeFont\s)(.*)/) { - $line = "$1$3"; - $line =~ s/\s+\"\s+\"\s+/ /; - } - push @out, $line; - } - return @out; -} - -############################################################################### -# setupSymlinks() -# set symlink for psfonts.map according to dvipsPreferOutline variable -# -sub setupSymlinks { - my ($dvipsPreferOutline, $dvipsoutputdir, $pdftexDownloadBase14, $pdftexoutputdir) = @_; - my $src; - my %link; - my @link; - - if ($dvipsPreferOutline eq "true") { - $src = "psfonts_t1.map"; - } else { - $src = "psfonts_pk.map"; - } - unlink "$dvipsoutputdir/psfonts.map" unless $opts{"dry-run"}; - push @link, &SymlinkOrCopy("$dvipsoutputdir", "$src", "psfonts.map"); - - if ($pdftexDownloadBase14 eq "true") { - $src = "pdftex_dl14.map"; - } else { - $src = "pdftex_ndl14.map"; - } - unlink "$pdftexoutputdir/pdftex.map" unless $opts{"dry-run"}; - push @link, &SymlinkOrCopy("$pdftexoutputdir", "$src", "pdftex.map"); - %link = @link; - return \%link; -} - -############################################################################### -# SymlinkOrCopy(dir, src, dest) -# create symlinks if possible, otherwise copy files -# -sub SymlinkOrCopy { - my ($dir, $src, $dest) = @_; - return ($src, $dest) if $opts{"dry-run"}; - if (&win32 || $opts{'copy'}) { # always copy - ©File("$dir/$src", "$dir/$dest"); - } else { # symlink if supported by fs, copy otherwise - system("cd \"$dir\" && ln -s $src $dest 2>/dev/null || " - . "cp -p \"$dir/$src\" \"$dir/$dest\""); - } - # remember for "Files generated" in &mkMaps. - return ($dest, $src); -} - - -############################################################################### -# transLW35(mode args ...) -# transform fontname and filenames according to transformation specified -# by mode. Possible values: -# URW|URWkb|ADOBE|ADOBEkb -# -sub transLW35 { - my ($mode, @lines) = @_; - - my @psADOBE = ( - 's/ URWGothicL-Demi / AvantGarde-Demi /', - 's/ URWGothicL-DemiObli / AvantGarde-DemiOblique /', - 's/ URWGothicL-Book / AvantGarde-Book /', - 's/ URWGothicL-BookObli / AvantGarde-BookOblique /', - 's/ URWBookmanL-DemiBold / Bookman-Demi /', - 's/ URWBookmanL-DemiBoldItal / Bookman-DemiItalic /', - 's/ URWBookmanL-Ligh / Bookman-Light /', - 's/ URWBookmanL-LighItal / Bookman-LightItalic /', - 's/ NimbusMonL-Bold / Courier-Bold /', - 's/ NimbusMonL-BoldObli / Courier-BoldOblique /', - 's/ NimbusMonL-Regu / Courier /', - 's/ NimbusMonL-ReguObli / Courier-Oblique /', - 's/ NimbusSanL-Bold / Helvetica-Bold /', - 's/ NimbusSanL-BoldCond / Helvetica-Narrow-Bold /', - 's/ NimbusSanL-BoldItal / Helvetica-BoldOblique /', - 's/ NimbusSanL-BoldCondItal / Helvetica-Narrow-BoldOblique /', - 's/ NimbusSanL-Regu / Helvetica /', - 's/ NimbusSanL-ReguCond / Helvetica-Narrow /', - 's/ NimbusSanL-ReguItal / Helvetica-Oblique /', - 's/ NimbusSanL-ReguCondItal / Helvetica-Narrow-Oblique /', - 's/ CenturySchL-Bold / NewCenturySchlbk-Bold /', - 's/ CenturySchL-BoldItal / NewCenturySchlbk-BoldItalic /', - 's/ CenturySchL-Roma / NewCenturySchlbk-Roman /', - 's/ CenturySchL-Ital / NewCenturySchlbk-Italic /', - 's/ URWPalladioL-Bold / Palatino-Bold /', - 's/ URWPalladioL-BoldItal / Palatino-BoldItalic /', - 's/ URWPalladioL-Roma / Palatino-Roman /', - 's/ URWPalladioL-Ital / Palatino-Italic /', - 's/ StandardSymL / Symbol /', - 's/ NimbusRomNo9L-Medi / Times-Bold /', - 's/ NimbusRomNo9L-MediItal / Times-BoldItalic /', - 's/ NimbusRomNo9L-Regu / Times-Roman /', - 's/ NimbusRomNo9L-ReguItal / Times-Italic /', - 's/ URWChanceryL-MediItal / ZapfChancery-MediumItalic /', - 's/ Dingbats / ZapfDingbats /', - ); - - my @fileADOBEkb = ( - 's/\buagd8a.pfb\b/pagd8a.pfb/', - 's/\buagdo8a.pfb\b/pagdo8a.pfb/', - 's/\buagk8a.pfb\b/pagk8a.pfb/', - 's/\buagko8a.pfb\b/pagko8a.pfb/', - 's/\bubkd8a.pfb\b/pbkd8a.pfb/', - 's/\bubkdi8a.pfb\b/pbkdi8a.pfb/', - 's/\bubkl8a.pfb\b/pbkl8a.pfb/', - 's/\bubkli8a.pfb\b/pbkli8a.pfb/', - 's/\bucrb8a.pfb\b/pcrb8a.pfb/', - 's/\bucrbo8a.pfb\b/pcrbo8a.pfb/', - 's/\bucrr8a.pfb\b/pcrr8a.pfb/', - 's/\bucrro8a.pfb\b/pcrro8a.pfb/', - 's/\buhvb8a.pfb\b/phvb8a.pfb/', - 's/\buhvb8ac.pfb\b/phvb8an.pfb/', - 's/\buhvbo8a.pfb\b/phvbo8a.pfb/', - 's/\buhvbo8ac.pfb\b/phvbo8an.pfb/', - 's/\buhvr8a.pfb\b/phvr8a.pfb/', - 's/\buhvr8ac.pfb\b/phvr8an.pfb/', - 's/\buhvro8a.pfb\b/phvro8a.pfb/', - 's/\buhvro8ac.pfb\b/phvro8an.pfb/', - 's/\buncb8a.pfb\b/pncb8a.pfb/', - 's/\buncbi8a.pfb\b/pncbi8a.pfb/', - 's/\buncr8a.pfb\b/pncr8a.pfb/', - 's/\buncri8a.pfb\b/pncri8a.pfb/', - 's/\buplb8a.pfb\b/pplb8a.pfb/', - 's/\buplbi8a.pfb\b/pplbi8a.pfb/', - 's/\buplr8a.pfb\b/pplr8a.pfb/', - 's/\buplri8a.pfb\b/pplri8a.pfb/', - 's/\busyr.pfb\b/psyr.pfb/', - 's/\butmb8a.pfb\b/ptmb8a.pfb/', - 's/\butmbi8a.pfb\b/ptmbi8a.pfb/', - 's/\butmr8a.pfb\b/ptmr8a.pfb/', - 's/\butmri8a.pfb\b/ptmri8a.pfb/', - 's/\buzcmi8a.pfb\b/pzcmi8a.pfb/', - 's/\buzdr.pfb\b/pzdr.pfb/', - ); - - my @fileURW = ( - 's/\buagd8a.pfb\b/a010015l.pfb/', - 's/\buagdo8a.pfb\b/a010035l.pfb/', - 's/\buagk8a.pfb\b/a010013l.pfb/', - 's/\buagko8a.pfb\b/a010033l.pfb/', - 's/\bubkd8a.pfb\b/b018015l.pfb/', - 's/\bubkdi8a.pfb\b/b018035l.pfb/', - 's/\bubkl8a.pfb\b/b018012l.pfb/', - 's/\bubkli8a.pfb\b/b018032l.pfb/', - 's/\bucrb8a.pfb\b/n022004l.pfb/', - 's/\bucrbo8a.pfb\b/n022024l.pfb/', - 's/\bucrr8a.pfb\b/n022003l.pfb/', - 's/\bucrro8a.pfb\b/n022023l.pfb/', - 's/\buhvb8a.pfb\b/n019004l.pfb/', - 's/\buhvb8ac.pfb\b/n019044l.pfb/', - 's/\buhvbo8a.pfb\b/n019024l.pfb/', - 's/\buhvbo8ac.pfb\b/n019064l.pfb/', - 's/\buhvr8a.pfb\b/n019003l.pfb/', - 's/\buhvr8ac.pfb\b/n019043l.pfb/', - 's/\buhvro8a.pfb\b/n019023l.pfb/', - 's/\buhvro8ac.pfb\b/n019063l.pfb/', - 's/\buncb8a.pfb\b/c059016l.pfb/', - 's/\buncbi8a.pfb\b/c059036l.pfb/', - 's/\buncr8a.pfb\b/c059013l.pfb/', - 's/\buncri8a.pfb\b/c059033l.pfb/', - 's/\buplb8a.pfb\b/p052004l.pfb/', - 's/\buplbi8a.pfb\b/p052024l.pfb/', - 's/\buplr8a.pfb\b/p052003l.pfb/', - 's/\buplri8a.pfb\b/p052023l.pfb/', - 's/\busyr.pfb\b/s050000l.pfb/', - 's/\butmb8a.pfb\b/n021004l.pfb/', - 's/\butmbi8a.pfb\b/n021024l.pfb/', - 's/\butmr8a.pfb\b/n021003l.pfb/', - 's/\butmri8a.pfb\b/n021023l.pfb/', - 's/\buzcmi8a.pfb\b/z003034l.pfb/', - 's/\buzdr.pfb\b/d050000l.pfb/', - ); - - my @fileADOBE = ( - 's/\buagd8a.pfb\b/agd_____.pfb/', - 's/\buagdo8a.pfb\b/agdo____.pfb/', - 's/\buagk8a.pfb\b/agw_____.pfb/', - 's/\buagko8a.pfb\b/agwo____.pfb/', - 's/\bubkd8a.pfb\b/bkd_____.pfb/', - 's/\bubkdi8a.pfb\b/bkdi____.pfb/', - 's/\bubkl8a.pfb\b/bkl_____.pfb/', - 's/\bubkli8a.pfb\b/bkli____.pfb/', - 's/\bucrb8a.pfb\b/cob_____.pfb/', - 's/\bucrbo8a.pfb\b/cobo____.pfb/', - 's/\bucrr8a.pfb\b/com_____.pfb/', - 's/\bucrro8a.pfb\b/coo_____.pfb/', - 's/\buhvb8a.pfb\b/hvb_____.pfb/', - 's/\buhvb8ac.pfb\b/hvnb____.pfb/', - 's/\buhvbo8a.pfb\b/hvbo____.pfb/', - 's/\buhvbo8ac.pfb\b/hvnbo___.pfb/', - 's/\buhvr8a.pfb\b/hv______.pfb/', - 's/\buhvr8ac.pfb\b/hvn_____.pfb/', - 's/\buhvro8a.pfb\b/hvo_____.pfb/', - 's/\buhvro8ac.pfb\b/hvno____.pfb/', - 's/\buncb8a.pfb\b/ncb_____.pfb/', - 's/\buncbi8a.pfb\b/ncbi____.pfb/', - 's/\buncr8a.pfb\b/ncr_____.pfb/', - 's/\buncri8a.pfb\b/nci_____.pfb/', - 's/\buplb8a.pfb\b/pob_____.pfb/', - 's/\buplbi8a.pfb\b/pobi____.pfb/', - 's/\buplr8a.pfb\b/por_____.pfb/', - 's/\buplri8a.pfb\b/poi_____.pfb/', - 's/\busyr.pfb\b/sy______.pfb/', - 's/\butmb8a.pfb\b/tib_____.pfb/', - 's/\butmbi8a.pfb\b/tibi____.pfb/', - 's/\butmr8a.pfb\b/tir_____.pfb/', - 's/\butmri8a.pfb\b/tii_____.pfb/', - 's/\buzcmi8a.pfb\b/zcmi____.pfb/', - 's/\buzdr.pfb\b/zd______.pfb/', - ); - - if ($mode eq "" || $mode eq "URWkb") { - # do nothing - } elsif ($mode eq "URW") { - for my $r (@fileURW) { - map { eval($r); } @lines; - } - } elsif ($mode eq "ADOBE" || $mode eq "ADOBEkb") { - for my $r (@psADOBE) { - map { eval($r); } @lines; - } - my @filemode = eval ("\@file" . $mode); - for my $r (@filemode) { - map { eval($r); } @lines; - } - } - return @lines; -} - -############################################################################### -# cidx2dvips() -# reads from stdin, writes to stdout. It transforms "cid-x"-like syntax into -# "dvips"-like syntax. -# -# Specifying the PS Name: -# dvips needs the PSname instead of the file name. Thus we allow specifying -# the PSname in the comment: -# The PS Name can be specified in the font definition line -# by including the following sequence somewhere after the -# other components: -# -# %!PS -# -# where -# is either a space or a tab character -# is *one* word, defined by \w\w* perl re -# is a non-\w char or the end of line -# -# That means we could have -# ... %here the PS font name: %!PS fontname some other comment -# ... %!PS fontname %other comments -# ... %!PS fontname -# -############################################################################### - -# reimplementation of the cryptic code that was there before -sub cidx2dvips { - my ($s) = @_; - my %fname_psname = ( - # Morisawa - 'A-OTF-FutoGoB101Pr6N-Bold' => 'FutoGoB101Pr6N-Bold', - 'A-OTF-FutoGoB101Pro-Bold' => 'FutoGoB101Pro-Bold', - 'A-OTF-FutoMinA101Pr6N-Bold' => 'FutoMinA101Pr6N-Bold', - 'A-OTF-FutoMinA101Pro-Bold' => 'FutoMinA101Pro-Bold', - 'A-OTF-GothicBBBPr6N-Medium' => 'GothicBBBPr6N-Medium', - 'A-OTF-GothicBBBPro-Medium' => 'GothicBBBPro-Medium', - 'A-OTF-Jun101Pr6N-Light' => 'Jun101Pr6N-Light', - 'A-OTF-Jun101Pro-Light' => 'Jun101Pro-Light', - 'A-OTF-MidashiGoPr6N-MB31' => 'MidashiGoPr6N-MB31', - 'A-OTF-MidashiGoPro-MB31' => 'MidashiGoPro-MB31', - 'A-OTF-RyuminPr6N-Light' => 'RyuminPr6N-Light', - 'A-OTF-RyuminPro-Light' => 'RyuminPro-Light', - # Hiragino font file names and PS names are the same - # - # IPA - 'ipaexg' => 'IPAexGothic', - 'ipaexm' => 'IPAexMincho', - 'ipag' => 'IPAGothic', - 'ipam' => 'IPAMincho', - # - # Kozuka font names and PS names are the same - ); - my @d; - foreach (@$s) { - # ship empty lines and comment lines out as is - if (m/^\s*(%.*)?$/) { - push(@d, $_); - next; - } - # get rid of new lines for now - chomp; - # save the line for warnings - my $l = $_; - # first check whether a PSname is given - my $psname; - # - # the matching on \w* is greedy, so will take all the word chars available - # that means we do not need to test for end of word - if ($_ =~ m/%!PS\s\s*([0-9A-Za-z-_][0-9A-Za-z-_]*)/) { - $psname = $1; - } - # remove comments - s/[^0-9A-Za-z-_]*%.*$//; - # replace supported ",SOMETHING" constructs - my $italicmax = 0; - if (m/,BoldItalic/) { - $italicmax = .3; - s/,BoldItalic//; - } - s/,Bold//; - if (m/,Italic/) { - $italicmax = .3; - s/,Italic//; - } - # break out if unsupported constructs are found: @ / , - next if (m![\@/,]!); - # make everything single spaced - s/\s\s*/ /g; - # unicode encoded fonts are not supported - next if (m!^\w\w* unicode !); - # now we have the following format - # some options like -e or -s - if ($_ !~ m/([^ ][^ ]*) ([^ ][^ ]*) ([^ ][^ ]*)( (.*))?$/) { - print STDERR "cidx2dvips warning: Cannot translate font line:\n==> $l\n"; - print STDERR "Current translation status: ==>$_==\n"; - next; - } - my $tfmname = $1; - my $cid = $2; - my $fname = $3; - my $opts = (defined($5) ? " $5" : ""); - # remove extensions from $fname - $fname =~ s/\.[Oo][Tt][Ff]//; - $fname =~ s/\.[Tt][Tt][FfCc]//; - # remove leading ! from $fname - $fname =~ s/^!//; - # remove leading :: from $fname - $fname =~ s/:[0-9]+://; - # remove leading space from $opt - $opts =~ s/^\s+//; - # replace -e and -s in the options - $opts =~ s/-e ([.0-9-][.0-9-]*)/ "$1 ExtendFont"/; - if (m/-s ([.0-9-][.0-9-]*)/) { - if ($italicmax > 0) { - # we have already a definition of SlantFont via ,Italic or ,BoldItalic - # warn the user that larger one is kept - print STDERR "cidx2dvips: warning: Double slant specified via Italic and -s:\n==> $l\n==> Using only the biggest slant value.\n"; - } - $italicmax = $1 if ($1 > $italicmax); - $opts =~ s/-s ([.0-9-][.0-9-]*)//; - } - if ($italicmax != 0) { - $opts .= " \"$italicmax SlantFont\""; - } - # print out the result - if (defined($psname)) { - push @d, "$tfmname $psname-$cid$opts\n"; - } else { - if (defined($fname_psname{$fname})) { - push @d, "$tfmname $fname_psname{$fname}-$cid$opts\n"; - } else { - push @d, "$tfmname $fname-$cid$opts\n"; - } - } - } - return @d; -} - -sub cidx2dvips_old { - my ($s) = @_; - my @d; - foreach (@$s) { - if (m/^%/) { - push(@d, $_); - next; - } - s/,BoldItalic/ -s .3/; - s/,Bold//; - s/,Italic/ -s .3/; - s/\s\s*/ /g; - if ($_ =~ /.*[@\:\/,]/) {next;} - elsif ($_ =~ /^[^ ][^ ]* unicode /) {next;} - s/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)\.[Oo][Tt][Ff]/$1/; - s/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)\.[Tt][Tt][FfCc]/$1/; - s/$/ %/; - s/^(([^ ]*).*)/$1$2/; - s/^([^ ][^ ]* ([^ ][^ ]*) !*([^ ][^ ]*).*)/$1 $3-$2/; - s/^(.* -e ([.0-9-][.0-9-]*).*)/$1 "$2 ExtendFont"/; - s/^(.* -s ([.0-9-][.0-9-]*).*)/$1 "$2 SlantFont"/; - s/.*%//; - push(@d, $_); - } - return @d -} - -sub get_cfg { - my ($v) = @_; - if (defined($alldata->{'merged'}{'setting'}{$v})) { - return ( $alldata->{'merged'}{'setting'}{$v}{'val'}, - $alldata->{'merged'}{'setting'}{$v}{'origin'} ); - } else { - return ($settings{$v}{'default'}, "default"); - } -} - -sub mkMaps { - my $logfile; - - $logfile = "$TEXMFVAR/web2c/updmap.log"; - - if (! $opts{'dry-run'}) { - mkdirhier("$TEXMFVAR/web2c"); - open LOG, ">$logfile" - or die "$prg: Can't open log file \"$logfile\": $!"; - print LOG &version(); - printf LOG "%s\n\n", scalar localtime(); - print LOG "Using the following config files:\n"; - for (@{$opts{'cnffile'}}) { - print LOG " $_\n"; - } - } - sub print_and_log { - my $str=shift; - print $str if !$opts{'quiet'}; - print LOG $str unless $opts{'dry-run'}; - } - sub only_log { - print LOG shift unless $opts{'dry-run'}; - } - - my ($mode, $mode_origin) = get_cfg('LW35'); - my ($dvipsPreferOutline, $dvipsPreferOutline_origin) = - get_cfg('dvipsPreferOutline'); - my ($dvipsDownloadBase35, $dvipsDownloadBase35_origin) = - get_cfg('dvipsDownloadBase35'); - my ($pdftexDownloadBase14, $pdftexDownloadBase14_origin) = - get_cfg('pdftexDownloadBase14'); - my ($pxdviUse, $pxdviUse_origin) = get_cfg('pxdviUse'); - my ($kanjiEmbed, $kanjiEmbed_origin) = get_cfg('kanjiEmbed'); - my ($kanjiVariant, $kanjiVariant_origin) = get_cfg('kanjiVariant'); - - print_and_log ("\n$prg is creating new map files" - . "\nusing the following configuration:" - . "\n LW35 font names : " - . "$mode ($mode_origin)" - . "\n prefer outlines : " - . "$dvipsPreferOutline ($dvipsPreferOutline_origin)" - . "\n texhash enabled : " - . ($opts{'nohash'} ? "false" : "true") - . "\n download standard fonts (dvips) : " - . "$dvipsDownloadBase35 ($dvipsDownloadBase35_origin)" - . "\n download standard fonts (pdftex) : " - . "$pdftexDownloadBase14 ($pdftexDownloadBase14_origin)" - . "\n kanjiEmbed replacement string : " - . "$kanjiEmbed ($kanjiEmbed_origin)" - . "\n kanjiVariant replacement string : " - . "$kanjiVariant ($kanjiVariant_origin)" - . "\n create a mapfile for pxdvi : " - . "$pxdviUse ($pxdviUse_origin)" - . "\n\n"); - - print_and_log ("Scanning for LW35 support files"); - my $dvips35 = $alldata->{'maps'}{"dvips35.map"}{'fullpath'}; - my $pdftex35 = $alldata->{'maps'}{"pdftex35.map"}{'fullpath'}; - my $ps2pk35 = $alldata->{'maps'}{"ps2pk35.map"}{'fullpath'}; - my $LW35 = "\n$dvips35\n$pdftex35\n$ps2pk35\n\n"; - only_log ("\n"); - only_log ($LW35); - print_and_log (" [ 3 files]\n"); - only_log ("\n"); - - print_and_log ("Scanning for MixedMap entries"); - my @mixedmaps; - my @notmixedmaps; - my @kanjimaps; - for my $m (keys %{$alldata->{'maps'}}) { - my $origin = $alldata->{'maps'}{$m}{'origin'}; - next if !defined($origin); - next if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'status'} eq "disabled"); - push @mixedmaps, $m - if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "MixedMap"); - push @notmixedmaps, $m - if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "Map"); - push @kanjimaps, $m - if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "KanjiMap"); - } - - @mixedmaps = sort @mixedmaps; - @notmixedmaps = sort @notmixedmaps; - @kanjimaps = sort @kanjimaps; - only_log("\n"); - foreach my $m (sort @mixedmaps) { - if (defined($alldata->{'maps'}{$m}{'fullpath'})) { - only_log($alldata->{'maps'}{$m}{'fullpath'} . "\n"); - } else { - only_log("$m (full path not set?)\n"); - } - } - only_log("\n"); - print_and_log (sprintf(" [%3d files]\n", scalar @mixedmaps)); - only_log("\n"); - - print_and_log ("Scanning for KanjiMap entries"); - only_log("\n"); - foreach my $m (@kanjimaps) { - if (defined($alldata->{'maps'}{$m}{'fullpath'})) { - only_log($alldata->{'maps'}{$m}{'fullpath'} . "\n"); - } else { - only_log("$m (full path not set?)\n"); - } - } - only_log("\n"); - print_and_log (sprintf(" [%3d files]\n", scalar @kanjimaps)); - only_log("\n"); - - print_and_log ("Scanning for Map entries"); - only_log("\n"); - foreach my $m (@notmixedmaps) { - if (defined($alldata->{'maps'}{$m}{'fullpath'})) { - only_log($alldata->{'maps'}{$m}{'fullpath'} . "\n"); - } else { - only_log("$m (full path not set?)\n"); - } - } - only_log("\n"); - print_and_log (sprintf(" [%3d files]\n\n", scalar @notmixedmaps)); - only_log("\n"); - - # Create psfonts_t1.map, psfonts_pk.map, ps2pk.map and pdftex.map: - my $dvipsoutputdir = $opts{'dvipsoutputdir'}; - my $pdftexoutputdir = $opts{'pdftexoutputdir'}; - my $dvipdfmxoutputdir = $opts{'dvipdfmxoutputdir'}; - my $pxdvioutputdir = $opts{'pxdvioutputdir'}; - if (!$opts{'dry-run'}) { - my @managed_files = ("$dvipsoutputdir/download35.map", - "$dvipsoutputdir/builtin35.map", - "$dvipsoutputdir/psfonts_t1.map", - "$dvipsoutputdir/psfonts_pk.map", - "$pdftexoutputdir/pdftex_dl14.map", - "$pdftexoutputdir/pdftex_ndl14.map", - "$dvipdfmxoutputdir/kanjix.map", - "$dvipsoutputdir/ps2pk.map"); - push @managed_files, "$pxdvioutputdir/xdvi-ptex.map" - if ($pxdviUse eq "true"); - for my $file (@managed_files) { - open FILE, ">$file"; - print FILE "% $file:\ -% maintained by updmap[-sys] (multi).\ -% Don't change this file directly. Use updmap[-sys] instead.\ -% See the updmap documentation.\ -% A log of the run that created this file is available here:\ -% $logfile\ -"; - close FILE; - } - } - - my @kanjimaps_fonts = getFonts(@kanjimaps); - @kanjimaps_fonts = &normalizeLines(@kanjimaps_fonts); - my @ps2pk_fonts = getFonts('-all', "ps2pk35.map"); - my @dvips35_fonts = getFonts('-all', "dvips35.map"); - my @pdftex35_fonts = getFonts('-all', "pdftex35.map"); - my @mixedmaps_fonts = getFonts(@mixedmaps); - my @notmixedmaps_fonts = getFonts(@notmixedmaps); - - print "Generating output for dvipdfmx...\n" if !$opts{'quiet'}; - &writeLines(">$dvipdfmxoutputdir/kanjix.map", @kanjimaps_fonts); - - if ($pxdviUse eq "true") { - # we use the very same data as for kanjix.map, but generate - # a different file, so that in case a user wants to hand-craft it - print "Generating output for pxdvi...\n" if !$opts{'quiet'}; - &writeLines(">$pxdvioutputdir/xdvi-ptex.map", @kanjimaps_fonts); - } - - - print "Generating output for ps2pk...\n" if !$opts{'quiet'}; - my @ps2pk_map; - push @ps2pk_map, "% ps2pk35.map"; - push @ps2pk_map, transLW35($mode, @ps2pk_fonts); - push @ps2pk_map, @mixedmaps_fonts; - push @ps2pk_map, @notmixedmaps_fonts; - &writeLines(">$dvipsoutputdir/ps2pk.map", - normalizeLines(@ps2pk_map)); - - print "Generating output for dvips...\n" if !$opts{'quiet'}; - my @download35_map; - push @download35_map, "% ps2pk35.map"; - push @download35_map, transLW35($mode, @ps2pk_fonts); - &writeLines(">$dvipsoutputdir/download35.map", - normalizeLines(@download35_map)); - - my @builtin35_map; - push @builtin35_map, "% dvips35.map"; - push @builtin35_map, transLW35($mode, @dvips35_fonts); - &writeLines(">$dvipsoutputdir/builtin35.map", - normalizeLines(@builtin35_map)); - - my @dftdvips_fonts = - (($dvipsDownloadBase35 eq "true") ? @ps2pk_fonts : @dvips35_fonts); - - my @psfonts_t1_map; - if ($dvipsDownloadBase35 eq "true") { - push @psfonts_t1_map, "% ps2pk35.map"; - @dftdvips_fonts = @ps2pk_fonts; - } else { - push @psfonts_t1_map, "% dvips35.map"; - @dftdvips_fonts = @dvips35_fonts; - } - push @psfonts_t1_map, transLW35($mode, @dftdvips_fonts); - my @tmpkanji2 = cidx2dvips(\@kanjimaps_fonts); - push @psfonts_t1_map, @mixedmaps_fonts; - push @psfonts_t1_map, @notmixedmaps_fonts; - push @psfonts_t1_map, @tmpkanji2; - &writeLines(">$dvipsoutputdir/psfonts_t1.map", - normalizeLines(@psfonts_t1_map)); - - my @psfonts_pk_map; - push @psfonts_pk_map, transLW35($mode, @dftdvips_fonts); - push @psfonts_pk_map, @notmixedmaps_fonts; - push @psfonts_pk_map, @tmpkanji2; - &writeLines(">$dvipsoutputdir/psfonts_pk.map", - normalizeLines(@psfonts_pk_map)); - - print "Generating output for pdftex...\n" if !$opts{'quiet'}; - # remove PaintType due to Sebastian's request - my @pdftexmaps_ndl; - push @pdftexmaps_ndl, "% pdftex35.map"; - push @pdftexmaps_ndl, transLW35($mode, @pdftex35_fonts); - push @pdftexmaps_ndl, @mixedmaps_fonts; - push @pdftexmaps_ndl, @notmixedmaps_fonts; - @pdftexmaps_ndl = grep { $_ !~ m/(^%\|PaintType)/ } @pdftexmaps_ndl; - - my @pdftexmaps_dl; - push @pdftexmaps_dl, "% ps2pk35.map"; - push @pdftexmaps_dl, transLW35($mode, @ps2pk_fonts); - push @pdftexmaps_dl, @mixedmaps_fonts; - push @pdftexmaps_dl, @notmixedmaps_fonts; - @pdftexmaps_dl = grep { $_ !~ m/(^%\|PaintType)/ } @pdftexmaps_dl; - - my @pdftex_ndl14_map = @pdftexmaps_ndl; - @pdftex_ndl14_map = &normalizeLines(@pdftex_ndl14_map); - @pdftex_ndl14_map = &to_pdftex(@pdftex_ndl14_map); - &writeLines(">$pdftexoutputdir/pdftex_ndl14.map", @pdftex_ndl14_map); - - my @pdftex_dl14_map = @pdftexmaps_dl; - @pdftex_dl14_map = &normalizeLines(@pdftex_dl14_map); - @pdftex_dl14_map = &to_pdftex(@pdftex_dl14_map); - &writeLines(">$pdftexoutputdir/pdftex_dl14.map", @pdftex_dl14_map); - - our $link = &setupSymlinks($dvipsPreferOutline, $dvipsoutputdir, $pdftexDownloadBase14, $pdftexoutputdir); - - print_and_log ("\nFiles generated:\n"); - sub dir { - my ($d, $f, $target)=@_; - our $link; - if (-e "$d/$f") { - my @stat=lstat("$d/$f"); - my ($s,$m,$h,$D,$M,$Y)=localtime($stat[9]); - my $timestamp=sprintf ("%04d-%02d-%02d %02d:%02d:%02d", - $Y+1900, $M+1, $D, $h, $m, $s); - my $date=sprintf "%12d %s %s", $stat[7], $timestamp, $f; - print_and_log ($date); - - if (-l "$d/$f") { - my $lnk=sprintf " -> %s\n", readlink ("$d/$f"); - print_and_log ($lnk); - } elsif ($f eq $target) { - if (&files_are_identical("$d/$f", "$d/" . $link->{$target})) { - print_and_log (" = $link->{$target}\n"); - } else { - print_and_log (" = ?????\n"); # This shouldn't happen. - } - } else { - print_and_log ("\n"); - } - } else { - print STDERR "Warning: File $d/$f doesn't exist.\n"; - print LOG "Warning: File $d/$f doesn't exist.\n" - unless $opts{'dry-run'}; - } - } - - my $d; - $d = "$dvipsoutputdir"; - print_and_log(" $d:\n"); - foreach my $f ('builtin35.map', 'download35.map', 'psfonts_pk.map', - 'psfonts_t1.map', 'ps2pk.map', 'psfonts.map') { - dir ($d, $f, 'psfonts.map'); - $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; - } - $d = "$pdftexoutputdir"; - print_and_log(" $d:\n"); - foreach my $f ('pdftex_dl14.map', 'pdftex_ndl14.map', 'pdftex.map') { - dir ($d, $f, 'pdftex.map'); - $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; - } - $d="$dvipdfmxoutputdir"; - print_and_log(" $d:\n"); - foreach my $f ('kanjix.map') { - dir ($d, $f, ''); - $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; - } - if ($pxdviUse eq "true") { - $d="$pxdvioutputdir"; - print_and_log(" $d:\n"); - foreach my $f ('xdvi-ptex.map') { - dir ($d, $f, ''); - $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; - } - } - close LOG unless $opts{'dry-run'}; - print "\nTranscript written on \"$logfile\".\n" if !$opts{'quiet'}; - -} - - -sub locateMap { - my $map = shift; - my $ret = `kpsewhich --format=map $map`; - chomp($ret); - return $ret; -} - -sub processOptions { - # first process the stupid setoption= s@{1,2} which is not accepted - # furthermore, try to work around missing s{1,2} support in older perls - my $oldconfig = Getopt::Long::Configure(qw(pass_through)); - our @setoptions; - our @enable; - sub read_one_or_two { - my ($opt, $val) = @_; - our @setoptions; - our @enable; - # check if = occirs in $val, if not, get the next argument - if ($val =~ m/=/) { - if ($opt eq "setoption") { - push @setoptions, $val; - } else { - push @enable, $val; - } - } else { - my $vv = shift @ARGV; - die "Try \"$prg --help\" for more information.\n" - if !defined($vv); - if ($opt eq "setoption") { - push @setoptions, "$val=$vv"; - } else { - push @enable, "$val=$vv"; - } - } - } - GetOptions("setoption=s@" => \&read_one_or_two, - "enable=s@" => \&read_one_or_two) or - die "Try \"$prg --help\" for more information.\n"; - - @{$opts{'setoption'}} = @setoptions if (@setoptions); - @{$opts{'enable'}} = @enable if (@enable); - - Getopt::Long::Configure($oldconfig); - - # now continue with normal option handling - - GetOptions(\%opts, @cmdline_options) or - die "Try \"$prg --help\" for more information.\n"; -} - -# determines the output dir for driver from cmd line, or if not given -# from TEXMFVAR -sub setupOutputDir { - my $driver = shift; - if (!$opts{$driver . "outputdir"}) { - if ($opts{'outputdir'}) { - $opts{$driver . "outputdir"} = $opts{'outputdir'}; - } else { - $opts{$driver . "outputdir"} = "$TEXMFVAR/fonts/map/$driver/updmap"; - } - } - my $od = $opts{$driver . "outputdir"}; - if (!$opts{"dry-run"}) { - &mkdirhier($od); - if (! -w $od) { - die "$prg: Directory \"$od\" isn't writable: $!"; - } - } - print "$driver output dir: \"$od\"\n" if !$opts{'quiet'}; - return $od; -} - -############################################################################### -# setOption (@options) -# parse @options for "key=value" (one element of @options) -# we can only have "key=value" since that is the way it was prepared -# in process_options -# (These were the values provided to --setoption.) -# -sub setOptions { - my (@options) = @_; - for (my $i = 0; $i < @options; $i++) { - my $o = $options[$i]; - - my ($key,$val) = split (/=/, $o, 2); - - die "$prg: unexpected empty key or val for options (@options), goodbye.\n" - if !$key || !defined($val); - - &setOption ($key, $val); - } - return save_updmap($alldata->{'changes_config'}); -} - -sub enable_disable_maps { - my (@what) = @_; - my $tc = $alldata->{'changes_config'}; - die "$prg: top config file $tc has not been read." - if (!defined($alldata->{'updmap'}{$tc})); - my $changed = 0; - - for my $w (@what) { - if ($w =~ m/=/) { - # this is --enable MapType=MapName - my ($type, $map) = split ('=', $w); - enable_map($tc, $type, $map); - } else { - # this is --disable MapName - disable_map($tc, $w); - } - } - return save_updmap($tc); -} - -sub enable_map { - my ($tc, $type, $map) = @_; - - die "$prg: invalid mapType $type" if ($type !~ m/^(Map|MixedMap|KanjiMap)$/); - - if (defined($alldata->{'updmap'}{$tc}{'maps'}{$map})) { - # the map data has already been read in, no special precautions necessary - if (($alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} eq "enabled") && - ($alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} eq $type)) { - # nothing to do here ... be happy! - return; - } else { - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "enabled"; - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = $type; - $alldata->{'maps'}{$map}{'origin'} = $tc; - $alldata->{'maps'}{$map}{'status'} = "enabled"; - $alldata->{'updmap'}{$tc}{'changed'} = 1; - } - } else { - # add a new map file! - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = $type; - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "enabled"; - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'line'} = -1; - $alldata->{'updmap'}{$tc}{'changed'} = 1; - $alldata->{'maps'}{$map}{'origin'} = $tc; - $alldata->{'maps'}{$map}{'status'} = "enabled"; - } -} - -sub disable_map { - my ($tc, $map) = @_; - - if (defined($alldata->{'updmap'}{$tc}{'maps'}{$map})) { - # the map data has already been read in, no special precautions necessary - if ($alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} eq "disabled") { - # nothing to do here ... be happy! - } else { - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "disabled"; - $alldata->{'maps'}{$map}{'origin'} = $tc; - $alldata->{'maps'}{$map}{'status'} = "disabled"; - $alldata->{'updmap'}{$tc}{'changed'} = 1; - } - } else { - # disable a Map type that might be activated in a lower ranked updmap.cfg - if (!defined($alldata->{'maps'}{$map})) { - warning("Map is not present anywhere, why should I disable it?\n"); - return; - } - my $orig = $alldata->{'maps'}{$map}{'origin'}; - # add a new entry to the top level where we disable it - # copy over the type from the last entry - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = - $alldata->{'updmap'}{$orig}{'maps'}{$map}{'type'}; - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "disabled"; - $alldata->{'updmap'}{$tc}{'maps'}{$map}{'line'} = -1; - # rewrite the origin - $alldata->{'maps'}{$map}{'origin'} = $tc; - $alldata->{'maps'}{$map}{'status'} = "disabled"; - # go on for writing - $alldata->{'updmap'}{$tc}{'changed'} = 1; - } -} - - -# returns 1 if actually saved due to changes -sub save_updmap { - my $fn = shift; - return if $opts{'dry-run'}; - my %upd = %{$alldata->{'updmap'}{$fn}}; - if ($upd{'changed'}) { - mkdirhier(dirname($fn)); - open (FN, ">$fn") || die "$prg: can't write to $fn: $!"; - my @lines = @{$upd{'lines'}}; - if (!@lines) { - print "Creating new config file $fn\n"; - # update lsR database - $updLSR->{add}($fn); - $updLSR->{exec}(); - # reset the LSR stuff, otherwise we add files several times - $updLSR->{reset}(); - } - # collect the lines with data - my %line_to_setting; - my %line_to_map; - my @add_setting; - my @add_map; - if (defined($upd{'setting'})) { - for my $k (keys %{$upd{'setting'}}) { - if ($upd{'setting'}{$k}{'line'} == -1) { - push @add_setting, $k; - } else { - $line_to_setting{$upd{'setting'}{$k}{'line'}} = $k; - } - } - } - if (defined($upd{'maps'})) { - for my $k (keys %{$upd{'maps'}}) { - if ($upd{'maps'}{$k}{'line'} == -1) { - push @add_map, $k; - } else { - $line_to_map{$upd{'maps'}{$k}{'line'}} = $k; - } - } - } - for my $i (0..$#lines) { - if (defined($line_to_setting{$i})) { - my $k = $line_to_setting{$i}; - my $v = $upd{'setting'}{$k}{'val'}; - print FN "$k $v\n"; - } elsif (defined($line_to_map{$i})) { - my $m = $line_to_map{$i}; - my $rm; - if (defined($upd{'maps'}{$m}{'original'})) { - # we have the case that @noEmbed@ was replaced by the respective - # setting. Before writing out we have to replace this back with - # the original line!A - $rm = $upd{'maps'}{$m}{'original'}; - } else { - $rm = $m; - } - my $t = $upd{'maps'}{$m}{'type'}; - my $p = ($upd{'maps'}{$m}{'status'} eq "disabled" ? "#! " : ""); - print FN "$p$t $rm\n"; - } else { - print FN "$lines[$i]\n"; - } - } - # add the new settings and maps - for my $k (@add_setting) { - my $v = $upd{'setting'}{$k}{'val'}; - print FN "$k $v\n"; - } - for my $m (@add_map) { - my $t = $upd{'maps'}{$m}{'type'}; - my $p = ($upd{'maps'}{$m}{'status'} eq "disabled" ? "#! " : ""); - print FN "$p$t $m\n"; - } - close(FN) || warn("Cannot close file handle for $fn: $!"); - delete $alldata->{'updmap'}{$fn}{'changed'}; - return 1; - } - return 0; -} - -###################### -# check for correct option value -# -sub check_option { - my ($opt, $val) = @_; - if ((($settings{$opt}{'type'} eq "binary") && - $val ne "true" && $val ne "false") || - (($settings{$opt}{'type'} eq "string") && - !member($val, @{$settings{$opt}{'possible'}}))) { - return 0; - } - return 1; -} - -############################################################################### -# setOption (conf_file, option, value) -# sets option to value in the config file (replacing the existing setting -# or by adding a new line to the config file). -# -sub setOption { - my ($opt, $val) = @_; - - die "$prg: Unsupported option $opt." if (!defined($settings{$opt})); - die "$0: Invalid value $val for option $opt." - if (!check_option($opt, $val)); - - # silently accept this old option name, just in case. - return if $opt eq "dvipdfmDownloadBase14"; - - #print "Setting option $opt to $val...\n" if !$opts{'quiet'}; - my $tc = $alldata->{'changes_config'}; - - die "$prg: top config file $tc has not been read." - if (!defined($alldata->{'updmap'}{$tc})); - - if (defined($alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'})) { - # the value is already set, do nothing - if ($alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'} eq $val) { - return; - } - $alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'} = $val; - $alldata->{'updmap'}{$tc}{'changed'} = 1; - } else { - $alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'} = $val; - $alldata->{'updmap'}{$tc}{'setting'}{$opt}{'line'} = -1; - $alldata->{'updmap'}{$tc}{'changed'} = 1; - } -} - - -############################################################################### -# copyFile() -# copy file $src to $dst, sets $dst creation and mod time -# -sub copyFile { - my ($src, $dst) = @_; - my $dir; - ($dir=$dst)=~s/(.*)\/.*/$1/; - mkdirhier($dir); - - $src eq $dst && return "can't copy $src to itself!\n"; - - open IN, "<$src" or die "$0: can't open source file $src for copying: $!"; - open OUT, ">$dst"; - - binmode(IN); - binmode(OUT); - print OUT ; - close(OUT); - close(IN); - my @t = stat($src); - utime($t[8], $t[9], $dst); -} - -############################################################################### -# files_are_identical(file_A, file_B) -# compare two files. Same as cmp(1). -# -sub files_are_identical { - my $file_A=shift; - my $file_B=shift; - my $retval=0; - - open IN, "$file_A"; - my $A=(); - close IN; - open IN, "$file_B"; - my $B=(); - close IN; - - $retval=1 if ($A eq $B); - return $retval; -} - -############################################################################### -# files_are_different(file_A, file_B[, comment_char]) -# compare two equalized files. -# -sub files_are_different { - my $file_A=shift; - my $file_B=shift; - my $comment=shift; - my $retval=0; - - my $A=equalize_file("$file_A", $comment); - my $B=equalize_file("$file_B", $comment); - $retval=1 unless ($A eq $B); - return $retval; -} - -############################################################################### -# equalize_file(filename[, comment_char]) -# read a file and return its processed content as a string. -# look into the source code for more details. -# -sub equalize_file { - my $file=shift; - my $comment=shift; - my @temp; - - open IN, "$file"; - my @lines = (); - close IN; - chomp(@lines); - - for (@lines) { - s/\s*${comment}.*// if (defined $comment); # remove comments - next if /^\s*$/; # remove empty lines - s/\s+/ /g; # replace multiple whitespace chars by a single one - push @temp, $_; - } - return join('X', sort(@temp)); -} - -############################################################################### -# normalizeLines() -# not the original function, we want it to keep comments, that are -# anyway only the file names we are adding! -# whitespace is exactly one space, no empty lines, -# no whitespace at end of line, one space before and after " -# -sub normalizeLines { - my @lines = @_; - my %count = (); - - # @lines = grep { $_ !~ m/^[*#;%]/ } @lines; - map {$_ =~ s/\s+/ /gx } @lines; - @lines = grep { $_ !~ m/^\s*$/x } @lines; - map { $_ =~ s/\s$//x ; - $_ =~ s/\s*\"\s*/ \" /gx; - $_ =~ s/\" ([^\"]*) \"/\"$1\"/gx; - } @lines; - - # @lines = grep {++$count{$_} < 2 } (sort @lines); - @lines = grep {++$count{$_} < 2 } (@lines); - - return @lines; -} - - -################################################################# -# -# reading updmap-cfg files and the actual map files -# -# the following hash saves *all* the information and is passed around -# we do not fill everything from the very beginning to make sure that -# we only read what is necessary (speed!) -# -# initialized by main -# $alldata->{'changes_config'} = the config file where changes are saved -# -# initialized by read_updmap_files -# $alldata->{'order'} = [ list of updmap in decreasing priority ] -# $alldata->{'updmap'}{$full_path_name_of_updmap}{'lines'} = \@lines -# $alldata->{'updmap'}{$full_path_name_of_updmap}{'setting'}{$key}{'val'} = $val -# $alldata->{'updmap'}{$full_path_name_of_updmap}{'setting'}{$key}{'line'} = $i -# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'type'} -# = 'Map'|'MixedMap'|'KanjiMap'|'disabled' -# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'status'} -# = 'enabled'|'disabled' -# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'line'} = $i -# $alldata->{'maps'}{$m}{'origin'} = $updmap_path_name -# $alldata->{'maps'}{$m}{'status'} = enabled | disabled -# -# initialized by read_map_files -# $alldata->{'maps'}{$m}{'fonts'}{$font} = $definition -# $alldata->{'fonts'}{$f}{'origin'} = $map -# -# initialized by merge_data -# $alldata->{'merged'}{'setting'}{$key}{'val'} = $val -# $alldata->{'merged'}{'setting'}{$key}{'origin'} = $origin_updmap_cfg -# $alldata->{'merged'}{'allMaps'}{'fonts'}{$fontdef} = $rest -# $alldata->{'merged'}{'noMixedMaps'}{'fonts'}{$fontdef} = $rest -# $alldata->{'merged'}{'KanjiMaps'}{'fonts'}{$fontdef} = $rest -# - -sub read_updmap_files { - my (@l) = @_; - for my $l (@l) { - my $updmap = read_updmap_file($l); - $alldata->{'updmap'}{$l}{'lines'} = $updmap->{'lines'}; - if (defined($updmap->{'setting'})) { - for my $k (keys %{$updmap->{'setting'}}) { - $alldata->{'updmap'}{$l}{'setting'}{$k}{'val'} = $updmap->{'setting'}{$k}{'val'}; - $alldata->{'updmap'}{$l}{'setting'}{$k}{'line'} = $updmap->{'setting'}{$k}{'line'}; - } - } - if (defined($updmap->{'maps'})) { - for my $k (keys %{$updmap->{'maps'}}) { - $alldata->{'updmap'}{$l}{'maps'}{$k}{'type'} = $updmap->{'maps'}{$k}{'type'}; - $alldata->{'updmap'}{$l}{'maps'}{$k}{'status'} = $updmap->{'maps'}{$k}{'status'}; - $alldata->{'updmap'}{$l}{'maps'}{$k}{'line'} = $updmap->{'maps'}{$k}{'line'}; - } - } - } - # in case the changes_config is a new one read it in and initialize it here - my $cc = $alldata->{'changes_config'}; - if (! -r $cc) { - $alldata->{'updmap'}{$cc}{'lines'} = [ ]; - } - # - $alldata->{'order'} = \@l; -} - -sub merge_settings_replace_kanji { - # - my @l = @{$alldata->{'order'}}; - # - # for security clean out everything that was there - %{$alldata->{'merged'}} = (); - # - # first read in the settings - # we read it in *reverse* order and simple fill up the combined data - # thus if there are multiple definitions/settings, the one coming from - # the first in the original list will win! - for my $l (reverse @l) { - # merge settings - if (defined($alldata->{'updmap'}{$l}{'setting'})) { - for my $k (keys %{$alldata->{'updmap'}{$l}{'setting'}}) { - $alldata->{'merged'}{'setting'}{$k}{'val'} = $alldata->{'updmap'}{$l}{'setting'}{$k}{'val'}; - $alldata->{'merged'}{'setting'}{$k}{'origin'} = $l; - } - } - } - # - my ($kanjiEmbed, $kanjiEmbed_origin) = get_cfg('kanjiEmbed'); - my ($kanjiVariant, $kanjiVariant_origin) = get_cfg('kanjiVariant'); - # - # go through all map files and check that the text is properly replaced - # after the replacement check that the generated map file actually - # exists, we do NOT want to break in this case! - # - for my $l (@l) { - for my $m (keys %{$alldata->{'updmap'}{$l}{'maps'}}) { - if ($m =~ m/\@kanjiEmbed@/ || $m =~ m/\@kanjiVariant@/) { - my $newm = $m; - $newm =~ s/\@kanjiEmbed@/$kanjiEmbed/; - $newm =~ s/\@kanjiVariant@/$kanjiVariant/; - if (locateMap($newm)) { - # now we have to update various linked items - $alldata->{'updmap'}{$l}{'maps'}{$newm}{'type'} = - $alldata->{'updmap'}{$l}{'maps'}{$m}{'type'}; - $alldata->{'updmap'}{$l}{'maps'}{$newm}{'status'} = - $alldata->{'updmap'}{$l}{'maps'}{$m}{'status'}; - $alldata->{'updmap'}{$l}{'maps'}{$newm}{'line'} = - $alldata->{'updmap'}{$l}{'maps'}{$m}{'line'}; - $alldata->{'updmap'}{$l}{'maps'}{$newm}{'original'} = $m; - } else { - print "$prg: generated map $newm (from $m) does not exists, not activating it!\n"; - } - # in any case delete the @kanji...@ entry line, such a map will - # never exist - delete $alldata->{'updmap'}{$l}{'maps'}{$m}; - } - } - } - # - # first round determine which maps should be used and which type, as - # different updmap.cfg files might specify different types of maps - # (MixedMap or Map or KanjiMap). - # Again, we have to do that in reverse order - for my $l (reverse @l) { - if (defined($alldata->{'updmap'}{$l}{'maps'})) { - for my $m (keys %{$alldata->{'updmap'}{$l}{'maps'}}) { - $alldata->{'maps'}{$m}{'origin'} = $l; - $alldata->{'maps'}{$m}{'status'} = $alldata->{'updmap'}{$l}{'maps'}{$m}{'status'}; - } - } - } -} - -sub read_updmap_file { - my $fn = shift; - my $is_old_local = ($fn =~ m/updmap-local.cfg/ ? 1 : 0); - my %data; - if (!open(FN,"<$fn")) { - die ("Cannot read $fn: $!"); - } - # we count lines from 0 ..!!!! - my $i = -1; - my @lines = ; - chomp(@lines); - $data{'lines'} = [ @lines ]; - close(FN) || warn("Cannot close $fn: $!"); - for (@lines) { - $i++; - chomp; - if ($is_old_local) { - # in case we read an old updmap-local.cfg we have to make sure - # that the disable lines - # ^#!foo.map - # are rewritten to proper disable lines - # ^#! Map foo.map - # we are guessing here the type of the map (namely Map) - $_ =~ s/^#!([^ ])/#! Map $1/; - } - next if /^\s*$/; - next if /^\s*#$/; - next if /^\s*#[^!]/; - next if /^\s*##/; - next if /^#![^ ]/; - # allow for commands on the line itself - s/([^#].*)#.*$/$1/; - my ($a, $b, @rest) = split ' '; - # make sure we get empty strings as arguments - $b = "" if (!defined($b)); - if ($a eq "#!") { - if ($b eq "Map" || $b eq "MixedMap" || $b eq "KanjiMap") { - my $c = shift @rest; - if (!defined($c)) { - warning("$prg: apparently not a real disable line, ignored: $_\n"); - } else { - if (defined($data{'maps'}{$c})) { - warning("$prg: double mention of $c in $fn\n"); - } - $data{'maps'}{$c}{'status'} = 'disabled'; - $data{'maps'}{$c}{'type'} = $b; - $data{'maps'}{$c}{'line'} = $i; - } - } - next; - } - if (@rest) { - warning("$prg: line $i in $fn contains a syntax error, more than two words!\n"); - } - if (defined($settings{$a})) { - if (check_option($a, $b)) { - $data{'setting'}{$a}{'val'} = $b; - $data{'setting'}{$a}{'line'} = $i; - } else { - warning("$prg: unknown setting for $a: $b, ignored!\n"); - } - } elsif ($a eq "Map" || $a eq "MixedMap" || $a eq "KanjiMap") { - if (defined($data{'maps'}{$b}) && $data{'maps'}{$b}{'type'} ne $a) { - warning("$prg: double mention of $b with conflicting types in $fn\n"); - } else { - $data{'maps'}{$b}{'type'} = $a; - $data{'maps'}{$b}{'status'} = 'enabled'; - $data{'maps'}{$b}{'line'} = $i; - } - } else { - warning("$prg: unrecognized line $i in $fn: $_\n"); - } - } - return \%data; -} - -sub read_map_files { - if (!defined($alldata->{'updmap'})) { - return; - } - my @missing; - my @l = @{$alldata->{'order'}}; - # first collect all the map files we are interested in - # and determine whether they exist, and get their full path - my @maps; - for my $f (@l) { - next if !defined($alldata->{'updmap'}{$f}{'maps'}); - for my $m (keys %{$alldata->{'updmap'}{$f}{'maps'}}) { - # only read a map file if its final status is enabled! - push @maps, $m if ($alldata->{'maps'}{$m}{'status'} eq 'enabled'); - } - } - for my $m (qw/dvips35.map pdftex35.map ps2pk35.map/) { - push @maps, $m; - $alldata->{'maps'}{$m}{'status'} = 'enabled'; - } - @maps = sort_uniq(@maps); - my @fullpath = `kpsewhich --format=map @maps`; - chomp @fullpath; - foreach my $map (@maps) { - my ($ff) = grep /\/$map(\.map)?$/, @fullpath; - if ($ff) { - $alldata->{'maps'}{$map}{'fullpath'} = $ff; - } else { - # if the map file is not found, then push it onto the list of - # missing map files, since we know that it is enabled - push @missing, $map; - } - } - - # - # read in the three basic fonts definition maps - for my $m (qw/dvips35.map pdftex35.map ps2pk35.map/) { - my $ret = read_map_file($alldata->{'maps'}{$m}{'fullpath'}); - my @ff = (); - for my $font (keys %$ret) { - $alldata->{'fonts'}{$font}{'origin'} = $m; - $alldata->{'maps'}{$m}{'fonts'}{$font} = $ret->{$font}; - } - } - # we read the updmap in reverse directions, since we - # replace the origin field of font definition always with the - # top one - for my $f (reverse @l) { - my @maps = keys %{$alldata->{'updmap'}{$f}{'maps'}}; - for my $m (@maps) { - # we do not read a map file multiple times, if $alldata{'maps'}{$m} is - # defined we expect that it was read and do skip it - next if defined($alldata->{'maps'}{$m}{'fonts'}); - # we do not read a map files content if it is disabled - next if ($alldata->{'maps'}{$m}{'status'} eq 'disabled'); - if (!defined($alldata->{'maps'}{$m}{'fullpath'})) { - # we have already pushed these map files onto the list of missing - # map files, so do nothing here - next; - } - my $ret = read_map_file($alldata->{'maps'}{$m}{'fullpath'}); - if (defined($ret)) { - for my $font (keys %$ret) { - if (defined($alldata->{'fonts'}{$font})) { - # we got another definition, warn on that - # if the origin is not defined by now, the font is defined - # multiple times in the same map file, otherwise it is - # defined in another map file already - if (defined($alldata->{'fonts'}{$font}{'origin'})) { - my $fontorig = $alldata->{'fonts'}{$font}{'origin'}; - my $maporig; - if (($fontorig eq "ps2pk35.map") || - ($fontorig eq "pdftex35.map") || - ($fontorig eq "dvips35.map")) { - $maporig = "built in map - both used - warning!"; - } else { - $maporig = "from " . $alldata->{'maps'}{$fontorig}{'origin'}; - } - warning("$prg: font $font is defined multiple times:\n"); - warning("$prg: $fontorig ($maporig)\n"); - warning("$prg: $m (from $f) (used)\n"); - } else { - warning("$prg: font $font is multiply defined in $m, using an arbitrary instance!\n"); - } - } - $alldata->{'fonts'}{$font}{'origin'} = $m; - $alldata->{'maps'}{$m}{'fonts'}{$font} = $ret->{$font}; - } - } - } - } - return (@missing); -} - -sub read_map_file { - my $fn = shift; - my @lines; - if (!open(MF,"<$fn")) { - warn("cannot open $fn: $!"); - return; - } - @lines = ; - close(MF); - chomp(@lines); - my %data; - for (@lines) { - next if /^\s*#/; - next if /^\s*%/; - next if /^\s*$/; - my ($a, $b) = split(' ', $_, 2); - $data{$a} = $b; - } - return \%data; -} - -# -# merging the various font definitions -# -sub merge_data { - my @l = @{$alldata->{'order'}}; - # - # now merge the data - # - for my $m (keys %{$alldata->{'maps'}}) { - my $origin = $alldata->{'maps'}{$m}{'origin'}; - next if !defined($origin); - next if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'status'} eq "disabled"); - for my $f (keys %{$alldata->{'maps'}{$m}{'fonts'}}) { - # use the font definition only for those fonts where the origin matches - if ($alldata->{'fonts'}{$f}{'origin'} eq $m) { - $alldata->{'merged'}{'allMaps'}{'fonts'}{$f} = - $alldata->{'maps'}{$m}{'fonts'}{$f} - if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} ne "KanjiMap"); - $alldata->{'merged'}{'noMixedMaps'}{'fonts'}{$f} = - $alldata->{'maps'}{$m}{'fonts'}{$f} - if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "Map"); - $alldata->{'merged'}{'KanjiMap'}{'fonts'}{$f} = - $alldata->{'maps'}{$m}{'fonts'}{$f} - if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "KanjiMap"); - } - } - } -} - - -# -# $HOME and sudo and updmap-sys horror -# some instances of sudo do not reset $HOME to the home of root -# as an effect of "sudo updmap" creates root owned files in the home -# of a normal user, and "sudo updmap-sys" uses map files and updmap.cfg -# files from the directory of a normal user, but creating files -# in TEXMFSYSCONFIG. This is *all* wrong. -# we check: if we are running as UID 0 (root) on Unix and the -# ENV{HOME} is NOT the same as the one of root, then give a warning -# and reset it to the real home dir of root. - -sub reset_root_home { - if (!win32() && ($> == 0)) { # $> is effective uid - my $envhome = $ENV{'HOME'}; - # if $HOME isn't an existing directory, we don't care. - if (defined($envhome) && (-d $envhome)) { - # we want to avoid calling getpwuid as far as possible, so if - # $envhome is one of some usual values we accept it without worrying. - if ($envhome =~ m,^(/|/root|/var/root)/*$,) { - return; - } - # $HOME is defined, check what is the home of root in reality - my (undef,undef,undef,undef,undef,undef,undef,$roothome) = getpwuid(0); - if (defined($roothome)) { - if ($envhome ne $roothome) { - warning("$prg: resetting \$HOME value (was $envhome) to root's " - . "actual home ($roothome).\n"); - $ENV{'HOME'} = $roothome; - } else { - # envhome and roothome do agree, nothing to do, that is the good case - } - } else { - warning("$prg: home of root not defined, strange!\n"); - } - } - } -} - -sub warning { - print STDERR @_; -} - -# -# help, version etc etc -# - -sub version { - my $ret = sprintf "%s (TeX Live, multi) version %s\n", $prg, $version; - return $ret; -} - -sub help { - my $usage = <<"EOF"; -Usage: $prg [OPTION] ... [COMMAND] - or: $prg-sys [OPTION] ... [COMMAND] - -Update the default font map files used by pdftex, dvips, and dvipdfm(x), -and optionally pxdvi, as determined by all configuration files updmap.cfg -(the ones returned by running "kpsewhich --all updmap.cfg", but see below). - -Among other things, these map files are used to determine which fonts -should be used as bitmaps and which as outlines, and to determine which -font files are included in the PDF or PostScript output. - -By default, the TeX filename database (ls-R) is also updated. - -Options: - --cnffile FILE read FILE for the updmap configuration - (can be given multiple times, in which case - all the files are used) - --dvipdfmxoutputdir DIR specify output directory (dvipdfm(x) syntax) - --dvipsoutputdir DIR specify output directory (dvips syntax) - --pdftexoutputdir DIR specify output directory (pdftex syntax) - --pxdvioutputdir DIR specify output directory (pxdvi syntax) - --outputdir DIR specify output directory (for all files) - --copy cp generic files rather than using symlinks - --force recreate files even if config hasn't changed - --nomkmap do not recreate map files - --nohash do not run texhash - -n, --dry-run only show the configuration, no output - --quiet, --silent reduce verbosity - -Commands: - --help show this message and exit - --version show version information and exit - --showoption OPTION show the current setting of OPTION - --showoptions OPTION show possible settings for OPTION - --setoption OPTION VALUE set OPTION to value; option names below - --setoption OPTION=VALUE as above, just different syntax - --enable MAPTYPE MAPFILE add "MAPTYPE MAPFILE" to updmap.cfg, - where MAPTYPE is Map, MixedMap, or KanjiMap - --enable Map=MAPFILE add \"Map MAPFILE\" to updmap.cfg - --enable MixedMap=MAPFILE add \"MixedMap MAPFILE\" to updmap.cfg - --enable KanjiMap=MAPFILE add \"KanjiMap MAPFILE\" to updmap.cfg - --disable MAPFILE disable MAPFILE, of whatever type - --listmaps list all active and inactive maps - --listavailablemaps same as --listmaps, but without - unavailable map files - --syncwithtrees disable unavailable map files in updmap.cfg - -Explanation of the map types: the (only) difference between Map and -MixedMap is that MixedMap entries are not added to psfonts_pk.map. -The purpose is to help users with devices that render Type 1 outline -fonts worse than mode-tuned Type 1 bitmap fonts. So, MixedMap is used -for fonts that are available as both Type 1 and Metafont. -KanjiMap entries are added to psfonts_t1.map and kanjix.map. - -Explanation of the OPTION names for --showoptions, --showoption, --setoption: - - dvipsPreferOutline true|false (default true) - Whether dvips uses bitmaps or outlines, when both are available. - dvipsDownloadBase35 true|false (default true) - Whether dvips includes the standard 35 PostScript fonts in its output. - pdftexDownloadBase14 true|false (default true) - Whether pdftex includes the standard 14 PDF fonts in its output. - pxdviUse true|false (default false) - Whether maps for pxdvi (Japanese-patched xdvi) are under updmap's control. - kanjiEmbed (any string) - kanjiVariant (any string) - See below. - LW35 URWkb|URW|ADOBEkb|ADOBE (default URWkb) - Adapt the font and file names of the standard 35 PostScript fonts. - URWkb URW fonts with "berry" filenames (e.g. uhvbo8ac.pfb) - URW URW fonts with "vendor" filenames (e.g. n019064l.pfb) - ADOBEkb Adobe fonts with "berry" filenames (e.g. phvbo8an.pfb) - ADOBE Adobe fonts with "vendor" filenames (e.g. hvnbo___.pfb) - - These options are only read and acted on by updmap; dvips, pdftex, etc., - do not know anything about them. They work by changing the default map - file which the programs read, so they can be overridden by specifying - command-line options or configuration files to the programs, as - explained at the beginning of updmap.cfg. - - The options kanjiEmbed and kanjiVariant specify special replacements - in the map lines. If a map contains the string \@kanjiEmbed\@, then - this will be replaced by the value of that option; similarly for - kanjiVariant. In this way, users of Japanese TeX can select different - fonts to be included in the final output. - -Explanation of trees and files normally used: - - If --cnffile is specified on the command line (possibly multiple - times), its value(s) are used. Otherwise, updmap reads all the - updmap.cfg files found by running \`kpsewhich -all updmap.cfg', in the - order returned by kpsewhich, with one exception: an updmap.cfg found - in TEXMFLOCAL is given higher priority than the updmap.cfg in - TEXMFMAIN, to ensure that local adjustments by administrators take - precedence over what is shipped in TeX Live. - - In any case, if multiple updmap.cfg files are found, all the maps - mentioned in all the updmap.cfg files are merged. - - Thus, if updmap.cfg files are present in all trees, and the default - layout is used as shipped with TeX Live, the following files are - read, in the given order. - - For updmap-sys: - TEXMFSYSCONFIG \$TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg - TEXMFSYSVAR \$TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg - TEXMFLOCAL \$TEXLIVE/texmf-local/web2c/updmap.cfg - TEXMFMAIN \$TEXLIVE/YYYY/texmf/web2c/updmap.cfg - TEXMFDIST \$TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg - - For updmap: - TEXMFCONFIG \$HOME/.texliveYYYY/texmf-config/web2c/updmap.cfg - TEXMFVAR \$HOME/.texliveYYYY/texmf-var/web2c/updmap.cfg - TEXMFHOME \$HOME/texmf/web2c/updmap.cfg - TEXMFSYSCONFIG \$TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg - TEXMFSYSVAR \$TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg - TEXMFLOCAL \$TEXLIVE/texmf-local/web2c/updmap.cfg - TEXMFMAIN \$TEXLIVE/YYYY/texmf/web2c/updmap.cfg - TEXMFDIST \$TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg - - (where YYYY is the TeX Live release version). - - There is another exception to keep upgradability from earlier versions - of TeX Live: if a file TEXMFLOCAL/web2c/updmap-local.cfg exists - (formerly used by tlmgr to merge local fonts), then the file - TEXMFLOCAL/web2c/updmap.cfg is ignored (if it exists) and that - updmap-local.cfg is used instead. In this case, updmap recognizes the - previous syntax for disabling map files in updmap-local.cfg (this - syntax is different from what is used now). - - According to the actions, updmap might write to one of the given files - or create a new updmap.cfg, described further below. - - Where changes are saved: if config files are given on the command - line, then the first one given will be used to save any changes from - --setoption, --enable or --disable. If the config files are taken - from kpsewhich output, then the algorithm is more complex: - - 1) If \$TEXMFCONFIG/web2c/updmap.cfg or \$TEXMFHOME/web2c/updmap.cfg - appears in the list of used files, then the one listed first by - kpsewhich --all (equivalently, the one returned by kpsewhich - updmap.cfg), is used. - - 2) If neither of the above two are present and changes are made, a - new config file is created in \$TEXMFCONFIG/web2c/updmap.cfg. - - Resolving multiple definitions of a font: - If a font is defined in more than one map file, then the definition - coming from the first-listed updmap.cfg is used. If a font is - defined multiple times within the same map file, one is chosen - arbitrarily. In both cases a warning is issued. - - Disabling maps: - updmap.cfg files with higher priority (listed earlier) can disable - maps mentioned in lower priority (listed later) updmap.cfg files by - writing, e.g., - \#! Map mapname.map - or - \#! MixedMap mapname.map - in the higher-priority updmap.cfg file. - - As an example, suppose you have a copy of MathTime Pro fonts - and want to disable the Belleek version of the fonts; that is, - disable the map belleek.map. You can create the file - \$TEXMFCONFIG/web2c/updmap.cfg with the content - #! Map belleek.map - Map mt-plus.map - Map mt-yy.map - and call $prg. - - updmap writes the map files for dvips (psfonts.map) and pdftex - (pdftex.map) to the TEXMFVAR/fonts/map/updmap/{dvips,pdftex}/ - directories. - - The log file is written to TEXMFVAR/web2c/updmap.log. - - When updmap-sys is run, TEXMFSYSCONFIG and TEXMFSYSVAR are used - instead of TEXMFCONFIG and TEXMFVAR, respectively. This is the only - difference between updmap-sys and updmap. - - Other locations may be used if you give them on the command line, or - these trees don't exist, or you are not using the original TeX Live. - - To see the precise locations of the various files that - will be read and written, give the -n option (or read the source). - -For step-by-step instructions on making new fonts known to TeX, read -http://tug.org/fonts/fontinstall.html. For even more terse -instructions, read the beginning of updmap.cfg. - -Report bugs to: tex-k\@tug.org -TeX Live home page: -EOF -; - print &version(); - print $usage; - exit 0; -} - -### Local Variables: -### perl-indent-level: 2 -### tab-width: 2 -### indent-tabs-mode: nil -### End: -# vim:set tabstop=2 expandtab: # diff --git a/Master/texmf-dist/scripts/texdoctk/texdoctk.pl b/Master/texmf-dist/scripts/texdoctk/texdoctk.pl new file mode 100755 index 00000000000..36497183e3b --- /dev/null +++ b/Master/texmf-dist/scripts/texdoctk/texdoctk.pl @@ -0,0 +1,1857 @@ +#! /usr/bin/env perl +############################################################################### +# texdoctk - GUI for TeX documentation access +# Copyright (C) 2000-2004 Thomas Ruedas +# Updated in 2010 by Manuel Pegourie-Gonnard +# This program is provided under the GNU Public License; see the file +# README.texdoctk for details about requirements, installation, configuration, +# and the full disclaimer. +############################################################################### +my ($version, $date) = ("0.6.1", "2004-11-05"); +use strict; +use Tk; +use Getopt::Long; +Getopt::Long::config('bundling'); +use File::Basename; + +BEGIN { + Win32::SetChildShowWindow(0) if defined &Win32::SetChildShowWindow; +} + +my $IsWin32 = ($^O =~ /MSWin32/i); + +if ($IsWin32) { + require Win32::API; +# Win32::API->import( qw( +# &something +# )); +} + +# initialization of some internal variables +$|=1; +my $quiet=1; +my $autoview; +my $xfmt_viewer=1, +my @tdcolors; +my %butcol; +my $srchentry; +my $srchflag=0; +my $srchtype; # 0 = database, 1 = texdoc +my $tmpfno; +# system variables +my ($texmfmain,$texmfdist,$texmfdoc,$texmflocal,$texmfhome, + $texdocpath,$distdocpath,$docdocpath,$localdocpath,$homedocpath, + $datadir, + $dvi_viewer,$dvips_conv,$ps_viewer,$pdf_viewer, + $pdfps_conv,$html_viewer,$htmlps_conv,$htmlps_redir, + $txt_viewer,$txtps_conv,$txtps_redir,$print_cmd); + +# defaults: unix values +my $qq="'"; +my $HomeEnv=$ENV{HOME}; +my $TeXDocRcDefaults="texdocrc.defaults"; +my $TempDir; $TempDir=$ENV{TMPDIR} or $TempDir="/tmp"; +my $CmdConsole="xterm -e "; + +if ($IsWin32) { + $qq = "\""; + $HomeEnv = $ENV{'USERPROFILE'}; + chomp $HomeEnv; + $TeXDocRcDefaults = "texdocrc-win32.defaults"; + $TempDir = &GetTempPath; + $CmdConsole = "cmd /c "; +} + +my $myrc="${HomeEnv}/.texdocrc"; # optional personal settings file + +my ($line,@dummy); +my @tmpfiles; +# read system-wide defaults from texdocrc.defaults +my $sysrc=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} ${TeXDocRcDefaults}`; +my $database=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk.dat`; +my $locdatabase=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk-local.dat`; +my $homedatabase=`kpsewhich --progname=texdoctk --format=${qq}other text files${qq} texdoctk-pers.dat`; +chomp $locdatabase; +chomp $homedatabase; +chomp $sysrc; +&readrc($sysrc,1); +@dummy=split("/",$sysrc); +pop @dummy; +$datadir=join('/',@dummy); +# possibly use personal settings instead of defaults +if (-e $myrc) { &readrc($myrc,2); } +# command line options +GetOptions('v'=>\$quiet,'a'=>\$autoview); +my $special=0; +my @button; +$button[17]="Miscellaneous"; +my (@packname,@topic,@doc,@keywords,@maxind,%stydoc); +# read database file +my $i=-1; +my $j; +open(DATABASE,"$database") || &fatalmsg("Couldn't open database $database.\n"); +while ($line = ) { + LINETYPE: { + ($line =~ /^\@/) && do { # category + ++$i; + if ($i == $#button) { + pop @button; + push @button,(substr($line,1,-1)); + $special=1; + } else { + $button[$i]=substr($line,1,-1); + } + $j=0; + last LINETYPE; + }; + ($line =~ /^(#|$)/) && do { # comment or empty line + last LINETYPE; + }; +# list item + @dummy=split(";",$line); + $packname[$i][$j]=$dummy[0]; + $topic[$i][$j]=$dummy[1]; + $doc[$i][$j]=$dummy[2]; + $keywords[$i][$j]=$dummy[3]; + if ($doc[$i][$j] =~ /sty$/ && $keywords[$i][$j]) { + $stydoc{"$doc[$i][$j]"}=substr($keywords[$i][$j],1,1); + unless ($stydoc{"$doc[$i][$j]"} =~ /^\d$/) { + $stydoc{"$doc[$i][$j]"}=0; + } + } + $maxind[$i]=$j; + ++$j; + }; +} +close(DATABASE); +# Read site-local and user's database(s) if it/they exist(s) +foreach my $dbfile ($locdatabase,$homedatabase) { + if (-e "$dbfile") { + open(DATABASE,"$dbfile") || + print "Couldn't open additional database $dbfile.\n"; + $i=17; # local/user: if no category is specified in database, add to "Misc" + while ($line = ) { + LINETYPE: { + ($line =~ /^\@/) && do { # category + $i=&arrindex(@button,substr($line,1,-1)); + if ($i >= $#button) { + $i=$#button; + pop @button; + push @button,(substr($line,1,-1)); + $special=1; + } + last LINETYPE; + }; + ($line =~ /^(#|$)/) && do { # comment or empty line + last LINETYPE; + }; +# list item + @dummy=split(";",$line); + $j=&arrindex(@{$packname[$i]},$dummy[0]); + if ($j > $#{$packname[$i]}) { + $packname[$i][$j]=$dummy[0]; + $topic[$i][$j]=$dummy[1]; + $doc[$i][$j]=$dummy[2]; + $keywords[$i][$j]=$dummy[3]; + if ($doc[$i][$j] =~ /sty$/ && $keywords[$i][$j]) { + $stydoc{"$doc[$i][$j]"}=substr($keywords[$i][$j],1,1); + unless ($stydoc{"$doc[$i][$j]"} =~ /^\d$/) { + $stydoc{"$doc[$i][$j]"}=0; + } + } + $maxind[$i]=$j; + ++$j; + } + }; + } + close(DATABASE); + $special=1 if ($i == 17 && $j > 0); + } +} + +# Tk +# hash table for toplevel windows; used to avoid multiple calls of same window +my %tlwins; +my %buttonlist; +# create frames for main window: commands on top, frame for buttons below +my $main=new MainWindow; +$tlwins{'mainwindow'}{'addr'}=$main; +$main->resizable(0,0); +$main->title("TeX Documentation Browser"); +$main->bind('all',''=>\&clean_exit); +$main->bind('all',''=>sub { $main->raise(); }); +$main->bind('all',''=>\&helptext); +$main->bind('all',''=>sub { $main->raise(); &mksrch; }); +$main->bind('all',''=>\&settings); +my $cmdframe=$main->Frame(-background=>"#ffcc99"); +my $buttonframe=$main->Frame; +$cmdframe->pack(-side=>'top',-fill=>'x'); +$buttonframe->pack(-side=>'bottom'); +# normal cursor +my $defcursor=$main->cget(-cursor); +# make buttons for command frame +my $Qbut=$cmdframe->Button(-text=>'Quit',%butcol, + -command=>\&clean_exit)->pack(-side=>'left'); +$tlwins{'mainwindow'}{'buttons'}[0]=$Qbut; +# define common default font for labels and text explicitly +my $deffont=$Qbut->cget(-font); +# ensure readability on high-res screens (suggested by R.Kotucha) +$deffont='Helvetica -16 bold' if &x_resolution > 1200; +$Qbut->configure(-font=>$deffont); +$tlwins{'mainwindow'}{'buttons'}[1]=$cmdframe->Button( + -text=>'Database search', + -font=>$deffont,%butcol, + -command=>[\&mksrch, 0] + )->pack(-side=>'left'); +$tlwins{'mainwindow'}{'buttons'}[2]=$cmdframe->Button( + -text=>'File search', + -font=>$deffont,%butcol, + -command=>[\&mksrch, 1] + )->pack(-side=>'left'); +$tlwins{'mainwindow'}{'buttons'}[3]=$cmdframe->Button(-text=>'Help/About', + -font=>$deffont,%butcol, + -command=>\&helptext + )->pack(-side=>'right'); +$tlwins{'mainwindow'}{'buttons'}[4]=$cmdframe->Button(-text=>'Settings', + -font=>$deffont,%butcol, + -command=>\&settings + )->pack(-side=>'right'); +# make buttons for category button frame +my $lbut=0; +my $l; +foreach (@button) { $l=length $_; $lbut=$l if ( $l > $lbut) } +my @catg; +my ($i2,$i3); +my $nbutt=scalar @button; +my $ncols=$nbutt/3-1; +foreach (0..$ncols) { + $i=$_; + $i2=$i+$nbutt/3; + $i3=$i+2*$nbutt/3; + $catg[$i]=$buttonframe->Button(-text=>$button[$i], + -font=>$deffont,%butcol, + -width=>$lbut, + -command=>[\&tpslct,$i,\@dummy])->grid + ($catg[$i2]=$buttonframe->Button(-text=>$button[$i2], + -font=>$deffont,%butcol, + -width=>$lbut, + -command=>[\&tpslct,$i2,\@dummy]), + $catg[$i3]=$buttonframe->Button(-text=>$button[$i3], + -font=>$deffont,%butcol, + -width=>$lbut, + -command=>[\&tpslct,$i3,\@dummy])); +} +# disable last button (lower right) if no local specials are found in list +my $ncat; +if ($special == 0) { + $catg[$#button]->configure(-state=>'disabled'); + $ncat=$nbutt-1; +} else { + $ncat=$nbutt; +} +for ($i=0,$j=5; $i<@catg; ++$i,++$j) { + $tlwins{'mainwindow'}{'buttons'}[$j]=$catg[$i]; +} +MainLoop; + +########## SUBROUTINES ######################################################## +# toplevel for selecting a topic of a category for viewing or printing +sub tpslct { + my($opt,@srchitems)=@_; + my (@lbitems,@lbdocs,$dspselect,$docselect,$wtitle); + if ($opt >= 0) { +# main window buttons +# see if toplevel window is already there + if (Exists($tlwins{$opt}{'addr'})) { + $tlwins{$opt}{'addr'}->deiconify(); + $tlwins{$opt}{'addr'}->raise(); + return; + } + for ($j=0; $j <= $maxind[$opt]; ++$j) { + push @lbitems,$topic[$opt][$j]; + push @lbdocs,$doc[$opt][$j]; + } + $wtitle=$button[$opt]; + } else { +# search results + my $spec_wtitle=shift @srchitems; + for ($j=0; $j < $#srchitems; $j+=2) { + my $k=$j+1; + push @lbitems,$topic[$srchitems[$j]][$srchitems[$k]]; + push @lbdocs,$doc[$srchitems[$j]][$srchitems[$k]]; + } + $wtitle = ($srchtype ? "File" : "Database") + . " search results for $spec_wtitle"; + } +# toplevel window of category $opt with two frames + my $tpwin=$main->Toplevel(-title=>$wtitle); + $tlwins{$opt}{'addr'}=$tpwin; + my $tpdsp=$tpwin->Frame(-relief=>'groove')->pack(-side=>'top'); + my $tpslc=$tpwin->Frame()->pack(-side=>'top'); +# selection frame with listbox and buttons +# label for listbox + my $tplabel=$tpslc->Label(-text=>($srchtype ? "Files" : "Topics"), + -font=>$deffont)->pack(-anchor=>'w', + -side=>'top'); +# listbox with optional scrollbar + my $tplist=$tpslc->Scrolled("Listbox", + -font=>$deffont, + -scrollbars=>'osoe', +# -height=>0, + -width=>0, + -selectmode=>'single', + -exportselection=>0, + -cursor=>'hand2')->pack(-side=>'left', + -fill=>'y', + -expand=>1); + $tplist->insert('end',@lbitems); # fill topics into listbox +# buttons frame + my $tpbframe=$tpslc->Frame(-borderwidth=>8); + $tpbframe->pack(-side=>'right'); +# make buttons for command frame + my $n_buttons = 0; + $tlwins{$opt}{'buttons'}[$n_buttons++]= + $tpbframe->Button(-text=>'View', + -font=>$deffont,%butcol, + -command=>sub{ &viewslc($docselect,$tpbframe);}, + -width=>6)->pack(-side=>'top'); + if (! $IsWin32) { + $tlwins{$opt}{'buttons'}[$n_buttons++]= + $tpbframe->Button(-text=>'Print', + -font=>$deffont,%butcol, + -command=>sub{ &prtslc($docselect,$tpbframe);}, + -width=>6)->pack(-side=>'top'); + } + $tlwins{$opt}{'buttons'}[$n_buttons++]= + $tpbframe->Button(-text=>'Cancel', + -font=>$deffont,%butcol, + -command=>sub{ destroy $tpwin; undef $tlwins{$opt};}, + -width=>6)->pack(-side=>'bottom'); +# if only 1 item is in the list (most likely in search results), select it + if (scalar @lbitems == 1) { + $tplist->selectionSet(0); + $dspselect=$lbitems[0]; + $docselect=$lbdocs[0]; + &viewslc($docselect,$tpbframe) + if ($autoview && $wtitle =~ /^Search results/); + } +# display frame + my $dsplabel=$tpdsp->Label(-text=>'Selection:', + -font=>$deffont)->pack(-anchor=>'w',, + -fill=>'x', + -side=>'left'); + my $dspslc=$tpdsp->Label(-textvariable=>\$dspselect, + -font=>$deffont, + -borderwidth=>2)->pack(-anchor=>'w', + -fill=>'x', + -side=>'right'); +# handle selection; only one selection possible + $tplist->bind(''=>sub{my ($slctind)=$tplist->curselection(); + $dspselect=$lbitems[$slctind]; + $docselect=$lbdocs[$slctind];}); +# key bindings + $tplist->bind(''=>sub{ + &viewslc($docselect,$tpbframe);}); + $tpwin->bind(''=>sub{ + &viewslc($docselect,$tpbframe);}); + $tpwin->bind(''=>sub{ + &prtslc($docselect,$tpbframe);}); + $tpwin->bind(''=>sub{destroy $tpwin; undef $tlwins{$opt};}); + $tplist->bind(''=>sub{ + if ($docselect) { + &showpath($docselect,$tpbframe); + } else { + &popmsg(2,"No selection;\nuse left mouse button.",$tpbframe); + }}); +} + +# view document selected in listbox +sub viewslc { + my($slc,$parframe)=@_; + my $viewer; + my $itype=-1; + my $browser=0; + my $styflag=0; + unless (defined $slc) { + &popmsg(2,"No selection was made.",$parframe); + return; + } + $parframe->configure(-cursor=>'watch'); + chomp $slc; + my @dummy=split('\.',$slc); + DOC_FORMAT: { # determine document type + ($dummy[-1] =~ /dvi/) && do { $viewer=$dvi_viewer; last DOC_FORMAT; }; + ($dummy[-1] =~ /ps/) && do { $viewer=$ps_viewer; last DOC_FORMAT; }; + ($dummy[-1] =~ /pdf/) && do { $viewer=$pdf_viewer; last DOC_FORMAT; }; + ($dummy[-1] =~ /txt/ || $dummy[-1] =~ /faq$/) && do { + $viewer=($txt_viewer eq "TDK_OWN" || + $txt_viewer =~ /xterm/) ? + $txt_viewer : "${CmdConsole} $txt_viewer"; + last DOC_FORMAT; + }; + ($dummy[-1] =~ /README/i || $dummy[-2] =~ /\/README$/i) && do { + $viewer=($txt_viewer eq "TDK_OWN" || + $txt_viewer =~ /xterm/) ? + $txt_viewer : "${CmdConsole} $txt_viewer"; + last DOC_FORMAT; + }; + ($dummy[-1] =~ /htm/) && do { + $viewer=$html_viewer; + if ($html_viewer =~ /netscape/i) { # check if Netscape is open + my $lockfile="${HomeEnv}/.netscape/lock"; + $browser=1 if (-e $lockfile || -l $lockfile); + } elsif ($html_viewer =~ /mozilla/i) { # check if Mozilla is open + my $mozcheck= + `mozilla -remote 'openFile($texmfmain/doc/index.html)'`; + $browser=1 unless ($?); + } + last DOC_FORMAT; + }; +# some packages have no normal documentation but useful info in the .sty + ($dummy[-1] =~ /sty$/) && do { + $viewer=($txt_viewer eq "TDK_OWN" || + $txt_viewer =~ /xterm/) ? + $txt_viewer : "${CmdConsole} $txt_viewer"; + $slc="../tex/$slc"; # .sty files are in ${tex,local}docpath/../tex/ + $styflag=1; + last DOC_FORMAT; + }; + $parframe->configure(-cursor=>$defcursor); + if ($xfmt_viewer != 1) { + &popmsg(2,"$dummy[-1]: not a known document format",$parframe); + return; + } + }; + if ($viewer eq "") { + if ($xfmt_viewer == 1) { + &popmsg(-1,'Unknown format; assuming plain text.',$parframe); + $viewer=($txt_viewer eq "TDK_OWN" || + $txt_viewer =~ /xterm/) ? + $txt_viewer : "${CmdConsole} $txt_viewer"; + } else { + &popmsg(2,"$dummy[-1]: no viewer available/specified for this format", + $parframe); + $parframe->configure(-cursor=>$defcursor); + return; + } + } +# build complete path and start viewer if file exists + my $slcdoc; + $slcdoc=&finddoc($slcdoc,$slc,$parframe); + if ($slcdoc ne "") { +# change to doc directory in case there are pictures + my $docpath=substr($slcdoc,0,(rindex($slcdoc,'/',(length $slcdoc)))); + chomp $slcdoc; + chdir ($docpath); +# try to get doc out of .sty file + if ($styflag) { + &popmsg(-1,'Trying to extract documentation out of .sty file; +might be cluttered with program comments.', + $parframe); + $slcdoc=&stripsty($slcdoc,substr($slc,7)); + } +# for text files use built-in text viewer if set + if ($IsWin32) { + if ($viewer eq "TDK_OWN") { + &ShellExecute('open', $slcdoc); + $parframe->configure(-cursor=>$defcursor); + return; + } + else { + system("$viewer $slcdoc"); + } + } + else { + if ($viewer eq "TDK_OWN") { + &textview($slcdoc); + $parframe->configure(-cursor=>$defcursor); + return; + } + if ($quiet == 0) { # show messages + if ($browser == 0) { # normal viewers or new Netscape/Mozilla + system("$viewer $slcdoc &"); + } else { # open doc in existing Netscape/Mozilla window + system("$viewer -remote 'openFile($slcdoc)' &"); + &popmsg(-1,"Opening document in existing $viewer window.", + $parframe); + } + } else { # viewer messages written to /dev/null instead of terminal + if ($browser == 0) { # normal viewers or new Netscape/Mozilla + system("perl -we 'use strict; \ +my \$dump=\"\"; \ +open(NULL,\">/dev/null\"); \ +open (VIEWQ,\"$viewer $slcdoc |\"); \ +while (\$dump=) { print NULL \$dump; } \ +close(VIEWQ); \ +close(NULL);' &"); + } else { # open doc in existing window (Netscape or Mozilla) + # not quiet; I didn't get an inline perl call like in + # the other branch working + system("$viewer -remote 'openFile($slcdoc)' &"); + &popmsg(-1,"Opening document in existing $viewer window.", + $parframe); + } + } + } + } + $parframe->configure(-cursor=>$defcursor); +} + +# Tk widget for text document +sub textview { + my($txtfile)=@_; +# see if toplevel window with this file is already there + if (Exists($tlwins{$txtfile}{'addr'})) { + $tlwins{$txtfile}{'addr'}->deiconify(); + $tlwins{$txtfile}{'addr'}->raise(); + return; + } + my $tfv_tk=$main->Toplevel(-title=>"Text file viewer"); + $tfv_tk->resizable(0,1); + $tlwins{$txtfile}{'addr'}=$tfv_tk; + $tfv_tk->Label(-text=>"File: $txtfile", + -font=>$deffont, + -relief=>'ridge', + -borderwidth=>3)->pack(-side=>'top', + -fill=>'x', + -ipady=>10, + -anchor=>'s'); + my $txtbody=$tfv_tk->Scrolled("Text", + -relief=>'flat', + -font=>$deffont, + -height=>20, + -width=>80, + -scrollbars=>"e")->pack(-side=>'top', + -fill=>'y', + -expand=>1); + open(TXTFILE,"$txtfile"); + while () { $txtbody->insert('end',$_); } + close(TXTFILE); + $txtbody->configure(-state=>'disabled'); + $tlwins{$txtfile}{'buttons'}[0]= + $tfv_tk->Button(-text=>'Close', + -font=>$deffont,%butcol, + -command=>sub{ destroy $tfv_tk; + undef $tlwins{$txtfile}; + })->pack(-side=>'bottom', + -fill=>'x'); + $tfv_tk->bind(''=>sub{destroy $tfv_tk; + undef $tlwins{$txtfile}; + }); +} + +# print document selected in listbox +sub prtslc { + my($slc,$parframe)=@_; + $tmpfno=&randname; + my $pstmpfile="${TempDir}/texdoc_$tmpfno.ps"; + push @tmpfiles,$pstmpfile; + my $status; + chomp $slc; + unless (defined $slc) { + &popmsg(2,"No selection was made.",$parframe); + return; + } + if ($print_cmd eq "") { + &popmsg(2,"No printer specified.",$parframe); + return; + } +# build complete path and check existence of file + my @dummy=split('\.',$slc); + if ($dummy[-1] =~ /sty$/) { + $slc="../tex/$slc"; # .sty files are in ${tex,local,home}docpath/../tex + } + my $slcdoc; + $slcdoc=&finddoc($slcdoc,$slc,$parframe); + return if ($slcdoc eq ""); +# change to doc directory in case there are pictures + my $docpath=substr($slcdoc,0,(rindex($slcdoc,'/',(length $slcdoc)))); + chdir ($docpath); + DOC_FORMAT: { # determine document type +# convert dvi files to ps before printing + ($dummy[-1] =~ /dvi/) && do { + if ($dvips_conv eq "") { + &popmsg(2,"No converter available for dvi->ps conversion.", + $parframe); + return; + } + &popmsg(-1,"Converting dvi to ps for printing and sending file to print...",$parframe); + $status=system("$dvips_conv $slcdoc -o $pstmpfile"); + if ($status != 0) { + &popmsg(2,"Error: Conversion dvi->ps failed!",$parframe); + } + last DOC_FORMAT; + }; +# PostScript is printed directly + ($dummy[-1] =~ /ps/) && do { + &popmsg(-1,"Sending file to $print_cmd...",$parframe); + $pstmpfile=$slcdoc; + last DOC_FORMAT; + }; +# convert pdf files to ps before printing + ($dummy[-1] =~ /pdf/) && do { + if ($pdfps_conv eq "") { + &popmsg(2,"No converter available for pdf->ps conversion.", + $parframe); + return; + } + &popmsg(-1,"Converting pdf to ps for printing and sending file to print...",$parframe); + system("$pdfps_conv $slcdoc $pstmpfile"); + last DOC_FORMAT; + }; +# convert html files to ps before printing + ($dummy[-1] =~ /htm/) && do { + if ($htmlps_conv eq "") { + &popmsg(2,"No converter available for html->ps conversion.", + $parframe); + return; + } + &popmsg(-1,"Converting html to ps for printing and sending file to print...",$parframe); + my $htmlps_redir_sign=($htmlps_redir == 1) ? ">" :""; + system("$htmlps_conv $slcdoc $htmlps_redir_sign $pstmpfile"); + last DOC_FORMAT; + }; +# convert txt files to ps before printing + ($dummy[-1] =~ /txt/ || $dummy[-1] =~ /faq$/ + || $dummy[-1] =~ /README/i) && do { + if ($txtps_conv eq "") { + &popmsg(2,"No converter available for txt->ps conversion.", + $parframe); + return; + } + &popmsg(-1,"Converting txt to ps for printing and sending file to print...",$parframe); + my $txtps_redir_sign=($txtps_redir == 1) ? ">" :""; + system("$txtps_conv $slcdoc $txtps_redir_sign $pstmpfile"); + last DOC_FORMAT; + }; +# convert extracted comments from sty files to ps before printing + ($dummy[-1] =~ /sty$/) && do { + if ($txtps_conv eq "") { + &popmsg(2,"No converter available for sty(txt)->ps conversion.", + $parframe); + return; + } + &popmsg(-1,"Converting sty(txt) to ps for printing and sending file to print...",$parframe); +# try to get doc out of .sty file + &popmsg(-1,'Trying to extract documentation out of .sty file; +might be cluttered with program comments.', + $parframe); + $slcdoc=&stripsty($slcdoc,substr($slc,7)); + my $txtps_redir_sign=($txtps_redir == 1) ? ">" :""; + system("$txtps_conv $slcdoc $txtps_redir_sign $pstmpfile"); + last DOC_FORMAT; + }; + &popmsg(2,"$dummy[-1]: cannot print document format",$parframe); + return; + }; + system("$print_cmd $pstmpfile"); +} + +# test existence and search a documentation which is not in specified place +sub finddoc { + my($slcdoc,$slc,$parframe)=@_; + my ($dummy,$status); + SLCDOCFIND: foreach ($texdocpath,$distdocpath,$docdocpath) { + $slcdoc="$_/$slc"; + if (-e $slcdoc) { +# found where it should be + return $slcdoc; + } else { +# see if the documentation file is in the local doc tree... + my @srchslcdoc=($slcdoc); + if ($localdocpath) { + push @srchslcdoc,"$localdocpath/$slc"; + return $srchslcdoc[-1] if (-e $srchslcdoc[-1]); + } +# ... or the user's doc tree... + if ($homedocpath) { + push @srchslcdoc,"$homedocpath/$slc"; + return $srchslcdoc[-1] if (-e $srchslcdoc[-1]); + } +# ... otherwise proceed with searching + $status=-1; +# see if the documentation file is compressed + CMPREND: foreach my $cmprtype ("gz","bz2","zip") { + foreach (@srchslcdoc) { + $dummy="$_.$cmprtype"; + if (-e $dummy) { # yes, it is compressed + $tmpfno=&randname; + my $rawname=basename($slc,""); + $slcdoc="${TempDir}/texdoc_$tmpfno$rawname"; + push @tmpfiles,$slcdoc; + my ($dcmp,$dcmp_opt); + COMPRESS: { # determine compression type + ($cmprtype eq "gz") && do { + $dcmp="gzip"; + $dcmp_opt="-cd"; + last COMPRESS; + }; + ($cmprtype eq "bz2") && do { + $dcmp="bzip2"; + $dcmp_opt="-cd"; + last COMPRESS; + }; + ($cmprtype eq "zip") && do { + $dcmp="zip"; + $dcmp_opt="-p"; + last COMPRESS; + }; + }; +# try to decompress + $status=system("$dcmp $dcmp_opt $dummy > $slcdoc"); + if ($status != 0) { # failure + &popmsg(2, + "$dcmp: Couldn't decompress file, cancelling.", + $parframe); + $slcdoc=""; + return $slcdoc; + } +# last CMPREND; does not work, what we need is: + return $slcdoc; + } + } + } + } + } + if ($status != 0) { + $parframe->configure(-cursor=>'watch'); +# try to find it elsewhere with kpsewhich + my $rawname=basename($slc,""); + $slcdoc=($slcdoc =~ /\.sty$/) ? + `kpsewhich $rawname` : + `kpsewhich --format=${qq}TeX system documentation${qq} $rawname`; + if ($slcdoc eq "") { # nothing found; cancel + &popmsg(2,"$rawname not found, cancelling.",$parframe); + $slcdoc=""; + } + $parframe->configure(-cursor=>$defcursor); + } + return $slcdoc; +} + +# determine existence and show paths of files (Button-3) +sub showpath { + my ($docselect,$tpbframe)=@_; + my $found=0; + if ($docselect =~ /\.sty$/) { + STYPATH: foreach my $fullpath ("$texmfmain/tex/$docselect", + "$texmfdist/tex/$docselect", + "$texmflocal/tex/$docselect", + "$texmfhome/tex/$docselect") { + if (-e $fullpath) { + &popmsg(0,"Selected file:\n$fullpath",$tpbframe); + $found=1; + last STYPATH; + } + } + if (!$found) { + &popmsg(2,"Selected file:\n$docselect\ndoes not exist.",$tpbframe) } + } else { + DOCPATH: foreach my $fullpath ("$texdocpath/$docselect", + "$distdocpath/$docselect", + "$docdocpath/$docselect", + "$localdocpath/$docselect", + "$homedocpath/$docselect") { + foreach ('','.gz','.bz2','.zip') { + my $fullpathext="$fullpath$_"; + if (-e $fullpathext) { + &popmsg(0,"Selected file:\n$fullpathext",$tpbframe); + $found=1; + last DOCPATH; + } + } + } + if (!$found) { + &popmsg(2,"Selected file:\n$docselect\ndoes not exist (neither in normal form nor compressed).",$tpbframe) } + } +} + +# make or destroy search entry widget +sub mksrch { + my ($type) = @_; + if ($srchflag == 1) { + if ($type == $srchtype) { + destroy $srchentry; + $srchflag=0; + } else { + $srchtype = $type; + } + } else { + $srchtype = $type; +# get the search string + $srchentry=$cmdframe->Entry(-cursor=>'xterm', + -font=>$deffont, + -width=>20, + -takefocus=>1)->pack(-side=>'left'); + $srchentry->focus(); + $srchentry->bind(''=>[\&srchstr, $srchentry]); + $srchflag=1; +# key binding + $srchentry->bind(''=>sub{destroy $srchentry; $srchflag=0;}); + $srchentry->bind(''=>sub{destroy $srchentry; $srchflag=0;}); + } +} + +# call search routine and display results +sub srchstr { + my $string; + my @reslist; + $string=$srchentry->get(); +# search + $main->Busy(-recurse => 1); + if ($srchtype == 0) { + @reslist = &srchdb($string); + } else { + @reslist = &srchtd($string); + } + $main->Unbusy(); +# destroy entry widget and show results + destroy $srchentry; + $srchflag=0; + if (scalar @reslist == 0) { + &popmsg(0, ($srchtype == 0 ? 'Database' : 'File'). + " search for $string: no matches found.\n". + "You may want to try a ". + ($srchtype == 0 ? 'File' : 'Databse') . " search.\n\n". + "If nothing else works, CTAN offers an online search form:\n". + "http://ctan.org/search.html\n", + $cmdframe); + } else { + &tpslct(-1, $string, @reslist); + } +} + +# search using texdoc +sub srchtd { + my ($string) = @_; + my @res; + my $tdout = `texdoc -M -l $string`; + if ($?) { + &popmsg(0,"texdoc failed, sorry: $!\n". + "Please report this problem on the texlive mailing list.\n"); + return; + } else { + my $i = 0; + for my $line (split /\n/, $tdout) { + my @fields = split /\t/, $line; + $doc[$ncat][$i] = $fields[2]; + $topic[$ncat][$i] = basename($fields[2]); + $packname[$ncat][$i] = "no package name"; + push @res, ($ncat, $i++); + } + return @res; + } +} + +# search a string in @packname, @topic and @keywords +sub srchdb { + my ($string) = @_; + my (@results, @reslist); + if ($string) { + for ($i=0; $i<$ncat; ++$i) { + for ($j=0; $j<$maxind[$i]+1; ++$j) { + SRCH: { + ($topic[$i][$j] =~ /$string/i) && do { + push @results,($i,$j); + last SRCH; + }; + (defined $keywords[$i][$j]) && do { + if ($keywords[$i][$j] =~ /$string/i) { + push @results,($i,$j); + last SRCH; + } + }; + ($packname[$i][$j] =~ /$string/i) && do { + push @results,($i,$j); + last SRCH; + }; + }; + } + } + } else { # return full database + $string='all database entries'; + for ($i=0; $i<$ncat; ++$i) { + for ($j=0; $j<$maxind[$i]+1; ++$j) { push @results,($i,$j); } + } + } + unless (scalar @results == 0) { +# cancel multiple entries + my ($omit,$pack1,$pack2); + @reslist=($results[0],$results[1]); + for ($i=0; $i<$#results; $i+=2) { + $omit=0; + $pack1=$packname[$results[$i]][$results[$i+1]]; + for ($j=0; $j<$#reslist; $j+=2) { + $pack2=$packname[$reslist[$j]][$reslist[$j+1]]; + if ($pack1 eq $pack2) { $omit=1; last; } + } + if ($omit == 0) { push @reslist,($results[$i],$results[$i+1]); } + } + } + return @reslist; +} + +# extract documentation of .sty files; a flag in the @keywords array shows +# where the doc is located: +# -0-: no specific place; -1-: at end, behind \endinput; -2-: at beginning, +# terminated by %%%%%%; -3-: at beginning, terminated with blank line +sub stripsty { + my ($slcdoc,$slc)=@_; + my @stydoc; + $tmpfno=&randname; + my $tmpslcdoc="${TempDir}/texdoc_$tmpfno.txt"; + push @tmpfiles,$tmpslcdoc; + open (STY,"$slcdoc"); + LOC: { + ($stydoc{$slc} == 0) && do { # no specific place, suck in everything :-( + while ($line = ) { push @stydoc,$line if ($line =~ /^%/); } + last LOC; + }; + ($stydoc{$slc} == 1) && do { # at end, behind \endinput + while ($line = ) { + last if ($line =~ /^\s*\\endinput/ && !($line =~ /^%/)); + } + while ($line = ) { push @stydoc,$line; } + last LOC; + }; + ($stydoc{$slc} == 2) && do { # up to a certain %%%%%%%, hopefully the 1st + for (my $i=0; $i<9; ++$i) { $stydoc[$i]=; } # after the 8th line + while ($line = ) { + last if ($line =~ /^%{4,}/); + push @stydoc,$line; + } + last LOC; + }; + ($stydoc{$slc} == 3) && do { # up to 1st blank/apparently empty line + while ($line = ) { + last if ($line =~ /^\s*$/); + push @stydoc,$line; + } + last LOC; + }; + }; + close(STY); + open(TMPSTY,">$tmpslcdoc"); + foreach (@stydoc) { print TMPSTY $_; } + close(TMPSTY); + return $tmpslcdoc; +} + +# pop up a note or an error or warning message toplevel window +sub popmsg { + my($level,$msg,$parframe)=@_; + my $degree; + LEVEL: { + ($level == -1) && do { $degree="Info"; last LEVEL; }; + ($level == 0) && do { $degree="Note"; last LEVEL; }; + ($level == 1) && do { + return if ($quiet == 1); + $degree="Warning"; + last LEVEL + }; + ($level == 2) && do { $degree="Error"; last LEVEL; }; + }; + my $msgwin=$parframe->Toplevel(-title=>$degree); + my $lbl=$msgwin->Label(-text=>uc($degree), + -font=>$deffont)->pack(-side=>'top', -fill=>'x'); +# get size of message text + my @dummy=split("\n",$msg); + my $nline=scalar @dummy; + my $msgwidth=0; + my $lline; + foreach (@dummy) { + $lline=length $_; + if ($lline > $msgwidth) { $msgwidth=$lline; } + } + my $message=$msgwin->Text(-relief=>'flat', + -font=>$deffont, + -height=>$nline, + -width=>$msgwidth)->pack(-side=>'top'); + $message->insert('end',$msg); + $message->configure(-state=>'disabled'); + if ($level < 0) { # transient message window + $msgwin->after(3000,sub{destroy $msgwin}); + } else { # persistent message window + $msgwin->Button(-text=>'Close', + -font=>$deffont,%butcol, + -command=>sub{destroy $msgwin})->pack(-side=>'bottom', + -fill=>'x'); + $msgwin->bind(''=>sub{destroy $msgwin}); + } +} + +# show/change settings (don't show this to an expert :-/ ) +sub settings { + my ($homedocpath_tmp,$quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, + $dvi_viewer_tmp,$dvips_conv_tmp, + $ps_viewer_tmp,$pdf_viewer_tmp,$pdfps_conv_tmp, + $html_viewer_tmp,$htmlps_conv_tmp,$htmlps_redir_tmp, + $txt_viewer_tmp,$txtps_conv_tmp,$txtps_redir_tmp,$print_cmd_tmp)= + ($homedocpath,$quiet,$autoview,$xfmt_viewer, + $dvi_viewer,$dvips_conv,$ps_viewer, + $pdf_viewer,$pdfps_conv,$html_viewer, + $htmlps_conv,$htmlps_redir,$txt_viewer, + $txtps_conv,$txtps_redir,$print_cmd); + my @tdcolors_tmp=@tdcolors; +# see if toplevel window is already there + if (Exists($tlwins{"setmenu"}{'addr'})) { + $tlwins{"setmenu"}{'addr'}->deiconify(); + $tlwins{"setmenu"}{'addr'}->raise(); + return; + } + my $setmenu=$main->Toplevel(-title=>'Settings'); + $setmenu->resizable(0,0); + $tlwins{"setmenu"}{'addr'}=$setmenu; +# documentation path + my $datlabel; + $datlabel="Database file(s) used: teTeX"; + $datlabel.=", local database" if (-e $locdatabase); + $datlabel.=", user database" if (-e $homedatabase); + my $docframe=$setmenu->Frame(-relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -expand=>1); + my $docframestring="\nDistribution documentation root path(s):\n$texdocpath"; + $docframestring.=", $distdocpath" if (-e $distdocpath); + $docframestring.=", $docdocpath" if (length $docdocpath); + if ($localdocpath && $localdocpath ne $texdocpath) { + $docframestring.="\nLocal documentation root path: $localdocpath\n"; + } + $docframe->Label(-text=>"$docframestring", + -font=>$deffont)->pack(-side=>'top', + -anchor=>'w', + -fill=>'x', + -expand=>1); + if (defined $texmfhome && -d $texmfhome) { + $homedocpath_tmp=basename($homedocpath_tmp,""); + my $usrdocframe=$docframe->Frame(-relief=>'flat')->pack(-side=>'top', + -fill=>'x'); + my $usrdoclabel=$usrdocframe->Label(-text=>"User's documentation root path: $texmfhome/", + -font=>$deffont)->pack(-side=>'left'); + my $usrdocentry=$usrdocframe->Entry(-textvariable=>\$homedocpath_tmp, + -font=>$deffont)->pack(-side=>'left'); + } + $docframe->Label(-text=>"$datlabel.", + -font=>$deffont)->pack(-side=>'top', + -anchor=>'w', + -ipady=>2, + -fill=>'x', + -expand=>1); +# General viewer behaviour + my $genvframe=$setmenu->Frame(-label=>'General viewer behaviour', + -relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -ipady=>6, + -expand=>1); + my $genvframe1=$genvframe->Frame()->pack(-side=>'left'); + my $genvsub1=$genvframe1->Frame()->pack(-side=>'top', + -anchor=>'w', + -ipady=>3); + my $genvecbut=$genvsub1-> + Checkbutton(-variable=>\$quiet_tmp)->pack(-side=>'left', + -anchor=>'sw'); + my $genvelabel=$genvsub1->Label(-text=>'Suppress error messages', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $genvsub2=$genvframe1->Frame()->pack(-side=>'top', + -anchor=>'w'); + my $genvscbut=$genvsub2-> + Checkbutton(-variable=>\$autoview_tmp)->pack(-side=>'left', + -anchor=>'sw'); + my $genvslabel=$genvsub2->Label(-text=>'Autostart viewer for one-item listboxes', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $genvsub3=$genvframe1->Frame()->pack(-side=>'top', + -anchor=>'w'); + my $genvxcbut=$genvsub3-> + Checkbutton(-variable=>\$xfmt_viewer_tmp)->pack(-side=>'left', + -anchor=>'sw'); + my $genvxlabel=$genvsub3->Label(-text=>'Use text viewer for unknown file format', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); +# colours of GUI + my @tdcolors_d=@tdcolors_tmp; + $tlwins{'setmenu'}{'buttons'}[0]= + $genvframe->Button(-text=>'Change viewer colours', + -command=>sub { + @tdcolors_tmp=&popcolor($setmenu,@tdcolors_tmp); + @tdcolors_d=@tdcolors_tmp; + }, + -font=>$deffont,%butcol)->pack(-side=>'right'); +# DVI + my $dviframe=$setmenu->Frame(-label=>'DVI', + -relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -ipady=>6, + -expand=>1); + my $dvisub1=$dviframe->Frame()->pack(-side=>'top', + -anchor=>'w'); + my $dvisub2=$dviframe->Frame()->pack(-side=>'top', + -anchor=>'w', + -ipady=>6); + my $dvivlabel=$dvisub1->Label(-text=>'Viewer command', + -anchor=>'w', + -font=>$deffont)->pack(-side=>'left'); + my $dviventry=$dvisub1->Entry(-textvariable=>\$dvi_viewer_tmp, + -font=>$deffont)->pack(-side=>'left'); + my $dviclabel=$dvisub2->Label(-text=>'DVI->PS converter command', + -anchor=>'w', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $dvilbwidth=length 'DVI->PS converter command'; + $dvivlabel->configure(-width=>1.1*$dvilbwidth); + $dviclabel->configure(-width=>1.1*$dvilbwidth); + my $dvicentry=$dvisub2->Entry(-textvariable=>\$dvips_conv_tmp, + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); +# PostScript + my $psframe=$setmenu->Frame(-label=>'PostScript', + -relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -ipady=>10, + -expand=>1); + my $psvlabel=$psframe->Label(-text=>'Viewer command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'w'); + my $psventry=$psframe->Entry(-textvariable=>\$ps_viewer_tmp, + -font=>$deffont)->pack(-side=>'left'); +# PDF + my $pdfframe=$setmenu->Frame(-label=>'PDF', + -relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -ipady=>6, + -expand=>1); + my $pdfsub1=$pdfframe->Frame()->pack(-side=>'top', + -anchor=>'w'); + my $pdfsub2=$pdfframe->Frame()->pack(-side=>'top', + -anchor=>'w', + -ipady=>6); + my $pdfvlabel=$pdfsub1->Label(-text=>'Viewer command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'w'); + my $pdfventry=$pdfsub1->Entry(-textvariable=>\$pdf_viewer_tmp, + -font=>$deffont)->pack(-side=>'left'); + my $pdfclabel=$pdfsub2->Label(-text=>'PDF->PS converter command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $pdfcentry=$pdfsub2->Entry(-textvariable=>\$pdfps_conv_tmp, + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); +# HTML + my $htmlframe=$setmenu->Frame(-label=>'HTML', + -relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -ipady=>6, + -expand=>1); + my $htmlsub1=$htmlframe->Frame()->pack(-side=>'top', + -anchor=>'w'); + my $htmlsub2=$htmlframe->Frame()->pack(-side=>'top', + -anchor=>'w', + -ipady=>6); + my $htmlvlabel=$htmlsub1->Label(-text=>'Viewer command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'w'); + my $htmlventry=$htmlsub1->Entry(-textvariable=>\$html_viewer_tmp, + -font=>$deffont)->pack(-side=>'left'); + my $htmlclabel=$htmlsub2->Label(-text=>'HTML->PS converter command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $htmlcentry=$htmlsub2->Entry(-textvariable=>\$htmlps_conv_tmp, + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $htmlrlabel=$htmlsub2->Label(-text=>'Output redirect needed', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $htmlrcbut=$htmlsub2-> + Checkbutton(-variable=>\$htmlps_redir_tmp)->pack(-side=>'left', + -anchor=>'sw'); +# plain text + my $txtframe=$setmenu->Frame(-label=>'Plain text', + -relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -ipady=>6, + -expand=>1); + my $txtsub1=$txtframe->Frame()->pack(-side=>'top', + -anchor=>'w'); + my $txtsub2=$txtframe->Frame()->pack(-side=>'top', + -anchor=>'w', + -ipady=>6); + my $txtvlabel=$txtsub1->Label(-text=>'Viewer command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'w'); + my $txtventry=$txtsub1->Entry(-textvariable=>\$txt_viewer_tmp, + -font=>$deffont)->pack(-side=>'left'); + my $txt_view_flag; + if ($txt_viewer_tmp eq "TDK_OWN") { + $txt_view_flag=1; + $txtventry->configure(-state=>'disabled'); + } else { + $txt_view_flag=0; + $txtventry->configure(-state=>'normal'); + } + my $txtvilabel=$txtsub1->Label(-text=>"\tUse texdoctk\'s own viewer", + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $txtvcbut=$txtsub1-> + Checkbutton(-variable=>\$txt_view_flag, + -command=>sub { + if ($txt_view_flag == 1) { + $txt_viewer_tmp="TDK_OWN"; + $txtventry->configure(-state=>'disabled'); + } else { + $txt_viewer_tmp=$txt_viewer; + $txtventry->configure(-state=>'normal'); + $txtventry->focus(); + } + })->pack(-side=>'left', + -anchor=>'sw'); + my $txtclabel=$txtsub2->Label(-text=>'Text->PS converter command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $txtcentry=$txtsub2->Entry(-textvariable=>\$txtps_conv_tmp, + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $txtrlabel=$txtsub2->Label(-text=>'Output redirect needed', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'sw'); + my $txtrcbut=$txtsub2-> + Checkbutton(-variable=>\$txtps_redir_tmp)->pack(-side=>'left', + -anchor=>'sw'); +# printer + my $prtframe=$setmenu->Frame(-label=>'Printer', + -relief=>'groove', + -borderwidth=>2)->pack(-side=>'top', + -fill=>'x', + -ipady=>10, + -expand=>1); + my $prtclabel=$prtframe->Label(-text=>'Command', + -font=>$deffont)->pack(-side=>'left', + -anchor=>'w'); + my $prtcentry=$prtframe->Entry(-textvariable=>\$print_cmd_tmp, + -font=>$deffont)->pack(-side=>'left'); +# buttons and key bindings + my $setbfr=$setmenu->Frame()->pack(-side=>'bottom'); + $tlwins{'setmenu'}{'buttons'}[1]= + $setbfr->Button(-text=>'OK', + -font=>$deffont,%butcol, + -command=>sub{ + $homedocpath="$texmfhome/$homedocpath_tmp"; + ($quiet,$autoview,$xfmt_viewer, + $dvi_viewer,$dvips_conv, + $ps_viewer,$pdf_viewer, + $pdfps_conv,$html_viewer, + $htmlps_conv,$htmlps_redir, + $txt_viewer,$txtps_conv,$txtps_redir,$print_cmd)= + ($quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, + $dvi_viewer_tmp,$dvips_conv_tmp, + $ps_viewer_tmp, + $pdf_viewer_tmp,$pdfps_conv_tmp, + $html_viewer_tmp, + $htmlps_conv_tmp,$htmlps_redir_tmp, + $txt_viewer_tmp,$txtps_conv_tmp, + $txtps_redir_tmp,$print_cmd_tmp); + @tdcolors=@tdcolors_tmp; + %butcol=('-background'=>$tdcolors[0], + '-foreground'=>$tdcolors[1], + '-activebackground'=>$tdcolors[2], + '-activeforeground'=>$tdcolors[3]); + foreach my $tlkey (keys %tlwins) { + foreach (@{$tlwins{$tlkey}{'buttons'}}) { + $_->configure(%butcol); + } + } + if ($txt_viewer eq "" && + defined $ENV{PAGER}) { + $txt_viewer=$ENV{PAGER}; + } + destroy $setmenu}, + -width=>6)->pack(-side=>'left', + -padx=>10, + -pady=>10); + $tlwins{'setmenu'}{'buttons'}[2]= + $setbfr->Button(-text=>'Save', + -font=>$deffont,%butcol, + -command=>sub{ + $setmenu->configure(-cursor=>'watch'); + &popmsg(-1,"Writing settings to $myrc",$setmenu); + my $tdcolors_tmp=join(' ',@tdcolors_tmp); + &writerc($homedocpath_tmp, + $quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, + $tdcolors_tmp, + $dvi_viewer_tmp,$dvips_conv_tmp, + $ps_viewer_tmp, + $pdf_viewer_tmp,$pdfps_conv_tmp, + $html_viewer_tmp, + $htmlps_conv_tmp,$htmlps_redir_tmp, + $txt_viewer_tmp,$txtps_conv_tmp, + $txtps_redir_tmp,$print_cmd_tmp,$setmenu); + $setmenu->configure(-cursor=>$defcursor); + })->pack(-side=>'left', + -padx=>10); + $tlwins{'setmenu'}{'buttons'}[3]= + $setbfr->Button(-text=>'Cancel', + -font=>$deffont,%butcol, + -command=>sub{destroy $setmenu; + undef $tlwins{"setmenu"}; + })->pack(-side=>'left', + -padx=>10); + $setmenu->bind(''=>sub{destroy $setmenu; + undef $tlwins{"setmenu"};}); +} + +# dialog toplevel for color settings +sub popcolor { + my ($parframe,@entryvar)=@_; +# see if toplevel window is already there + if (Exists($tlwins{'chngcol'}{'addr'})) { + $tlwins{'chngcol'}{'addr'}->deiconify(); + $tlwins{'chngcol'}{'addr'}->raise(); + return; + } + my $dlgwin=$parframe->Toplevel(-title=>'Change colours'); + $dlgwin->resizable(0,0); + $tlwins{'chngcol'}{'addr'}=$dlgwin; +# entry widgets for default/active back/foreground + $dlgwin->Label(-text=>'Enter colours as names or RGB #xxxxxx values', + -font=>$deffont)->pack(-side=>'top'); + my $dlgdef=$dlgwin->Frame()->pack(-side=>'top'); + my $dlgact=$dlgwin->Frame()->pack(-side=>'top'); + my $dlgdef1=$dlgdef->Frame()->pack(-side=>'left'); + my $dlgtfr0=$dlgdef1->Frame()->pack(-side=>'top'); + my $dlgtfr1=$dlgdef1->Frame()->pack(-side=>'top'); + my $dlgact1=$dlgact->Frame()->pack(-side=>'left'); + my $dlgtfr2=$dlgact1->Frame()->pack(-side=>'top'); + my $dlgtfr3=$dlgact1->Frame()->pack(-side=>'top'); + $dlgtfr0->Label(-text=>"Default background", + -anchor=>'w', + -width=>18, + -font=>$deffont)->pack(-side=>'left'); + $dlgtfr0->Entry(-textvariable=>\$entryvar[0], + -font=>$deffont)->pack(-side=>'left'); + $dlgtfr1->Label(-text=>"Default foreground", + -anchor=>'w', + -width=>18, + -font=>$deffont)->pack(-side=>'left'); + $dlgtfr1->Entry(-textvariable=>\$entryvar[1], + -font=>$deffont)->pack(-side=>'left'); + my $deflabel=$dlgdef->Label(-text=>'Default', + -relief=>'ridge', + -width=>10, + -height=>2)->pack(-side=>'right', + -padx=>7); + $dlgtfr2->Label(-text=>"Active background", + -anchor=>'w', + -width=>18, + -font=>$deffont)->pack(-side=>'left'); + $dlgtfr2->Entry(-textvariable=>\$entryvar[2], + -font=>$deffont)->pack(-side=>'left'); + $dlgtfr3->Label(-text=>"Active foreground", + -anchor=>'w', + -width=>18, + -font=>$deffont)->pack(-side=>'left'); + $dlgtfr3->Entry(-textvariable=>\$entryvar[3], + -font=>$deffont)->pack(-side=>'left'); + my $actlabel=$dlgact->Label(-text=>'Active', + -background=>$entryvar[2], + -foreground=>$entryvar[3], + -relief=>'ridge', + -width=>10, + -height=>2)->pack(-side=>'right', + -padx=>7); +# buttons + my $setbfr=$dlgwin->Frame()->pack(-side=>'bottom'); + my $chngflag=0; + $tlwins{'chngcol'}{'buttons'}[0]= + $setbfr->Button(-text=>'OK', + -font=>$deffont,%butcol, + -command=>sub { + foreach (@entryvar) { # RGB form with leading # + $_="#$_" if (/^[A-Fa-f0-9]{6}$/); + } + $chngflag=1 if (&colcheck($dlgwin,@entryvar)); + }, + -width=>6)->pack(-side=>'left', + -padx=>5, + -pady=>10); + $tlwins{'chngcol'}{'buttons'}[1]= + $setbfr->Button(-text=>'Preview', + -font=>$deffont,%butcol, + -command=>sub { + foreach (@entryvar) { # RGB form with leading # + $_="#$_" if (/^[A-Fa-f0-9]{6}$/); + } + if (&colcheck($dlgwin,@entryvar)) { + $deflabel-> + configure(-background=>$entryvar[0], + -foreground=>$entryvar[1]); + $actlabel-> + configure(-background=>$entryvar[2], + -foreground=>$entryvar[3]); + } + }, + -width=>6)->pack(-side=>'left', + -padx=>5, + -pady=>10); + $tlwins{'chngcol'}{'buttons'}[2]= + $setbfr->Button(-text=>'Cancel', + -font=>$deffont,%butcol, + -command=>sub{destroy $dlgwin; + undef $tlwins{'chngcol'}; + })->pack(-side=>'right', + -padx=>5, + -pady=>10); + $dlgwin->bind(''=>sub{destroy $dlgwin; + undef $tlwins{'chngcol'}; }); + $dlgwin->waitVariable(\$chngflag); + destroy $dlgwin; + undef $tlwins{'chngcol'}; + return @entryvar; +} + +# check colours set in popcolor; relies on the existence of X11's showrgb +sub colcheck { + my ($dlgwin,@entryvar)=@_; + my $ecnt=0; + foreach (@entryvar) { # all colours defined? + last unless ($_); + ++$ecnt; + } + &popmsg(2,'Some colours undefined.',$dlgwin) if ($ecnt != 4); + my $defcol=0; + if (`which showrgb`) { # test for proper name + my @rgb=`showrgb`; + my @norgb; + foreach my $colour (@entryvar) { + if ($colour =~ /^#[A-Fa-f0-9]{6}$/ || grep /\b$colour\b/i,@rgb) { + ++$defcol; + } else { + push @norgb,$colour; + } + } + if ($defcol != 4) { + my $norgb=join("\n",@norgb); + &popmsg(2,"Some colours invalid:\n$norgb",$dlgwin); + } + } else { $defcol=4; } + return ($ecnt == 4 && $defcol == 4) ? 1 : 0; +} + +# write user's ~/.texdocrc +sub writerc { + use File::Copy qw/cp mv/; + my ($homedocpath_tmp,$quiet_tmp,$autoview_tmp,$xfmt_viewer_tmp, + $tdcolors_tmp, + $dvi_viewer_tmp,$dvips_conv_tmp, + $ps_viewer_tmp, + $pdf_viewer_tmp,$pdfps_conv_tmp, + $html_viewer_tmp, + $htmlps_conv_tmp,$htmlps_redir_tmp, + $txt_viewer_tmp,$txtps_conv_tmp, + $txtps_redir_tmp,$print_cmd_tmp,$parframe)=@_; + my $err=0; + mv $myrc,"$myrc.save" if (-e $myrc); + open(MYRC,">$myrc"); + print MYRC "# user's .texdocrc, generated by program\n +# root of user's doc directory (from \$HOMETEXMF) +# can be left empty if \$TEXMFHOME is undefined +HOMEDOCPATH=$homedocpath_tmp +# general viewer behaviour (y or yes to make active) +QUIET=$quiet_tmp +AUTOVIEW=$autoview_tmp +XFMT_VIEWER=$xfmt_viewer_tmp +# button colours: default and active back-/foreground +# names and RGB values are both allowed; use the form #xxxxxx for RGB +TDCOLORS=$tdcolors_tmp +# the following variables contain whole commands, i.e. options can be given +# DVI settings +DVI_VIEWER=$dvi_viewer_tmp +DVIPS_CONV=$dvips_conv_tmp +# PostScript handling +PS_VIEWER=$ps_viewer_tmp +# PDF handling +PDF_VIEWER=$pdf_viewer_tmp +PDFPS_CONV=$pdfps_conv_tmp +# HTML handling +HTML_VIEWER=$html_viewer_tmp +HTMLPS_CONV=$htmlps_conv_tmp +# HTMLPS_REDIR must be on, if the html->ps converter normally writes its output +# to stdout instead of a file (e.g. as html2ps) (y or yes to make active) +HTMLPS_REDIR=$htmlps_redir_tmp +# Plain text handling +# TDK_OWN is texdoctk's own text file viewer +TXT_VIEWER=$txt_viewer_tmp +TXTPS_CONV=$txtps_conv_tmp +# TXTPS_REDIR must be on, if the txt->ps converter normally writes its output +# to stdout instead of a file (e.g. as a2ps) (y or yes to make active) +TXTPS_REDIR=$txtps_redir_tmp +# printer +PRINT_CMD=$print_cmd_tmp +\n# end of config\n"; + close(MYRC); +} + +# help window (toplevel) +sub helptext { +# see if toplevel window is already there + if (Exists($tlwins{"helptext"}{'addr'})) { + $tlwins{"helptext"}{'addr'}->deiconify(); + $tlwins{"helptext"}{'addr'}->raise(); + return; + } + my $help=$main->Toplevel(-title=>'Help/About'); + $help->resizable(0,1); + $tlwins{'helptext'}{'addr'}=$help; + $help->Label(-text=>"texdoctk +TeX documentation browser +v$version ($date)", + -font=>$deffont)->pack(-side=>'top', + -ipady=>10, + -anchor=>'s'); + my $helpbody=$help->Scrolled("Text", + -relief=>'flat', + -font=>$deffont, + -height=>20, + -width=>60, + -scrollbars=>"e")->pack(-side=>'top', + -fill=>'y', + -expand=>1); + my $pos=tell DATA; + while () { + $_ =~ s/\$sysrc/$sysrc/; + last if (/^#/); + $helpbody->insert('end',$_); + } + seek(DATA,$pos,0); + $helpbody->configure(-state=>'disabled'); + $tlwins{'helptext'}{'buttons'}[0]= + $help->Button(-text=>'Close', + -font=>$deffont,%butcol, + -command=>sub{destroy $help; + undef $tlwins{"helptext"}; + })->pack(-side=>'bottom', + -fill=>'x'); + $help->bind(''=>sub{destroy $help; undef $tlwins{"helptext"};}); +} + +# read config file; personal settings override the default settings +sub readrc { + my($rcfile,$icall)=@_; + my ($var,$val); + my $pathflag=0; + my $pathflagl=0; + my $pathflagh=0; + my $tdcolors=''; +# for backward compatibility of converter/printer options + my ($dvips_opts,$pdfps_opts,$print_opts); +# read defaults resp. local/personal settings + CALL: { + ($icall == 1) && do { + open (RC,"$rcfile") || + &fatalmsg("Couldn't open system-wide default config file ${TeXDocRcDefaults}.\n"); + last CALL; + }; + ($icall == 2) && do { + open (RC,"$rcfile") || + &fatalmsg("Couldn't open personal config file ~/.texdocrc.\n"); + last CALL; + }; + }; + while ($line = ) { + next if ($line =~ /^($|#)/); + chomp $line; + ($var,$val)=split("=",$line,2); + RCVARS: { + ($var =~ /texdocpath/i) && do { # TEXDOCPATH + if (length $val > 0) { + $pathflag=1; + eval(join("",("\$",lc($var),"=\$val"))); + } + last RCVARS; + }; + ($var =~ /localdocpath/i) && do { # LOCALDOCPATH + if (length $val > 0) { + $pathflagl=1; + eval(join("",("\$",lc($var),"=\$val"))); + } + last RCVARS; + }; + ($var =~ /homedocpath/i) && do { # HOMEDOCPATH + if ($icall == 2 && length $val > 0) { # set only in ~/.texdocrc + $pathflagh=1; + eval(join("",("\$",lc($var),"=\$val"))); + } + last RCVARS; + }; + # other variables + eval(join("",("\$",lc($var),"=\$val"))); + }; + } + close(RC); +# find texmf/doc, and possibly other distribution texmf trees + if ($rcfile eq $sysrc || $pathflag == 1) { + $texmfmain=`kpsewhich --expand-path=${qq}\$TEXMFMAIN${qq}`; + chomp $texmfmain; + $texdocpath="$texmfmain/$texdocpath"; + $texmfdist=`kpsewhich --expand-path=${qq}\$TEXMFDIST${qq}`; + chomp $texmfdist; + $distdocpath=join('/',"$texmfdist",basename($texdocpath,"")) + if (length $texmfdist); + # TeXLive has this texmf-doc + $texmfdoc=join('/',"$texmfmain-doc",basename($texdocpath,"")); + if (-e $texmfdoc) { + chomp $texmfdoc; + $docdocpath="$texmfdoc/$docdocpath"; + } + } +# find texmf-local/doc, if there is one + if ($rcfile eq $sysrc || $pathflagl == 1) { + $texmflocal=`kpsewhich --expand-path=${qq}\$TEXMFLOCAL${qq}`; + chomp $texmflocal; + if (length $texmflocal) { + # if LOCALDOCPATH is not explicitly defined, it equals TEXDOCPATH + unless (defined $localdocpath) { + $localdocpath=basename($texdocpath,""); + } + $localdocpath="$texmflocal/$localdocpath"; + } + } +# find user's $HOMETEXMF/doc, if there is one + if ($icall == 2 || $pathflagh == 1) { + $texmfhome=`kpsewhich --expand-path=${qq}\$HOMETEXMF${qq}`; + chomp $texmfhome; + if (length $texmfhome) { + # if HOMEDOCPATH is not explicitly defined, it equals TEXDOCPATH + unless (defined $homedocpath) { + $homedocpath=basename($texdocpath,""); + } + $homedocpath="$texmfhome/$homedocpath"; + } + } +# colours: create array + @tdcolors=split(' ',$tdcolors); + if (scalar @tdcolors != 4) { # if old texdocrc file is used + if (!(-e $myrc) || (-e $myrc && $icall == 2)) { + print "NOTE: Button colours not set in $rcfile; using defaults.\n"; + @tdcolors=('#d9d9d9','Black','#ececec','red'); + } + } + %butcol=('-background'=>$tdcolors[0], + '-foreground'=>$tdcolors[1], + '-activebackground'=>$tdcolors[2], + '-activeforeground'=>$tdcolors[3]); +# viewer: suppress viewer warnings/use $PAGER if no $txt_viewer is defined + $quiet=($quiet =~ /y/i || $quiet eq "1") ? 1 : 0; + if (!(defined $txt_viewer) && defined $ENV{PAGER}) { + $txt_viewer=$ENV{PAGER}; + } +# viewer: autostart viewer if listbox of search results contains only 1 item + $autoview=($autoview =~ /y/i || $autoview eq "1") ? 1 : 0; +# viewer: use text viewer to open files with unrecognized format + $xfmt_viewer=($xfmt_viewer =~ /y/i || $xfmt_viewer eq "1") ? 1 : 0; +# converter: output redirection flags for HTML/Text->PS converters + $htmlps_redir=($htmlps_redir =~ /(y|1)/i) ? 1 : 0; + $txtps_redir=($txtps_redir =~ /(y|1)/i) ? 1 : 0; +# for backward compatibility of converter/printer options + $dvips_conv.=" $dvips_opts" if ($dvips_opts); + $pdfps_conv.=" $pdfps_opts" if ($pdfps_opts); + $print_cmd.=" $print_opts" if ($print_opts); +} + +# determine resolution if xwininfo is available +# slightly modified from a patch contributed by Reinhard Kotucha +sub x_resolution { + my $x_res; + if ($IsWin32) { + $x_res = &GetScreenWidth; + } + else { + open(XINF,"xwininfo -root|") or return 1200; + while () { + chop; + if (/Width:/) { ($x_res=$_)=/Width:\s+(\d+)/; last; } + } + close(XINF); + } + return $x_res; +} + +# generate a random name for temporary files +sub randname { + my $namestr; + my @chars=("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"); + my $time=time; + my $maxcnt=3+substr($time,-1); + for (my $i=0; $i<=$maxcnt; $i++) { $namestr.=$chars[rand(51)] } + my @tmp=split(/./,$time/$$); + $namestr.=$tmp[1]; + until (length($namestr) > 16) { $namestr.=int(rand(1000000)) } + return $namestr; +} + +# find index of an array entry +sub arrindex { + my @array=@_; + my $item=pop @array; + my $i=0; + foreach (@array) { + last if ($_ eq $item); + ++$i; + } + return $i; +} + +# clean up and exit +sub clean_exit { + foreach (@tmpfiles) { if (-e $_) { unlink $_; } } + exit; +} + +# alternative main window, launched for fatal error messages on startup +sub fatalmsg { + my($msg)=@_; + print STDERR $msg; # also print to stderr +# create frame for main window + my $main=new MainWindow; + $main->resizable(0,0); + $main->title("TeX Documentation Browser"); + $main->bind(''=>sub { exit }); + $main->bind(''=>sub { exit }); + my $msgframe=$main->Frame(-background=>"#ffcc99"); + my $cmdframe=$main->Frame; + $msgframe->pack(-side=>'top'); + $cmdframe->pack(-side=>'bottom',-fill=>'x'); +# make buttons for command frame + my $Qbut=$cmdframe->Button(-text=>'Kill',%butcol, + -command=>sub { exit })->pack(-fill=>'x'); +# define common default font for labels and text explicitly + my @deffont=$Qbut->configure(-font); +# ensure readability on high-res screens (suggested by R.Kotucha) + $deffont='Helvetica -16 bold' if &x_resolution > 1200; + $Qbut->configure(-font=>$deffont); + $msgframe->Label(-text=>'FATAL ERROR', + -font=>$deffont)->pack(-side=>'top', -fill=>'x'); +# get size of message text + my @dummy=split("\n",$msg); + my $nline=scalar @dummy; + my $msgwidth=0; + my $lline; + foreach (@dummy) { + $lline=length $_; + if ($lline > $msgwidth) { $msgwidth=$lline; } + } + my $message=$msgframe->Text(-relief=>'flat', + -font=>$deffont, + -height=>$nline, + -width=>$msgwidth)->pack(-side=>'top'); + $message->insert('end',$msg); + $message->configure(-state=>'disabled'); + MainLoop; +} + +if ($IsWin32) { + sub GetScreenWidth { + my $GetDeviceCaps = new Win32::API('gdi32', 'GetDeviceCaps', 'NN', 'N'); + my $HORZRES = 8; # from WinGDI.h + if(not defined $GetDeviceCaps) { + die "Can't import API GetDeviceCaps: $!\n"; + } + return $GetDeviceCaps->Call(0, $HORZRES); + } + + sub GetTempPath { + my $GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', 'N'); + if(not defined $GetTempPath) { + die "Can't import API GetTempPath: $!\n"; + } + my $lpBuffer = " " x 260; + + $GetTempPath->Call(80, $lpBuffer); + } + + sub ShellExecute { + my ($command, $file) = @_; + my $ShellExecute = new Win32::API('shell32', 'ShellExecute', 'NPPPPN', 'N'); + if(not defined $ShellExecute) { + die "Can't import API ShellExecute: $!\n"; + } + $ShellExecute->Call(0, $command, $file, '', '', 0); + } + + sub GetHomeDir { + my $home = $ENV{'HOME'}; + # Should check for CSIDL_... + return $home; + } +} +__END__ +Many TeX programmers provide more or less detailed manuals for +their programs or packages. They are usually available as .dvi, +.ps, .pdf, .html or plain text files (sometimes included in the +.sty files instead of a separate documentation file) and can be +accessed with this browser, which is simply an interface to find a +documentation more easily. It starts the respective viewer for +reading the selected documentation making use of a database file +which contains the path entries according to the current teTeX +texmf/doc structure; additional usage of a system-wide local and +of individual user texmf trees with corresponding databases is also +possible. +The documentations are grouped in several categories shown in the +main window; pressing one of its buttons lists all documentations +belonging to this topic. +The topic window lets you select one documentation file, view or +send it to the default printer. By right-clicking on the selected +item you get the complete path of the file. +The search button of the main window allows you to search the +database for a string; it does not search file names. Enter the +string and hit to start the search or to +cancel. Just hitting without typing something in will +show the full list of files in the database. +Defaults for the documentation root directory, the viewers, the +converters, certain options and the printer are set in the global +configuration file $sysrc. +However, each user can put a copy of it as .texdocrc into his home +directory to modify them according to his needs; modification or +generation of ~/.texdocrc can also be done with the Settings menu. +Additionally, the settings can be changed temporarily with this +menu. + +The following key shortcuts are defined for use with the browser: + Quit browser + Raise the Main window to the foreground + Search a keyword in database (case insensitive) + Cancel/close subwindow or search entry widget + View selected document (topic windows) + Print selected document (topic windows) + Open settings menu + Kill fatal error message window (same as + ) + Open this help + Equivalent to button press; + OK in selection menu and search + Next/previous widget + +There are the following command line options: + -a autostart viewer if a listbox of search results + contains only one item; can also be set in a + configuration file + -v disable suppression of viewer messages sent to + stderr and of certain permanent message popup + windows, in case this was not set in a + configuration file; default: off + +Some more information is available in the manpage of texdoctk. + +Comments and suggestions to: +Thomas Ruedas +tr@dlc.ku.dk or tex-k@tug.org +# Local Variables: +# mode: perl +# auto-fill-hook: do-auto-fill +# End: +# vim: ts=8 sw=4 noexpandtab diff --git a/Master/texmf-dist/scripts/texlive/allcm.sh b/Master/texmf-dist/scripts/texlive/allcm.sh new file mode 100755 index 00000000000..945c7c88457 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/allcm.sh @@ -0,0 +1,118 @@ +#!/bin/sh + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +progname=`basename $0` +tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ + +case "$progname" in + allec) + encoding=T1;; + *) + encoding=OT1;; +esac + +case "$1" in + -r) + DVIPS=dvired + shift + ;; + *) + DVIPS=dvips + ;; +esac + +body() +{ + cat <<-'eof' + \pagestyle{empty} + \parindent0in + \hfuzz=\maxdimen + \hbadness=10000 + \textheight9.5in + \textwidth6.5in + \newcommand{\myformula}{\sum a_{b_{c_d}} = c} + \newcommand{\mytext}{text $\mathcal{\myformula}\mathrm{\myformula} + \mathbf{\myformula}\mathsf{\myformula}\mathtt{\myformula} + \mathnormal{\myformula}\mathit{\myformula}$} + + \newcommand{\TestSizes}{{% + \tiny \mytext\scriptsize \mytext\footnotesize \mytext\small \mytext + \normalsize \mytext + \large \mytext\Large \mytext\LARGE \mytext\huge \mytext\Huge \mytext}} + \newcommand{\TestRM}{rm-family: {\rmfamily\TestSizes}\newline} + \newcommand{\TestSF}{sf-family: {\sffamily\TestSizes}\newline} + \newcommand{\TestTT}{tt-family: {\ttfamily\TestSizes}\newline} + \newcommand{\TestFamilies}{\TestRM\TestSF\TestTT\newline} + \newcommand{\TestMD}{md-series: {\mdseries\TestFamilies}} + \newcommand{\TestBF}{bf-series: {\bfseries\TestFamilies}} + \newcommand{\TestSeries}{\TestBF\TestMD\par} + \newcommand{\TestUP}{up-shape: {\upshape\TestSeries}\par} + \newcommand{\TestIT}{it-shape: {\itshape\TestSeries}\par} + \newcommand{\TestSL}{sl-shape: {\slshape\TestSeries}\par} + \newcommand{\TestSC}{sc-shape: {\scshape\TestSeries}\par} + \newcommand{\TestShapes}{\TestUP\TestIT\TestSL\TestSC} + \begin{document} + \TestShapes + \end{document} +eof +} + +head() +{ + echo '\documentclass['$1'pt]{article}' + echo '\usepackage['$encoding']{fontenc}' +} + +# before we create the tmpdir, set trap for cleanup +trap ' + rm -rf $tmpdir + exit 1 +' 1 2 3 7 13 15 + +(umask 077; mkdir "$tmpdir") || { + echo "$progname: failed to create temp directory." >&2 + exit 1 +} + +cd $tmpdir || exit 1 +echo >&2 +echo "---------------------------------------------------------------------" >&2 +echo ">>>>>>>>>>> Generating testfiles for 10pt, 11pt and 12pt. <<<<<<<<<<" >&2 +echo "---------------------------------------------------------------------" >&2 +head 10 > allcm10.tex +head 11 > allcm11.tex +head 12 > allcm12.tex +body >> allcm10.tex +body >> allcm11.tex +body >> allcm12.tex + +echo >&2 +echo "---------------------------------------------------------------------" >&2 +echo ">>>>>>>>>>> Calling latex... <<<<<<<<<<" >&2 +echo "---------------------------------------------------------------------" >&2 +latex allcm10 >/dev/null +latex allcm11 >/dev/null +latex allcm12 >/dev/null + +echo >&2 +echo "---------------------------------------------------------------------" >&2 +echo ">>>>>>>>>>> Now, calling $DVIPS to make missing fonts... <<<<<<<<<<" >&2 +echo "---------------------------------------------------------------------" >&2 +$DVIPS ${1+"$@"} -V -f allcm10 > /dev/null +$DVIPS ${1+"$@"} -V -f allcm11 > /dev/null +$DVIPS ${1+"$@"} -V -f allcm12 > /dev/null + +cd / +rm -rf $tmpdir diff --git a/Master/texmf-dist/scripts/texlive/allneeded.sh b/Master/texmf-dist/scripts/texlive/allneeded.sh new file mode 100755 index 00000000000..15c62c84adb --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/allneeded.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +progname=`basename $0` +dvired=false + +case $1 in +-r) DVIPS="dvips -x707" + shift;; +*) DVIPS=dvips;; +esac + +case $# in +0) echo "Usage: $progname [-r] files ..." >&2 + exit ;; +esac + +findopt= +dvipsopt= + +for i +do + if [ -f $i ] || [ -d $i ]; then + findopt="$findopt $i" + else + dvipsopt="$dvipsopt $i" + fi +done + +find $findopt -name \*.dvi -type f -print | + while true; do + read i + test -z "$i" && exit + echo "processing file '$i' ..." + $DVIPS $dvipsopt -f "$i" >/dev/null + echo + done diff --git a/Master/texmf-dist/scripts/texlive/dvi2fax.sh b/Master/texmf-dist/scripts/texlive/dvi2fax.sh new file mode 100755 index 00000000000..fdfa83211eb --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/dvi2fax.sh @@ -0,0 +1,41 @@ +#!/bin/sh +# options for dvips are passwd down + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +progname=`basename "$0"` +help() +{ + echo "Usage: $progname [-hi|-lo] file[.dvi] [options for dvips]" + echo " -hi: use high fax resolution (204x196) (default)" + echo " -lo: use low fax resolution (204x98)" + echo + echo "Example: $progname foo -l 2" +} + +dvipsconf=dfaxhigh; gsdev=dfaxhigh +case $1 in + -hi) gsdev=dfaxhigh; shift;; + -lo) gsdev=dfaxlow; shift;; +esac + +case $# in + 0) help >&2 + exit 1 + ;; +esac + +NAME=`basename "$1" .dvi` +dvips "$@" -P$dvipsconf -f | + gs -q -dSAFER -sDEVICE=$gsdev -sOutputFile="$NAME-%03d.fax" -sNOPAUSE - diff --git a/Master/texmf-dist/scripts/texlive/dvired.sh b/Master/texmf-dist/scripts/texlive/dvired.sh new file mode 100755 index 00000000000..4eb3586119d --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/dvired.sh @@ -0,0 +1,98 @@ +#!/bin/sh +#============================================================================== +# Version: 0.3 +# Module: dvired +# Purpose: Translate dvi-file into postscript with reduced output size. +# Two logical pages will be put on onto each physical sheet of +# paper. +# System: Linux. UNIX(tm) systems may work as well :-) +# Requires: pstops (http://www.dcs.ed.ac.uk/home/ajcd/psutils/), dvips +# Created: 19.11.1992 +# Last Change: 13.08.1999 +# Language: sh +# Author: Thomas Esser +# Address: te@dbs.uni-hannover.de +# Copyright: (c) 1994, 1999 by Thomas Esser +# Copying: GNU GENERAL PUBLIC LICENSE +#============================================================================== + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +help() +{ + cat < "$of" + ;; +esac diff --git a/Master/texmf-dist/scripts/texlive/e2pall.pl b/Master/texmf-dist/scripts/texlive/e2pall.pl new file mode 100755 index 00000000000..2997f8b1102 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/e2pall.pl @@ -0,0 +1,89 @@ +#!/usr/bin/env perl + +# Author: Jody Klymak , publisted by a posting +# to the pdftex mailinglist. + +# recursively finds all your eps files. Looks down \input{fname}. +# CAVEATS: +# 1) cannot handle \input{fname} split over more than one line. +# 1.5) cannot handle multiple \input{} or \includegraphics{} on one line. +# 2) Must be run from same directory as the Latex file. +# 3) Does not look down $TEXINPUTS or anything fancy like that... +# 4) Handling of \include is untested (though I guess its trivial) +# 5) Assumes *all* your graphics inclusions are [e]ps. But don't +# fret, because if they are not epstopdf dies anyhow.... +# 6) Does not distinguish between percent (\%) and comment (%). + +# Changelog: +# 20030103 -- Lachlan Andrew +# * Only append '.tex' if $fname doesn't exist. +# * Correctly handle lines with '}' after the \includegraphics{} +# * Allow multiple extensions for graphics files. .eps -> .ps -> none +# (Should try them in the same order as \includegraphics does +# -- given by \DeclareGraphicsExtensions{}?) +# * Allow \include the same way as \input +# * Allow \includegraphics{} to be split over multiple lines +# * Check that commands begin with '\', and allow spaces before arguments + +# EDIT these two lines for your system.... + +$Eps2PdfCom = "epstopdf"; +$ThisFunCom = "e2pall"; + +$fname=$ARGV[0]; + +# check for a *.tex at the end... +if ((-f "$fname")=="" && $fname !~ /.tex$/){ + $fname = "$fname.tex"; +} + +open(TEXFILE,$fname) or die "Cannot open file $fname"; +# print "Finding *.eps files in $fname\n"; + +$seekingArg = 0; +while($line=){ + # truncate $line after % sign.... + $line=~s/%.*//; + # check for /input.... + if ($line=~/\\input *{([^}]*)}/){ + print `$ThisFunCom $1`; + } + # check for /include.... + if ($line=~/\\include *{([^}]*)}/){ + print `$ThisFunCom $1`; + } + + $base = ""; + if ($line=~/\\includegraphics.*{([^}]*)}/){ + $base = $1; + } + elsif ($seekingArg==1 && ($line=~/{([^}]*)}/)){ + $base = $1; + } + elsif ($line=~/\\includegraphics/){ + $seekingArg = 1; + } + + if ($base ne "") { + $seekingArg = 0; + if ((-f "$base.eps")!="") { + $srcfile = "$base.eps"; + } + elsif ((-f "$base.ps")!=""){ + $srcfile = "$base.ps"; + } + else { + $srcfile = $base; + } + # check that the [e]ps version is newer than the pdf version.... + if ((-M "$base.pdf")=="" || (-M "$base.pdf") >= (-M "$srcfile")){ + print "Constructing \t $base.pdf from $srcfile\n"; + print `$Eps2PdfCom $srcfile`; + } + else{ + print "$base.pdf \t is up to date with $srcfile\n"; + } + + }; +} +close(TEXFILE); diff --git a/Master/texmf-dist/scripts/texlive/fmtutil-sys.sh b/Master/texmf-dist/scripts/texlive/fmtutil-sys.sh new file mode 100755 index 00000000000..bfb52f94e1f --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/fmtutil-sys.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# fmtutil-sys: Thomas Esser, public domain. + +# wrapper script for fmtutil with TEXMFVAR and TEXMFCONFIG set to +# TEXMFSYSVAR / TEXMFSYSCONFIG + +test -f /bin/ksh && test -z "$RUNNING_KSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } +unset RUNNING_KSH + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' +export PATH + +v=`kpsewhich -var-value TEXMFSYSVAR` +c=`kpsewhich -var-value TEXMFSYSCONFIG` + +TEXMFVAR="$v" +TEXMFCONFIG="$c" +export TEXMFVAR TEXMFCONFIG + +exec fmtutil ${1+"$@"} diff --git a/Master/texmf-dist/scripts/texlive/fmtutil.sh b/Master/texmf-dist/scripts/texlive/fmtutil.sh new file mode 100755 index 00000000000..06ef11380b4 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/fmtutil.sh @@ -0,0 +1,1017 @@ +#!/bin/sh +# fmtutil - utility to maintain format files. +# Public domain. Originally written by Thomas Esser. +# Run with --help for usage. + +# program history: +# further changes in texk/tetex/ChangeLog. +# 2007-01-04 patch by JK to support $engine subdir (enabled by default) +# Fr Apr 8 19:15:05 CEST 2005 cleanup now has an argument for the return code +# Do Mar 02 10:42:31 CET 2006 add tmpdir to TEXFORMATS +# So Ma 27 18:52:06 CEST 2005 honor $TMPDIR, $TEMP and $TMP, not just $TMP +# Sa Jan 15 18:13:46 CET 2005 avoid multiple variable assignments in one statement +# Di Jan 11 11:42:36 CET 2005 fix --byhyphen with relative hyphenfile +# Fr Dez 31 16:51:29 CET 2004 option catcfg added (for being called by texconfig) +# Do Dez 30 21:53:27 CET 2004 rename variable verbose to verboseFlag +# Sa Dez 25 12:44:23 CET 2004 implementation adopted for teTeX-3.0 (tcfmgr) +# Do Okt 28 11:09:36 CEST 2004 added --refresh +# Fr Sep 17 19:25:28 CEST 2004 save $0 in a variable before calling a function +# Sun May 9 23:24:06 CEST 2004 changes for new web2c: format names +# are now *.fmt, nothing else, disable +# "plain" symlinks +# Thu May 6 14:16:19 CEST 2004: "mv .../dev/null \ + && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } +unset RUNNING_KSH + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +progname=fmtutil +argv0=$0 +version='$Id: fmtutil 25899 2012-04-09 23:09:26Z karl $' + +cnf=fmtutil.cnf # name of the config file +export PATH + +############################################################################### +# cleanup() +# clean up the temp area and exit with proper exit status +############################################################################### +cleanup() +{ + rc=$1 + # for debugging, exit $rc here so $tmpdir with its logs sticks around. + $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ + && { cd / && rm -rf "$tmpdir"; } + (exit $rc); exit $rc +} + +############################################################################### +# help() and version() +# display help (or version) message and exit +############################################################################### +help() +{ + cat < +eof + cleanup 0 +} + +versionfunc() +{ + cat </dev/null; then + ed "$file" >/dev/null 2>&1 <<-eof + /$pat/ + c + $line + . + w + q +eof + else + echo "$line" >> $file + fi +} + +############################################################################### +# setmatch(match) +# setting the "match state" to true or false. Used to see if there was at +# least one match. +############################################################################### +setmatch() +{ + match=$1 +} + +############################################################################### +# getmatch() +# return success if there was at least one match. +############################################################################### +getmatch() +{ + test "x$match" = xtrue +} + +############################################################################### +# initTexmfMain() +# get $MT_TEXMFMAIN from $TEXMFMAIN +############################################################################### +initTexmfMain() +{ + case $MT_TEXMFMAIN in + "") MT_TEXMFMAIN=`kpsewhich --var-value=TEXMFMAIN`;; + esac + export MT_TEXMFMAIN +} + +############################################################################### +# cache_vars() +# locate files / kpathsea variables and export variables to environment +# this speeds up future calls to e.g. mktexupd +############################################################################### +cache_vars() +{ + : ${MT_VARTEXFONTS=`kpsewhich --expand-var='$VARTEXFONTS' | sed 's%^!!%%'`} + : ${MT_MKTEXNAM=`kpsewhich --format='web2c files' mktexnam`} + : ${MT_MKTEXNAM_OPT=`kpsewhich --format='web2c files' mktexnam.opt`} + : ${MT_MKTEXDIR=`kpsewhich --format='web2c files' mktexdir`} + : ${MT_MKTEXDIR_OPT=`kpsewhich --format='web2c files' mktexdir.opt`} + : ${MT_MKTEXUPD=`kpsewhich --format='web2c files' mktexupd`} + : ${MT_MKTEX_CNF=`kpsewhich --format='web2c files' mktex.cnf`} + : ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`} + export MT_VARTEXFONTS MT_MKTEXNAM MT_MKTEXNAM_OPT MT_MKTEXDIR + export MT_MKTEXDIR_OPT MT_MKTEXUPD MT_MKTEX_CNF MT_MKTEX_OPT +} + +############################################################################### +# abort(errmsg) +# print `errmsg' to stderr and exit with error code 1 +############################################################################### +abort() +{ + echo "$progname: $1." >&2 + cleanup 1 +} + +############################################################################### +# maybe_abort(errmsg) +# print `errmsg' to stderr and +# unless noAbortFlag is set exit with error code 1 +############################################################################### +maybe_abort() +{ + echo "$progname: $1." >&2 + $noAbortFlag || cleanup 1 +} + +############################################################################### +# verboseMsg(msg) +# print `msg' to stderr is $verbose is true +############################################################################### +verboseMsg() { + $verboseFlag && verbose echo ${1+"$@"} +} + +############################################################################### +# byebye() +# report any failures and exit the program +############################################################################### +byebye() +{ + if $has_warnings; then + { + cat <&2 + fi + + if $has_errors; then + { + cat <&2 + cleanup 1 + else + cleanup 0 + fi +} + +############################################################################### +# init_log_warning() +# reset the list of warning messages +############################################################################### +init_log_warning() +{ + log_warning_msg= + has_warnings=false +} + +############################################################################### +# init_log_failure() +# reset the list of failure messages +############################################################################### +init_log_failure() +{ + log_failure_msg= + has_errors=false +} + +############################################################################### +# log_warning(errmsg) +# report and save warning message `errmsg' +############################################################################### +log_warning() +{ + echo "Warning: $@" >&2 + if test -z "$log_warning_msg"; then + log_warning_msg="$@" + else + OLDIFS=$IFS; IFS= + log_warning_msg="$log_warning_msg +$@" + IFS=$OLDIFS + fi + has_warnings=true +} + +############################################################################### +# log_failure(errmsg) +# report and save failure message `errmsg' +############################################################################### +log_failure() +{ + echo "Error: $@" >&2 + if test -z "$log_failure_msg"; then + log_failure_msg="$@" + else + OLDIFS=$IFS; IFS= + log_failure_msg="$log_failure_msg +$@" + IFS=$OLDIFS + fi + has_errors=true +} + +############################################################################### +# verbose (cmd) +# execute cmd. Redirect output depending on $mktexfmtMode. +############################################################################### +verbose() +{ + $mktexfmtMode && ${1+"$@"} >&2 || ${1+"$@"} +} + +############################################################################### +# mktexdir(args) +# call mktexdir script, disable all features (to prevent sticky directories) +############################################################################### +mktexdir() +{ + initTexmfMain + MT_FEATURES=none "$MT_TEXMFMAIN/web2c/mktexdir" "$@" >&2 +} + +############################################################################### +# tcfmgr(args) +# call tcfmgr script +############################################################################### +tcfmgr() +{ + initTexmfMain + "$MT_TEXMFMAIN/texconfig/tcfmgr" "$@" +} + +############################################################################### +# mktexupd(args) +# call mktexupd script +############################################################################### +mktexupd() +{ + initTexmfMain + "$MT_TEXMFMAIN/web2c/mktexupd" "$@" +} + +############################################################################### +# main() +# parse commandline arguments, initialize variables, +# switch into temp. direcrory, execute desired command +############################################################################### +main() +{ + destdir= # global variable: where do we put the format files? + cnf_file= # global variable: full name of the config file + cmd= # desired action from command line + needsCleanup=false + need_find_hyphenfile=false + cfgparam= + cfgmaint= + verboseFlag=true + noAbortFlag=false + # eradicate double slashes to avoid kpathsea expansion. + tmpdir=`echo ${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ | sed s,//,/,g` + + # mktexfmtMode: if called as mktexfmt, set to true. Will echo the + # first generated filename after successful generation to stdout then + # (and nothing else), since kpathsea can only deal with one. + mktexfmtMode=false + case $argv0 in + mktexfmt|*/mktexfmt) + mktexfmtMode=true + fullfmt=$1; shift + case $fullfmt in + ""|--help) help ;; + --version) versionfunc ;; + --*) abort "unknown option $fullfmt, try --help" ;; + *.fmt|*.mem|*.base) + set x --byfmt `echo $fullfmt | sed 's@\.[a-z]*$@@'` ${1+"$@"} + shift + ;; + *.*) abort "unknown format type: $fullfmt" ;; + *) set x --byfmt $fullfmt; shift ;; + esac + ;; + esac + + use_engine_dir=true # whether to use web2c/$engine subdirs + while + case $1 in + --cnffile) + shift; cnf_file=$1; cfgparam=1;; + --cnffile=*) + cnf_file=`echo "$1" | sed 's/--cnffile=//'`; cfgparam=1; shift ;; + --fmtdir) + shift; destdir=$1;; + --fmtdir=*) + destdir=`echo "$1" | sed 's/--fmtdir=//'`; shift ;; + --no-engine-subdir) + use_engine_dir=false;; + --all|-a) + cmd=all;; + --edit|-e) + cmd=edit; cfgmaint=1;; + --missing|-m) + cmd=missing;; + --refresh|-r) + cmd=refresh;; + --byengine) + shift; cmd=byengine; arg=$1;; + --byengine=*) + cmd=byengine; arg=`echo "$1" | sed 's/--byengine=//'`; shift ;; + --byfmt|-f) + shift; cmd=byfmt; arg=$1;; + --byfmt=*) + cmd=byfmt; arg=`echo "$1" | sed 's/--byfmt=//'`; shift ;; + --byhyphen|-h) + shift; cmd=byhyphen; arg=$1;; + --byhyphen=*) + cmd=byhyphen; arg=`echo "$1" | sed 's/--byhyphen=//'`; shift ;; + --showhyphen|-s) + shift; cmd=showhyphen; arg=$1;; + --showhyphen=*) + cmd=showhyphen; arg=`echo "$1" | sed 's/--showhyphen=//'`; shift ;; + --help|-help) + cmd=help;; + --version) + cmd=version;; + --enablefmt) + shift; cmd=enablefmt; arg=$1; cfgmaint=1;; + --enablefmt=*) + cmd=enablefmt; arg=`echo "$1" | sed 's/--enablefmt=//'`; cfgmaint=1; shift;; + --disablefmt) + shift; cmd=disablefmt; arg=$1; cfgmaint=1;; + --disablefmt=*) + cmd=disablefmt; arg=`echo "$1" | sed 's/--disablefmt=//'`; cfgmaint=1; shift;; + --catcfg) + cmd=catcfg;; + --listcfg) + cmd=listcfg;; + --no-error-if-no-format) + noAbortFlag=true;; + --quiet|-q|--silent) + verboseFlag=false;; + --test|--dolinks|--force) + ;; + "") break;; + *) abort "unknown option \`$1'; try $progname --help if you need it";; + esac + do test $# -gt 0 && shift; done + + case "$cmd" in + "") abort "missing command; try $progname --help if you need it";; + help) help;; + version) versionfunc;; + esac + + if test -n "$cfgparam"; then + test -f "$cnf_file" || abort "config file \`$cnf_file' not found (ls-R missing?)" + fi + + if test -n "$cfgmaint"; then + if test -z "$cfgparam"; then + setupTmpDir + co=`tcfmgr --tmp $tmpdir --cmd co --file $cnf` + test $? = 0 || cleanup 1 + set x $co; shift + id=$1; cnf_file=$3; orig=$4 + verboseMsg "$progname: initial config file is \`$orig'" + fi + else + if test -z "$cfgparam"; then + cnf_file=`tcfmgr --cmd find --file $cnf` + test -f "$cnf_file" || abort "config file \`$cnf' not found" + fi + fi + + # these commands need no temp directory, so do them here: + case "$cmd" in + catcfg) + grep -v '^ *#' "$cnf_file" | sed 's@^ *@@; s@ *$@@' | grep . | sort + cleanup $? ;; + edit) + echo "$0: fmtutil --edit is disabled in TeX Live;" >&2 + echo "$0: use a file fmtutil-local.cnf instead." >&2 + echo "$0: See tlmgr --help or http://tug.org/texlive/doc/tlmgr.html." >&2 + cleanup 0 ;; + enablefmt|disablefmt) + $cmd $arg ;; # does not return + listcfg) + listcfg_loop + cleanup $? ;; + showhyphen) + show_hyphen_file "$arg" + cleanup $? ;; + esac + + if test -n "$cfgmaint"; then + if test -z "$cfgparam"; then + ci=`tcfmgr --tmp $tmpdir --cmd ci --id $id` + if test $? = 0; then + if test -n "$ci"; then + verboseMsg "$progname: configuration file updated: \`$ci'" + else + verboseMsg "$progname: configuration file unchanged." + fi + else + abort "failed to update configuration file." + fi + fi + cleanup $? + fi + + # set up destdir: + if test -z "$destdir"; then + : ${MT_TEXMFVAR=`kpsewhich -var-value=TEXMFVAR`} + destdir=$MT_TEXMFVAR/web2c + fi + test -d "$destdir" || mktexdir "$destdir" >/dev/null 2>&1 + test -d "$destdir" || abort "format directory \`$destdir' does not exist" + test -w "$destdir" || abort "format directory \`$destdir' is not writable" + + thisdir=`pwd` + + : ${KPSE_DOT=$thisdir} + export KPSE_DOT + + # due to KPSE_DOT, we don't search the current directory, so include + # it explicitly for formats that \write and later on \read + TEXINPUTS="$tmpdir:$TEXINPUTS"; export TEXINPUTS + # for formats that load other formats (e.g., jadetex loads latex.fmt), + # add the current directory to TEXFORMATS, too. Currently unnecessary + # for MFBASES and MPMEMS. + TEXFORMATS="$tmpdir:$TEXFORMATS"; export TEXFORMATS + + setupTmpDir + cd "$tmpdir" || cleanup 1 + + # make local paths absolute: + case "$destdir" in + /*) ;; + *) destdir="$thisdir/$destdir";; + esac + case "$cnf_file" in + /*) ;; + *) cnf_file="$thisdir/$cnf_file";; + esac + + cache_vars + init_log_failure + init_log_warning + # execute the desired command: + case "$cmd" in + all) + recreate_all;; + missing) + create_missing;; + refresh) + recreate_existing;; + byengine) + recreate_by_engine "$arg";; + byfmt) + recreate_by_fmt "$arg";; + byhyphen) + recreate_by_hyphenfile "$arg";; + esac + + byebye +} + +############################################################################### +# parse_line(config_line) sets global variables: +# format: name of the format, e.g. pdflatex +# engine: name of the TeX engine, e.g. tex, etex, pdftex +# texargs: flags for initex and name of the ini file (e.g. -mltex frlatex.ini) +# fmtfile: name of the format file (without directory, but with extension) +# +# Support for building internationalized formats sets: +# pool: base name of pool file (to support translated pool files) +# tcx: translation file used when creating the format +# +# Example (for fmtutil.cnf): +# mex-pl tex mexconf.tex nls=tex-pl,il2-pl mex.ini +# +# The nls parameter (pool,tcx) can only be specified as the first argument +# inside the 4th field in fmtutil.cnf. +# +# exit code: returns error code if the ini file is not installed +############################################################################### +parse_line() +{ + case $1 in + '#!') disabled=true; shift;; + *) disabled=false;; + esac + format=$1 + engine=$2 + hyphenation=$3 + shift; shift; shift + + # handle nls support: pool + tcx + pool=; tcx= + case $1 in + nls=*) + pool=`echo $1 | sed 's@nls=@@; s@,.*@@'` + tcx=`echo $1 | sed 's@nls=[^,]*@@; s@^,@@'` + shift # nls stuff is not handled by the engine directly, + # so we shift this away + ;; + esac + + texargs="$@" + + case "$engine" in + mpost) fmtfile="$format.mem"; kpsefmt=mp; texengine=metapost;; + mf|mfw|mf-nowin) fmtfile="$format.base"; kpsefmt=mf; texengine=metafont;; + *) fmtfile="$format.fmt"; kpsefmt=tex; texengine=$engine;; + esac + + # remove any * for the sake of the kpsewhich lookup. + eval lastarg=\$$# + inifile=`echo $lastarg | sed 's%^\*%%'` + + # See if we can find $inifile for return code: + kpsewhich -progname=$format -format=$kpsefmt $inifile >/dev/null 2>&1 +} + +############################################################################### +# find_hyphenfile(format, hyphenation) searches for hyphenation along +# searchpath of format +# exit code: returns error is file is not found +############################################################################### +find_hyphenfile() +{ + format="$1"; hyphenation="`echo $2 | sed 's/,/ /g'`" + case $hyphenation in + -) ;; + *) kpsewhich -progname="$format" -format=tex $hyphenation;; + esac +} + +############################################################################### +# find_info_for_name(format) +# Look up the config line for format `format' and call parse_line to set +# global variables. +############################################################################### +find_info_for_name() +{ + format="$1" + + # set x `awk '$1 == format {print; exit}' format="$format" "$cnf_file"`; shift + set x `egrep "^$format( | )" "$cnf_file" | sed q`; shift + test $# = 0 && abort "no info for format \`$format'" + parse_line "$@" +} + +############################################################################### +# run_initex() +# Calls initex. Assumes that global variables are set by parse_line. +############################################################################### +run_initex() +{ + + # install a pool file and set tcx flag if requested in lang= option: + rm -f *.pool + poolfile= + tcxflag= + test -n "$pool" \ + && poolfile=`(kpsewhich -progname=$engine $pool.pool) 2>/dev/null` + if test -n "$poolfile" && test -f "$poolfile"; then + verboseMsg "$progname: attempting to create localized format using pool=$pool and tcx=$tcx." + cp "$poolfile" $engine.pool + test -n "$tcx" && tcxflag=-translate-file=$tcx + localpool=true + else + localpool=false + fi + + jobswitch="-jobname=$format" + case "$format" in + metafun) prgswitch=-progname=mpost;; + mptopdf|cont-??) prgswitch=-progname=context;; + *) prgswitch=-progname=$format;; + esac + + rm -f $fmtfile + + # Check for infinite recursion before running the iniTeX: + # We do this check only if we are running in mktexfmt mode + # otherwise double format definitions will create an infinite loop, too + $mktexfmtMode || mktexfmt_loop= + case :$mktexfmt_loop: in + *:"$format/$engine":*) + abort "Infinite recursion detected, giving up!" ;; + esac + mktexfmt_loop=$mktexfmt_loop:$format/$engine + export mktexfmt_loop + + verboseMsg "$progname: running \`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' ..." + + # run in a subshell to get a local effect of TEXPOOL manipulation: + ( + # If necessary, set TEXPOOL. Use absolute path, because of KPSE_DOT. + $localpool && { TEXPOOL="`pwd`:$TEXPOOL"; export TEXPOOL; } + verbose $engine -ini $tcxflag $jobswitch $prgswitch $texargs + ) /dev/null 2>&1 && + log_warning "\`$engine -ini $tcxflag $jobswitch $prgswitch $texargs' possibly failed." + + # We don't want user-interaction for the following "mv" commands: + mv "$format.log" "$fulldestdir/$format.log" /dev/null" + + # No match before the loop: + setmatch false + + recreate_loop + + # Now check if there was at least one match: + getmatch || maybe_abort "no format depends on hyphen file \`$hyphenfile'" +} + +############################################################################### +# recreate_by_engine(enginename) +# recreate all formats that are based on enginename +############################################################################### +recreate_by_engine() +{ + enginename=$1 + + match_cmd="test x\$engine = x$enginename" + + # No match before the loop: + setmatch false + + recreate_loop + + # Now check if there was at least one match: + getmatch || maybe_abort "no format depends on engine \`$enginename'" +} + + + +############################################################################### +# show_hyphen_file(format) +# prints full name of the hyphenfile for format +# +# exit code: returns error code if the ini file is not installed or if +# the hyphen file cannot be found +############################################################################### +show_hyphen_file() +{ + fmtname=$1 + + find_info_for_name "$fmtname" || abort "no info for format \`$fmtname'" + if test "x$hyphenation" = x-; then + echo - + cleanup 0 + fi + find_hyphenfile "$format" "$hyphenation" \ + || abort "hyphenfile \`$hyphenation' not found" +} + +############################################################################### +# disablefmt(format) +# disables format in configuration file +############################################################################### +disablefmt() +{ + grep "^$1[ ]" $cnf_file >/dev/null || { (exit 0); return 0; } + + ed $cnf_file >/dev/null 2>&1 <<-eof + g/^$1[ ]/s/^/#! / + w + q +eof + (exit 0); return 0 +} + +############################################################################### +# enablefmt(format) +# enables format in configuration file +############################################################################### +enablefmt() +{ + grep "^#![ ]*$1[ ]" $cnf_file >/dev/null || { (exit 0); return 0; } + ed $cnf_file >/dev/null 2>&1 <<-eof + g/^#![ ]*$1[ ]/s/..[ ]*// + w + q +eof + (exit 0); return 0 +} + +main ${1+"$@"} +cleanup 0 diff --git a/Master/texmf-dist/scripts/texlive/fontinst.sh b/Master/texmf-dist/scripts/texlive/fontinst.sh new file mode 100755 index 00000000000..7d1271517ad --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/fontinst.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +tex -progname=fontinst \&tex ${1+"$@"} diff --git a/Master/texmf-dist/scripts/texlive/kpsetool.sh b/Master/texmf-dist/scripts/texlive/kpsetool.sh new file mode 100755 index 00000000000..463097fd4a9 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/kpsetool.sh @@ -0,0 +1,118 @@ +#!/bin/sh + +# kpsetool. Script to make teTeX-style kpsetool, kpsexpand and kpsepath +# available. Web2C's kpsewhich offers a superset of the functionality. +# For compatibilty with old versions of teTeX, this script provides the +# old command line interface of kpsetool, kpsexpand and kpsepath. All the +# real work is done inside Web2C's kpsewhich. +# Thomas Esser , Mar 1997, public domain. + +export PATH + +usage=" +Usage: kpsexpand [options] string +Usage: kpsetool -w [options] pathtype filename +Usage: kpsepath [options] pathtype + +Valid options are the following: + -n progname : pretend to be progname to kpathsea + -m mode : set Metafont mode + -w : locate files (similar to kpsewhich) + -p : act like kpsepath + -v : act like kpsexpand + +Valid pathtypes are: + gf : generic font bitmap + pk : packed bitmap font + base : Metafont memory dump + bib : BibTeX bibliography source + bst : BibTeX style files + cnf : Kpathsea runtime configuration files + fmt : TeX memory dump + mem : MetaPost memory dump + mf : Metafont source + mfpool : Metafont program strings + mp : MetaPost source + mppool : MetaPost program strings + mpsupport : MetaPost support files + pict : Other kinds of figures + tex : TeX source + texpool : TeX program strings + tfm : TeX font metrics + vf : virtual font + dvips_config : dvips config files + dvips_header : dvips header files + troff_font : troff fonts +" + +action=kpsexpand +case $0 in + */kpsewhich) action=kpsewhich;; + */kpsepath) action=kpsepath;; +esac + +progname=`echo $0 | sed 's@.*/@@'` +flags='' + +while true; do + case x"$1" in + x-n) + if test $# = 1; then + echo "$progname: missing argument for -n." + echo "$usage"; exit 1 + else + flags="$flags -progname=$2"; shift; shift + fi;; + x-m) + if test $# = 1; then + echo "$progname: missing argument for -m." + echo "$usage"; exit 1 + else + flags="$flags -mode=$2"; shift; shift + fi;; + x-w) action=kpsewhich; shift;; + x-p) action=kpsepath; shift;; + x-v) action=kpsexpand; shift;; + *) break;; + esac +done + +case "$action" in + kpsewhich|kpsepath) + case "$1" in + gf) format='gf';; + pk) format='pk';; + base) format='.base';; + bib) format='.bib';; + bst) format='.bst';; + cnf) format='.cnf';; + fmt) format='.fmt';; + mem) format='.mem';; + mf) format='.mf';; + mfpool) format='.pool';; + mp) format='.mp';; + mppool) format='.pool';; + mpsupport) format='MetaPost support';; + pict) format='.eps';; + tex) format='.tex';; + texpool) format='.pool';; + tfm) format='.tfm';; + vf) format='.vf';; + dvips_config) format='dvips config';; + dvips_header) format='.pro';; + troff_font) format='Troff fonts';; + *) echo "$progname: $1: unknown format"; echo "$usage"; exit 1;; + esac + shift;; +esac + +case "$action" in + kpsewhich) + test $# = 1 || { echo "$progname: missing filename"; echo "$usage"; exit 1; } + kpsewhich $flags -format="$format" "$1";; + kpsepath) + kpsewhich $flags -show-path="$format";; + kpsexpand) + test $# = 1 || { echo "$progname: missing string"; echo "$usage"; exit 1; } + kpsewhich $flags -expand-var="$1";; +esac diff --git a/Master/texmf-dist/scripts/texlive/kpsewhere.sh b/Master/texmf-dist/scripts/texlive/kpsewhere.sh new file mode 100755 index 00000000000..51088ee80d6 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/kpsewhere.sh @@ -0,0 +1,63 @@ +#!/bin/sh +# +# Thomas Esser, Hans Fredrik Nordhaug, 2003, 2004. +# Public domain. +# +# kpsewhere is an extension to kpsewhich (as where is for which in tcsh). +# The intention is to provide a way to check for conflicts/shadowed +# files. +# +# Original version by Hans Fredrik Nordhaug +# +# Bugs / limitations: +# conflicts/shadowed files whithin each texmf tree are not found. +# + + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +export PATH + +help='Usage: kpsewhere [OPTION]... [FILENAME]... + Expanding kpsewhich to iterate over each texmf tree listed in $TEXMF + separately. + + See kpsewhich for help on options. + + --help show this help' + +options= +while + case $1 in + -h|-help|--help) + echo "$help" >&2 + exit 0;; + -*) options="${options} '${1}'";; + *) break;; + esac +do shift; done + +case $# in + 0) + echo "$help" >&2 + exit 1 + ;; +esac + +IFS=':' +for file +do + for path in `kpsewhich --expand-path='$TEXMF'` + do + eval TEXMF=\$path kpsewhich $options \"\$file\" + done +done +exit 0 diff --git a/Master/texmf-dist/scripts/texlive/ps2frag.sh b/Master/texmf-dist/scripts/texlive/ps2frag.sh new file mode 100755 index 00000000000..b8e673be087 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/ps2frag.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +tty -s && { + echo + echo "Warning: the ps2frag script is not needed with this version of psfrag." + echo "Please read the manpage ps2frag(1) and the documentation of the" + echo "psfrag package." + echo +} >&2 + +exit 0 diff --git a/Master/texmf-dist/scripts/texlive/pslatex.sh b/Master/texmf-dist/scripts/texlive/pslatex.sh new file mode 100755 index 00000000000..4badef0ec12 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/pslatex.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# Copyright 1994 David Carlisle +# This file may be redistributed and/or modified under the terms of the +# LaTeX Project Public License distributed from CTAN archives in directory +# macros/latex/base/lppl.txt; either version 1 of the License, or (at +# your option) any later version. + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +# we want to be able to use options to latex: +while :; do + case $1 in + -*) + latexoptions="$latexoptions \"$1\"" + shift;; + *) + break;; + esac +done + +echo +echo "*************************************" +echo "* Using LaTeX, with pslatex package *" +echo "*************************************" +echo + +# messing around with \PSLATEXTMP is for AUCTeX which calls +# documents via latex \nonstopmode \input{file} + +latex $latexoptions \ + "\AtBeginDocument{\RequirePackage{pslatex}}"\ + "\def\PSLATEXTMP{\futurelet\PSLATEXTMP\PSLATEXTMPB}"\ + "\def\PSLATEXTMPB{\ifx\PSLATEXTMP\nonstopmode\else\input\fi}"\ + "\PSLATEXTMP" ${1+"$@"} diff --git a/Master/texmf-dist/scripts/texlive/rubibtex.sh b/Master/texmf-dist/scripts/texlive/rubibtex.sh new file mode 100755 index 00000000000..373e6e1194d --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/rubibtex.sh @@ -0,0 +1,110 @@ +#!/bin/sh + +# rubibtex, based on the original version contained in the t2 bundle. +# Thomas Esser, Public Domain. + +progname=rubibtex +tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/$progname.$$ +job=$1 +backup="$tmpdir/orig.aux" + +case $job in + "") + echo "usage: $progname file" >&2 + exit 1 +esac + +if test ! -f "$job.aux"; then + echo "$progname: file \`$job.aux' does not exist." >&2 + exit 1 +fi + +trap ' + rm -rf "$tmpdir" + exit 1 +' 1 2 3 7 13 15 +(umask 077; mkdir "$tmpdir") \ + || { echo "$progname: could not create directory \`$tmpdir'" >&2; exit 1; } + +cat <"$job.aux" >"$backup" || { + echo "$progname: could not create backup of file \`$job.aux' as \`$backup'." >&2 + rm -rf "$tmpdir" + exit 1 +} + +sed ' + /^\\citation/ { + s/\\IeC {\\CYRA }/á/g + s/\\IeC {\\CYRB }/â/g + s/\\IeC {\\CYRV }/÷/g + s/\\IeC {\\CYRG }/ç/g + s/\\IeC {\\CYRD }/ä/g + s/\\IeC {\\CYRE }/å/g + s/\\IeC {\\CYRYO }/³/g + s/\\IeC {\\CYRZH }/ö/g + s/\\IeC {\\CYRZ }/ú/g + s/\\IeC {\\CYRI }/é/g + s/\\IeC {\\CYRISHRT }/ê/g + s/\\IeC {\\CYRK }/ë/g + s/\\IeC {\\CYRL }/ì/g + s/\\IeC {\\CYRM }/í/g + s/\\IeC {\\CYRN }/î/g + s/\\IeC {\\CYRO }/ï/g + s/\\IeC {\\CYRP }/ð/g + s/\\IeC {\\CYRR }/ò/g + s/\\IeC {\\CYRS }/ó/g + s/\\IeC {\\CYRT }/ô/g + s/\\IeC {\\CYRU }/õ/g + s/\\IeC {\\CYRF }/æ/g + s/\\IeC {\\CYRH }/è/g + s/\\IeC {\\CYRC }/ã/g + s/\\IeC {\\CYRCH }/þ/g + s/\\IeC {\\CYRSH }/û/g + s/\\IeC {\\CYRSHCH }/ý/g + s/\\IeC {\\CYRHRDSN }/ÿ/g + s/\\IeC {\\CYRERY }/ù/g + s/\\IeC {\\CYRSFTSN }/ø/g + s/\\IeC {\\CYREREV }/ü/g + s/\\IeC {\\CYRYU }/à/g + s/\\IeC {\\CYRYA }/ñ/g + s/\\IeC {\\cyra }/Á/g + s/\\IeC {\\cyrb }/Â/g + s/\\IeC {\\cyrv }/×/g + s/\\IeC {\\cyrg }/Ç/g + s/\\IeC {\\cyrd }/Ä/g + s/\\IeC {\\cyre }/Å/g + s/\\IeC {\\cyryo }/£/g + s/\\IeC {\\cyrzh }/Ö/g + s/\\IeC {\\cyrz }/Ú/g + s/\\IeC {\\cyri }/É/g + s/\\IeC {\\cyrishrt }/Ê/g + s/\\IeC {\\cyrk }/Ë/g + s/\\IeC {\\cyrl }/Ì/g + s/\\IeC {\\cyrm }/Í/g + s/\\IeC {\\cyrn }/Î/g + s/\\IeC {\\cyro }/Ï/g + s/\\IeC {\\cyrp }/Ð/g + s/\\IeC {\\cyrr }/Ò/g + s/\\IeC {\\cyrs }/Ó/g + s/\\IeC {\\cyrt }/Ô/g + s/\\IeC {\\cyru }/Õ/g + s/\\IeC {\\cyrf }/Æ/g + s/\\IeC {\\cyrh }/È/g + s/\\IeC {\\cyrc }/Ã/g + s/\\IeC {\\cyrch }/Þ/g + s/\\IeC {\\cyrsh }/Û/g + s/\\IeC {\\cyrshch }/Ý/g + s/\\IeC {\\cyrhrdsn }/ß/g + s/\\IeC {\\cyrery }/Ù/g + s/\\IeC {\\cyrsftsn }/Ø/g + s/\\IeC {\\cyrerev }/Ü/g + s/\\IeC {\\cyryu }/À/g + s/\\IeC {\\cyrya }/Ñ/g + } +' <"$backup" >"$job.aux" + +bibtex "$job" + +cat "$backup" > "$job.aux" +rm -rf "$tmpdir" +exit 0 diff --git a/Master/texmf-dist/scripts/texlive/rumakeindex.sh b/Master/texmf-dist/scripts/texlive/rumakeindex.sh new file mode 100755 index 00000000000..b7b0c072729 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/rumakeindex.sh @@ -0,0 +1,77 @@ +#!/bin/sh + +BASE=`basename "$1" .idx` +IDX=$BASE.idx +IND=$BASE.ind +ILG=$BASE.ilg + +sed ' +/^\\indexentry{/ { +s/\\IeC {\\CYRA }/¾/g +s/\\IeC {\\cyra }/¿/g +s/\\IeC {\\CYRB }/À/g +s/\\IeC {\\cyrb }/Á/g +s/\\IeC {\\CYRV }/Â/g +s/\\IeC {\\cyrv }/Ã/g +s/\\IeC {\\CYRG }/Ä/g +s/\\IeC {\\cyrg }/Å/g +s/\\IeC {\\CYRD }/Æ/g +s/\\IeC {\\cyrd }/Ç/g +s/\\IeC {\\CYRE }/È/g +s/\\IeC {\\cyre }/É/g +s/\\IeC {\\CYRYO }/Ê/g +s/\\IeC {\\cyryo }/Ë/g +s/\\IeC {\\CYRZH }/Ì/g +s/\\IeC {\\cyrzh }/Í/g +s/\\IeC {\\CYRZ }/Î/g +s/\\IeC {\\cyrz }/Ï/g +s/\\IeC {\\CYRI }/Ð/g +s/\\IeC {\\cyri }/Ñ/g +s/\\IeC {\\CYRISHRT }/Ò/g +s/\\IeC {\\cyrishrt }/Ó/g +s/\\IeC {\\CYRK }/Ô/g +s/\\IeC {\\cyrk }/Õ/g +s/\\IeC {\\CYRL }/Ö/g +s/\\IeC {\\cyrl }/×/g +s/\\IeC {\\CYRM }/Ø/g +s/\\IeC {\\cyrm }/Ù/g +s/\\IeC {\\CYRN }/Ú/g +s/\\IeC {\\cyrn }/Û/g +s/\\IeC {\\CYRO }/Ü/g +s/\\IeC {\\cyro }/Ý/g +s/\\IeC {\\CYRP }/Þ/g +s/\\IeC {\\cyrp }/ß/g +s/\\IeC {\\CYRR }/à/g +s/\\IeC {\\cyrr }/á/g +s/\\IeC {\\CYRS }/â/g +s/\\IeC {\\cyrs }/ã/g +s/\\IeC {\\CYRT }/ä/g +s/\\IeC {\\cyrt }/å/g +s/\\IeC {\\CYRU }/æ/g +s/\\IeC {\\cyru }/ç/g +s/\\IeC {\\CYRF }/è/g +s/\\IeC {\\cyrf }/é/g +s/\\IeC {\\CYRH }/ê/g +s/\\IeC {\\cyrh }/ë/g +s/\\IeC {\\CYRC }/ì/g +s/\\IeC {\\cyrc }/í/g +s/\\IeC {\\CYRCH }/î/g +s/\\IeC {\\cyrch }/ï/g +s/\\IeC {\\CYRSH }/ð/g +s/\\IeC {\\cyrsh }/ñ/g +s/\\IeC {\\CYRSHCH }/ò/g +s/\\IeC {\\cyrshch }/ó/g +s/\\IeC {\\CYRHRDSN }/ô/g +s/\\IeC {\\cyrhrdsn }/õ/g +s/\\IeC {\\CYRERY }/ö/g +s/\\IeC {\\cyrery }/÷/g +s/\\IeC {\\CYRSFTSN }/ø/g +s/\\IeC {\\cyrsftsn }/ù/g +s/\\IeC {\\CYREREV }/ú/g +s/\\IeC {\\cyrerev }/û/g +s/\\IeC {\\CYRYU }/ü/g +s/\\IeC {\\cyryu }/ý/g +s/\\IeC {\\CYRYA }/þ/g +s/\\IeC {\\cyrya }/ÿ/g +}' $IDX | makeindex -t $ILG | tr '¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ' \ + 'áÁâÂ÷×çÇäÄåų£öÖúÚéÉêÊëËìÌíÍîÎïÏðÐòÒóÓôÔõÕæÆèÈãÃþÞûÛýÝÿßùÙøØüÜàÀñÑ' > $IND diff --git a/Master/texmf-dist/scripts/texlive/texconfig-dialog.sh b/Master/texmf-dist/scripts/texlive/texconfig-dialog.sh new file mode 100755 index 00000000000..e1868d91574 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/texconfig-dialog.sh @@ -0,0 +1,486 @@ +#!/bin/sh + +# TeX-Config version 3.0 +# Thomas Esser, te@dbs.uni-hannover.de. Public domain. + +# invoke the right shell: + +test -f /bin/ksh && test -z "$RUNNING_KSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } +unset RUNNING_KSH + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +export PATH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +# the version string +version='$Id: texconfig-dialog 23826 2011-09-05 17:59:15Z karl $' + +: ${PAGER=more} +progname=texconfig-dialog +tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/tcdtmp.$$ +log=$tmpdir/log +tmpmenu=$tmpdir/tmpmenu +needsCleanup=false + +############################################################################### +# cleanup() +# clean up the temp area and exit with proper exit status +############################################################################### +cleanup() +{ + rc=$1 + $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ + && { cd / && rm -rf "$tmpdir"; } + termCtl reset + (exit $rc); exit $rc +} + +############################################################################### +# setupTmpDir() +# set up a temp directory and a trap to remove it +############################################################################### +setupTmpDir() +{ + case $needsCleanup in + true) return;; + esac + + trap 'cleanup 1' 1 2 3 7 13 15 + needsCleanup=true + (umask 077; mkdir "$tmpdir") \ + || abort "could not create directory \`$tmpdir'" +} + +############################################################################### +# abort(errmsg) +# print `errmsg' to stderr and exit with error code 1 +############################################################################### +abort() +{ + echo "$progname: $1." >&2 + cleanup 1 +} + +logexec() +{ + (echo; echo ">>> Executing \`$@' <<<") >> $log + "$@" 2>&1 | tee -a $log +} + +############################################################################### +# runDialog(args, ...) +# execute the right dialog program with the right default parameters +############################################################################### +runDialog() +{ + if test -n "$DIALOG_PROG"; then + termCtl clear + $DIALOG_PROG --title "TeX setup utility" ${1+"$@"} + runDialogRc=$? + termCtl clear + else + abort "could not find dialog or whiptail program to run" + fi + (exit $runDialogRc) + return $runDialogRc +} + +############################################################################### +# findDialog(void) +# set DIALOG_PROG to the system dialog program, or the empty string. +############################################################################### +findDialog() +{ + for bin in whiptail dialog + do + binLoc=`texconfig findprog $bin` + case $binLoc in + "") DIALOG_PROG="";; + *) DIALOG_PROG=$binLoc; break;; + esac + done +} + +############################################################################### +# mktexdir(args) +# call mktexdir script, disable all features (to prevent sticky directories) +############################################################################### +mktexdir() +{ + MT_FEATURES=none "$TEXMFMAIN/web2c/mktexdir" "$@" >&2 +} + +############################################################################### +# termCtl(arg) +# some convenience utilities for terminal control +############################################################################### +termCtl() +{ + case $1 in + clear) + test -n "$NO_CLEAR" && return + tty >/dev/null 2>&1 && clear + ;; + reset) + test -n "$NO_CLEAR" && return + reset 2>/dev/null + stty sane 2>/dev/null + reset 2>/dev/null + termCtl clear + ;; + readln) + echo + echo "press return to continue..." + read a + ;; + esac +} + +############################################################################### +# menuMain(void) +# the main menu +############################################################################### +menuMain() +{ + cat <<-'eof' + The interactive texconfig utility will be started now. Make sure + your screen has at least 24 rows and 80 columns. If texconfig + crashes now, you can still set up your teTeX system using the + batch mode of texconfig. Try 'texconfig help' to get a list + of options. + + The interactive mode works best with a real vt100 terminal or + inside an xterm window. +eof + termCtl readln + + while :; do + logMessage='view logfile' + + runDialog \ + --menu " +Hint: all output of external commands (e.g. tex) is logged into +a file. You can look at this file using "LOG". If cursor keys make +trouble, you may have more luck with +/- and TAB. +" \ + 23 80 14 \ + EXIT 'exit' \ + PAPER 'default paper: A4 or letter (us)' \ + MODE 'default metafont mode and resolution' \ + REHASH 'rebuild filename databases' \ + FORMATS 'edit format definitions' \ + HYPHENATION 'customize hyphenation' \ + DVIPS 'dvips configuration' \ + FAQ 'view frequently asked questions + answers' \ + CONF 'show configuration' \ + LOG "$logMessage" \ + 2>"$tmpmenu" || break + + case `cat "$tmpmenu"` in + EXIT) + break + ;; + PAPER) + menuPaper + ;; + MODE) + menuMode + ;; + REHASH) + logexec texconfig rehash + termCtl readln + ;; + FORMATS) + texconfig formats + termCtl readln + ;; + HYPHENATION) + menuHyphenation + ;; + DVIPS) + menuDvips + ;; + FAQ) + texconfig faq + termCtl readln + ;; + CONF) + logexec texconfig conf + termCtl readln + ;; + LOG) + <"$log" eval $PAGER + termCtl readln + ;; + esac + done +} + +menuGetMode() +{ + # we need eval to get the command line right... :-( + eval \ + runDialog \ + --menu \"" +Chosse a mode to be used when metafont generates font bitmaps. The resolution is the most important point, but there might +be differences between modes of the same resolution. See the comments in the file modes.mf for more details. +\"" \ + 23 80 14 \ + `texconfig mode-list` 2>"$tmpmenu" +} + +menuMode() +{ + menuGetMode + mode=`cat "$tmpmenu"` + + if test -n "$mode"; then + logexec texconfig mode "$mode" + termCtl readln + fi +} + +menuDvips() +{ + menuDvipsDest=ps + + while :; do + case $menuDvipsDest in + ps) + menuDvipsPrinterOpt= + menuDvipsMsg=" +dvips GLOBAL section. Define the most common default settings (config.ps). +To define settings for a specific printer, first ADD a printer definition, +then CHANGE it. +" + ;; + *) + menuDvipsPrinterOpt="-P $menuDvipsDest" + menuDvipsMsg=" +dvips settings for printer $menuDvipsDest (config.$menuDvipsDest). Define +local settings for this printer. To switch back to global settings mode, +select GLOBAL. +" + ;; + esac + + runDialog \ + --menu "$menuDvipsMsg +You can use dvips for non PostScript printers, if you can setup your +printing system to convert PostScript to a format that your printer can +handle. Maybe, you can use GhostScript to do the conversion (if your +printer is supported)." \ + 23 80 9 \ + RETURN 'back to the main menu' \ + DEST 'define default destination of the generated Postscript' \ + MODE 'change metafont mode/resolution' \ + OFFSET 'shift output by some offset' \ + PAPER 'define the default paper' \ + GLOBAL 'change global settings (config.ps)' \ + CHANGE 'change printer settings (config.$PRINTER)' \ + ADD 'add a printer configuration' \ + DEL 'remove a printer configuration' \ + 2>"$tmpmenu" || break + + menuDvipsAns=`cat "$tmpmenu"` + case $menuDvipsAns in + RETURN) + break + ;; + DEST) + runDialog --inputbox "Enter the command to print. + +In general, you need a command like 'lpr' or 'lpr -Pfoo'. + +NOTE: If you just press return, printing will be disabled and the output saved to a file by default. +" 23 80 2>"$tmpmenu" + if test $? = 0; then + menuDvipsAns=`cat "$tmpmenu"` + case $menuDvipsAns in + "") + menuDvipsPrintOpt=- + ;; + *) + menuDvipsPrintOpt=$menuDvipsAns + ;; + esac + logexec texconfig dvips $menuDvipsPrinterOpt printcmd "$menuDvipsPrintOpt" + termCtl readln + fi + ;; + MODE) + menuGetMode + mode=`cat "$tmpmenu"` + + if test -n "$mode"; then + logexec texconfig dvips $menuDvipsPrinterOpt mode "$mode" + termCtl readln + fi + ;; + OFFSET) + runDialog --inputbox "Enter a dimension pair (a rightwards offset and a downwards +offset), e.g. 2mm,-0.5in (right 2mm and up .5in):" 23 80 2>"$tmpmenu"; menuDvipsAns=`cat "$tmpmenu"` + case $menuDvipsAns in + "") : ;; + *) + logexec texconfig dvips $menuDvipsPrinterOpt offset "$menuDvipsAns" + termCtl readln + ;; + esac + ;; + PAPER) + eval runDialog \ + --menu \'\\n\\nChoose the default papersize definition for dvips.\\n\\n\' \ + 23 80 8 `texconfig dvips paper-list` \ + 2>"$tmpmenu" + paper=`cat "$tmpmenu"` + if test -n "$paper"; then + logexec texconfig dvips paper "$paper" + termCtl readln + fi + ;; + GLOBAL) + menuDvipsDest=ps + ;; + CHANGE) + runDialog --inputbox "Printer name (for future settings of DEST / MODE / OFFSET)" 23 80 2>"$tmpmenu" + menuDvipsAns=`cat $tmpmenu` + case $menuDvipsAns in + "") : ;; + *) menuDvipsDest=$menuDvipsAns;; + esac + ;; + ADD) + runDialog --inputbox "Printer name (for printer to add)" 23 80 2>"$tmpmenu" + menuDvipsAns=`cat $tmpmenu` + case $menuDvipsAns in + "") : ;; + *) + logexec texconfig dvips add $menuDvipsAns + termCtl readln + ;; + esac + ;; + DEL) + runDialog --inputbox "Printer name (for printer to delete)" 23 80 2>"$tmpmenu" + menuDvipsAns=`cat $tmpmenu` + case $menuDvipsAns in + "") : ;; + *) + logexec texconfig dvips del $menuDvipsAns + termCtl readln + ;; + esac + ;; + esac + done +} + +menuPaper() +{ + runDialog \ + --menu " +Select your default paper format. +" \ + 23 80 14 \ + RETURN 'return to the main menu' \ + A4 'ISO A4 (210x297mm)' \ + LETTER 'US (8.5x11in)' 2>"$tmpmenu" + + p=`cat "$tmpmenu"` + case $p in + A4) + logexec texconfig paper a4 + termCtl readln + ;; + LETTER) + logexec texconfig paper letter + termCtl readln + ;; + esac +} + +menuHyphenation() +{ + runDialog \ + --menu " +Choose format to set up hyphenation for. +" \ + 23 80 14 \ + `texconfig hyphen-list | sed 's@\(.*\)@\1 \1@'` 2>"$tmpmenu" + p=`cat "$tmpmenu"` + case $p in + "") + return + ;; + *) + texconfig hyphen "$p" + termCtl readln + esac +} + +# main() + +case $1 in + help|--help) + cat <<-eof + Usage: $progname [--help|--version] +eof + exit 0 + ;; + --version) + cat <<-eof + $progname version $version. +eof + exit 0 + ;; +esac + + +: ${TEXMFCONFIG=`kpsewhich -var-value=TEXMFCONFIG`} +: ${TEXMFVAR=`kpsewhich -var-value=TEXMFVAR`} +: ${TEXMFMAIN=`kpsewhich -var-value=TEXMFMAIN`} +export TEXMFCONFIG TEXMFVAR TEXMFMAIN + +setupTmpDir +echo "$progname: started `date`" > $log +findDialog + +test -d "$TEXMFCONFIG" \ + || mktexdir "$TEXMFCONFIG" >/dev/null 2>&1 \ + || echo "$progname: directory \`$TEXMFCONFIG' (from TEXMFCONFIG variable) does not exist and cannot be created" >&2 + +canWriteConfig=false +if test -d "$TEXMFCONFIG"; then + if test -w "$TEXMFCONFIG"; then + canWriteConfig=true + else + echo "$progname: directory \`$TEXMFCONFIG' (from TEXMFCONFIG variable) is not writable." + echo "$progname: configuration data cannot be changed." >&2 + fi +fi + +test -d "$TEXMFVAR" \ + || mktexdir "$TEXMFVAR" >/dev/null 2>&1 \ + || echo "$progname: directory \`$TEXMFVAR' (from TEXMFVAR variable) does not exist and cannot be created" >&2 + +canWriteVardata=false +if test -d "$TEXMFVAR"; then + if test -w "$TEXMFVAR"; then + canWriteVardata=true + else + echo "$progname: directory \`$TEXMFVAR' (from TEXMFVAR variable) is not writable." + echo "$progname: cached variable runtime data files cannot be written." >&2 + fi +fi + +menuMain +cleanup 0 diff --git a/Master/texmf-dist/scripts/texlive/texconfig-sys.sh b/Master/texmf-dist/scripts/texlive/texconfig-sys.sh new file mode 100755 index 00000000000..ff549003ad2 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/texconfig-sys.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# $Id: texconfig-sys 20962 2011-01-07 11:45:38Z peter $ + +# texconfig-sys: Thomas Esser, public domain. + +# wrapper script for texconfig with TEXMFVAR and TEXMFCONFIG set to +# TEXMFSYSVAR / TEXMFSYSCONFIG + +test -f /bin/ksh && test -z "$RUNNING_KSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } +unset RUNNING_KSH + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +export PATH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +v=`kpsewhich -var-value TEXMFSYSVAR` +c=`kpsewhich -var-value TEXMFSYSCONFIG` + +TEXMFVAR="$v" +TEXMFCONFIG="$c" +export TEXMFVAR TEXMFCONFIG + +exec texconfig ${1+"$@"} diff --git a/Master/texmf-dist/scripts/texlive/texconfig.sh b/Master/texmf-dist/scripts/texlive/texconfig.sh new file mode 100755 index 00000000000..c9cc73c8305 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/texconfig.sh @@ -0,0 +1,1432 @@ +#!/bin/sh + +# TeXConfig version 3.0 +# Originally written by Thomas Esser. Public domain. +# Now maintained as part of TeX Live; correspondence to tex-live@tug.org. + +# invoke the right shell: + +test -f /bin/ksh && test -z "$RUNNING_KSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } +unset RUNNING_KSH + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +export PATH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +# initializations... +progname=texconfig + +# the version string +version='$Id$' + +envVars=" + AFMFONTS BIBINPUTS BSTINPUTS CMAPFONTS CWEBINPUTS ENCFONTS GFFONTS + GLYPHFONTS INDEXSTYLE LIGFONTS MFBASES MFINPUTS MFPOOL MFTINPUTS + MISCFONTS MPINPUTS MPMEMS MPPOOL MPSUPPORT OCPINPUTS OFMFONTS + OPENTYPEFONTS OPLFONTS OTPINPUTS OVFFONTS OVPFONTS PDFTEXCONFIG PKFONTS + PSHEADERS SFDFONTS T1FONTS T1INPUTS T42FONTS TEXBIB TEXCONFIG TEXDOCS + TEXFONTMAPS TEXFONTS TEXFORMATS TEXINDEXSTYLE TEXINPUTS TEXMFCNF + TEXMFDBS TEXMFINI TEXMFSCRIPTS TEXPICTS TEXPKS TEXPOOL TEXPSHEADERS + TEXSOURCES TFMFONTS TRFONTS TTFONTS VFFONTS WEB2C WEBINPUTS +" +tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/tctmp.$$ +needsCleanup=false +lastUpdatedFile= + +# +############################################################################### +# setupFMT(void) - find a suitable version of fmt / adjust +# +setupFMT() +{ + case $FMT in + "") + FMT=fmt + test ! -x /bin/fmt && test ! -f /usr/bin/fmt && + { test -x /bin/adjust || test -x /usr/bin/adjust; } && FMT=adjust + ;; + *) + return + ;; + esac +} + +############################################################################### +# myFmt(args) - run $FMT +# +myFmt() +{ + setupFMT + $FMT ${1+"$@"} +} + +############################################################################### +# echoShowVariable(args ...) +# show environment variables which names are as args and their values +# +echoShowVariable() +{ + for esv + do + var=$esv + eval val=\"\${$var+=}\${$var- is unset}\" + echo "$var$val" + done | grep -v 'is unset$' +} + +############################################################################### +# echoShowKpseVariable(args ...) +# show kpathsea variables which names are as args and their values +# +echoShowKpseVariable() +{ + for eskv + do + var=$eskv + val=`kpsewhich -var-value="$eskv"` + echo "$var=$val" + done +} + +############################################################################### +# echoLocateBinary(args ...) - show where programs actually exist +# +echoLocateBinary() +{ + for elb + do + elbLoc=`checkForBinary "$elb"` + if test -n "$ELB_PATH_ONLY"; then + test -n "$elbLoc" && echo "$elbLoc" + else + case $elbLoc in + "") echo "$elb: not found";; + *) echo "$elb: $elbLoc";; + esac + fi + done +} + +############################################################################### +# echoLocateCfgfile(args ...) - show where files actually exist +# +echoLocateCfgfile() +{ + for elc + do + case $elc in + texmf.cnf) elcLoc=`kpsewhich $elc`;; + *) elcLoc=`tcfmgr --cmd find --file "$elc"`;; + esac + case $elcLoc in + "") echo "$elc: not found";; + *) echo "$elcLoc";; + esac + done +} + +############################################################################### +# checkForBinary(prog) - echo full path of prog +# +checkForBinary() +{ + cfbBinary=$1 + + OLDIFS=$IFS + IFS=: + set x `echo "$PATH" | sed 's/^:/.:/; s/:$/:./; s/::/:.:/g'`; shift + found=false + for pathElem + do + case $pathElem in + "") continue;; + *) test -f "$pathElem/$cfbBinary" && { echo "$pathElem/$cfbBinary"; found=true; break; } + esac + done + IFS=$OLDIFS + case $found in + true) (exit 0); return 0;; + false) (exit 1); return 1;; + esac +} + +############################################################################### +# cleanup() - clean up the temp area and exit with proper exit status +# +cleanup() +{ + rc=$1 + $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ + && { cd / && rm -rf "$tmpdir"; } + (exit $rc); exit $rc +} + +############################################################################### +# setupTmpDir() - set up a temp directory and a trap to remove it +# +setupTmpDir() +{ + case $needsCleanup in + true) return;; + esac + + trap 'cleanup 1' 1 2 3 7 13 15 + needsCleanup=true + (umask 077; mkdir "$tmpdir") \ + || abort "could not create directory \`$tmpdir'" +} + +############################################################################### +# setupTexmfmain() - get value for MT_TEXMFMAIN (with caching) +# +setupTexmfmain() +{ + case $MT_TEXMFMAIN in + "") MT_TEXMFMAIN=`kpsewhich -var-value=TEXMFMAIN`;; + *) return;; + esac +} + +############################################################################### +# setupTexmfmain() - get value for MT_TEXMFDIST (with caching) +# +setupTexmfdist() +{ + case $MT_TEXMFDIST in + "") MT_TEXMFDIST=`kpsewhich -var-value=TEXMFDIST`;; + *) return;; + esac +} + +############################################################################### +# setupTexmfvar() - get value for MT_TEXMFVAR (with caching) +# +setupTexmfvar() +{ + case $MT_TEXMVAR in + "") MT_TEXMVAR=`kpsewhich -var-value=TEXMFVAR`;; + *) return;; + esac +} + +############################################################################### +# setupSystexmf() - get value for MT_SYSTEXMF (with caching) +# +setupSystexmf() +{ + case $MT_SYSTEXMF in + "") MT_SYSTEXMF=`kpsewhich -var-value=SYSTEXMF`;; + *) return;; + esac +} + +############################################################################### +# abort(errmsg) +# print `errmsg' to stderr and exit with error code 1 +# +abort() +{ + echo "$progname: $1." >&2 + cleanup 1 +} + +############################################################################### +# mktexdir(args) +# call mktexdir script, disable all features (to prevent sticky directories) +# +mktexdir() +{ + setupTexmfmain + MT_FEATURES=none "$MT_TEXMFMAIN/web2c/mktexdir" "$@" >&2 +} + +############################################################################### +# tcfmgr(args) - call tcfmgr script +# +tcfmgr() +{ + setupTexmfmain + "$MT_TEXMFMAIN/texconfig/tcfmgr" "$@" +} + +############################################################################### +# mktexupd(args) - call mktexupd script +# +mktexupd() +{ + setupTexmfmain + "$MT_TEXMFMAIN/web2c/mktexupd" "$@" +} + +############################################################################### +# getRelDir(file) +# matches file against SYSTEXMF. Returns relative directory of file within +# a texmf tree in variable relPart. +# +getRelDir() +{ + file=$1 + relPart= + + setupSystexmf + OLDIFS=$IFS + IFS=' +' + set x `echo "$MT_SYSTEXMF" | tr : ' +'`; shift + IFS=$OLDIFS + + # now loop over all components of SYSTEXMF + for dir + do + test -n "$dir" || continue + case "$file" in + $dir/*) + relPart=`echo "$file" | sed "s%$dir/*%%"` + break + ;; + esac + done + + # now check for success / failure + case $relPart in + ""|$file) + # empty or full filename -> getRelDir failed! + (exit 1); return 1 + ;; + *) + # relPart should just have the "dirname" part: + relPart=`echo "$relPart" | sed 's%/*[^/]*$%%'` + (exit 0); return 0 + ;; + esac +} + +############################################################################### +# configReplace(file pattern line) +# The first line in file that matches pattern gets replaced by line. +# line will be added at the end of the file if pattern does not match. +# +configReplace() +{ + configReplaceFile=$1; configReplacePat=$2; configReplaceLine=$3 + + if grep "$configReplacePat" "$configReplaceFile" >/dev/null; then + ed "$configReplaceFile" >/dev/null 2>&1 <<-eof + /$configReplacePat/c + $configReplaceLine + . + w + q +eof + else + echo "$configReplaceLine" >> $configReplaceFile + fi +} + +############################################################################### +# fmgrConfigReplace (file regex value) +# replaces line matching regex by value in file +# +fmgrConfigReplace() +{ + fmgrConfigReplaceChanged=false + + moreArgs="" + while + case $1 in + --*) moreArgs="$moreArgs $1 $2";; + *) break;; + esac + do shift; shift; done + fmgrConfigReplaceFile=$1 + fmgrConfigReplaceRegex=$2 + fmgrConfigReplaceValue=$3 + + setupTmpDir + co=`tcfmgr $moreArgs --tmp $tmpdir --cmd co --file $fmgrConfigReplaceFile` + if test $? != 0; then + echo "$progname: fmgrConfigReplace co failed for \`$fmgrConfigReplaceFile'" >&2 + (exit 1); return 1 + fi + set x $co; shift + fmgrConfigReplaceID=$1; fmgrConfigReplaceCfgFile=$3; fmgrConfigReplaceOrigFile=$4 + configReplace "$fmgrConfigReplaceCfgFile" "$fmgrConfigReplaceRegex" "$fmgrConfigReplaceValue" + ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$fmgrConfigReplaceID"` + if test $? != 0; then + echo "$progname: fmgrConfigReplace ci failed for \`$fmgrConfigReplaceFile'" >&2 + (exit 1); return 1 + fi + case $ci in + "") :;; + $lastUpdatedFile) + fmgrConfigReplaceChanged=true;; + *) echo "$progname: updated configuration saved as file \`$ci'" >&2 + fmgrConfigReplaceChanged=true + lastUpdatedFile=$ci;; + esac + (exit 0); return 0 +} + +############################################################################### +# setupDvipsPaper(paper) +# rearranges config.ps to make paper the first paper definition +# +setupDvipsPaper() +{ + setupDvipsPaperChanged=false + setupDvipsPaperFile=config.ps + setupDvipsPaperDftPaper=$1 + + setupTmpDir + co=`tcfmgr --tmp $tmpdir --cmd co --file $setupDvipsPaperFile` + if test $? != 0; then + echo "$progname: setupDvipsPaper co failed for \`$setupDvipsPaperFile'" >&2 + (exit 1); return 1 + fi + set x $co; shift + setupDvipsPaperID=$1; setupDvipsPaperCfgFile=$3; setupDvipsPaperOrigFile=$4 + + ed "$setupDvipsPaperCfgFile" > /dev/null 2>&1 <<-eof + /@ /ka + \$a + @ + . + /@ $setupDvipsPaperDftPaper /;/@ /-1m'a-1 + \$d + w + q +eof + + ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$setupDvipsPaperID"` + if test $? != 0; then + echo "$progname: setupDvipsPaper ci failed for \`$setupDvipsPaperFile'" >&2 + (exit 1); return 1 + fi + case $ci in + "") :;; + $lastUpdatedFile) + setupDvipsPaperChanged=true;; + *) echo "$progname: updated configuration saved as file \`$ci'" >&2 + setupDvipsPaperChanged=true + lastUpdatedFile=$ci;; + esac + (exit 0); return 0 +} + +############################################################################### +# setupModesMfFile(void) - find modes.mf file (with caching) +# +setupModesMfFile() +{ + case $modesMfFile in + "") + modesMfFile=`tcfmgr --cmd find --file modes.mf` + ;; + *) + return + ;; + esac +} + +############################################################################### +# locateConfigPsFile(void) - find config.ps file (with caching) +# +locateConfigPsFile() +{ + case $configPsFile in + "") + configPsFile=`tcfmgr --cmd find --file config.ps` + ;; + *) + return + ;; + esac +} + +############################################################################### +# listMfModes(file) - list modes from modes.mf file +# +listMfModes() +{ + grep mode_def "$modesMfFile" | + sed -e "s/mode_def //" \ + -e "s/ .*%[^ ]* / '/" \ + -e "s/\$/' /" | + egrep -v "^(help|%)" | sort +} + +############################################################################### +# listDvipsPapers(void) - list paper definitions from config.ps +# +listDvipsPapers() +{ + grep '@ ' $configPsFile | sed "s/..//;s/ / '/;s/\$/' /" +} + +############################################################################### +# getFormatsForHyphen(void) +# list all formats which have customizable hyphenation +# +getFormatsForHyphen() +{ + fmtutil --catcfg | awk '$3 != "-" {print $1}' | sort +} + +############################################################################### +# getRes(mode) - print resolution (both X and Y axis) to metafont mode +# +getRes() +{ + getResMode=$1 + ( + cd $tmpdir + cat >mftmp.mf <<-'eof' + let myexit = primitive_end_; + mode_setup; + string xdpi; + xdpi := decimal round pixels_per_inch; + message "XDPI = " & xdpi; + string ydpi; + ydpi := decimal round (pixels_per_inch * aspect_ratio); + message "YDPI = " & ydpi; + fontmaking := 0; + myexit; +eof + mf '\mode='"$getResMode"'; \input ./mftmp' &2; rc=1;; + *) + echo "$progname: unknown PAPER \`$3' given as argument for \`$progname dvipdfm paper'" >&2 + echo "$progname: try \`$progname dvipdfm paper' for help" >&2 + rc=1 ;; + esac ;; + # texconfig dvipdfm "" + "") + echo "$help" >&2; rc=1 ;; + # texconfig dvipdfm + *) + echo "$progname: unknown option \`$2' given as argument for \`$progname dvipdfm'" >&2 + echo "$progname: try \`$progname dvipdfm' for help" >&2 + rc=1 + ;; + esac + ;; + + # texconfig dvipdfmx + dvipdfmx) + help="Usage: $progname dvipdfmx paper PAPER + +Valid PAPER settings: + letter legal ledger tabloid a4 a3" + case $2 in + # texconfig dvipdfmx paper + paper-list) + for p in letter legal ledger tabloid a4 a3; do echo $p; done + ;; + paper) + case $3 in + letter|legal|ledger|tabloid|a4|a3) + fmgrConfigReplace dvipdfmx.cfg '^p' "p $3";; + "") echo "$help" >&2; rc=1;; + *) + echo "$progname: unknown PAPER \`$3' given as argument for \`$progname dvipdfmx paper'" >&2 + echo "$progname: try \`$progname dvipdfmx paper' for help" >&2 + rc=1 ;; + esac ;; + # texconfig dvipdfmx "" + "") + echo "$help" >&2; rc=1 ;; + # texconfig dvipdfmx + *) + echo "$progname: unknown option \`$2' given as argument for \`$progname dvipdfmx'" >&2 + echo "$progname: try \`$progname dvipdfmx' for help" >&2 + rc=1 + ;; + esac + ;; + + # texconfig dvips + dvips) + shift + help="Usage: $progname dvips add PRINTER + $progname dvips del PRINTER + $progname dvips paper PAPER + $progname dvips [-P PRINTER] mode MODE + $progname dvips [-P PRINTER] offset OFFSET + $progname dvips [-P PRINTER] printcmd CMD" + case $1 in + -P) + case $2 in + "") + echo "$progname: missing arg for parameter -P" >&2 + rc=1; (exit $rc); return $rc + ;; + *) + otherPrinter=true + otherPrinterName=$2 + otherPrinterFile=`kpsewhich -format='dvips config' "config.$otherPrinterName"` + case $otherPrinterFile in + "") + echo "$progname: configuration file \`config.$otherPrinterName' for printer \`$otherPrinterName' not found" >&2 + rc=1; (exit $rc); return $rc + ;; + *) shift; shift;; + esac + ;; + esac + ;; + *) + otherPrinter=false + ;; + esac + case $otherPrinter in + true) + tcBatchDvipsPrinter=$otherPrinterName + moreFmgrArgs="--reldir dvips/config --infile $otherPrinterFile" + ;; + *) + tcBatchDvipsPrinter=ps + ;; + esac + case $1 in + add) + case $2 in + "") + echo "Usage: $progname dvips add PRINTER" >&2 + rc=1 + ;; + *) + printerName=$2 + pFile=`kpsewhich -format='dvips config' "config.$printerName"` + case $pFile in + "") + setupTmpDir + tcfRet=`tcfmgr --emptyinfile --reldir dvips/config --cmd co --tmp $tmpdir --file "config.$printerName"` + if test $? != 0; then + echo "$progname: failed to add new configuration file \`config.$printerName'" >&2 + rc=1 + else + set x $tcfRet; shift + tcBatchDvipsAddID=$1; tcBatchDvipsAddFile=$3 + echo "% file config.$printerName; added by texconfig" > "$tcBatchDvipsAddFile" + tcfRet=`tcfmgr --tmp $tmpdir --id "$tcBatchDvipsAddID" --cmd ci` + if test $? != 0; then + echo "$progname: failed to add new configuration file \`config.$printerName'" >&2 + rc=1 + else + echo "$progname: file $tcfRet added" >&2 + fi + fi + ;; + *) + echo "$progname: configuration file for printer \`$printerName' already exists (\`$pFile')" >&2 + rc=1 + ;; + esac + ;; + esac + ;; + del) + case $2 in + "") + echo "Usage: $progname dvips del PRINTER" >&2 + rc=1 + ;; + *) + printerName=$2 + pFile=`kpsewhich -format='dvips config' "config.$printerName"` + case $pFile in + "") + echo "$progname: configuration file for printer \`$printerName' (config.$printerName) not found" >&2 + rc=1 + ;; + *) + if rm "$pFile"; then + echo "$progname: file \`$pFile' removed" >&2 + else + echo "$progname: failed to remove file \`$pFile'" >&2 + rc=1 + fi + ;; + esac + ;; + esac + ;; + paper-list) + locateConfigPsFile + listDvipsPapers + ;; + paper) + case $2 in + "") + echo "Usage: $progname dvips paper PAPER" >&2 + echo >&2; echo "Valid PAPER settings:" >&2 + locateConfigPsFile + listDvipsPapers | sed 's@ .*@@; s@^@ @' | myFmt + rc=1 + ;; + *) + tcBatchDvipsPaper=$2 + locateConfigPsFile + case "$configPsFile" in + "") + echo "$progname: file config.ps not found" >&2; rc=1 + ;; + *) + if grep "@ $tcBatchDvipsPaper " $configPsFile >/dev/null 2>&1; then + setupDvipsPaper "$tcBatchDvipsPaper" + else + echo "$progname: paper \`$tcBatchDvipsPaper' not found in file \`$configPsFile'" >&2; rc=1 + fi + ;; + esac + ;; + esac + ;; + mode) + case $2 in + "") + echo "Usage: $progname dvips mode MODE + +Valid MODE settings:" + setupModesMfFile + listMfModes | sed 's@ .*@@; s@^@ @' | myFmt + rc=1 + ;; + *) + tcBatchDvipsMode=$2 + setupTmpDir + setupModesMfFile + if checkElemInList "$tcBatchDvipsMode" `listMfModes | sed 's@ .*@@'`; then + set x `getRes "$tcBatchDvipsMode"`; shift + resX=$1; resY=$2 + fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^M' "M $tcBatchDvipsMode" + fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^D' "D $resX" + fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^X' "X $resX" + fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^Y' "Y $resY" + else + echo "$progname: unknown MODE \`$tcBatchDvipsMode' given as argument for \`$progname dvips mode'" >&2 + echo "$progname: try \`$progname dvips mode' for help" >&2 + rc=1 + fi + ;; + esac + ;; + offset) + offset=$2 + case $offset in + "") + echo "Usage: $progname dvips offset OFFSET" + rc=1 + ;; + *) + fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^O' "O $offset" + esac + ;; + printcmd) + printcmd=$2 + case $printcmd in + "") + echo "Usage: $progname dvips printcmd CMD" + rc=1 + ;; + -) + fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^o' o + ;; + *) + fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^o' "o |$printcmd" + ;; + esac + ;; + "") + echo "$help" >&2; rc=1 + ;; + *) + echo "$progname: unknown option \`$1' given as argument for \`$progname dvips'" >&2 + echo "$progname: try \`$progname dvips' for help" >&2 + rc=1 + ;; + esac + ;; + + faq) + setupTexmfmain + if test -f $MT_TEXMFMAIN/doc/tetex/teTeX-FAQ; then + <$MT_TEXMFMAIN/doc/tetex/teTeX-FAQ eval ${PAGER-more} + else + echo "$progname: faq not found (usually in \$TEXMFMAIN/doc/tetex/teTeX-FAQ)" >&2 + rc=1 + fi + ;; + + findprog) + shift + ELB_PATH_ONLY=1 echoLocateBinary "$@" + ;; + + # handle "texconfig font" + font) + help="Usage: $progname font vardir DIR + $progname font ro + $progname font rw + +The vardir option changes the VARTEXFONTS variable in the texmf.cnf file. + +The rw option makes the VARTEXFONTS directory (and subtrees pk, tfm, +source) world writable and sets the features appendonlydir:varfonts +in mktex.cnf. + +The ro option makes the VARTEXFONTS directory (and subtrees pk, tfm, +source) writable for the owner only and sets the feature texmfvar in +mktex.cnf. + +For more information about these \`features', consult the teTeX manual +(e.g. by running \`texdoc TETEXDOC')." + + case $2 in + vardir) + case $3 in + "") + echo "$help" >&2 + rc=1 + ;; + *) + tcBatchFontVardir=$3 + tfc=`kpsewhich texmf.cnf` + if test -n "$tfc"; then + if test -w "$tfc"; then + configReplace "$tfc" '^VARTEXFONTS' "VARTEXFONTS = $tcBatchFontVardir" + else + echo "$progname: setting up vardir failed. Reason: no permission to write file \`$tfc'" >&2 + rc=1 + fi + else + echo "$progname: setting up vardir failed. Reason: failed to find file texmf.cnf" >&2 + rc=1 + fi + ;; + esac + ;; + rw) + MT_VARTEXFONTS=`kpsewhich -var-value VARTEXFONTS` + if test -z "$MT_VARTEXFONTS"; then + echo "$progname: failed to set \`font rw'; reason: could not determine VARTEXFONTS variable." >&2; rc=1 + return + fi + test -d "$MT_VARTEXFONTS" || mktexdir "$MT_VARTEXFONTS" + if test ! -d "$MT_VARTEXFONTS"; then + echo "$progname: failed to set \`font rw'; reason: directory \`$MT_VARTEXFONTS' does not exist." >&2; rc=1 + return + fi + chmod 1777 "$MT_VARTEXFONTS" || { + echo "$progname: failed to modify permissions in \`$MT_VARTEXFONTS'." >&2; rc=1 + return; + } + ( + cd "$MT_VARTEXFONTS" || exit + echo "$progname: modifying permissions in \`$MT_VARTEXFONTS' ..." >&2 + for d in pk tfm source; do + test -d "$d" && find $d -type d -exec chmod 1777 '{}' \; + done + echo "$progname: all permissions set." >&2 + ) + setupTmpDir + fmgrConfigReplace mktex.cnf '^: ..MT_FEATURES=' ": \${MT_FEATURES=appendonlydir:varfonts}" + ;; + ro) + MT_VARTEXFONTS=`kpsewhich -var-value VARTEXFONTS` + if test -z "$MT_VARTEXFONTS"; then + echo "$progname: failed to set \`font ro'; reason: could not determine VARTEXFONTS variable." >&2; rc=1 + return + fi + test -d "$MT_VARTEXFONTS" || mktexdir "$MT_VARTEXFONTS" + if test ! -d "$MT_VARTEXFONTS"; then + echo "$progname: failed to set \`font ro'; reason: directory \`$MT_VARTEXFONTS' does not exist." >&2; rc=1 + return + fi + chmod 755 "$MT_VARTEXFONTS" || { + echo "$progname: failed to modify permissions in \`$MT_VARTEXFONTS'." >&2; rc=1 + return; + } + ( + cd "$MT_VARTEXFONTS" || exit + echo "$progname: modifying permissions in \`$MT_VARTEXFONTS' ..." >&2 + for d in pk tfm source; do + test -d "$d" && find "$d" -type d -exec chmod 755 '{}' \; + done + echo "$progname: all permissions set." >&2 + ) + setupTmpDir + fmgrConfigReplace mktex.cnf '^: ..MT_FEATURES=' ": \${MT_FEATURES=texmfvar}" + ;; + "") echo "$help" >&2; rc=1;; + *) echo "$progname: unknown option \`$2' given as argument for \`$progname font'" >&2 + echo "$progname: try \`$progname font' for help" >&2 + rc=1 + ;; + esac + ;; + + formats) + cat >&2 <&2 + fmtutil --catcfg > $tmpdir/pre + fmtutil --edit + echo "$progname: analyzing new configuration..." >&2 + fmtutil --catcfg > $tmpdir/post + + if cmp $tmpdir/pre $tmpdir/post >/dev/null 2>&1; then + echo "$progname: no new/updated formats available ..." >&2 + else + echo "$progname: updating formats ..." >&2 + comm -13 $tmpdir/pre $tmpdir/post > $tmpdir/addOrChange + for i in `awk '{print $1}' $tmpdir/addOrChange`; do + fmtutil --byfmt "$i" || rc=1 + done + texlinks --multiplatform || rc=1 + fi + ;; + + help|--help|-h) + echo "$help" + ;; + + # "hyphen FORMAT" + hyphen) + cat >&2 <&2; rc=1 + ;; + *) + if checkElemInList "$tcBatchHyphenFormat" $formatsForHyphen; then + + tcBatchHyphenFile=`fmtutil --showhyphen "$tcBatchHyphenFormat"` + case $tcBatchHyphenFile in + "") + echo "$progname: could not find hyphen setup file for format \`$tcBatchHyphenFormat'" >&2 + rc=1 + return + ;; + esac + + getRelDir "$tcBatchHyphenFile" + case $relPart in + "") + # edit tcBatchHyphenFile directly + tcBatchHFID= + setupTmpDir + tcBatchHFEdit=$tcBatchHyphenFile + tcBatchHFOrig=$tmpdir/hforig + cp "$tcBatchHyphenFile" "$tcBatchHFOrig" + ;; + *) + # use tcfmgr + tcBatchHyphenFileBasename=`echo "$tcBatchHyphenFile" | sed 's@.*/@@'` + setupTmpDir + co=`tcfmgr --tmp $tmpdir --cmd co --file "$tcBatchHyphenFileBasename" --reldir "$relPart" --infile "$tcBatchHyphenFile"` + if test $? != 0; then + echo "$progname: failed to check out file \`$tcBatchHyphenFile'" >&2 + rc=1 + return 1 + else + set x $co; shift + tcBatchHFID=$1; tcBatchHFEdit=$3; tcBatchHFOrig=$4 + fi + ;; + esac + ${VISUAL-${EDITOR-vi}} "$tcBatchHFEdit" + if cmp "$tcBatchHFEdit" "$tcBatchHFOrig" >/dev/null 2>&1; then + echo "$progname: configuration unchanged." >&2 + else + case $tcBatchHFID in + "") + tcBatchHFOut=$tcBatchHFEdit + echo "$progname: updated configuration saved as file \`$tcBatchHFOut'" >&2 + lastUpdatedFile=$ci + ;; + *) + ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$tcBatchHFID"` + if test $? != 0; then + echo "$progname: failed to check in file \`$tcBatchHyphenFileBasename'" >&2 + rc=1 + return + else + tcBatchHFOut=$ci + echo "$progname: updated configuration saved as file \`$tcBatchHFOut'" >&2 + lastUpdatedFile=$ci + fi + ;; + esac + fmtutil --byhyphen "$tcBatchHFOut" + fi + else + echo "$progname: invalid format \`$tcBatchHyphenFormat' specified as argument for \`$progname hyphen'" >&2 + echo "$progname: for getting help, try \`$progname hyphen'" >&2 + rc=1 + fi + ;; + esac + ;; + + hyphen-list) + getFormatsForHyphen + ;; + + init) + case $2 in + "") + if fmtutil --all \ + && texlinks --multiplatform \ + && updmap; then + : + else + rc=1 + fi + ;; + *) + shift 1 + for i in "$@"; do + fmtutil --byfmt "$i" || rc=1 + done + ;; + esac + ;; + + mode-list) + setupModesMfFile + listMfModes + ;; + + mode) + case $2 in + "") + echo "Usage: $progname mode MODE + +Valid MODE settings:" + setupModesMfFile + listMfModes | sed 's@ .*@@; s@^@ @' | myFmt + rc=1 + ;; + *) + tcBatchMode=$2 + setupModesMfFile + if checkElemInList $tcBatchMode `listMfModes | sed 's@ .*@@'`; then + + # modify mktex.cnf + setupTmpDir + fmgrConfigReplace mktex.cnf '^: ..MODE=' ": \${MODE=$tcBatchMode}" + set x `getRes "$tcBatchMode"`; shift + tcBatchRes=$1 + fmgrConfigReplace mktex.cnf '^: ..BDPI=' ": \${BDPI=$tcBatchRes}" + + if checkForBinary dvips >/dev/null && tcfmgr --cmd find --file config.ps >/dev/null 2>&1; then + tcBatch dvips mode "$tcBatchMode" + fi + if checkForBinary pdftex >/dev/null && tcfmgr --cmd find --file pdftexconfig.tex >/dev/null 2>&1; then + tcBatch pdftex mode "$tcBatchMode" + fi + else + echo "$progname: unknown mode \`$tcBatchMode' specified as argument for \`$progname mode'" >&2; rc=1 + fi + ;; + esac + ;; + + paper) + help="Usage: $progname paper PAPER + +Valid PAPER settings: + letter a4" + + p=$2; pXdvi=$2; pDvips=$2 + case $2 in + letter) + pXdvi=us;; + a4) + pXdvi=a4;; + "") echo "$help" >&2; rc=1; return;; + *) + echo "$progname: unknown PAPER \`$2' given as argument for \`$progname paper'" >&2 + echo "$progname: try \`$progname paper' for help" >&2 + rc=1 + return;; + esac + if checkForBinary dvips >/dev/null && tcfmgr --cmd find --file config.ps >/dev/null 2>&1; then + tcBatch dvips paper $pDvips + fi + if checkForBinary dvipdfm >/dev/null && tcfmgr --cmd find --file config >/dev/null 2>&1; then + tcBatch dvipdfm paper $p + fi + if checkForBinary dvipdfmx >/dev/null && tcfmgr --cmd find --file dvipdfmx.cfg >/dev/null 2>&1; then + tcBatch dvipdfmx paper $p + fi + if checkForBinary xdvi >/dev/null && tcfmgr --cmd find --file XDvi >/dev/null 2>&1; then + tcBatch xdvi paper $pXdvi + fi + if checkForBinary pdftex >/dev/null && tcfmgr --cmd find --file pdftexconfig.tex >/dev/null 2>&1; then + tcBatch pdftex paper $p + fi + ;; + + pdftex) + help="Usage: $progname pdftex paper PAPER + +Valid PAPER settings: + a4 letter" + case $2 in + + mode) + case $3 in + "") + echo "Usage: $progname pdftex mode MODE" + rc=1 + ;; + *) + tcBatchPdftexMode=$3 + setupTmpDir + setupModesMfFile + if checkElemInList "$tcBatchPdftexMode" `listMfModes | sed 's@ .*@@'`; then + set x `getRes "$tcBatchPdftexMode"`; shift + fmgrConfigReplace pdftexconfig.tex 'pdfpkresolution' "\\pdfpkresolution=$1" + if $fmgrConfigReplaceChanged; then + fmtutil --refresh + fi + else + echo "$progname: unknown MODE \`$tcBatchPdftexMode' given as argument for \`$progname pdftex mode'" >&2 + rc=1 + fi + ;; + esac + ;; + + paper) + case $3 in + letter) + w="8.5 true in"; h="11 true in" + setupTmpDir + fmgrConfigReplace pdftexconfig.tex pdfpagewidth '\pdfpagewidth='"$w" + wChanged=$fmgrConfigReplaceChanged + fmgrConfigReplace pdftexconfig.tex pdfpageheight '\pdfpageheight='"$h" + if $wChanged || $fmgrConfigReplaceChanged; then + fmtutil --refresh + fi + ;; + a4) + w="210 true mm"; h="297 true mm" + fmgrConfigReplace pdftexconfig.tex pdfpagewidth '\pdfpagewidth='"$w" + wChanged=$fmgrConfigReplaceChanged + fmgrConfigReplace pdftexconfig.tex pdfpageheight '\pdfpageheight='"$h" + if $wChanged || $fmgrConfigReplaceChanged; then + fmtutil --refresh + fi + ;; + "") echo "$help" >&2; rc=1;; + *) + echo "$progname: unknown PAPER \`$3' given as argument for \`$progname pdftex paper'" >&2 + echo "$progname: try \`$progname pdftex paper' for help" >&2 + rc=1 ;; + esac ;; + "") + echo "$help" >&2; rc=1;; + *) + echo "$progname: unknown option \`$2' given as argument for \`$progname pdftex'" >&2 + echo "$progname: try \`$progname pdftex' for help" >&2 + rc=1 + ;; + esac + ;; + + rehash) + mktexlsr + ;; + + # + version|--version) + echo "$progname version $version" + setupTexmfmain + setupTexmfdist + showDistVersionInfo + (exit 0); exit 0;; + + # handle "xdvi paper PAPER" + xdvi) + tcBatchXdviPapers='us "8.5x11" +usr "11x8.5" +legal "8.5x14" +foolscap "13.5x17.0" +a1 "59.4x84.0cm" +a2 "42.0x59.4cm" +a3 "29.7x42.0cm" +a4 "21.0x29.7cm" +a5 "14.85x21.0cm" +a6 "10.5x14.85cm" +a7 "7.42x10.5cm" +a1r "84.0x59.4cm" +a2r "59.4x42.0cm" +a3r "42.0x29.7cm" +a4r "29.7x21.0cm" +a5r "21.0x14.85cm" +a6r "14.85x10.5cm" +a7r "10.5x7.42cm" +b1 "70.6x100.0cm" +b2 "50.0x70.6cm" +b3 "35.3x50.0cm" +b4 "25.0x35.3cm" +b5 "17.6x25.0cm" +b6 "13.5x17.6cm" +b7 "8.8x13.5cm" +b1r "100.0x70.6cm" +b2r "70.6x50.0cm" +b3r "50.0x35.3cm" +b4r "35.3x25.0cm" +b5r "25.0x17.6cm" +b6r "17.6x13.5cm" +b7r "13.5x8.8cm" +c1 "64.8x91.6cm" +c2 "45.8x64.8cm" +c3 "32.4x45.8cm" +c4 "22.9x32.4cm" +c5 "16.2x22.9cm" +c6 "11.46x16.2cm" +c7 "8.1x11.46cm" +c1r "91.6x64.8cm" +c2r "64.8x45.8cm" +c3r "45.8x32.4cm" +c4r "32.4x22.9cm" +c5r "22.9x16.2cm" +c6r "16.2x11.46cm" +c7r "11.46x8.1cm"' + help="Usage: $progname xdvi paper PAPER + +Valid PAPER settings: + a1 a1r a2 a2r a3 a3r a4 a4r a5 a5r a6 a6r a7 a7r + b1 b1r b2 b2r b3 b3r b4 b4r b5 b5r b6 b6r b7 b7r + c1 c1r c2 c2r c3 c3r c4 c4r c5 c5r c6 c6r c7 c7r + foolscap legal us usr" + case $2 in + paper-list) + echo "$tcBatchXdviPapers" + ;; + paper) + case $3 in + a1|a1r|a2|a2r|a3|a3r|a4|a4r|a5|a5r|a6|a6r|a7|a7r|b1|b1r|b2|b2r|b3|b3r|b4|b4r|b5|b5r|b6|b6r|b7|b7r|c1|c1r|c2|c2r|c3|c3r|c4|c4r|c5|c5r|c6|c6r|c7|c7r|foolscap|legal|us|usr) + fmgrConfigReplace XDvi paper: "*paper: $3" + ;; + "") echo "$help" >&2; rc=1;; + *) + echo "$progname: unknown PAPER \`$3' given as argument for \`$progname xdvi paper'" >&2 + echo "$progname: try \`$progname xdvi paper' for help" >&2 + rc=1 ;; + esac ;; + "") + echo "$help" >&2; rc=1;; + *) + echo "$progname: unknown option \`$2' given as argument for \`$progname xdvi'" >&2 + echo "$progname: try \`$progname xdvi' for help" >&2 + rc=1 + ;; + esac + ;; + *) + echo "$progname: unknown option \`$1' given as argument for \`$progname'" >&2 + echo "$progname: try \`$progname help' for help" >&2 + rc=1 + esac +} + +############################################################################### +# tcInteractive(void) +# handle interactive mode +############################################################################### +tcInteractive() +{ + texconfig-dialog +} + +############################################################################### +# main() +############################################################################### +rc=0 +case $# in + 0) tcInteractive;; + *) tcBatch "$@";; +esac + +cleanup $rc diff --git a/Master/texmf-dist/scripts/texlive/texlinks.sh b/Master/texmf-dist/scripts/texlive/texlinks.sh new file mode 100755 index 00000000000..09b3488d263 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/texlinks.sh @@ -0,0 +1,335 @@ +#!/bin/sh +# $Id: texlinks 18035 2010-04-28 17:41:52Z mpg $ + +# Thomas Esser, 1999, 2002, 2003. public domain. + +# texlinks: script to maintain symlinks from format to engine. Interprets +# the lines given in fmtutil.cnf. + +# History: +# (Further changes in ChangeLog.) +# Tue Oct 9 14:23:01 BST 2007 +# Added unlink option (-u) to aid OpenBSD package uninstall +# Edd Barrett +# Sun Aug 28 21:41:06 CEST 2005 +# remove special cases for csplain,cslatex,pdfcslatex,pdfcsplain +# Fr Apr 8 19:15:05 CEST 2005 +# cleanup now has an argument for the return code +# So Mar 27 18:52:06 CEST 2005 +# honor $TMPDIR, $TEMP and $TMP, not just $TMP +# Mon May 10 20:52:48 CEST 2004 +# kpseaccess instead of access +# Thu Dec 25 22:11:53 CET 2003, te: +# add version string +# Tue Apr 9 22:46:34 CEST 2002, te: +# do not create symlinks for cont-??, metafun and mptopdf + +test -f /bin/sh5 && test -z "$RUNNING_SH5" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_SH5=true; export RUNNING_SH5; exec /bin/sh5 $0 ${1+"$@"}; } +unset RUNNING_SH5 + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +export PATH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +version='$Id: texlinks 18035 2010-04-28 17:41:52Z mpg $' +progname=texlinks +cnf=fmtutil.cnf # name of the config file + +usage='Usage: texlinks [OPTION]... [DIRECTORY]... + +Create symbolic links format -> engine according to fmtutil setup. + +Mandatory arguments to long options are mandatory for short options too. + -e, --exeext EXT append EXT to symlink targets (default: none) + -f, --cnffile FILE use FILE as config file (default: fmtutil.cnf) + -m, --multiplatform operate in all platform specific directories + (default: operate only in directory for this platform) + -q, --quiet silently skip existing scripts / binaries + (default: issue warning) + -s, --silent same as -q + -u, --unlink remove symlinks created by texlinks + -v, --verbose enable verbose messages (default: off) + -h, --help show this help text + --version show version string + +The DIRECTORY arguments are an optional list of directories in which to +operate. If no directories are specified and --multiplatform is +likewise not specified, the directory of this script itself is used. +With --multiplatform, all child dirs of an upper-level bin/ dir are used. + +Report bugs to: tex-k@tug.org +TeX Live home page: +' + +############################################################################### +# abort(errmsg) +# print `errmsg' to stderr and exit with error code 1 +############################################################################### +abort() { errmsg "texlinks: $1."; cleanup 1; } + +# error message to stderr: +errmsg() { echo "$@" >&2; } + +# give message to stderr only if "verbose" mode is on: +verbose_echo() { $verbose && errmsg "$@"; } + +# in verbose mode: show command that is executed: +verbose_do() { verbose_echo "$@"; "$@"; } + +############################################################################### +# cleanup() +# clean up the temp area and exit with proper exit status +############################################################################### +cleanup() +{ + rc=$1 + $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \ + && { rm -f "$tmpdir"/*; cd /; rmdir "$tmpdir"; } + exit $rc +} + +############################################################################### +# setupTmpDir() +# set up a temp directory and a trap to remove it +############################################################################### +setupTmpDir() +{ + $needsCleanup && return + + trap 'cleanup 1' 1 2 3 7 13 15 + needsCleanup=true + (umask 077; mkdir "$tmpdir") \ + || abort "could not create directory \`$tmpdir'" +} + + +# search a binary along $PATH: +check_for_binary() +{ + testbin=$1 + set x `echo "$PATH" | sed 's/^:/.:/; s/:$/:./; s/::/:.:/g; s/:/ /g'`; shift + for i + do + if [ -x "$i/$testbin" ]; then + echo "$i/$testbin" + return 0 + fi + done + return 1 +} + + +############################################################################### +# install_link(dest src) +# create a symlink like ln -s dest src, but make sure that src is not +# an existing binary, possibly adding the executable extension if +# passed on the command. +############################################################################### +install_link() +{ + # make symlink src -> dest + dest=$1; src=$2 + + case $src in + */mf) + if test "$dest" = mf-nowin; then + if test -f $selfautoloc/mfw; then + dest=mfw # name for windows-enabled mf, once upon a time + verbose_echo "both mfw and mf-nowin exists, $src linked to $dest" + fi + if test -f $selfautoloc/mf && test -f $selfautoloc/mf-nowin; then + # have both mf and mf-nowin binaries. no link. + verbose_echo "skipped metafont symlink $src -> $dest (special case)" + return + fi + fi + ;; + esac + + # append .exe if supplied (for cygwin). + test -n "$exeext" && dest="$dest$exeext" + + case $src in + */cont-??|*/mptopdf) + # context includes wrapper scripts that create/run these. + verbose_echo "skipped ConTeXtish symlink $src -> $dest (special case)" + ;; + *) + test "x$src" != "x`(ls -ld $src | awk '{print $NF}') 2>/dev/null`" && + rm -f "$src" + + if test -f "$src"; then + case $silent in + true) + ;; + *) + errmsg "install_link $src -> $dest failed: file already exists." + ;; + esac + else + verbose_do ln -s "$dest" "$src" + fi + ;; + esac +} + +############################################################################### +# search_symlinkdir() +# look if $PATH has only symlinks to the real binaries and find that +# directory. Also check if this directory is writable. +############################################################################### +search_symlinkdir() +{ + kpsewhich=`check_for_binary kpsewhich` + test -z "$kpsewhich" && return 1 + symlinkdir=`echo $kpsewhich | sed 's@/*kpsewhich$@@'` + kpseaccess -w "$symlinkdir" || return 1 + touch "$symlinkdir/tl$$" + if test -f "$selfautoloc/tl$$"; then + rm -f "$symlinkdir/tl$$" + return 1 + else + rm -f "$symlinkdir/tl$$" + return 0 + fi +} + +############################################################################### +# upd_symlinkdir() +# if $PATH has only symlinks to the real binaries, update that directory +# that holds the symlinks +############################################################################### +upd_symlinkdir() +{ + search_symlinkdir || return 0 + for i in `sed 's@ .*@@' cnf_file_ln.$$`; do + install_link "$selfautoloc/$i" "$symlinkdir/$i" + done +} + +############################################################################### +# rm_link() +# Delete a previously installed link +############################################################################### +rm_link() +{ + link=$1; + if test -e $link; then + if test -h $link; then + verbose_do rm -Rf $link + else + verbose_echo "kept $link, since not a symlink" + fi + else + verbose_echo "skipped $link, non-existent" + fi +} + +############################################################################### +# main() +# parse commandline arguments, initialize variables, +# switch into temp. direcrory, execute desired command +############################################################################### +main() +{ + cnf_file= # global variable: full name of the config file + dirs= + needsCleanup=false + + exeext= + multiplatform=false + verbose=false + unlink=false + silent=false + thisdir=`pwd` + : ${KPSE_DOT=$thisdir}; export KPSE_DOT + selfautoloc=`kpsewhich --expand-var='$SELFAUTOLOC'` + while + case $1 in + --h*|-h) + echo "$usage"; exit 0;; + --version) + echo "$progname version $version"; exit 0;; + --cnffile|-f) + shift; cnf_file=$1;; + --e*|-e) shift; exeext=$1;; + --m*|-m) multiplatform=true;; + --s*|-s|--q*|-q) silent=true;; + --u*|-u) unlink=true;; + --v*|-v) verbose=true;; + -*) errmsg "fmtutil: unknown option \`$1' ignored.";; + *) break;; + esac + do test $# -gt 0 && shift; done + dirs="$*" + + # if no cnf_file from command-line, look it up with kpsewhich: + test -z "$cnf_file" && cnf_file=`kpsewhich --format='web2c files' $cnf` + test -f "$cnf_file" || abort "config file \`$cnf' not found" + + + tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/texlinks.$$ + setupTmpDir + cd "$tmpdir" || cleanup 1 + + sed '/^[ ]*#/d; /^[ ]*$/d' $cnf_file \ + | awk '{print $1, $2}' > cnf_file_ln.$$ + + if test -z "$dirs"; then + if test $multiplatform = true; then + case $selfautoloc in + */bin) dirs=$selfautoloc;; + *) parent=`kpsewhich --expand-var='$SELFAUTODIR'` + dirs=`find $parent -type f -name kpsewhich -print \ + | sed 's@/kpsewhich$@@'`;; + esac + else + dirs=$selfautoloc + fi + fi + + for d in $dirs; do + kpseaccess -w $d \ + || { errmsg "$d: no write permissions. Skipping..."; continue; } + # cnf_file_ln.$$ has lines with "format engine" pairs + set x `cat cnf_file_ln.$$`; shift + while test $# != 0; do + fmt=$1; engine=$2; shift; shift + + # Some broken shells destroy the positional arguments when calling a + # shellfunction. Therefore, we save and restore them "by hand" in the + # main_args_while variable. + main_args_while="$@" + + test "x$fmt" = "x$engine" && continue + if test -f "$d/$engine$exeext"; then + case $unlink in + true) + rm_link "$d/$fmt";; + *) + install_link "$engine" "$d/$fmt";; + esac + else + verbose_echo "skipped $d/$engine, engine does not exist" + fi + + # restore positional arguments: + set x $main_args_while; shift + + done + done + upd_symlinkdir +} + +main ${1+"$@"} + +# set successful return code +cleanup 0 diff --git a/Master/texmf-dist/scripts/texlive/updmap-sys.sh b/Master/texmf-dist/scripts/texlive/updmap-sys.sh new file mode 100755 index 00000000000..6f3c8365658 --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/updmap-sys.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# updmap-sys: Thomas Esser, public domain. + +# wrapper script for updmap with TEXMFVAR and TEXMFCONFIG set to +# TEXMFSYSVAR / TEXMFSYSCONFIG + +test -f /bin/ksh && test -z "$RUNNING_KSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \ + && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; } +unset RUNNING_KSH + +test -f /bin/bsh && test -z "$RUNNING_BSH" \ + && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \ + && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; } +unset RUNNING_BSH + +export PATH + +# hack around a bug in zsh: +test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"' + +v=`kpsewhich -var-value TEXMFSYSVAR` +c=`kpsewhich -var-value TEXMFSYSCONFIG` + +TEXMFVAR="$v" +TEXMFCONFIG="$c" +export TEXMFVAR TEXMFCONFIG + +exec updmap ${1+"$@"} diff --git a/Master/texmf-dist/scripts/texlive/updmap.pl b/Master/texmf-dist/scripts/texlive/updmap.pl new file mode 100755 index 00000000000..c87e7d09b7f --- /dev/null +++ b/Master/texmf-dist/scripts/texlive/updmap.pl @@ -0,0 +1,2306 @@ +#!/usr/bin/env perl +# mupdmap: utility to maintain map files for outline fonts. +# $Id: updmap.pl 27264 2012-07-31 05:10:29Z preining $ +# +# Copyright 2011, 2012 Norbert Preining +# This file is licensed under the GNU General Public License version 2 +# or any later version. +# +# History: +# Original shell script (C) 2002 Thomas Esser +# first perl variant (C) Fabrice Popineau +# later adaptions by Reinhard Kotucha and Karl Berry +# the original versions were licensed under the following agreement: +# Anyone may freely use, modify, and/or distribute this file, without +# limitation. +# +# TODO +# - check all other invocations +# - after TL2012? Maybe remove support for reading updmap-local.cfg +# + +my $TEXMFROOT; + +BEGIN { + $^W=1; + $TEXMFROOT = `kpsewhich -var-value=TEXMFROOT`; + if ($?) { + print STDERR "updmap: Cannot find TEXMFROOT, aborting!\n"; + exit 1; + } + chomp($TEXMFROOT); + unshift (@INC, "$TEXMFROOT/tlpkg"); +} + + +my $version = '$Id: updmap.pl 27264 2012-07-31 05:10:29Z preining $'; + +use Getopt::Long qw(:config no_autoabbrev ignore_case_always); +use strict; +use TeXLive::TLUtils qw(mkdirhier mktexupd win32 basename dirname + sort_uniq member); + +#use Data::Dumper; +#$Data::Dumper::Indent = 1; + +(my $prg = basename($0)) =~ s/\.pl$//; + +# sudo sometimes does not reset the home dir of root, check on that +# see more comments at the definition of the function itself +# this function checks by itself whether it is running on windows or not +reset_root_home(); + +chomp(my $TEXMFMAIN = `kpsewhich --var-value=TEXMFMAIN`); +chomp(my $TEXMFVAR = `kpsewhich -var-value=TEXMFVAR`); +chomp(my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`); +chomp(my $TEXMFHOME = `kpsewhich -var-value=TEXMFHOME`); + +# make sure that on windows *everything* is in lower case for comparison +if (win32()) { + $TEXMFMAIN = lc($TEXMFMAIN); + $TEXMFVAR = lc($TEXMFVAR); + $TEXMFCONFIG = lc($TEXMFCONFIG); + $TEXMFROOT = lc($TEXMFROOT); + $TEXMFHOME = lc($TEXMFHOME); +} + + +my %opts = ( quiet => 0, nohash => 0, nomkmap => 0 ); +my $alldata; +my $updLSR; + +my @cmdline_options = ( + "listfiles", + "cnffile=s@", + "copy", + "disable=s@", + "dvipdfmoutputdir=s", + "dvipdfmxoutputdir=s", + "dvipsoutputdir=s", + # the following does not work, Getopt::Long looses the first + # entry in a multi setting, treat it separately in processOptions + # furthermore, it is not supported by older perls, so do it differently + #"enable=s{1,2}", + "edit", + "force", + "listavailablemaps", + "listmaps|l", + "nohash", + "nomkmap", + "dry-run|n", + "outputdir=s", + "pdftexoutputdir=s", + "pxdvioutputdir=s", + "quiet|silent|q", + # the following is a correct specification of an option according + # to the manual, but it does not work! + # we will treat that option by itself in processOptions + # furthermore, it is not supported by older perls, so do it differently + #"setoption=s@{1,2}", + "showoptions=s@", + "showoption=s@", + "syncwithtrees", + "version", + "help|h", + # some debugging invocations + "_readsave=s", + ); + +my %settings = ( + dvipsPreferOutline => { + type => "binary", + default => "true", + }, + LW35 => { + type => "string", + possible => [ qw/URW URWkb ADOBE ADOBEkb/ ], + default => "URWkb", + }, + dvipsDownloadBase35 => { + type => "binary", + default => "true", + }, + pdftexDownloadBase14 => { + type => "binary", + default => "true", + }, + dvipdfmDownloadBase14 => { + type => "binary", + default => "true", + }, + pxdviUse => { + type => "binary", + default => "false", + }, + kanjiEmbed => { + type => "any", + default => "noEmbed", + }, + kanjiVariant => { + type => "any", + default => "", + }, +); + +&main(); + +############### + +sub main { + processOptions(); + + help() if $opts{'help'}; + + if ($opts{'version'}) { + print version(); + exit (0); + } + + if ($opts{'dvipdfmoutputdir'} && !defined($opts{'dvipdfmxoutputdir'})) { + $opts{'dvipdfmxoutputdir'} = $opts{'dvipdfmoutputdir'}; + printf STDERR "Using --dvipdfmoutputdir options for dvipdfmx, but please use --dvipdfmxoutputdir\n"; + } + + if ($opts{'dvipdfmoutputdir'} && $opts{'dvipdfmxoutputdir'} && + $opts{'dvipdfmoutputdir'} ne $opts{'dvipdfmxoutputdir'}) { + printf STDERR "Options for --dvipdfmoutputdir and --dvipdfmxoutputdir do not agree\nplease use only --dvipdfmxoutputdir. Exiting.\n"; + exit(1); + } + + if ($opts{'_readsave'}) { + read_updmap_files($opts{'_readsave'}); + merge_settings_replace_kanji(); + print "READING DONE ============================\n"; + #print Dumper($alldata); + $alldata->{'updmap'}{$opts{'_readsave'}}{'changed'} = 1; + save_updmap($opts{'_readsave'}); + exit 0; + } + + if ($opts{'showoptions'}) { + for my $o (@{$opts{'showoptions'}}) { + if (defined($settings{$o})) { + if ($settings{$o}{'type'} eq "binary") { + print "true false\n"; + } elsif ($settings{$o}{'type'} eq "string") { + print "@{$settings{$o}{'possible'}}\n"; + } elsif ($settings{$o}{'type'} eq "any") { + print "(any string)\n"; + } else { + print "strange: unknown type of option $o\nplease report\n"; + } + } else { + print "$prg: unknown option: $o\n"; + } + } + exit 0; + } + + # config file for changes + my $changes_config_file; + + # determine which config files should be used + # replaces the former "setupCfgFile" + # + # we also determine here where changes will be saved to + if ($opts{'cnffile'}) { + my @tmp; + for my $f (@{$opts{'cnffile'}}) { + if (! -f $f) { + die "$prg: Config file \"$f\" not found."; + } + push @tmp, (win32() ? lc($f) : $f); + } + @{$opts{'cnffile'}} = @tmp; + # in case that config files are given on the command line, the first + # in the list is the one where changes will be written to. + ($changes_config_file) = @{$opts{'cnffile'}}; + } else { + my @all_files = `kpsewhich -all updmap.cfg`; + chomp(@all_files); + my @used_files; + for my $f (@all_files) { + push @used_files, (win32() ? lc($f) : $f); + } + # + my $TEXMFLOCALVAR; + my @TEXMFLOCAL; + if (win32()) { + chomp($TEXMFLOCALVAR =`kpsewhich --expand-path=\$TEXMFLOCAL`); + @TEXMFLOCAL = map { lc } split(/;/ , $TEXMFLOCALVAR); + } else { + chomp($TEXMFLOCALVAR =`kpsewhich --expand-path='\$TEXMFLOCAL'`); + @TEXMFLOCAL = split /:/ , $TEXMFLOCALVAR; + } + # + # search for TEXMFLOCAL/web2c/updmap.cfg + # check for compatibility with old updmap-local.cfg + my @tmlused; + for my $tml (@TEXMFLOCAL) { + my $TMLabs = Cwd::abs_path($tml); + next if (!$TMLabs); + my $oldfound = 0; + if (-r "$TMLabs/web2c/updmap-local.cfg") { + push @tmlused, "$TMLabs/web2c/updmap-local.cfg"; + warning("Old configuration file\n $TMLabs/web2c/updmap-local.cfg\nfound! "); + $oldfound = 1; + } + if (-r "$TMLabs/web2c/updmap.cfg") { + if ($oldfound) { + warning("Will read it *instead* of\n $TMLabs/web2c/updmap.cfg\n"); + } else { + push @tmlused, "$TMLabs/web2c/updmap.cfg"; + } + } + warning("Please consider moving the information from updmap-local.cfg to\n $TMLabs/web2c/updmap.cfg\n") + if ($oldfound); + } + # + # reorder used files: we move TEXMFLOCAL (if used) just above TEXMFMAIN + # as sysadmins will probably adjust values there + # + # updmap (user): + # ============== + # as found: + # TEXMFCONFIG $HOME/.texliveYYYY/texmf-config/web2c/updmap.cfg + # TEXMFVAR $HOME/.texliveYYYY/texmf-var/web2c/updmap.cfg + # TEXMFHOME $HOME/texmf/web2c/updmap.cfg + # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg + # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg + # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg + # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg + # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg + # + # as used: + # TEXMFCONFIG $HOME/.texliveYYYY/texmf-config/web2c/updmap.cfg + # TEXMFVAR $HOME/.texliveYYYY/texmf-var/web2c/updmap.cfg + # TEXMFHOME $HOME/texmf/web2c/updmap.cfg + # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg + # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg + # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg + # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg + # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg + # + # updmap-sys (root): + # ================== + # as found: + # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg + # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg + # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg + # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg + # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg + # + # as used: + # TEXMFSYSCONFIG $TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg + # TEXMFSYSVAR $TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg + # TEXMFLOCAL $TEXLIVE/texmf-local/web2c/updmap.cfg + # TEXMFMAIN $TEXLIVE/YYYY/texmf/web2c/updmap.cfg + # TEXMFDIST $TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg + # + if (@tmlused) { + my @tmp; + for my $f (@used_files) { + if ($f =~ m!\Q$TEXMFMAIN/\E!) { + push @tmp, @tmlused; + push @tmp, $f; + } else { + my $pushit = 1; + for my $tml (@TEXMFLOCAL) { + if ($f =~ m!\Q$tml\E!) { + $pushit = 0; + last; + } + } + push @tmp, $f if ($pushit); + } + } + @used_files = @tmp; + } + @{$opts{'cnffile'}} = @used_files; + # + # determine the config file that we will use for changes + # if in the list of used files contains either one from + # TEXMFHOME or TEXMFCONFIG (which is TEXMFSYSCONFIG in the -sys case) + # then use the *top* file (which will be either one of the two), + # if none of the two exists, create a file in TEXMFCONFIG and use it + my $use_top = 0; + for my $f (@used_files) { + if ($f =~ m!(\Q$TEXMFHOME\E|\Q$TEXMFCONFIG\E)/web2c/updmap.cfg!) { + $use_top = 1; + last; + } + } + if ($use_top) { + ($changes_config_file) = @used_files; + } else { + # add the empty config file + my $dn = "$TEXMFCONFIG/web2c"; + $changes_config_file = "$dn/updmap.cfg"; + } + } + if (!$opts{'quiet'}) { + print "$prg is using the following updmap.cfg files (in precedence order):\n"; + for my $f (@{$opts{'cnffile'}}) { + print " $f\n"; + } + print "$prg is using the following updmap.cfg file for writing changes:\n"; + print " $changes_config_file\n"; + } + if ($opts{'listfiles'}) { + # we listed it above, so be done + exit 0; + } + + $alldata->{'changes_config'} = $changes_config_file; + + read_updmap_files(@{$opts{'cnffile'}}); + + if ($opts{'showoption'}) { + merge_settings_replace_kanji(); + for my $o (@{$opts{'showoption'}}) { + if (defined($settings{$o})) { + my ($v, $vo) = get_cfg($o); + $v = "\"$v\"" if ($v =~ m/\s/); + print "$o=$v ($vo)\n"; + } else { + printf STDERR "$prg: unknown option: $o\n"; + } + } + exit 0; + } + + if ($opts{'listmaps'}) { + merge_settings_replace_kanji(); + for my $m (keys %{$alldata->{'maps'}}) { + my $origin = $alldata->{'maps'}{$m}{'origin'}; + print $alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'}, " $m ", + $alldata->{'updmap'}{$origin}{'maps'}{$m}{'status'}, " in $origin\n"; + } + exit 0; + } + + # we do changes always in the used config file with the highest + # priority + my $bakFile = $changes_config_file; + $bakFile =~ s/\.cfg$/.bak/; + my $changed = 0; + + if ($opts{'syncwithtrees'}) { + merge_settings_replace_kanji(); + my @missing = read_map_files(); + if (@missing) { + print "Missing map files found, disabling\n"; + for my $m (@missing) { + my $orig = $alldata->{'maps'}{$m}{'origin'}; + print "\t$m (in $orig)\n"; + } + print "in $changes_config_file\n"; + print "Do you really want to continue (y/N)? "; + my $answer = ; + $answer = "n" if !defined($answer); + chomp($answer); + print "answer =$answer=\n"; + if ($answer ne "y" && $answer ne "Y") { + print "Please fix manually before running updmap(-sys) again!\n"; + exit 0; + } + $changed ||= enable_disable_maps(@missing); + print "finished.\n"; + # the original script did not run any update of the map files here, + # should we do that? + } + exit 0; + } + + $updLSR = &mktexupd(); + $updLSR->{mustexist}(0); + + my $cmd; + if ($opts{'edit'}) { + if ($opts{"dry-run"}) { + printf STDERR "No, are you joking, you want to edit with --dry-run?\n"; + exit 1; + } + # it's not a good idea to edit updmap.cfg manually these days, + # but for compatibility we'll silently keep the option. + $cmd = 'edit'; + my $editor = $ENV{'VISUAL'} || $ENV{'EDITOR'}; + $editor ||= (&win32 ? "notepad" : "vi"); + if (-r $changes_config_file) { + ©File($changes_config_file, $bakFile); + } else { + touch($bakFile); + touch($changes_config_file); + } + system($editor, $changes_config_file); + $changed = files_are_different($bakFile, $changes_config_file); + } elsif ($opts{'setoption'}) { + $cmd = 'setOption'; + $changed = setOptions (@{$opts{'setoption'}}); + } elsif ($opts{'enable'} || $opts{'disable'}) { + $cmd = 'enableMap'; + $changed ||= enable_disable_maps(@{$opts{'enable'}}, @{$opts{'disable'}}); + } + + + if ($cmd && !$opts{'force'} && !$changed) { + print "$changes_config_file unchanged. Map files not recreated.\n" + if !$opts{'quiet'}; + } else { + if (!$opts{'nomkmap'}) { + # before we continue we have to make sure that a newly created config + # file is acually used. So we have to push the $changes_config_file + # onto the list of available files. Since it is already properly + # initialized and the merging is done later, all settings should be + # honored + my @aaa = @{$alldata->{'order'}}; + unshift @aaa, $changes_config_file; + $alldata->{'order'} = [ @aaa ]; + # + setupOutputDir("dvips"); + setupOutputDir("pdftex"); + setupOutputDir("dvipdfmx"); + setupOutputDir("pxdvi"); + merge_settings_replace_kanji(); + my @missing = read_map_files(); + if (@missing) { + print STDERR "\nERROR: The following map file(s) couldn't be found:\n"; + for my $m (@missing) { + my $orig = $alldata->{'maps'}{$m}{'origin'}; + print STDERR "\t$m (in $orig)\n"; + } + print STDERR "\n\tDid you run mktexlsr?\n\n" . + "\tYou can disable non-existent map entries using the option\n". + "\t --syncwithtrees.\n\n"; + exit 1; + } + merge_data(); + # for inspecting the output + #print STDERR Data::Dumper->Dump([$alldata], [qw(mapdata)]); + #print Dumper($alldata); + mkMaps(); + } + unlink ($bakFile) if (-r $bakFile); + } + + if (!$opts{'nohash'}) { + print "$prg: Updating ls-R files.\n" if !$opts{'quiet'}; + $updLSR->{exec}() unless $opts{"dry-run"}; + } + + return 0; +} + +################################################################## +# +# + +sub getFonts { + my ($first, @rest) = @_; + my $getall = 0; + my @maps = (); + return if !defined($first); + if ($first eq "-all") { + $getall = 1; + @maps = @rest; + } else { + @maps = ($first, @rest); + } + my @lines = (); + for my $m (@maps) { + if (defined($alldata->{'maps'}{$m})) { + print LOG "\n" . $alldata->{'maps'}{$m}{'fullpath'} . ":\n" unless $opts{'dry-run'}; + push @lines, "% $m"; + for my $k (sort keys %{$alldata->{'maps'}{$m}{'fonts'}}) { + if ($getall || $alldata->{'fonts'}{$k}{'origin'} eq $m) { + if (defined($alldata->{'maps'}{$m}{'fonts'}{$k})) { + push @lines, "$k " . $alldata->{'maps'}{$m}{'fonts'}{$k}; + } else { + print "undefined fonts for $k in $m ?!?!?\n"; + } + print LOG "$k\n" unless $opts{'dry-run'}; + } + } + } + } + chomp @lines; + return @lines; +} + +############################################################################### +# writeLines() +# write the lines in $filename +# +sub writeLines { + my ($fname, @lines) = @_; + return if $opts{"dry-run"}; + map { ($_ !~ m/\n$/ ? s/$/\n/ : $_ ) } @lines; + open FILE, ">$fname" or die "$prg: can't write lines to $fname: $!"; + print FILE @lines; + close FILE; +} + +############################################################################### +# to_pdftex() +# if $pdftexStripEnc is set, strip "PS_Encoding_Name ReEncodeFont" +# from map entries; they are ignored by pdftex. But since the sh +# incarnation of updmap included them, and we want to minimize +# differences, this is not done by default. +# +sub to_pdftex { + my $pdftexStripEnc = 0; + return @_ unless $pdftexStripEnc; + my @in = @_; + my @out; + foreach my $line (@in) { + if ($line =~ /^(.*\s+)(\S+\s+ReEncodeFont\s)(.*)/) { + $line = "$1$3"; + $line =~ s/\s+\"\s+\"\s+/ /; + } + push @out, $line; + } + return @out; +} + +############################################################################### +# setupSymlinks() +# set symlink for psfonts.map according to dvipsPreferOutline variable +# +sub setupSymlinks { + my ($dvipsPreferOutline, $dvipsoutputdir, $pdftexDownloadBase14, $pdftexoutputdir) = @_; + my $src; + my %link; + my @link; + + if ($dvipsPreferOutline eq "true") { + $src = "psfonts_t1.map"; + } else { + $src = "psfonts_pk.map"; + } + unlink "$dvipsoutputdir/psfonts.map" unless $opts{"dry-run"}; + push @link, &SymlinkOrCopy("$dvipsoutputdir", "$src", "psfonts.map"); + + if ($pdftexDownloadBase14 eq "true") { + $src = "pdftex_dl14.map"; + } else { + $src = "pdftex_ndl14.map"; + } + unlink "$pdftexoutputdir/pdftex.map" unless $opts{"dry-run"}; + push @link, &SymlinkOrCopy("$pdftexoutputdir", "$src", "pdftex.map"); + %link = @link; + return \%link; +} + +############################################################################### +# SymlinkOrCopy(dir, src, dest) +# create symlinks if possible, otherwise copy files +# +sub SymlinkOrCopy { + my ($dir, $src, $dest) = @_; + return ($src, $dest) if $opts{"dry-run"}; + if (&win32 || $opts{'copy'}) { # always copy + ©File("$dir/$src", "$dir/$dest"); + } else { # symlink if supported by fs, copy otherwise + system("cd \"$dir\" && ln -s $src $dest 2>/dev/null || " + . "cp -p \"$dir/$src\" \"$dir/$dest\""); + } + # remember for "Files generated" in &mkMaps. + return ($dest, $src); +} + + +############################################################################### +# transLW35(mode args ...) +# transform fontname and filenames according to transformation specified +# by mode. Possible values: +# URW|URWkb|ADOBE|ADOBEkb +# +sub transLW35 { + my ($mode, @lines) = @_; + + my @psADOBE = ( + 's/ URWGothicL-Demi / AvantGarde-Demi /', + 's/ URWGothicL-DemiObli / AvantGarde-DemiOblique /', + 's/ URWGothicL-Book / AvantGarde-Book /', + 's/ URWGothicL-BookObli / AvantGarde-BookOblique /', + 's/ URWBookmanL-DemiBold / Bookman-Demi /', + 's/ URWBookmanL-DemiBoldItal / Bookman-DemiItalic /', + 's/ URWBookmanL-Ligh / Bookman-Light /', + 's/ URWBookmanL-LighItal / Bookman-LightItalic /', + 's/ NimbusMonL-Bold / Courier-Bold /', + 's/ NimbusMonL-BoldObli / Courier-BoldOblique /', + 's/ NimbusMonL-Regu / Courier /', + 's/ NimbusMonL-ReguObli / Courier-Oblique /', + 's/ NimbusSanL-Bold / Helvetica-Bold /', + 's/ NimbusSanL-BoldCond / Helvetica-Narrow-Bold /', + 's/ NimbusSanL-BoldItal / Helvetica-BoldOblique /', + 's/ NimbusSanL-BoldCondItal / Helvetica-Narrow-BoldOblique /', + 's/ NimbusSanL-Regu / Helvetica /', + 's/ NimbusSanL-ReguCond / Helvetica-Narrow /', + 's/ NimbusSanL-ReguItal / Helvetica-Oblique /', + 's/ NimbusSanL-ReguCondItal / Helvetica-Narrow-Oblique /', + 's/ CenturySchL-Bold / NewCenturySchlbk-Bold /', + 's/ CenturySchL-BoldItal / NewCenturySchlbk-BoldItalic /', + 's/ CenturySchL-Roma / NewCenturySchlbk-Roman /', + 's/ CenturySchL-Ital / NewCenturySchlbk-Italic /', + 's/ URWPalladioL-Bold / Palatino-Bold /', + 's/ URWPalladioL-BoldItal / Palatino-BoldItalic /', + 's/ URWPalladioL-Roma / Palatino-Roman /', + 's/ URWPalladioL-Ital / Palatino-Italic /', + 's/ StandardSymL / Symbol /', + 's/ NimbusRomNo9L-Medi / Times-Bold /', + 's/ NimbusRomNo9L-MediItal / Times-BoldItalic /', + 's/ NimbusRomNo9L-Regu / Times-Roman /', + 's/ NimbusRomNo9L-ReguItal / Times-Italic /', + 's/ URWChanceryL-MediItal / ZapfChancery-MediumItalic /', + 's/ Dingbats / ZapfDingbats /', + ); + + my @fileADOBEkb = ( + 's/\buagd8a.pfb\b/pagd8a.pfb/', + 's/\buagdo8a.pfb\b/pagdo8a.pfb/', + 's/\buagk8a.pfb\b/pagk8a.pfb/', + 's/\buagko8a.pfb\b/pagko8a.pfb/', + 's/\bubkd8a.pfb\b/pbkd8a.pfb/', + 's/\bubkdi8a.pfb\b/pbkdi8a.pfb/', + 's/\bubkl8a.pfb\b/pbkl8a.pfb/', + 's/\bubkli8a.pfb\b/pbkli8a.pfb/', + 's/\bucrb8a.pfb\b/pcrb8a.pfb/', + 's/\bucrbo8a.pfb\b/pcrbo8a.pfb/', + 's/\bucrr8a.pfb\b/pcrr8a.pfb/', + 's/\bucrro8a.pfb\b/pcrro8a.pfb/', + 's/\buhvb8a.pfb\b/phvb8a.pfb/', + 's/\buhvb8ac.pfb\b/phvb8an.pfb/', + 's/\buhvbo8a.pfb\b/phvbo8a.pfb/', + 's/\buhvbo8ac.pfb\b/phvbo8an.pfb/', + 's/\buhvr8a.pfb\b/phvr8a.pfb/', + 's/\buhvr8ac.pfb\b/phvr8an.pfb/', + 's/\buhvro8a.pfb\b/phvro8a.pfb/', + 's/\buhvro8ac.pfb\b/phvro8an.pfb/', + 's/\buncb8a.pfb\b/pncb8a.pfb/', + 's/\buncbi8a.pfb\b/pncbi8a.pfb/', + 's/\buncr8a.pfb\b/pncr8a.pfb/', + 's/\buncri8a.pfb\b/pncri8a.pfb/', + 's/\buplb8a.pfb\b/pplb8a.pfb/', + 's/\buplbi8a.pfb\b/pplbi8a.pfb/', + 's/\buplr8a.pfb\b/pplr8a.pfb/', + 's/\buplri8a.pfb\b/pplri8a.pfb/', + 's/\busyr.pfb\b/psyr.pfb/', + 's/\butmb8a.pfb\b/ptmb8a.pfb/', + 's/\butmbi8a.pfb\b/ptmbi8a.pfb/', + 's/\butmr8a.pfb\b/ptmr8a.pfb/', + 's/\butmri8a.pfb\b/ptmri8a.pfb/', + 's/\buzcmi8a.pfb\b/pzcmi8a.pfb/', + 's/\buzdr.pfb\b/pzdr.pfb/', + ); + + my @fileURW = ( + 's/\buagd8a.pfb\b/a010015l.pfb/', + 's/\buagdo8a.pfb\b/a010035l.pfb/', + 's/\buagk8a.pfb\b/a010013l.pfb/', + 's/\buagko8a.pfb\b/a010033l.pfb/', + 's/\bubkd8a.pfb\b/b018015l.pfb/', + 's/\bubkdi8a.pfb\b/b018035l.pfb/', + 's/\bubkl8a.pfb\b/b018012l.pfb/', + 's/\bubkli8a.pfb\b/b018032l.pfb/', + 's/\bucrb8a.pfb\b/n022004l.pfb/', + 's/\bucrbo8a.pfb\b/n022024l.pfb/', + 's/\bucrr8a.pfb\b/n022003l.pfb/', + 's/\bucrro8a.pfb\b/n022023l.pfb/', + 's/\buhvb8a.pfb\b/n019004l.pfb/', + 's/\buhvb8ac.pfb\b/n019044l.pfb/', + 's/\buhvbo8a.pfb\b/n019024l.pfb/', + 's/\buhvbo8ac.pfb\b/n019064l.pfb/', + 's/\buhvr8a.pfb\b/n019003l.pfb/', + 's/\buhvr8ac.pfb\b/n019043l.pfb/', + 's/\buhvro8a.pfb\b/n019023l.pfb/', + 's/\buhvro8ac.pfb\b/n019063l.pfb/', + 's/\buncb8a.pfb\b/c059016l.pfb/', + 's/\buncbi8a.pfb\b/c059036l.pfb/', + 's/\buncr8a.pfb\b/c059013l.pfb/', + 's/\buncri8a.pfb\b/c059033l.pfb/', + 's/\buplb8a.pfb\b/p052004l.pfb/', + 's/\buplbi8a.pfb\b/p052024l.pfb/', + 's/\buplr8a.pfb\b/p052003l.pfb/', + 's/\buplri8a.pfb\b/p052023l.pfb/', + 's/\busyr.pfb\b/s050000l.pfb/', + 's/\butmb8a.pfb\b/n021004l.pfb/', + 's/\butmbi8a.pfb\b/n021024l.pfb/', + 's/\butmr8a.pfb\b/n021003l.pfb/', + 's/\butmri8a.pfb\b/n021023l.pfb/', + 's/\buzcmi8a.pfb\b/z003034l.pfb/', + 's/\buzdr.pfb\b/d050000l.pfb/', + ); + + my @fileADOBE = ( + 's/\buagd8a.pfb\b/agd_____.pfb/', + 's/\buagdo8a.pfb\b/agdo____.pfb/', + 's/\buagk8a.pfb\b/agw_____.pfb/', + 's/\buagko8a.pfb\b/agwo____.pfb/', + 's/\bubkd8a.pfb\b/bkd_____.pfb/', + 's/\bubkdi8a.pfb\b/bkdi____.pfb/', + 's/\bubkl8a.pfb\b/bkl_____.pfb/', + 's/\bubkli8a.pfb\b/bkli____.pfb/', + 's/\bucrb8a.pfb\b/cob_____.pfb/', + 's/\bucrbo8a.pfb\b/cobo____.pfb/', + 's/\bucrr8a.pfb\b/com_____.pfb/', + 's/\bucrro8a.pfb\b/coo_____.pfb/', + 's/\buhvb8a.pfb\b/hvb_____.pfb/', + 's/\buhvb8ac.pfb\b/hvnb____.pfb/', + 's/\buhvbo8a.pfb\b/hvbo____.pfb/', + 's/\buhvbo8ac.pfb\b/hvnbo___.pfb/', + 's/\buhvr8a.pfb\b/hv______.pfb/', + 's/\buhvr8ac.pfb\b/hvn_____.pfb/', + 's/\buhvro8a.pfb\b/hvo_____.pfb/', + 's/\buhvro8ac.pfb\b/hvno____.pfb/', + 's/\buncb8a.pfb\b/ncb_____.pfb/', + 's/\buncbi8a.pfb\b/ncbi____.pfb/', + 's/\buncr8a.pfb\b/ncr_____.pfb/', + 's/\buncri8a.pfb\b/nci_____.pfb/', + 's/\buplb8a.pfb\b/pob_____.pfb/', + 's/\buplbi8a.pfb\b/pobi____.pfb/', + 's/\buplr8a.pfb\b/por_____.pfb/', + 's/\buplri8a.pfb\b/poi_____.pfb/', + 's/\busyr.pfb\b/sy______.pfb/', + 's/\butmb8a.pfb\b/tib_____.pfb/', + 's/\butmbi8a.pfb\b/tibi____.pfb/', + 's/\butmr8a.pfb\b/tir_____.pfb/', + 's/\butmri8a.pfb\b/tii_____.pfb/', + 's/\buzcmi8a.pfb\b/zcmi____.pfb/', + 's/\buzdr.pfb\b/zd______.pfb/', + ); + + if ($mode eq "" || $mode eq "URWkb") { + # do nothing + } elsif ($mode eq "URW") { + for my $r (@fileURW) { + map { eval($r); } @lines; + } + } elsif ($mode eq "ADOBE" || $mode eq "ADOBEkb") { + for my $r (@psADOBE) { + map { eval($r); } @lines; + } + my @filemode = eval ("\@file" . $mode); + for my $r (@filemode) { + map { eval($r); } @lines; + } + } + return @lines; +} + +############################################################################### +# cidx2dvips() +# reads from stdin, writes to stdout. It transforms "cid-x"-like syntax into +# "dvips"-like syntax. +# +# Specifying the PS Name: +# dvips needs the PSname instead of the file name. Thus we allow specifying +# the PSname in the comment: +# The PS Name can be specified in the font definition line +# by including the following sequence somewhere after the +# other components: +# +# %!PS +# +# where +# is either a space or a tab character +# is *one* word, defined by \w\w* perl re +# is a non-\w char or the end of line +# +# That means we could have +# ... %here the PS font name: %!PS fontname some other comment +# ... %!PS fontname %other comments +# ... %!PS fontname +# +############################################################################### + +# reimplementation of the cryptic code that was there before +sub cidx2dvips { + my ($s) = @_; + my %fname_psname = ( + # Morisawa + 'A-OTF-FutoGoB101Pr6N-Bold' => 'FutoGoB101Pr6N-Bold', + 'A-OTF-FutoGoB101Pro-Bold' => 'FutoGoB101Pro-Bold', + 'A-OTF-FutoMinA101Pr6N-Bold' => 'FutoMinA101Pr6N-Bold', + 'A-OTF-FutoMinA101Pro-Bold' => 'FutoMinA101Pro-Bold', + 'A-OTF-GothicBBBPr6N-Medium' => 'GothicBBBPr6N-Medium', + 'A-OTF-GothicBBBPro-Medium' => 'GothicBBBPro-Medium', + 'A-OTF-Jun101Pr6N-Light' => 'Jun101Pr6N-Light', + 'A-OTF-Jun101Pro-Light' => 'Jun101Pro-Light', + 'A-OTF-MidashiGoPr6N-MB31' => 'MidashiGoPr6N-MB31', + 'A-OTF-MidashiGoPro-MB31' => 'MidashiGoPro-MB31', + 'A-OTF-RyuminPr6N-Light' => 'RyuminPr6N-Light', + 'A-OTF-RyuminPro-Light' => 'RyuminPro-Light', + # Hiragino font file names and PS names are the same + # + # IPA + 'ipaexg' => 'IPAexGothic', + 'ipaexm' => 'IPAexMincho', + 'ipag' => 'IPAGothic', + 'ipam' => 'IPAMincho', + # + # Kozuka font names and PS names are the same + ); + my @d; + foreach (@$s) { + # ship empty lines and comment lines out as is + if (m/^\s*(%.*)?$/) { + push(@d, $_); + next; + } + # get rid of new lines for now + chomp; + # save the line for warnings + my $l = $_; + # first check whether a PSname is given + my $psname; + # + # the matching on \w* is greedy, so will take all the word chars available + # that means we do not need to test for end of word + if ($_ =~ m/%!PS\s\s*([0-9A-Za-z-_][0-9A-Za-z-_]*)/) { + $psname = $1; + } + # remove comments + s/[^0-9A-Za-z-_]*%.*$//; + # replace supported ",SOMETHING" constructs + my $italicmax = 0; + if (m/,BoldItalic/) { + $italicmax = .3; + s/,BoldItalic//; + } + s/,Bold//; + if (m/,Italic/) { + $italicmax = .3; + s/,Italic//; + } + # break out if unsupported constructs are found: @ / , + next if (m![\@/,]!); + # make everything single spaced + s/\s\s*/ /g; + # unicode encoded fonts are not supported + next if (m!^\w\w* unicode !); + # now we have the following format + # some options like -e or -s + if ($_ !~ m/([^ ][^ ]*) ([^ ][^ ]*) ([^ ][^ ]*)( (.*))?$/) { + print STDERR "cidx2dvips warning: Cannot translate font line:\n==> $l\n"; + print STDERR "Current translation status: ==>$_==\n"; + next; + } + my $tfmname = $1; + my $cid = $2; + my $fname = $3; + my $opts = (defined($5) ? " $5" : ""); + # remove extensions from $fname + $fname =~ s/\.[Oo][Tt][Ff]//; + $fname =~ s/\.[Tt][Tt][FfCc]//; + # remove leading ! from $fname + $fname =~ s/^!//; + # remove leading :: from $fname + $fname =~ s/:[0-9]+://; + # remove leading space from $opt + $opts =~ s/^\s+//; + # replace -e and -s in the options + $opts =~ s/-e ([.0-9-][.0-9-]*)/ "$1 ExtendFont"/; + if (m/-s ([.0-9-][.0-9-]*)/) { + if ($italicmax > 0) { + # we have already a definition of SlantFont via ,Italic or ,BoldItalic + # warn the user that larger one is kept + print STDERR "cidx2dvips: warning: Double slant specified via Italic and -s:\n==> $l\n==> Using only the biggest slant value.\n"; + } + $italicmax = $1 if ($1 > $italicmax); + $opts =~ s/-s ([.0-9-][.0-9-]*)//; + } + if ($italicmax != 0) { + $opts .= " \"$italicmax SlantFont\""; + } + # print out the result + if (defined($psname)) { + push @d, "$tfmname $psname-$cid$opts\n"; + } else { + if (defined($fname_psname{$fname})) { + push @d, "$tfmname $fname_psname{$fname}-$cid$opts\n"; + } else { + push @d, "$tfmname $fname-$cid$opts\n"; + } + } + } + return @d; +} + +sub cidx2dvips_old { + my ($s) = @_; + my @d; + foreach (@$s) { + if (m/^%/) { + push(@d, $_); + next; + } + s/,BoldItalic/ -s .3/; + s/,Bold//; + s/,Italic/ -s .3/; + s/\s\s*/ /g; + if ($_ =~ /.*[@\:\/,]/) {next;} + elsif ($_ =~ /^[^ ][^ ]* unicode /) {next;} + s/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)\.[Oo][Tt][Ff]/$1/; + s/^([^ ][^ ]* [^ ][^ ]* [^ ][^ ]*)\.[Tt][Tt][FfCc]/$1/; + s/$/ %/; + s/^(([^ ]*).*)/$1$2/; + s/^([^ ][^ ]* ([^ ][^ ]*) !*([^ ][^ ]*).*)/$1 $3-$2/; + s/^(.* -e ([.0-9-][.0-9-]*).*)/$1 "$2 ExtendFont"/; + s/^(.* -s ([.0-9-][.0-9-]*).*)/$1 "$2 SlantFont"/; + s/.*%//; + push(@d, $_); + } + return @d +} + +sub get_cfg { + my ($v) = @_; + if (defined($alldata->{'merged'}{'setting'}{$v})) { + return ( $alldata->{'merged'}{'setting'}{$v}{'val'}, + $alldata->{'merged'}{'setting'}{$v}{'origin'} ); + } else { + return ($settings{$v}{'default'}, "default"); + } +} + +sub mkMaps { + my $logfile; + + $logfile = "$TEXMFVAR/web2c/updmap.log"; + + if (! $opts{'dry-run'}) { + mkdirhier("$TEXMFVAR/web2c"); + open LOG, ">$logfile" + or die "$prg: Can't open log file \"$logfile\": $!"; + print LOG &version(); + printf LOG "%s\n\n", scalar localtime(); + print LOG "Using the following config files:\n"; + for (@{$opts{'cnffile'}}) { + print LOG " $_\n"; + } + } + sub print_and_log { + my $str=shift; + print $str if !$opts{'quiet'}; + print LOG $str unless $opts{'dry-run'}; + } + sub only_log { + print LOG shift unless $opts{'dry-run'}; + } + + my ($mode, $mode_origin) = get_cfg('LW35'); + my ($dvipsPreferOutline, $dvipsPreferOutline_origin) = + get_cfg('dvipsPreferOutline'); + my ($dvipsDownloadBase35, $dvipsDownloadBase35_origin) = + get_cfg('dvipsDownloadBase35'); + my ($pdftexDownloadBase14, $pdftexDownloadBase14_origin) = + get_cfg('pdftexDownloadBase14'); + my ($pxdviUse, $pxdviUse_origin) = get_cfg('pxdviUse'); + my ($kanjiEmbed, $kanjiEmbed_origin) = get_cfg('kanjiEmbed'); + my ($kanjiVariant, $kanjiVariant_origin) = get_cfg('kanjiVariant'); + + print_and_log ("\n$prg is creating new map files" + . "\nusing the following configuration:" + . "\n LW35 font names : " + . "$mode ($mode_origin)" + . "\n prefer outlines : " + . "$dvipsPreferOutline ($dvipsPreferOutline_origin)" + . "\n texhash enabled : " + . ($opts{'nohash'} ? "false" : "true") + . "\n download standard fonts (dvips) : " + . "$dvipsDownloadBase35 ($dvipsDownloadBase35_origin)" + . "\n download standard fonts (pdftex) : " + . "$pdftexDownloadBase14 ($pdftexDownloadBase14_origin)" + . "\n kanjiEmbed replacement string : " + . "$kanjiEmbed ($kanjiEmbed_origin)" + . "\n kanjiVariant replacement string : " + . "$kanjiVariant ($kanjiVariant_origin)" + . "\n create a mapfile for pxdvi : " + . "$pxdviUse ($pxdviUse_origin)" + . "\n\n"); + + print_and_log ("Scanning for LW35 support files"); + my $dvips35 = $alldata->{'maps'}{"dvips35.map"}{'fullpath'}; + my $pdftex35 = $alldata->{'maps'}{"pdftex35.map"}{'fullpath'}; + my $ps2pk35 = $alldata->{'maps'}{"ps2pk35.map"}{'fullpath'}; + my $LW35 = "\n$dvips35\n$pdftex35\n$ps2pk35\n\n"; + only_log ("\n"); + only_log ($LW35); + print_and_log (" [ 3 files]\n"); + only_log ("\n"); + + print_and_log ("Scanning for MixedMap entries"); + my @mixedmaps; + my @notmixedmaps; + my @kanjimaps; + for my $m (keys %{$alldata->{'maps'}}) { + my $origin = $alldata->{'maps'}{$m}{'origin'}; + next if !defined($origin); + next if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'status'} eq "disabled"); + push @mixedmaps, $m + if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "MixedMap"); + push @notmixedmaps, $m + if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "Map"); + push @kanjimaps, $m + if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "KanjiMap"); + } + + @mixedmaps = sort @mixedmaps; + @notmixedmaps = sort @notmixedmaps; + @kanjimaps = sort @kanjimaps; + only_log("\n"); + foreach my $m (sort @mixedmaps) { + if (defined($alldata->{'maps'}{$m}{'fullpath'})) { + only_log($alldata->{'maps'}{$m}{'fullpath'} . "\n"); + } else { + only_log("$m (full path not set?)\n"); + } + } + only_log("\n"); + print_and_log (sprintf(" [%3d files]\n", scalar @mixedmaps)); + only_log("\n"); + + print_and_log ("Scanning for KanjiMap entries"); + only_log("\n"); + foreach my $m (@kanjimaps) { + if (defined($alldata->{'maps'}{$m}{'fullpath'})) { + only_log($alldata->{'maps'}{$m}{'fullpath'} . "\n"); + } else { + only_log("$m (full path not set?)\n"); + } + } + only_log("\n"); + print_and_log (sprintf(" [%3d files]\n", scalar @kanjimaps)); + only_log("\n"); + + print_and_log ("Scanning for Map entries"); + only_log("\n"); + foreach my $m (@notmixedmaps) { + if (defined($alldata->{'maps'}{$m}{'fullpath'})) { + only_log($alldata->{'maps'}{$m}{'fullpath'} . "\n"); + } else { + only_log("$m (full path not set?)\n"); + } + } + only_log("\n"); + print_and_log (sprintf(" [%3d files]\n\n", scalar @notmixedmaps)); + only_log("\n"); + + # Create psfonts_t1.map, psfonts_pk.map, ps2pk.map and pdftex.map: + my $dvipsoutputdir = $opts{'dvipsoutputdir'}; + my $pdftexoutputdir = $opts{'pdftexoutputdir'}; + my $dvipdfmxoutputdir = $opts{'dvipdfmxoutputdir'}; + my $pxdvioutputdir = $opts{'pxdvioutputdir'}; + if (!$opts{'dry-run'}) { + my @managed_files = ("$dvipsoutputdir/download35.map", + "$dvipsoutputdir/builtin35.map", + "$dvipsoutputdir/psfonts_t1.map", + "$dvipsoutputdir/psfonts_pk.map", + "$pdftexoutputdir/pdftex_dl14.map", + "$pdftexoutputdir/pdftex_ndl14.map", + "$dvipdfmxoutputdir/kanjix.map", + "$dvipsoutputdir/ps2pk.map"); + push @managed_files, "$pxdvioutputdir/xdvi-ptex.map" + if ($pxdviUse eq "true"); + for my $file (@managed_files) { + open FILE, ">$file"; + print FILE "% $file:\ +% maintained by updmap[-sys] (multi).\ +% Don't change this file directly. Use updmap[-sys] instead.\ +% See the updmap documentation.\ +% A log of the run that created this file is available here:\ +% $logfile\ +"; + close FILE; + } + } + + my @kanjimaps_fonts = getFonts(@kanjimaps); + @kanjimaps_fonts = &normalizeLines(@kanjimaps_fonts); + my @ps2pk_fonts = getFonts('-all', "ps2pk35.map"); + my @dvips35_fonts = getFonts('-all', "dvips35.map"); + my @pdftex35_fonts = getFonts('-all', "pdftex35.map"); + my @mixedmaps_fonts = getFonts(@mixedmaps); + my @notmixedmaps_fonts = getFonts(@notmixedmaps); + + print "Generating output for dvipdfmx...\n" if !$opts{'quiet'}; + &writeLines(">$dvipdfmxoutputdir/kanjix.map", @kanjimaps_fonts); + + if ($pxdviUse eq "true") { + # we use the very same data as for kanjix.map, but generate + # a different file, so that in case a user wants to hand-craft it + print "Generating output for pxdvi...\n" if !$opts{'quiet'}; + &writeLines(">$pxdvioutputdir/xdvi-ptex.map", @kanjimaps_fonts); + } + + + print "Generating output for ps2pk...\n" if !$opts{'quiet'}; + my @ps2pk_map; + push @ps2pk_map, "% ps2pk35.map"; + push @ps2pk_map, transLW35($mode, @ps2pk_fonts); + push @ps2pk_map, @mixedmaps_fonts; + push @ps2pk_map, @notmixedmaps_fonts; + &writeLines(">$dvipsoutputdir/ps2pk.map", + normalizeLines(@ps2pk_map)); + + print "Generating output for dvips...\n" if !$opts{'quiet'}; + my @download35_map; + push @download35_map, "% ps2pk35.map"; + push @download35_map, transLW35($mode, @ps2pk_fonts); + &writeLines(">$dvipsoutputdir/download35.map", + normalizeLines(@download35_map)); + + my @builtin35_map; + push @builtin35_map, "% dvips35.map"; + push @builtin35_map, transLW35($mode, @dvips35_fonts); + &writeLines(">$dvipsoutputdir/builtin35.map", + normalizeLines(@builtin35_map)); + + my @dftdvips_fonts = + (($dvipsDownloadBase35 eq "true") ? @ps2pk_fonts : @dvips35_fonts); + + my @psfonts_t1_map; + if ($dvipsDownloadBase35 eq "true") { + push @psfonts_t1_map, "% ps2pk35.map"; + @dftdvips_fonts = @ps2pk_fonts; + } else { + push @psfonts_t1_map, "% dvips35.map"; + @dftdvips_fonts = @dvips35_fonts; + } + push @psfonts_t1_map, transLW35($mode, @dftdvips_fonts); + my @tmpkanji2 = cidx2dvips(\@kanjimaps_fonts); + push @psfonts_t1_map, @mixedmaps_fonts; + push @psfonts_t1_map, @notmixedmaps_fonts; + push @psfonts_t1_map, @tmpkanji2; + &writeLines(">$dvipsoutputdir/psfonts_t1.map", + normalizeLines(@psfonts_t1_map)); + + my @psfonts_pk_map; + push @psfonts_pk_map, transLW35($mode, @dftdvips_fonts); + push @psfonts_pk_map, @notmixedmaps_fonts; + push @psfonts_pk_map, @tmpkanji2; + &writeLines(">$dvipsoutputdir/psfonts_pk.map", + normalizeLines(@psfonts_pk_map)); + + print "Generating output for pdftex...\n" if !$opts{'quiet'}; + # remove PaintType due to Sebastian's request + my @pdftexmaps_ndl; + push @pdftexmaps_ndl, "% pdftex35.map"; + push @pdftexmaps_ndl, transLW35($mode, @pdftex35_fonts); + push @pdftexmaps_ndl, @mixedmaps_fonts; + push @pdftexmaps_ndl, @notmixedmaps_fonts; + @pdftexmaps_ndl = grep { $_ !~ m/(^%\|PaintType)/ } @pdftexmaps_ndl; + + my @pdftexmaps_dl; + push @pdftexmaps_dl, "% ps2pk35.map"; + push @pdftexmaps_dl, transLW35($mode, @ps2pk_fonts); + push @pdftexmaps_dl, @mixedmaps_fonts; + push @pdftexmaps_dl, @notmixedmaps_fonts; + @pdftexmaps_dl = grep { $_ !~ m/(^%\|PaintType)/ } @pdftexmaps_dl; + + my @pdftex_ndl14_map = @pdftexmaps_ndl; + @pdftex_ndl14_map = &normalizeLines(@pdftex_ndl14_map); + @pdftex_ndl14_map = &to_pdftex(@pdftex_ndl14_map); + &writeLines(">$pdftexoutputdir/pdftex_ndl14.map", @pdftex_ndl14_map); + + my @pdftex_dl14_map = @pdftexmaps_dl; + @pdftex_dl14_map = &normalizeLines(@pdftex_dl14_map); + @pdftex_dl14_map = &to_pdftex(@pdftex_dl14_map); + &writeLines(">$pdftexoutputdir/pdftex_dl14.map", @pdftex_dl14_map); + + our $link = &setupSymlinks($dvipsPreferOutline, $dvipsoutputdir, $pdftexDownloadBase14, $pdftexoutputdir); + + print_and_log ("\nFiles generated:\n"); + sub dir { + my ($d, $f, $target)=@_; + our $link; + if (-e "$d/$f") { + my @stat=lstat("$d/$f"); + my ($s,$m,$h,$D,$M,$Y)=localtime($stat[9]); + my $timestamp=sprintf ("%04d-%02d-%02d %02d:%02d:%02d", + $Y+1900, $M+1, $D, $h, $m, $s); + my $date=sprintf "%12d %s %s", $stat[7], $timestamp, $f; + print_and_log ($date); + + if (-l "$d/$f") { + my $lnk=sprintf " -> %s\n", readlink ("$d/$f"); + print_and_log ($lnk); + } elsif ($f eq $target) { + if (&files_are_identical("$d/$f", "$d/" . $link->{$target})) { + print_and_log (" = $link->{$target}\n"); + } else { + print_and_log (" = ?????\n"); # This shouldn't happen. + } + } else { + print_and_log ("\n"); + } + } else { + print STDERR "Warning: File $d/$f doesn't exist.\n"; + print LOG "Warning: File $d/$f doesn't exist.\n" + unless $opts{'dry-run'}; + } + } + + my $d; + $d = "$dvipsoutputdir"; + print_and_log(" $d:\n"); + foreach my $f ('builtin35.map', 'download35.map', 'psfonts_pk.map', + 'psfonts_t1.map', 'ps2pk.map', 'psfonts.map') { + dir ($d, $f, 'psfonts.map'); + $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; + } + $d = "$pdftexoutputdir"; + print_and_log(" $d:\n"); + foreach my $f ('pdftex_dl14.map', 'pdftex_ndl14.map', 'pdftex.map') { + dir ($d, $f, 'pdftex.map'); + $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; + } + $d="$dvipdfmxoutputdir"; + print_and_log(" $d:\n"); + foreach my $f ('kanjix.map') { + dir ($d, $f, ''); + $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; + } + if ($pxdviUse eq "true") { + $d="$pxdvioutputdir"; + print_and_log(" $d:\n"); + foreach my $f ('xdvi-ptex.map') { + dir ($d, $f, ''); + $updLSR->{add}("$d/$f") unless $opts{'dry-run'}; + } + } + close LOG unless $opts{'dry-run'}; + print "\nTranscript written on \"$logfile\".\n" if !$opts{'quiet'}; + +} + + +sub locateMap { + my $map = shift; + my $ret = `kpsewhich --format=map $map`; + chomp($ret); + return $ret; +} + +sub processOptions { + # first process the stupid setoption= s@{1,2} which is not accepted + # furthermore, try to work around missing s{1,2} support in older perls + my $oldconfig = Getopt::Long::Configure(qw(pass_through)); + our @setoptions; + our @enable; + sub read_one_or_two { + my ($opt, $val) = @_; + our @setoptions; + our @enable; + # check if = occirs in $val, if not, get the next argument + if ($val =~ m/=/) { + if ($opt eq "setoption") { + push @setoptions, $val; + } else { + push @enable, $val; + } + } else { + my $vv = shift @ARGV; + die "Try \"$prg --help\" for more information.\n" + if !defined($vv); + if ($opt eq "setoption") { + push @setoptions, "$val=$vv"; + } else { + push @enable, "$val=$vv"; + } + } + } + GetOptions("setoption=s@" => \&read_one_or_two, + "enable=s@" => \&read_one_or_two) or + die "Try \"$prg --help\" for more information.\n"; + + @{$opts{'setoption'}} = @setoptions if (@setoptions); + @{$opts{'enable'}} = @enable if (@enable); + + Getopt::Long::Configure($oldconfig); + + # now continue with normal option handling + + GetOptions(\%opts, @cmdline_options) or + die "Try \"$prg --help\" for more information.\n"; +} + +# determines the output dir for driver from cmd line, or if not given +# from TEXMFVAR +sub setupOutputDir { + my $driver = shift; + if (!$opts{$driver . "outputdir"}) { + if ($opts{'outputdir'}) { + $opts{$driver . "outputdir"} = $opts{'outputdir'}; + } else { + $opts{$driver . "outputdir"} = "$TEXMFVAR/fonts/map/$driver/updmap"; + } + } + my $od = $opts{$driver . "outputdir"}; + if (!$opts{"dry-run"}) { + &mkdirhier($od); + if (! -w $od) { + die "$prg: Directory \"$od\" isn't writable: $!"; + } + } + print "$driver output dir: \"$od\"\n" if !$opts{'quiet'}; + return $od; +} + +############################################################################### +# setOption (@options) +# parse @options for "key=value" (one element of @options) +# we can only have "key=value" since that is the way it was prepared +# in process_options +# (These were the values provided to --setoption.) +# +sub setOptions { + my (@options) = @_; + for (my $i = 0; $i < @options; $i++) { + my $o = $options[$i]; + + my ($key,$val) = split (/=/, $o, 2); + + die "$prg: unexpected empty key or val for options (@options), goodbye.\n" + if !$key || !defined($val); + + &setOption ($key, $val); + } + return save_updmap($alldata->{'changes_config'}); +} + +sub enable_disable_maps { + my (@what) = @_; + my $tc = $alldata->{'changes_config'}; + die "$prg: top config file $tc has not been read." + if (!defined($alldata->{'updmap'}{$tc})); + my $changed = 0; + + for my $w (@what) { + if ($w =~ m/=/) { + # this is --enable MapType=MapName + my ($type, $map) = split ('=', $w); + enable_map($tc, $type, $map); + } else { + # this is --disable MapName + disable_map($tc, $w); + } + } + return save_updmap($tc); +} + +sub enable_map { + my ($tc, $type, $map) = @_; + + die "$prg: invalid mapType $type" if ($type !~ m/^(Map|MixedMap|KanjiMap)$/); + + if (defined($alldata->{'updmap'}{$tc}{'maps'}{$map})) { + # the map data has already been read in, no special precautions necessary + if (($alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} eq "enabled") && + ($alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} eq $type)) { + # nothing to do here ... be happy! + return; + } else { + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "enabled"; + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = $type; + $alldata->{'maps'}{$map}{'origin'} = $tc; + $alldata->{'maps'}{$map}{'status'} = "enabled"; + $alldata->{'updmap'}{$tc}{'changed'} = 1; + } + } else { + # add a new map file! + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = $type; + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "enabled"; + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'line'} = -1; + $alldata->{'updmap'}{$tc}{'changed'} = 1; + $alldata->{'maps'}{$map}{'origin'} = $tc; + $alldata->{'maps'}{$map}{'status'} = "enabled"; + } +} + +sub disable_map { + my ($tc, $map) = @_; + + if (defined($alldata->{'updmap'}{$tc}{'maps'}{$map})) { + # the map data has already been read in, no special precautions necessary + if ($alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} eq "disabled") { + # nothing to do here ... be happy! + } else { + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "disabled"; + $alldata->{'maps'}{$map}{'origin'} = $tc; + $alldata->{'maps'}{$map}{'status'} = "disabled"; + $alldata->{'updmap'}{$tc}{'changed'} = 1; + } + } else { + # disable a Map type that might be activated in a lower ranked updmap.cfg + if (!defined($alldata->{'maps'}{$map})) { + warning("Map is not present anywhere, why should I disable it?\n"); + return; + } + my $orig = $alldata->{'maps'}{$map}{'origin'}; + # add a new entry to the top level where we disable it + # copy over the type from the last entry + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'type'} = + $alldata->{'updmap'}{$orig}{'maps'}{$map}{'type'}; + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'status'} = "disabled"; + $alldata->{'updmap'}{$tc}{'maps'}{$map}{'line'} = -1; + # rewrite the origin + $alldata->{'maps'}{$map}{'origin'} = $tc; + $alldata->{'maps'}{$map}{'status'} = "disabled"; + # go on for writing + $alldata->{'updmap'}{$tc}{'changed'} = 1; + } +} + + +# returns 1 if actually saved due to changes +sub save_updmap { + my $fn = shift; + return if $opts{'dry-run'}; + my %upd = %{$alldata->{'updmap'}{$fn}}; + if ($upd{'changed'}) { + mkdirhier(dirname($fn)); + open (FN, ">$fn") || die "$prg: can't write to $fn: $!"; + my @lines = @{$upd{'lines'}}; + if (!@lines) { + print "Creating new config file $fn\n"; + # update lsR database + $updLSR->{add}($fn); + $updLSR->{exec}(); + # reset the LSR stuff, otherwise we add files several times + $updLSR->{reset}(); + } + # collect the lines with data + my %line_to_setting; + my %line_to_map; + my @add_setting; + my @add_map; + if (defined($upd{'setting'})) { + for my $k (keys %{$upd{'setting'}}) { + if ($upd{'setting'}{$k}{'line'} == -1) { + push @add_setting, $k; + } else { + $line_to_setting{$upd{'setting'}{$k}{'line'}} = $k; + } + } + } + if (defined($upd{'maps'})) { + for my $k (keys %{$upd{'maps'}}) { + if ($upd{'maps'}{$k}{'line'} == -1) { + push @add_map, $k; + } else { + $line_to_map{$upd{'maps'}{$k}{'line'}} = $k; + } + } + } + for my $i (0..$#lines) { + if (defined($line_to_setting{$i})) { + my $k = $line_to_setting{$i}; + my $v = $upd{'setting'}{$k}{'val'}; + print FN "$k $v\n"; + } elsif (defined($line_to_map{$i})) { + my $m = $line_to_map{$i}; + my $rm; + if (defined($upd{'maps'}{$m}{'original'})) { + # we have the case that @noEmbed@ was replaced by the respective + # setting. Before writing out we have to replace this back with + # the original line!A + $rm = $upd{'maps'}{$m}{'original'}; + } else { + $rm = $m; + } + my $t = $upd{'maps'}{$m}{'type'}; + my $p = ($upd{'maps'}{$m}{'status'} eq "disabled" ? "#! " : ""); + print FN "$p$t $rm\n"; + } else { + print FN "$lines[$i]\n"; + } + } + # add the new settings and maps + for my $k (@add_setting) { + my $v = $upd{'setting'}{$k}{'val'}; + print FN "$k $v\n"; + } + for my $m (@add_map) { + my $t = $upd{'maps'}{$m}{'type'}; + my $p = ($upd{'maps'}{$m}{'status'} eq "disabled" ? "#! " : ""); + print FN "$p$t $m\n"; + } + close(FN) || warn("Cannot close file handle for $fn: $!"); + delete $alldata->{'updmap'}{$fn}{'changed'}; + return 1; + } + return 0; +} + +###################### +# check for correct option value +# +sub check_option { + my ($opt, $val) = @_; + if ((($settings{$opt}{'type'} eq "binary") && + $val ne "true" && $val ne "false") || + (($settings{$opt}{'type'} eq "string") && + !member($val, @{$settings{$opt}{'possible'}}))) { + return 0; + } + return 1; +} + +############################################################################### +# setOption (conf_file, option, value) +# sets option to value in the config file (replacing the existing setting +# or by adding a new line to the config file). +# +sub setOption { + my ($opt, $val) = @_; + + die "$prg: Unsupported option $opt." if (!defined($settings{$opt})); + die "$0: Invalid value $val for option $opt." + if (!check_option($opt, $val)); + + # silently accept this old option name, just in case. + return if $opt eq "dvipdfmDownloadBase14"; + + #print "Setting option $opt to $val...\n" if !$opts{'quiet'}; + my $tc = $alldata->{'changes_config'}; + + die "$prg: top config file $tc has not been read." + if (!defined($alldata->{'updmap'}{$tc})); + + if (defined($alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'})) { + # the value is already set, do nothing + if ($alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'} eq $val) { + return; + } + $alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'} = $val; + $alldata->{'updmap'}{$tc}{'changed'} = 1; + } else { + $alldata->{'updmap'}{$tc}{'setting'}{$opt}{'val'} = $val; + $alldata->{'updmap'}{$tc}{'setting'}{$opt}{'line'} = -1; + $alldata->{'updmap'}{$tc}{'changed'} = 1; + } +} + + +############################################################################### +# copyFile() +# copy file $src to $dst, sets $dst creation and mod time +# +sub copyFile { + my ($src, $dst) = @_; + my $dir; + ($dir=$dst)=~s/(.*)\/.*/$1/; + mkdirhier($dir); + + $src eq $dst && return "can't copy $src to itself!\n"; + + open IN, "<$src" or die "$0: can't open source file $src for copying: $!"; + open OUT, ">$dst"; + + binmode(IN); + binmode(OUT); + print OUT ; + close(OUT); + close(IN); + my @t = stat($src); + utime($t[8], $t[9], $dst); +} + +############################################################################### +# files_are_identical(file_A, file_B) +# compare two files. Same as cmp(1). +# +sub files_are_identical { + my $file_A=shift; + my $file_B=shift; + my $retval=0; + + open IN, "$file_A"; + my $A=(); + close IN; + open IN, "$file_B"; + my $B=(); + close IN; + + $retval=1 if ($A eq $B); + return $retval; +} + +############################################################################### +# files_are_different(file_A, file_B[, comment_char]) +# compare two equalized files. +# +sub files_are_different { + my $file_A=shift; + my $file_B=shift; + my $comment=shift; + my $retval=0; + + my $A=equalize_file("$file_A", $comment); + my $B=equalize_file("$file_B", $comment); + $retval=1 unless ($A eq $B); + return $retval; +} + +############################################################################### +# equalize_file(filename[, comment_char]) +# read a file and return its processed content as a string. +# look into the source code for more details. +# +sub equalize_file { + my $file=shift; + my $comment=shift; + my @temp; + + open IN, "$file"; + my @lines = (); + close IN; + chomp(@lines); + + for (@lines) { + s/\s*${comment}.*// if (defined $comment); # remove comments + next if /^\s*$/; # remove empty lines + s/\s+/ /g; # replace multiple whitespace chars by a single one + push @temp, $_; + } + return join('X', sort(@temp)); +} + +############################################################################### +# normalizeLines() +# not the original function, we want it to keep comments, that are +# anyway only the file names we are adding! +# whitespace is exactly one space, no empty lines, +# no whitespace at end of line, one space before and after " +# +sub normalizeLines { + my @lines = @_; + my %count = (); + + # @lines = grep { $_ !~ m/^[*#;%]/ } @lines; + map {$_ =~ s/\s+/ /gx } @lines; + @lines = grep { $_ !~ m/^\s*$/x } @lines; + map { $_ =~ s/\s$//x ; + $_ =~ s/\s*\"\s*/ \" /gx; + $_ =~ s/\" ([^\"]*) \"/\"$1\"/gx; + } @lines; + + # @lines = grep {++$count{$_} < 2 } (sort @lines); + @lines = grep {++$count{$_} < 2 } (@lines); + + return @lines; +} + + +################################################################# +# +# reading updmap-cfg files and the actual map files +# +# the following hash saves *all* the information and is passed around +# we do not fill everything from the very beginning to make sure that +# we only read what is necessary (speed!) +# +# initialized by main +# $alldata->{'changes_config'} = the config file where changes are saved +# +# initialized by read_updmap_files +# $alldata->{'order'} = [ list of updmap in decreasing priority ] +# $alldata->{'updmap'}{$full_path_name_of_updmap}{'lines'} = \@lines +# $alldata->{'updmap'}{$full_path_name_of_updmap}{'setting'}{$key}{'val'} = $val +# $alldata->{'updmap'}{$full_path_name_of_updmap}{'setting'}{$key}{'line'} = $i +# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'type'} +# = 'Map'|'MixedMap'|'KanjiMap'|'disabled' +# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'status'} +# = 'enabled'|'disabled' +# $alldata->{'updmap'}{$full_path_name_of_updmap}{'maps'}{$mapname}{'line'} = $i +# $alldata->{'maps'}{$m}{'origin'} = $updmap_path_name +# $alldata->{'maps'}{$m}{'status'} = enabled | disabled +# +# initialized by read_map_files +# $alldata->{'maps'}{$m}{'fonts'}{$font} = $definition +# $alldata->{'fonts'}{$f}{'origin'} = $map +# +# initialized by merge_data +# $alldata->{'merged'}{'setting'}{$key}{'val'} = $val +# $alldata->{'merged'}{'setting'}{$key}{'origin'} = $origin_updmap_cfg +# $alldata->{'merged'}{'allMaps'}{'fonts'}{$fontdef} = $rest +# $alldata->{'merged'}{'noMixedMaps'}{'fonts'}{$fontdef} = $rest +# $alldata->{'merged'}{'KanjiMaps'}{'fonts'}{$fontdef} = $rest +# + +sub read_updmap_files { + my (@l) = @_; + for my $l (@l) { + my $updmap = read_updmap_file($l); + $alldata->{'updmap'}{$l}{'lines'} = $updmap->{'lines'}; + if (defined($updmap->{'setting'})) { + for my $k (keys %{$updmap->{'setting'}}) { + $alldata->{'updmap'}{$l}{'setting'}{$k}{'val'} = $updmap->{'setting'}{$k}{'val'}; + $alldata->{'updmap'}{$l}{'setting'}{$k}{'line'} = $updmap->{'setting'}{$k}{'line'}; + } + } + if (defined($updmap->{'maps'})) { + for my $k (keys %{$updmap->{'maps'}}) { + $alldata->{'updmap'}{$l}{'maps'}{$k}{'type'} = $updmap->{'maps'}{$k}{'type'}; + $alldata->{'updmap'}{$l}{'maps'}{$k}{'status'} = $updmap->{'maps'}{$k}{'status'}; + $alldata->{'updmap'}{$l}{'maps'}{$k}{'line'} = $updmap->{'maps'}{$k}{'line'}; + } + } + } + # in case the changes_config is a new one read it in and initialize it here + my $cc = $alldata->{'changes_config'}; + if (! -r $cc) { + $alldata->{'updmap'}{$cc}{'lines'} = [ ]; + } + # + $alldata->{'order'} = \@l; +} + +sub merge_settings_replace_kanji { + # + my @l = @{$alldata->{'order'}}; + # + # for security clean out everything that was there + %{$alldata->{'merged'}} = (); + # + # first read in the settings + # we read it in *reverse* order and simple fill up the combined data + # thus if there are multiple definitions/settings, the one coming from + # the first in the original list will win! + for my $l (reverse @l) { + # merge settings + if (defined($alldata->{'updmap'}{$l}{'setting'})) { + for my $k (keys %{$alldata->{'updmap'}{$l}{'setting'}}) { + $alldata->{'merged'}{'setting'}{$k}{'val'} = $alldata->{'updmap'}{$l}{'setting'}{$k}{'val'}; + $alldata->{'merged'}{'setting'}{$k}{'origin'} = $l; + } + } + } + # + my ($kanjiEmbed, $kanjiEmbed_origin) = get_cfg('kanjiEmbed'); + my ($kanjiVariant, $kanjiVariant_origin) = get_cfg('kanjiVariant'); + # + # go through all map files and check that the text is properly replaced + # after the replacement check that the generated map file actually + # exists, we do NOT want to break in this case! + # + for my $l (@l) { + for my $m (keys %{$alldata->{'updmap'}{$l}{'maps'}}) { + if ($m =~ m/\@kanjiEmbed@/ || $m =~ m/\@kanjiVariant@/) { + my $newm = $m; + $newm =~ s/\@kanjiEmbed@/$kanjiEmbed/; + $newm =~ s/\@kanjiVariant@/$kanjiVariant/; + if (locateMap($newm)) { + # now we have to update various linked items + $alldata->{'updmap'}{$l}{'maps'}{$newm}{'type'} = + $alldata->{'updmap'}{$l}{'maps'}{$m}{'type'}; + $alldata->{'updmap'}{$l}{'maps'}{$newm}{'status'} = + $alldata->{'updmap'}{$l}{'maps'}{$m}{'status'}; + $alldata->{'updmap'}{$l}{'maps'}{$newm}{'line'} = + $alldata->{'updmap'}{$l}{'maps'}{$m}{'line'}; + $alldata->{'updmap'}{$l}{'maps'}{$newm}{'original'} = $m; + } else { + print "$prg: generated map $newm (from $m) does not exists, not activating it!\n"; + } + # in any case delete the @kanji...@ entry line, such a map will + # never exist + delete $alldata->{'updmap'}{$l}{'maps'}{$m}; + } + } + } + # + # first round determine which maps should be used and which type, as + # different updmap.cfg files might specify different types of maps + # (MixedMap or Map or KanjiMap). + # Again, we have to do that in reverse order + for my $l (reverse @l) { + if (defined($alldata->{'updmap'}{$l}{'maps'})) { + for my $m (keys %{$alldata->{'updmap'}{$l}{'maps'}}) { + $alldata->{'maps'}{$m}{'origin'} = $l; + $alldata->{'maps'}{$m}{'status'} = $alldata->{'updmap'}{$l}{'maps'}{$m}{'status'}; + } + } + } +} + +sub read_updmap_file { + my $fn = shift; + my $is_old_local = ($fn =~ m/updmap-local.cfg/ ? 1 : 0); + my %data; + if (!open(FN,"<$fn")) { + die ("Cannot read $fn: $!"); + } + # we count lines from 0 ..!!!! + my $i = -1; + my @lines = ; + chomp(@lines); + $data{'lines'} = [ @lines ]; + close(FN) || warn("Cannot close $fn: $!"); + for (@lines) { + $i++; + chomp; + if ($is_old_local) { + # in case we read an old updmap-local.cfg we have to make sure + # that the disable lines + # ^#!foo.map + # are rewritten to proper disable lines + # ^#! Map foo.map + # we are guessing here the type of the map (namely Map) + $_ =~ s/^#!([^ ])/#! Map $1/; + } + next if /^\s*$/; + next if /^\s*#$/; + next if /^\s*#[^!]/; + next if /^\s*##/; + next if /^#![^ ]/; + # allow for commands on the line itself + s/([^#].*)#.*$/$1/; + my ($a, $b, @rest) = split ' '; + # make sure we get empty strings as arguments + $b = "" if (!defined($b)); + if ($a eq "#!") { + if ($b eq "Map" || $b eq "MixedMap" || $b eq "KanjiMap") { + my $c = shift @rest; + if (!defined($c)) { + warning("$prg: apparently not a real disable line, ignored: $_\n"); + } else { + if (defined($data{'maps'}{$c})) { + warning("$prg: double mention of $c in $fn\n"); + } + $data{'maps'}{$c}{'status'} = 'disabled'; + $data{'maps'}{$c}{'type'} = $b; + $data{'maps'}{$c}{'line'} = $i; + } + } + next; + } + if (@rest) { + warning("$prg: line $i in $fn contains a syntax error, more than two words!\n"); + } + if (defined($settings{$a})) { + if (check_option($a, $b)) { + $data{'setting'}{$a}{'val'} = $b; + $data{'setting'}{$a}{'line'} = $i; + } else { + warning("$prg: unknown setting for $a: $b, ignored!\n"); + } + } elsif ($a eq "Map" || $a eq "MixedMap" || $a eq "KanjiMap") { + if (defined($data{'maps'}{$b}) && $data{'maps'}{$b}{'type'} ne $a) { + warning("$prg: double mention of $b with conflicting types in $fn\n"); + } else { + $data{'maps'}{$b}{'type'} = $a; + $data{'maps'}{$b}{'status'} = 'enabled'; + $data{'maps'}{$b}{'line'} = $i; + } + } else { + warning("$prg: unrecognized line $i in $fn: $_\n"); + } + } + return \%data; +} + +sub read_map_files { + if (!defined($alldata->{'updmap'})) { + return; + } + my @missing; + my @l = @{$alldata->{'order'}}; + # first collect all the map files we are interested in + # and determine whether they exist, and get their full path + my @maps; + for my $f (@l) { + next if !defined($alldata->{'updmap'}{$f}{'maps'}); + for my $m (keys %{$alldata->{'updmap'}{$f}{'maps'}}) { + # only read a map file if its final status is enabled! + push @maps, $m if ($alldata->{'maps'}{$m}{'status'} eq 'enabled'); + } + } + for my $m (qw/dvips35.map pdftex35.map ps2pk35.map/) { + push @maps, $m; + $alldata->{'maps'}{$m}{'status'} = 'enabled'; + } + @maps = sort_uniq(@maps); + my @fullpath = `kpsewhich --format=map @maps`; + chomp @fullpath; + foreach my $map (@maps) { + my ($ff) = grep /\/$map(\.map)?$/, @fullpath; + if ($ff) { + $alldata->{'maps'}{$map}{'fullpath'} = $ff; + } else { + # if the map file is not found, then push it onto the list of + # missing map files, since we know that it is enabled + push @missing, $map; + } + } + + # + # read in the three basic fonts definition maps + for my $m (qw/dvips35.map pdftex35.map ps2pk35.map/) { + my $ret = read_map_file($alldata->{'maps'}{$m}{'fullpath'}); + my @ff = (); + for my $font (keys %$ret) { + $alldata->{'fonts'}{$font}{'origin'} = $m; + $alldata->{'maps'}{$m}{'fonts'}{$font} = $ret->{$font}; + } + } + # we read the updmap in reverse directions, since we + # replace the origin field of font definition always with the + # top one + for my $f (reverse @l) { + my @maps = keys %{$alldata->{'updmap'}{$f}{'maps'}}; + for my $m (@maps) { + # we do not read a map file multiple times, if $alldata{'maps'}{$m} is + # defined we expect that it was read and do skip it + next if defined($alldata->{'maps'}{$m}{'fonts'}); + # we do not read a map files content if it is disabled + next if ($alldata->{'maps'}{$m}{'status'} eq 'disabled'); + if (!defined($alldata->{'maps'}{$m}{'fullpath'})) { + # we have already pushed these map files onto the list of missing + # map files, so do nothing here + next; + } + my $ret = read_map_file($alldata->{'maps'}{$m}{'fullpath'}); + if (defined($ret)) { + for my $font (keys %$ret) { + if (defined($alldata->{'fonts'}{$font})) { + # we got another definition, warn on that + # if the origin is not defined by now, the font is defined + # multiple times in the same map file, otherwise it is + # defined in another map file already + if (defined($alldata->{'fonts'}{$font}{'origin'})) { + my $fontorig = $alldata->{'fonts'}{$font}{'origin'}; + my $maporig; + if (($fontorig eq "ps2pk35.map") || + ($fontorig eq "pdftex35.map") || + ($fontorig eq "dvips35.map")) { + $maporig = "built in map - both used - warning!"; + } else { + $maporig = "from " . $alldata->{'maps'}{$fontorig}{'origin'}; + } + warning("$prg: font $font is defined multiple times:\n"); + warning("$prg: $fontorig ($maporig)\n"); + warning("$prg: $m (from $f) (used)\n"); + } else { + warning("$prg: font $font is multiply defined in $m, using an arbitrary instance!\n"); + } + } + $alldata->{'fonts'}{$font}{'origin'} = $m; + $alldata->{'maps'}{$m}{'fonts'}{$font} = $ret->{$font}; + } + } + } + } + return (@missing); +} + +sub read_map_file { + my $fn = shift; + my @lines; + if (!open(MF,"<$fn")) { + warn("cannot open $fn: $!"); + return; + } + @lines = ; + close(MF); + chomp(@lines); + my %data; + for (@lines) { + next if /^\s*#/; + next if /^\s*%/; + next if /^\s*$/; + my ($a, $b) = split(' ', $_, 2); + $data{$a} = $b; + } + return \%data; +} + +# +# merging the various font definitions +# +sub merge_data { + my @l = @{$alldata->{'order'}}; + # + # now merge the data + # + for my $m (keys %{$alldata->{'maps'}}) { + my $origin = $alldata->{'maps'}{$m}{'origin'}; + next if !defined($origin); + next if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'status'} eq "disabled"); + for my $f (keys %{$alldata->{'maps'}{$m}{'fonts'}}) { + # use the font definition only for those fonts where the origin matches + if ($alldata->{'fonts'}{$f}{'origin'} eq $m) { + $alldata->{'merged'}{'allMaps'}{'fonts'}{$f} = + $alldata->{'maps'}{$m}{'fonts'}{$f} + if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} ne "KanjiMap"); + $alldata->{'merged'}{'noMixedMaps'}{'fonts'}{$f} = + $alldata->{'maps'}{$m}{'fonts'}{$f} + if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "Map"); + $alldata->{'merged'}{'KanjiMap'}{'fonts'}{$f} = + $alldata->{'maps'}{$m}{'fonts'}{$f} + if ($alldata->{'updmap'}{$origin}{'maps'}{$m}{'type'} eq "KanjiMap"); + } + } + } +} + + +# +# $HOME and sudo and updmap-sys horror +# some instances of sudo do not reset $HOME to the home of root +# as an effect of "sudo updmap" creates root owned files in the home +# of a normal user, and "sudo updmap-sys" uses map files and updmap.cfg +# files from the directory of a normal user, but creating files +# in TEXMFSYSCONFIG. This is *all* wrong. +# we check: if we are running as UID 0 (root) on Unix and the +# ENV{HOME} is NOT the same as the one of root, then give a warning +# and reset it to the real home dir of root. + +sub reset_root_home { + if (!win32() && ($> == 0)) { # $> is effective uid + my $envhome = $ENV{'HOME'}; + # if $HOME isn't an existing directory, we don't care. + if (defined($envhome) && (-d $envhome)) { + # we want to avoid calling getpwuid as far as possible, so if + # $envhome is one of some usual values we accept it without worrying. + if ($envhome =~ m,^(/|/root|/var/root)/*$,) { + return; + } + # $HOME is defined, check what is the home of root in reality + my (undef,undef,undef,undef,undef,undef,undef,$roothome) = getpwuid(0); + if (defined($roothome)) { + if ($envhome ne $roothome) { + warning("$prg: resetting \$HOME value (was $envhome) to root's " + . "actual home ($roothome).\n"); + $ENV{'HOME'} = $roothome; + } else { + # envhome and roothome do agree, nothing to do, that is the good case + } + } else { + warning("$prg: home of root not defined, strange!\n"); + } + } + } +} + +sub warning { + print STDERR @_; +} + +# +# help, version etc etc +# + +sub version { + my $ret = sprintf "%s (TeX Live, multi) version %s\n", $prg, $version; + return $ret; +} + +sub help { + my $usage = <<"EOF"; +Usage: $prg [OPTION] ... [COMMAND] + or: $prg-sys [OPTION] ... [COMMAND] + +Update the default font map files used by pdftex, dvips, and dvipdfm(x), +and optionally pxdvi, as determined by all configuration files updmap.cfg +(the ones returned by running "kpsewhich --all updmap.cfg", but see below). + +Among other things, these map files are used to determine which fonts +should be used as bitmaps and which as outlines, and to determine which +font files are included in the PDF or PostScript output. + +By default, the TeX filename database (ls-R) is also updated. + +Options: + --cnffile FILE read FILE for the updmap configuration + (can be given multiple times, in which case + all the files are used) + --dvipdfmxoutputdir DIR specify output directory (dvipdfm(x) syntax) + --dvipsoutputdir DIR specify output directory (dvips syntax) + --pdftexoutputdir DIR specify output directory (pdftex syntax) + --pxdvioutputdir DIR specify output directory (pxdvi syntax) + --outputdir DIR specify output directory (for all files) + --copy cp generic files rather than using symlinks + --force recreate files even if config hasn't changed + --nomkmap do not recreate map files + --nohash do not run texhash + -n, --dry-run only show the configuration, no output + --quiet, --silent reduce verbosity + +Commands: + --help show this message and exit + --version show version information and exit + --showoption OPTION show the current setting of OPTION + --showoptions OPTION show possible settings for OPTION + --setoption OPTION VALUE set OPTION to value; option names below + --setoption OPTION=VALUE as above, just different syntax + --enable MAPTYPE MAPFILE add "MAPTYPE MAPFILE" to updmap.cfg, + where MAPTYPE is Map, MixedMap, or KanjiMap + --enable Map=MAPFILE add \"Map MAPFILE\" to updmap.cfg + --enable MixedMap=MAPFILE add \"MixedMap MAPFILE\" to updmap.cfg + --enable KanjiMap=MAPFILE add \"KanjiMap MAPFILE\" to updmap.cfg + --disable MAPFILE disable MAPFILE, of whatever type + --listmaps list all active and inactive maps + --listavailablemaps same as --listmaps, but without + unavailable map files + --syncwithtrees disable unavailable map files in updmap.cfg + +Explanation of the map types: the (only) difference between Map and +MixedMap is that MixedMap entries are not added to psfonts_pk.map. +The purpose is to help users with devices that render Type 1 outline +fonts worse than mode-tuned Type 1 bitmap fonts. So, MixedMap is used +for fonts that are available as both Type 1 and Metafont. +KanjiMap entries are added to psfonts_t1.map and kanjix.map. + +Explanation of the OPTION names for --showoptions, --showoption, --setoption: + + dvipsPreferOutline true|false (default true) + Whether dvips uses bitmaps or outlines, when both are available. + dvipsDownloadBase35 true|false (default true) + Whether dvips includes the standard 35 PostScript fonts in its output. + pdftexDownloadBase14 true|false (default true) + Whether pdftex includes the standard 14 PDF fonts in its output. + pxdviUse true|false (default false) + Whether maps for pxdvi (Japanese-patched xdvi) are under updmap's control. + kanjiEmbed (any string) + kanjiVariant (any string) + See below. + LW35 URWkb|URW|ADOBEkb|ADOBE (default URWkb) + Adapt the font and file names of the standard 35 PostScript fonts. + URWkb URW fonts with "berry" filenames (e.g. uhvbo8ac.pfb) + URW URW fonts with "vendor" filenames (e.g. n019064l.pfb) + ADOBEkb Adobe fonts with "berry" filenames (e.g. phvbo8an.pfb) + ADOBE Adobe fonts with "vendor" filenames (e.g. hvnbo___.pfb) + + These options are only read and acted on by updmap; dvips, pdftex, etc., + do not know anything about them. They work by changing the default map + file which the programs read, so they can be overridden by specifying + command-line options or configuration files to the programs, as + explained at the beginning of updmap.cfg. + + The options kanjiEmbed and kanjiVariant specify special replacements + in the map lines. If a map contains the string \@kanjiEmbed\@, then + this will be replaced by the value of that option; similarly for + kanjiVariant. In this way, users of Japanese TeX can select different + fonts to be included in the final output. + +Explanation of trees and files normally used: + + If --cnffile is specified on the command line (possibly multiple + times), its value(s) are used. Otherwise, updmap reads all the + updmap.cfg files found by running \`kpsewhich -all updmap.cfg', in the + order returned by kpsewhich, with one exception: an updmap.cfg found + in TEXMFLOCAL is given higher priority than the updmap.cfg in + TEXMFMAIN, to ensure that local adjustments by administrators take + precedence over what is shipped in TeX Live. + + In any case, if multiple updmap.cfg files are found, all the maps + mentioned in all the updmap.cfg files are merged. + + Thus, if updmap.cfg files are present in all trees, and the default + layout is used as shipped with TeX Live, the following files are + read, in the given order. + + For updmap-sys: + TEXMFSYSCONFIG \$TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg + TEXMFSYSVAR \$TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg + TEXMFLOCAL \$TEXLIVE/texmf-local/web2c/updmap.cfg + TEXMFMAIN \$TEXLIVE/YYYY/texmf/web2c/updmap.cfg + TEXMFDIST \$TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg + + For updmap: + TEXMFCONFIG \$HOME/.texliveYYYY/texmf-config/web2c/updmap.cfg + TEXMFVAR \$HOME/.texliveYYYY/texmf-var/web2c/updmap.cfg + TEXMFHOME \$HOME/texmf/web2c/updmap.cfg + TEXMFSYSCONFIG \$TEXLIVE/YYYY/texmf-config/web2c/updmap.cfg + TEXMFSYSVAR \$TEXLIVE/YYYY/texmf-var/web2c/updmap.cfg + TEXMFLOCAL \$TEXLIVE/texmf-local/web2c/updmap.cfg + TEXMFMAIN \$TEXLIVE/YYYY/texmf/web2c/updmap.cfg + TEXMFDIST \$TEXLIVE/YYYY/texmf-dist/web2c/updmap.cfg + + (where YYYY is the TeX Live release version). + + There is another exception to keep upgradability from earlier versions + of TeX Live: if a file TEXMFLOCAL/web2c/updmap-local.cfg exists + (formerly used by tlmgr to merge local fonts), then the file + TEXMFLOCAL/web2c/updmap.cfg is ignored (if it exists) and that + updmap-local.cfg is used instead. In this case, updmap recognizes the + previous syntax for disabling map files in updmap-local.cfg (this + syntax is different from what is used now). + + According to the actions, updmap might write to one of the given files + or create a new updmap.cfg, described further below. + + Where changes are saved: if config files are given on the command + line, then the first one given will be used to save any changes from + --setoption, --enable or --disable. If the config files are taken + from kpsewhich output, then the algorithm is more complex: + + 1) If \$TEXMFCONFIG/web2c/updmap.cfg or \$TEXMFHOME/web2c/updmap.cfg + appears in the list of used files, then the one listed first by + kpsewhich --all (equivalently, the one returned by kpsewhich + updmap.cfg), is used. + + 2) If neither of the above two are present and changes are made, a + new config file is created in \$TEXMFCONFIG/web2c/updmap.cfg. + + Resolving multiple definitions of a font: + If a font is defined in more than one map file, then the definition + coming from the first-listed updmap.cfg is used. If a font is + defined multiple times within the same map file, one is chosen + arbitrarily. In both cases a warning is issued. + + Disabling maps: + updmap.cfg files with higher priority (listed earlier) can disable + maps mentioned in lower priority (listed later) updmap.cfg files by + writing, e.g., + \#! Map mapname.map + or + \#! MixedMap mapname.map + in the higher-priority updmap.cfg file. + + As an example, suppose you have a copy of MathTime Pro fonts + and want to disable the Belleek version of the fonts; that is, + disable the map belleek.map. You can create the file + \$TEXMFCONFIG/web2c/updmap.cfg with the content + #! Map belleek.map + Map mt-plus.map + Map mt-yy.map + and call $prg. + + updmap writes the map files for dvips (psfonts.map) and pdftex + (pdftex.map) to the TEXMFVAR/fonts/map/updmap/{dvips,pdftex}/ + directories. + + The log file is written to TEXMFVAR/web2c/updmap.log. + + When updmap-sys is run, TEXMFSYSCONFIG and TEXMFSYSVAR are used + instead of TEXMFCONFIG and TEXMFVAR, respectively. This is the only + difference between updmap-sys and updmap. + + Other locations may be used if you give them on the command line, or + these trees don't exist, or you are not using the original TeX Live. + + To see the precise locations of the various files that + will be read and written, give the -n option (or read the source). + +For step-by-step instructions on making new fonts known to TeX, read +http://tug.org/fonts/fontinstall.html. For even more terse +instructions, read the beginning of updmap.cfg. + +Report bugs to: tex-k\@tug.org +TeX Live home page: +EOF +; + print &version(); + print $usage; + exit 0; +} + +### Local Variables: +### perl-indent-level: 2 +### tab-width: 2 +### indent-tabs-mode: nil +### End: +# vim:set tabstop=2 expandtab: # -- cgit v1.2.3