#! /bin/sh # $Id$ # Copyright 2008 Siep Kroonenberg. # You may freely use, modify and/or distribute this file. if test "x$1" = x--help; then cat <<END_USAGE Usage: tl-portable Start a new subshell with the environment set so TeX Live can be run with minimal impact on the host, that is, run more or less directly from DVD or USB. For more, see the "Maximally portable" section in the TeX Live documentation (http://tug.org/texlive). END_USAGE exit 0 fi #calculate TeX Live root #it appears that dirname isn't always available TEXDIR0=$0 TEXDIR=${TEXDIR0%/*} if test "$TEXDIR" = "$TEXDIR0"; then TEXDIR="." fi unset TEXDIR0 dirsave=`pwd` cd $TEXDIR TEXDIR=`pwd` export TEXDIR cd $dirsave # Test whether the TeX Live directory is writable. We need an actual # write test, because network drives aren't always identified # correctly. We accept negatives at face value. if test -w $TEXDIR; then # make sure $TEXDIR is really writable testfile=1 while test -e $TEXDIR/$testfile do testfile=`expr $testfile + 1` done echo Testing whether $TEXDIR is writable... touch $TEXDIR/$testfile 2>/dev/null if test -e $TEXDIR/$testfile; then rm $TEXDIR/$testfile echo $TEXDIR is writable. TEXDIRW=$TEXDIR else echo $TEXDIR is not writable. TEXDIRW=$HOME/.tlportable2008 fi else TEXDIRW=$HOME/.tlportable2008 fi export TEXDIRW echo Using $TEXDIRW for generated files. # Use $TEXMFHOME for private data, # $TEXMFLOCAL for department- or workgroup data. # It is allright if $TEXMFLOCAL does not exist. TEXMFSYSVAR=$TEXDIRW/texmf-var if test -d $TEXDIR/texmf-var; then TEXMFSYSVAR=$TEXDIR/texmf-var fi export TEXMFSYSVAR TEXMFSYSCONFIG=$TEXDIRW/texmf-config if test -f $TEXDIR/texmf-config; then TEXMFSYSCONFIG=$TEXDIR/texmf-config fi export TEXMFSYSCONFIG TEXMFMAIN=$TEXDIR/texmf export TEXMFMAIN TEXMFDIST=$TEXDIR/texmf-dist export TEXMFDIST TEXMFLOCAL=$TEXDIR/texmf-local export TEXMFLOCAL TEXMFHOME=$TEXDIRW/texmf-home export TEXMFHOME TEXMFVAR=$TEXDIRW/texmf-var export TEXMFVAR TEXMFCONFIG=$TEXDIRW/texmf-config export TEXMFCONFIG platform=`$TEXDIR/install-tl --print-arch` if test "$platform" = ""; then echo 'Platform unsupported' exit 1 elif test ! -d $TEXDIR/bin/$platform; then echo 'Platform unsupported' exit 1 fi if $TEXDIR/install-tl --portable; then :; else echo "$0: Initialization of TeX Live failed!" >&2 exit 1 fi # Try to block initialization scripts. # Set custom prompt for secondary shell, but # I know of no good way to do this for the C shell. ENV=/dev/null export ENV PATH=$TEXDIR/bin/$platform:$PATH export PATH if test "$SHELL" = /bin/bash; then PS1='TL \w\$ ' export PS1 exec $SHELL --norc -i elif test "$SHELL" = /bin/zsh; then PS1='TL %d%% ' export PS1 exec $SHELL -f -i elif test "$SHELL" = /bin/csh; then exec $SHELL -f -i elif test "$SHELL" = /bin/tcsh; then exec $SHELL -f -i else PS1='TL $PWD\$ ' export PS1 exec $SHELL -f -i fi