Debian Codegraph @

texk/texlive/tl_support/tcfmgr

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # $Id: tcfmgr 34641 2014-07-17 16:38:18Z karl $
3 # tcfmgr - TeX configuration file manager (sort of).
4 # Public domain. Originally written by Thomas Esser.
5
6 # invoke the right shell:
7
8 testscip-shell system . . test. -f /bin/kshscip-shell filesystem . . `/bin/ksh`. && testscip-shell system . . test. -z "$RUNNING_KSH" \
9 && { UNAMES=`unamescip-shell system . . uname. -s`; testscip-shell system . . test. "x$UNAMES" = xULTRIX; } 2>/dev/nullscip-shell filesystem . . `/dev/null`. \
10 && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/kshscip-shell filesystem . . `/bin/ksh`. $0 ${1+"$@"}; }
11 unset RUNNING_KSH
12
13 testscip-shell system . . test. -f /bin/bshscip-shell filesystem . . `/bin/bsh`. && testscip-shell system . . test. -z "$RUNNING_BSH" \
14 && { UNAMES=`unamescip-shell system . . uname. -s`; testscip-shell system . . test. "x$UNAMES" = xAIX; } 2>/dev/nullscip-shell filesystem . . `/dev/null`. \
15 && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bshscip-shell filesystem . . `/bin/bsh`. $0 ${1+"$@"}; }
16 unset RUNNING_BSH
17
18 # preferentially use subprograms from our own directory.
19 mydir=`echoscip-shell system . . echo. "$0" | sedscip-shell system . . sed. 's,/[^/]*$,,'`
20 mydir=`cd "$mydir" && pwdscip-shell system . . pwd.`
21 PATH="$mydir:$PATH"; export PATH
22
23 # hack around a bug in zsh:
24 testscip-shell system . . test. -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
25
26 progname=tcfmgr
27
28 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort().()
29 {
30 echoscip-shell system . . echo. "$progname: $@." >&2
31 (exit 1); exit 1
32 }
33
34 mktexupdscip-shell shell texlive-bin 2026.20260303.78225+ds-4 mktexupd().()
35 {
36 setupMktexupdscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMktexupd().
37 "$TFC_MKTEXUPD" "$@" >&2
38 }
39
40 # call mktexdir script, disable all features (to prevent sticky directories)
41 mktexdirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 mktexdir().()
42 {
43 setupMktexDirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMktexDir().
44 MT_FEATURES=none "$TFC_MKTEXDIR" "$@" >&2
45 }
46
47 setupMapscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMap().()
48 {
49 case $setupMapOK in
50 "") : ;;
51 *) (exit 0); return 0;;
52 esac
53
54 case $TFC_MAP in
55 "") TFC_MAP=`(kpsewhich -progname=texconfig -format='other text files' tcfmgr.map) 2>/dev/nullscip-shell filesystem . . `/dev/null`.`;;
56 esac
57
58 case $TFC_MAP in
59 "") abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "config file \`tcfmgr.map' (usually in \$TEXMFMAIN/texconfig) not found (ls-R missing?)";;
60 esac
61
62 if testscip-shell system . . test. ! -f "$TFC_MAP"; then
63 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "config file \`TFC_MAP' does not exist"
64 fi
65 setupMapOK=true
66 }
67
68 setupTempscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTemp().()
69 {
70 case $setupTempOK in
71 "") : ;;
72 *) (exit 0); return 0;;
73 esac
74
75 case $TFC_TEMP in
76 "") TFC_TEMP=${TEMPDIR-/tmp};;
77 esac
78
79 if testscip-shell system . . test. ! -d "$TFC_TEMP"; then
80 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "temp directory \`$TFC_TEMP' does not exist"
81 fi
82
83 if testscip-shell system . . test. ! -w "$TFC_TEMP"; then
84 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "temp directory \`$TFC_TEMP' is not writable"
85 fi
86 setupTempOK=true
87 }
88
89 setupTexmfConfigscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTexmfConfig().()
90 {
91 case $TFC_TEXMFCONFIG in
92 "") TFC_TEXMFCONFIG=`(kpsewhich -var-value=TEXMFCONFIG) 2>/dev/nullscip-shell filesystem . . `/dev/null`.`;;
93 *) (exit 0); return 0;;
94 esac
95 case $TFC_TEXMFCONFIG in
96 "") abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "variable \$TEXMFCONFIG is not defined in texmf.cnf";;
97 esac
98 }
99
100 setupMktexDirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMktexDir().()
101 {
102 case $TFC_MKTEXDIR in
103 "") TFC_MKTEXDIR=`(kpsewhich --format='web2c files' mktexdir) 2>/dev/nullscip-shell filesystem . . `/dev/null`.`;;
104 esac
105
106 case $TFC_MKTEXDIR in
107 "") abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "program mktexdir (usually in \$TEXMFMAIN/web2c) not found";;
108 esac
109 }
110
111 setupMktexupdscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMktexupd().()
112 {
113 case $TFC_MKTEXUPD in
114 "") TFC_MKTEXUPD=`(kpsewhich --format='web2c files' mktexupd) 2>/dev/nullscip-shell filesystem . . `/dev/null`.`;;
115 esac
116
117 case $TFC_MKTEXUPD in
118 "") abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "program mktexupd (usually in \$TEXMFMAIN/web2c) not found";;
119 esac
120 }
121
122 writableCheckscip-shell shell texlive-bin 2026.20260303.78225+ds-4 writableCheck().()
123 {
124 setupTexmfConfigscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTexmfConfig().
125 if testscip-shell system . . test. ! -d "$TFC_TEXMFCONFIG"; then
126 mktexdirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 mktexdir(). "$TFC_TEXMFCONFIG" >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1
127 if testscip-shell system . . test. ! -d "$TFC_TEXMFCONFIG"; then
128 msg="Directory TEXMFCONFIG=\`$TFC_TEXMFCONFIG' does not exist"
129 (exit 1); return 1
130 fi
131 fi
132
133 case "$relDir" in
134 "") get_infoscip-shell shell texlive-bin 2026.20260303.78225+ds-4 get_info().;;
135 esac
136 if testscip-shell system . . test. -f "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE" \
137 && testscip-shell system . . test. -w "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE"
138 then
139 (exit 0); return 0
140 fi
141
142 if testscip-shell system . . test. -d "$TFC_TEXMFCONFIG/$relDir"; then
143 if testscip-shell system . . test. -w "$TFC_TEXMFCONFIG/$relDir"; then
144 (exit 0); return 0
145 else
146 msg="Directory \`$TFC_TEXMFCONFIG/$relDir' is not writable"
147 (exit 1); return 1
148 fi
149 else
150 # we assume that a "mkdir -p" would work if the top-level
151 # $TFC_TEXMFCONFIG is writable
152 if testscip-shell system . . test. -w "$TFC_TEXMFCONFIG"; then
153 (exit 0); return 0
154 else
155 msg="Directory \`$TFC_TEXMFCONFIG' is not writable"
156 (exit 1); return 1
157 fi
158 fi
159 }
160
161 get_infoscip-shell shell texlive-bin 2026.20260303.78225+ds-4 get_info().()
162 {
163 case "$TFC_FILE" in
164 "") abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "missing --file option or empty argument";;
165 esac
166 setupMapscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMap().
167 # prepare + get info
168 IFS=$TAB
169 # set -- x `(awk '$1 == file' file=$TFC_FILE <$TFC_MAP) 2>/dev/null`; shift
170 set -- x `(grepscip-shell system . . grep. "^$TFC_FILE[ ]" $TFC_MAP) 2>/dev/nullscip-shell filesystem . . `/dev/null`.`; shift
171 IFS=$STD_IFS
172
173 # assign results
174 file="$1"
175 relDir="$2"
176 kpseFormat="$3"
177 kpseProgArg="$4"
178
179 # sanity checks
180 case $file in
181 "") abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "no info for file \`$TFC_FILE' in map \`$TFC_MAP'";;
182 esac
183
184 case $relDir in
185 -) abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "no known standard location for file \`$TFC_FILE' in map \`$TFC_MAP'";;
186 esac
187
188 case $kpseProgArg in
189 -) kpseProgArg=kpsewhich;;
190 esac
191 }
192
193 check_outscip-shell shell texlive-bin 2026.20260303.78225+ds-4 check_out().()
194 {
195 if $createEmptyFile; then
196 :
197 else
198 case "$orig" in
199 "")
200 get_infoscip-shell shell texlive-bin 2026.20260303.78225+ds-4 get_info().
201 orig=`(kpsewhich -format="$kpseFormat" -progname="$kpseProgArg" "$TFC_FILE") 2>/dev/nullscip-shell filesystem . . `/dev/null`.`
202 ;;
203 *)
204 testscip-shell system . . test. -f "$orig" || orig=
205 esac
206
207 case $orig in
208 "") abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "file \`$TFC_FILE' not found";;
209 esac
210 fi
211
212 # writableCheck needs to get a valid relDir, so it calls get_info if necessary
213 if writableCheckscip-shell shell texlive-bin 2026.20260303.78225+ds-4 writableCheck().; then
214 : ok
215 else
216 catscip-shell system . . cat. >&2 <<eof
217
218 There was a problem finding a proper place to store configuration data.
219 The message was:
220 $msg
221
222 To overcome such problems, set up the environment variable TEXMFCONFIG to
223 point to a directory tree that is writable to you, e.g.
224 TEXMFCONFIG=\$HOME/texmf; export TEXMFCONFIG
225 or
226 setenv TEXMFCONFIG \$HOME/texmf
227 eof
228 (exit 1); exit 1
229 fi
230
231 setupTempscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTemp().
232 : ${TFC_ID=tfc$$}
233 for d in "$TFC_TEMP/$TFC_ID" "$TFC_TEMP/$TFC_ID/in" "$TFC_TEMP/$TFC_ID/out"; do
234 (umask 077; mkdirscip-shell system . . mkdir. "$d") || abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "could not create directory \`$d'"
235 done
236
237 if $createEmptyFile; then
238 (umask 022
239 > "$TFC_TEMP/$TFC_ID/in/$TFC_FILE"
240 > "$TFC_TEMP/$TFC_ID/out/$TFC_FILE")
241 else
242 cpscip-shell system . . cp. "$orig" "$TFC_TEMP/$TFC_ID/in/$TFC_FILE" \
243 || abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "copy \`$orig' -> \`$TFC_TEMP/$TFC_ID/in/$TFC_FILE' failed"
244
245 cpscip-shell system . . cp. "$orig" "$TFC_TEMP/$TFC_ID/out/$TFC_FILE" \
246 || abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "copy \`$orig' -> \`$TFC_TEMP/$TFC_ID/out/$TFC_FILE' failed"
247
248 chmodscip-shell system . . chmod. u+w "$TFC_TEMP/$TFC_ID/out/$TFC_FILE"
249 fi
250
251 catscip-shell system . . cat. >"$TFC_TEMP/$TFC_ID/relDir" <<eof
252 $relDir
253 eof
254
255 catscip-shell system . . cat. > "$TFC_TEMP/$TFC_ID/file" <<eof
256 $TFC_FILE
257 eof
258
259 echoscip-shell system . . echo. "$TFC_ID $TFC_TEMP/$TFC_ID/in/$TFC_FILE $TFC_TEMP/$TFC_ID/out/$TFC_FILE $orig"
260 }
261
262 check_inscip-shell shell texlive-bin 2026.20260303.78225+ds-4 check_in().()
263 {
264 setupTempscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTemp().
265
266 if testscip-shell system . . test. ! -d "$TFC_TEMP/$TFC_ID"; then
267 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "directory \`$TFC_TEMP/$TFC_ID' does not exist. Perhaps missing arg --id"
268 fi
269
270 case "$TFC_FILE" in
271 "") TFC_FILE=`(catscip-shell system . . cat. "$TFC_TEMP/$TFC_ID/file") 2>/dev/nullscip-shell filesystem . . `/dev/null`.`;;
272 esac
273
274 for f in "$TFC_TEMP/$TFC_ID/relDir" "$TFC_TEMP/$TFC_ID/file" "$TFC_TEMP/$TFC_ID/in/$TFC_FILE" "$TFC_TEMP/$TFC_ID/out/$TFC_FILE"; do
275 if testscip-shell system . . test. ! -f "$f"; then
276 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "Oops! file \`$f' does not exist"
277 fi
278 done
279
280 if (cmpscip-shell system . . cmp. "$TFC_TEMP/$TFC_ID/in/$TFC_FILE" "$TFC_TEMP/$TFC_ID/out/$TFC_FILE") >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
281 (exit 0); return 0
282 fi
283
284 setupTexmfConfigscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupTexmfConfig().
285 relDir=`catscip-shell system . . cat. "$TFC_TEMP/$TFC_ID/relDir"`
286 if testscip-shell system . . test. ! -d "$TFC_TEXMFCONFIG/$relDir"; then
287 setupMktexDirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMktexDir().
288 mktexdirscip-shell shell texlive-bin 2026.20260303.78225+ds-4 mktexdir(). "$TFC_TEXMFCONFIG/$relDir" || abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "could not create directory \`$TFC_TEXMFCONFIG/$relDir'"
289 fi
290
291 if testscip-shell system . . test. -f "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE"; then
292 needsLSRUpdate=false
293 testscip-shell system . . test. -w "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE" || rmscip-shell system . . rm. -f "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE"
294 else
295 needsLSRUpdate=true
296 fi
297
298 if testscip-shell system . . test. -f "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE"; then
299 catscip-shell system . . cat. <"$TFC_TEMP/$TFC_ID/out/$TFC_FILE" >"$TFC_TEXMFCONFIG/$relDir/$TFC_FILE" ||
300 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "failed to write new file \`$TFC_TEXMFCONFIG/$relDir/$TFC_FILE'"
301 else
302 cpscip-shell system . . cp. "$TFC_TEMP/$TFC_ID/out/$TFC_FILE" "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE" ||
303 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "failed to copy \`$TFC_TEMP/$TFC_ID/out/$TFC_FILE' to \`$TFC_TEXMFCONFIG/$relDir/$TFC_FILE'"
304 chmodscip-shell system . . chmod. 644 "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE" 2>/dev/nullscip-shell filesystem . . `/dev/null`.
305 fi
306 if $needsLSRUpdate; then
307 mktexupdscip-shell shell texlive-bin 2026.20260303.78225+ds-4 mktexupd(). "$TFC_TEXMFCONFIG/$relDir" "$TFC_FILE"
308 fi
309 echoscip-shell system . . echo. "$TFC_TEXMFCONFIG/$relDir/$TFC_FILE"
310 (exit 0); return 0
311 }
312
313 find_filescip-shell shell texlive-bin 2026.20260303.78225+ds-4 find_file().()
314 {
315 get_infoscip-shell shell texlive-bin 2026.20260303.78225+ds-4 get_info().
316 kpsewhich -format="$kpseFormat" -progname="$kpseProgArg" "$TFC_FILE"
317 }
318
319 helpscip-shell shell texlive-bin 2026.20260303.78225+ds-4 help().()
320 {
321 catscip-shell system . . cat. <<eof
322 Usage: $progname [option] ...
323
324 Valid options:
325 --reldir specify directory relative to texmf root
326 --infile specify input file
327 --emptyinfile create an empty input file
328 --map specify map file
329 --texmfconfig texmf tree for config files
330 --mktexdir full path of mktexdir
331 --mktexupd full path of mktexupd
332 --tmp temp directory
333 --id identity string (generated when running command co)
334 --file specify configuration entry from map file
335 --cmd command to execute
336 --help display this help
337
338 Valid commands (--cmd) are:
339 co check out
340 ci check in
341 find look up source for file
342 mapfile display path name of map file
343 eof
344 }
345
346 show_mapscip-shell shell texlive-bin 2026.20260303.78225+ds-4 show_map().()
347 {
348 setupMapscip-shell shell texlive-bin 2026.20260303.78225+ds-4 setupMap().
349 echoscip-shell system . . echo. "$TFC_MAP"
350 }
351
352 TAB=' '
353 SPACE=' '
354 NL='
355 '
356 createEmptyFile=false
357
358 STD_IFS="$TAB$SPACE$NL"
359 while
360 case $1 in
361 --reldir) relDir=$2; shift;;
362 --infile) orig=$2; shift;;
363 --emptyinfile) createEmptyFile=true;;
364 --map) TFC_MAP=$2; shift;;
365 --texmfconfig)
366 TFC_TEXMFCONFIG=$2; shift;;
367 --mktexdir)
368 TFC_MKTEXDIR=$2;;
369 --mktexupd)
370 TFC_MKTEXUPD=$2;;
371 --tmp) TFC_TEMP=$2; shift;;
372 --id) TFC_ID=$2; shift;;
373 --file)TFC_FILE=$2; shift;;
374 --cmd) TFC_CMD=$2; shift;;
375 --help) TFC_CMD=help;;
376 "") break;;
377 *) abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "unknown option \`$1'; try $progname --help"; (exit 1); exit 1;;
378 esac
379 do testscip-shell system . . test. $# -gt 0 && shift; done
380
381 case $TFC_CMD in
382 ci) check_inscip-shell shell texlive-bin 2026.20260303.78225+ds-4 check_in().;;
383 co) check_outscip-shell shell texlive-bin 2026.20260303.78225+ds-4 check_out().;;
384 find) find_filescip-shell shell texlive-bin 2026.20260303.78225+ds-4 find_file().;;
385 mapfile) show_mapscip-shell shell texlive-bin 2026.20260303.78225+ds-4 show_map().;;
386 help) helpscip-shell shell texlive-bin 2026.20260303.78225+ds-4 help().;;
387 "")
388 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "no command; try $progname --help"; (exit 1); exit 1;;
389 *)
390 abortscip-shell shell texlive-bin 2026.20260303.78225+ds-4 abort(). "unknown command \`$TFC_CMD'; try $progname --help"; (exit 1); exit 1;;
391 esac