2 # $Id: texconfig-dialog.sh 40066 2016-03-18 22:29:48Z karl $
4 # Originally written by Thomas Esser. Public domain.
5 # Now maintained as part of TeX Live; correspondence to tex-live@tug.org.
7 # invoke the right shell:
9 test -f /bin
/ksh
&& test -z "$RUNNING_KSH" \
10 && { UNAMES
=`uname -s`; test "x$UNAMES" = xULTRIX
; } 2>/dev
/null \
11 && { RUNNING_KSH
=true
; export RUNNING_KSH
; exec /bin
/ksh
$0 ${1+"$@"}; }
14 test -f /bin
/bsh
&& test -z "$RUNNING_BSH" \
15 && { UNAMES
=`uname -s`; test "x$UNAMES" = xAIX
; } 2>/dev
/null \
16 && { RUNNING_BSH
=true
; export RUNNING_BSH
; exec /bin
/bsh
$0 ${1+"$@"}; }
19 # hack around a bug in zsh:
20 test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
22 # preferentially use subprograms from our own directory.
23 mydir
=`echo "$0" | sed 's,/[^/]*$,,'`
24 mydir
=`cd "$mydir" && pwd`
25 PATH
="$mydir:$PATH"; export PATH
28 version
='$Id: texconfig-dialog.sh 40066 2016-03-18 22:29:48Z karl $'
31 progname
=texconfig-dialog
32 tmpdir
=${TMPDIR-${TEMP-${TMP-/tmp}}}/tcdtmp.$$
34 tmpmenu
=$tmpdir/tmpmenu
37 ###############################################################################
39 # clean up the temp area and exit with proper exit status
40 ###############################################################################
44 $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
45 && { cd / && rm -rf "$tmpdir"; }
46 # use clear rather than reset since we cannot easily save and restore
47 # the terminal settings, which is what would be ideal. See thread
48 # starting at http://tug.org/pipermail/tex-live/2016-March/037852.html.
53 ###############################################################################
55 # set up a temp directory and a trap to remove it
56 ###############################################################################
63 trap 'cleanup 1' 1 2 3 7 13 15
65 (umask 077; mkdir
"$tmpdir") \
66 || abort
"could not create directory \`$tmpdir'"
69 ###############################################################################
71 # print `errmsg' to stderr and exit with error code 1
72 ###############################################################################
75 echo "$progname: $1." >&2
81 (echo; echo ">>> Executing \`$@' <<<") >> $log
82 "$@" 2>&1 |
tee -a $log
85 ###############################################################################
86 # runDialog(args, ...)
87 # execute the right dialog program with the right default parameters
88 ###############################################################################
91 if test -n "$DIALOG_PROG"; then
93 $DIALOG_PROG --title "TeX setup utility" ${1+"$@"}
97 abort
"could not find dialog or whiptail program to run"
103 ###############################################################################
105 # set DIALOG_PROG to the system dialog program, or the empty string.
106 ###############################################################################
109 for bin
in whiptail dialog
111 binLoc
=`texconfig findprog $bin`
114 *) DIALOG_PROG
=$binLoc; break;;
119 ###############################################################################
121 # call mktexdir script, disable all features (to prevent sticky directories)
122 ###############################################################################
125 MT_FEATURES
=none
"$TEXMFMAIN/web2c/mktexdir" "$@" >&2
128 ###############################################################################
130 # some convenience utilities for terminal control
131 ###############################################################################
136 test -n "$NO_CLEAR" && return
137 tty
>/dev
/null
2>&1 && clear
140 test -n "$NO_CLEAR" && return
142 stty sane
2>/dev
/null
148 echo "press return to continue..."
154 ###############################################################################
157 ###############################################################################
161 The interactive texconfig utility will be started now. Make sure
162 your screen has at least 24 rows and 80 columns. If texconfig
163 crashes now, you can still set up your TeX system using the
164 batch mode of texconfig. Try 'texconfig help' to get a list
167 The interactive mode works best with a real vt100 terminal or
168 inside an xterm window.
170 More likely these days, you're better off using tlmgr.
171 See http://tug.org/texlive/tlmgr.html.
176 logMessage
='view logfile'
180 Hint: all output of external commands (e.g. tex) is logged into
181 a file. You can look at this file using "LOG
". If cursor keys make
182 trouble, you may have more luck with +/- and TAB.
186 PAPER
'default paper: A4 or letter (us)' \
187 MODE
'default metafont mode and resolution' \
188 REHASH
'rebuild filename databases' \
189 FORMATS
'edit format definitions' \
190 HYPHENATION
'customize hyphenation' \
191 DVIPS
'dvips configuration' \
192 FAQ
'view frequently asked questions + answers' \
193 CONF
'show configuration' \
195 2>"$tmpmenu" ||
break
197 case `cat "$tmpmenu"` in
208 logexec texconfig rehash
226 logexec texconfig conf
239 # we need eval to get the command line right... :-(
243 Chosse a mode to be used when metafont generates font bitmaps. The resolution is the most important point, but there might
244 be differences between modes of the same resolution. See the comments in the file modes.mf for more details.
247 `texconfig mode-list` 2>"$tmpmenu"
253 mode
=`cat "$tmpmenu"`
255 if test -n "$mode"; then
256 logexec texconfig mode
"$mode"
266 case $menuDvipsDest in
270 dvips GLOBAL section. Define the most common default settings (config.ps).
271 To define settings for a specific printer, first ADD a printer definition,
276 menuDvipsPrinterOpt
="-P $menuDvipsDest"
278 dvips settings for printer $menuDvipsDest (config.$menuDvipsDest). Define
279 local settings for this printer. To switch back to global settings mode,
286 --menu "$menuDvipsMsg
287 You can use dvips for non PostScript printers, if you can setup your
288 printing system to convert PostScript to a format that your printer can
289 handle. Maybe, you can use GhostScript to do the conversion (if your
290 printer is supported)." \
292 RETURN
'back to the main menu' \
293 DEST
'define default destination of the generated Postscript' \
294 MODE
'change metafont mode/resolution' \
295 OFFSET
'shift output by some offset' \
296 PAPER
'define the default paper' \
297 GLOBAL
'change global settings (config.ps)' \
298 CHANGE
'change printer settings (config.$PRINTER)' \
299 ADD
'add a printer configuration' \
300 DEL
'remove a printer configuration' \
301 2>"$tmpmenu" ||
break
303 menuDvipsAns
=`cat "$tmpmenu"`
304 case $menuDvipsAns in
309 runDialog
--inputbox "Enter the command to print.
311 In general, you need a command like 'lpr' or 'lpr -Pfoo'.
313 NOTE: If you just press return, printing will be disabled and the output saved to a file by default.
316 menuDvipsAns
=`cat "$tmpmenu"`
317 case $menuDvipsAns in
322 menuDvipsPrintOpt
=$menuDvipsAns
325 logexec texconfig dvips
$menuDvipsPrinterOpt printcmd
"$menuDvipsPrintOpt"
331 mode
=`cat "$tmpmenu"`
333 if test -n "$mode"; then
334 logexec texconfig dvips
$menuDvipsPrinterOpt mode
"$mode"
339 runDialog
--inputbox "Enter a dimension pair (a rightwards offset and a downwards
340 offset), e.g. 2mm,-0.5in (right 2mm and up .5in):" 23 80 2>"$tmpmenu"; menuDvipsAns
=`cat "$tmpmenu"`
341 case $menuDvipsAns in
344 logexec texconfig dvips
$menuDvipsPrinterOpt offset
"$menuDvipsAns"
351 --menu \'\\n
\\nChoose the default papersize definition
for dvips.
\\n
\\n
\' \
352 23 80 8 `texconfig dvips paper-list` \
354 paper
=`cat "$tmpmenu"`
355 if test -n "$paper"; then
356 logexec texconfig dvips paper
"$paper"
364 runDialog
--inputbox "Printer name (for future settings of DEST / MODE / OFFSET)" 23 80 2>"$tmpmenu"
365 menuDvipsAns
=`cat $tmpmenu`
366 case $menuDvipsAns in
368 *) menuDvipsDest
=$menuDvipsAns;;
372 runDialog
--inputbox "Printer name (for printer to add)" 23 80 2>"$tmpmenu"
373 menuDvipsAns
=`cat $tmpmenu`
374 case $menuDvipsAns in
377 logexec texconfig dvips add
$menuDvipsAns
383 runDialog
--inputbox "Printer name (for printer to delete)" 23 80 2>"$tmpmenu"
384 menuDvipsAns
=`cat $tmpmenu`
385 case $menuDvipsAns in
388 logexec texconfig dvips del
$menuDvipsAns
401 Select your default paper format.
404 RETURN
'return to the main menu' \
405 A4
'ISO A4 (210x297mm)' \
406 LETTER
'US (8.5x11in)' 2>"$tmpmenu"
411 logexec texconfig paper a4
415 logexec texconfig paper letter
425 Choose format to set up hyphenation for.
428 `texconfig hyphen-list | sed 's@\(.*\)@\1 \1@'` 2>"$tmpmenu"
435 texconfig hyphen
"$p"
445 Usage: $progname [--help|--version]
451 $progname version $version.
458 : ${TEXMFCONFIG=`kpsewhich -var-value=TEXMFCONFIG`}
459 : ${TEXMFVAR=`kpsewhich -var-value=TEXMFVAR`}
460 : ${TEXMFMAIN=`kpsewhich -var-value=TEXMFMAIN`}
461 export TEXMFCONFIG TEXMFVAR TEXMFMAIN
464 echo "$progname: started `date`" > $log
467 test -d "$TEXMFCONFIG" \
468 || mktexdir
"$TEXMFCONFIG" >/dev
/null
2>&1 \
469 ||
echo "$progname: directory \`$TEXMFCONFIG' (from TEXMFCONFIG variable) does not exist and cannot be created" >&2
472 if test -d "$TEXMFCONFIG"; then
473 if test -w "$TEXMFCONFIG"; then
476 echo "$progname: directory \`$TEXMFCONFIG' (from TEXMFCONFIG variable) is not writable."
477 echo "$progname: configuration data cannot be changed." >&2
481 test -d "$TEXMFVAR" \
482 || mktexdir
"$TEXMFVAR" >/dev
/null
2>&1 \
483 ||
echo "$progname: directory \`$TEXMFVAR' (from TEXMFVAR variable) does not exist and cannot be created" >&2
485 canWriteVardata
=false
486 if test -d "$TEXMFVAR"; then
487 if test -w "$TEXMFVAR"; then
490 echo "$progname: directory \`$TEXMFVAR' (from TEXMFVAR variable) is not writable."
491 echo "$progname: cached variable runtime data files cannot be written." >&2