| 1 |
#!/bin/sh |
| 2 |
# mktexdir (was mkinstalldirs) -- make directory hierarchy. |
| 3 |
# Author: Noah Friedman <[email protected]>, created: 1993-05-16. |
| 4 |
# Public domain. |
| 5 |
# |
| 6 |
# Modified for sticky directory creation, --help, --version, more, |
| 7 |
# by Thomas Esser, Karl Berry, Olaf Weber, et al. |
| 8 |
# Maintained as part of TeX Live, http://tug.org/tex-live. |
| 9 |
|
| 10 |
version='$Id: mktexdir 42425 2016-11-02 21:34:11Z karl $' |
| 11 |
progname=`echo $0 | sed 's%.*/%%'` |
| 12 |
|
| 13 |
# preferentially use subprograms from our own directory. |
| 14 |
mydir=`echo "$0" | sed 's,/[^/]*$,,'` |
| 15 |
mydir=`cd "$mydir" && pwd` |
| 16 |
PATH="$mydir:$PATH"; export PATH |
| 17 |
|
| 18 |
usage="Usage: $0 DIR... |
| 19 |
Create each DIR, including any missing leading directories." |
| 20 |
mt_max_args=$# |
| 21 |
|
| 22 |
# Common code for all scripts. |
| 23 |
: ${MT_TEXMFMAIN=`kpsewhich --expand-path='$TEXMFMAIN'`} |
| 24 |
: ${MT_MKTEX_OPT=`kpsewhich --format='web2c files' mktex.opt`} |
| 25 |
test -n "$MT_MKTEX_OPT" || MT_MKTEX_OPT="$MT_TEXMFMAIN/web2c/mktex.opt" |
| 26 |
if test ! -f "$MT_MKTEX_OPT"; then |
| 27 |
echo "$0: Cannot find mktex.opt; check your installation." >&2 |
| 28 |
exit 1 |
| 29 |
fi |
| 30 |
|
| 31 |
. "$MT_MKTEX_OPT" |
| 32 |
|
| 33 |
test -n "$MT_MKTEXDIR_OPT" && . "$MT_MKTEXDIR_OPT" |
| 34 |
|
| 35 |
test -z "$MT_APPEND_MASK" && MT_APPEND_MASK="=" |
| 36 |
|
| 37 |
errstatus=0 |
| 38 |
|
| 39 |
for file |
| 40 |
do |
| 41 |
case $file in |
| 42 |
/*) cd /;; |
| 43 |
*) cd $KPSE_DOT;; |
| 44 |
esac |
| 45 |
OLDIFS=$IFS; IFS=/; set fnord `echo "./$file"`; IFS=$OLDIFS; shift |
| 46 |
|
| 47 |
pathcomp= |
| 48 |
for d |
| 49 |
do |
| 50 |
test -z "$d" && continue |
| 51 |
pathcomp="$pathcomp$d" |
| 52 |
|
| 53 |
if test ! -d "./$pathcomp"; then |
| 54 |
# This shell stuff is not atomic, therefore ./$pathcomp |
| 55 |
# may have been created in another process and this mkdir will |
| 56 |
# fail despite the above test, so do it silently: |
| 57 |
mkdir "./$pathcomp" >/dev/null 2>&1 |
| 58 |
|
| 59 |
# So, if ./$pathcomp is a directory now, call it good. |
| 60 |
if test ! -d "./$pathcomp"; then |
| 61 |
# Otherwise, presumably it's a real error. Do the mkdir again |
| 62 |
# and let the error be seen, and quit the loop. |
| 63 |
# (Report at https://bugs.debian.org/794228.) |
| 64 |
mkdir "./$pathcomp" || { errstatus=$?; break; } |
| 65 |
fi |
| 66 |
chmod `kpsestat ${MT_APPEND_MASK} "$pathcomp"/..` "./$pathcomp" |
| 67 |
fi |
| 68 |
|
| 69 |
pathcomp="$pathcomp/" |
| 70 |
done |
| 71 |
done |
| 72 |
|
| 73 |
exit $errstatus |
| 74 |
|
| 75 |
# P.S. We don't want to rely on mkdir -p, because of possible |
| 76 |
# portability programs. See current mkinstalldirs source (in Automake). |