summaryrefslogtreecommitdiff
path: root/Build/source/selfautofix
blob: 2aa08b4985523d0788eb0672a4a95822a1a82224 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

# selfautofix: change absolute paths in texmf.cnf to $SELFAUTO references.
# Copyright: 1998, Thomas Esser. Public domain.

bindir=$1
web2c=$2

test -f "$web2c"/texmf.cnf || exit 0
grep 'original texmf.cnf --' "$web2c"/texmf.cnf >/dev/null 2>&1 || exit 0

bindirp=`echo $bindir | sed 's%/[^/][^/]*$%%'`
bindirpp=`echo $bindirp | sed 's%/[^/][^/]*$%%'`

cd $web2c || exit 0

sedfile=sed.$$
test -n "$bindir" \
  && echo "/^[ 	]*TEXMFCNF[ =]/!s%$bindir/%\$SELFAUTOLOC/%g" > $sedfile
test -n "$bindirp" \
  && echo "/^[ 	]*TEXMFCNF[ =]/!s%$bindirp/%\$SELFAUTODIR/%g" >> $sedfile
test -n "$bindirpp" \
  && echo "/^[ 	]*TEXMFCNF[ =]/!s%$bindirpp/%\$SELFAUTOPARENT/%g" >> $sedfile

cat >>$sedfile <<eof
/^%/!s%:%;%g
/^[ 	]*TEXMFCNF[ =]/s%;%:%g
eof

sed  -f $sedfile texmf.cnf >texmf.cnf.$$
test -s texmf.cnf.$$  && cat texmf.cnf.$$ > texmf.cnf
rm -f texmf.cnf.$$ $sedfile

exit 0