#!/bin/sh # TeX Live installation script # (c) Thomas Esser, Sebastian Rahtz, 1996, 1997 # # Permission to use and distribute, but no warranty. # Call this script with a full-featured bourne shell, which may be # /bin/sh, /bin/bsh (e.g. AIX-4.XX), /bin/sh5 (e.g. ULTRIX) or # /bin/bash (on GNU systems) on your system. # Example: # sh ./install-pkg.sh list=false; src=true; doc=true; texhash=true unset col pkg tarfile cddir while test $# -gt 0; do case $1 in -p) if test $# -ge 2; then pkg=$2; shift else fatal "Missing argument for -p" fi;; --package=*) pkg=`echo $1 | sed 's/.*=//'`;; -c) if test $# -ge 2; then col=$2; shift else fatal "Missing argument for -c" fi;; --collection=*) col=`echo $1 | sed 's/.*=//'`;; --nodoc) doc=false;; --nosrc) src=false;; --nohash) texhash=false;; --listonly) list=true;; --archive=*) tarfile=`echo $1 | sed 's/.*=//'` list=false;; --cddir=*) cddir=`echo $1 | sed 's/.*=//'`;; --listdir=*) listdir=`echo $1 | sed 's/.*=//'`;; *) break;; esac shift done fatal() { echo; echo echo "ERROR: $@." echo "This was a fatal error, my friend. Installation aborted." exit 1 } ################################################################ # a replacement for xargs (for systems that dont have it) ################################################################ mxargs() { ( COUNT=25 COUNTP=26 TEMP=${TMP-/tmp} TMPA=$TEMP/.tmp_xargs_a.$$ TMPB=$TEMP/.tmp_xargs_b.$$ trap "rm -f $TMPA $TMPB; trap '' 0; exit 0" 0 1 2 15 cat > $TMPA while test -s $TMPA; do args=`sed -n "1,${COUNT}p" <$TMPA` "$@" $args mv $TMPA $TMPB sed -n "${COUNTP},\$p" <$TMPB >$TMPA done ) } mkdirhier() { case $1 in /*) cd /;; esac OLDIFS=$IFS; IFS=/; eval set $1; IFS=$OLDIFS for i do test -d $i || mkdir $i || break cd $i || break done } find_in_path() { fip_testbin=$1 fip_result="" case "$fip_testbin" in /*) test -x "$fip_testbin" && test -f "$fip_testbin" && fip_result="$fip_result $fip_testbin";; *) OLDIFS=$IFS; IFS=:; eval set - $PATH; IFS=$OLDIFS for fip_this_dir do test -x "$fip_this_dir/$fip_testbin" && test -f "$fip_this_dir/$fip_testbin" && fip_result="$fip_result $fip_this_dir/$fip_testbin" done esac echo $fip_result } ################################################################ # search for a tar that either understands -I or -T ################################################################ test_tar() { testtar_tmp=${TMP-/tmp}/.testtar.$$ TARS="`find_in_path gtar` `find_in_path tar`" test -z "$TARS" && return ( exec 3>&1 1>/dev/null 2>&1 trap "cd /; rm -rf $testtar_tmp; trap '' 0; exit 0" 0 1 2 15 mkdir $testtar_tmp; cd $testtar_tmp mkdir a b tar cf test.tar a b rmdir a b echo a > list for TAR in $TARS; do $TAR -x -f test.tar -T list >/dev/null 2>&1 if test -d a && test ! -d b; then echo "$TAR -T" >&3 break fi rmdir a b >/dev/null 2>&1 $TAR -x -f test.tar -I list >/dev/null 2>&1 find . -ls if test -d a && test ! -d b; then echo "$TAR -I" >&3 break fi done ) } ################################################################ # if we find a good tar: use it. Else use xargs (or even mxargs) ################################################################ find_tar() { set x `test_tar`; shift if test -n "$1"; then GOODTAR=true TARPROG=$1; TAROPT=$2 else GOODTAR=false TARPROG=tar; TAROPT="" XARGS=`find_in_path xargs | sed 's/ .*//'` test -x "$XARGS" || XARGS=mxargs fi } find_tar thisdir=`pwd` CDDIR=${cddir-${OVERRIDE_CDDIR-$thisdir}} LISTS=${listdir-${OVERRIDE_LISTS-$CDDIR/share/texmf/lists}} work_dir=${TMP-/tmp}/.tmp.pkginst.$$ trap 'cd /; rm -rf $work_dir; trap 0' 0 1 2 15 { mkdir $work_dir && cd $work_dir; } || exit test -d $LISTS || fatal "$0: $LISTS: no such directory. Are you sure this is the TeX Live CD?" : ${TEXMF=`kpsewhich -expand-var '$TEXMFMAIN'`} TEXDIR=`echo $TEXMF | sed 's/share.texmf//'` echo Packages will be installed in $TEXDIR cd $work_dir rm -f tmp touch tmp if test -n "$col"; then if test -d $LISTS/$col; then cat $LISTS/$col/[a-z]* | grep -v TRANS.TBL >> tmp else echo "$0: $col: no such collection." fi fi if test -n "$pkg"; then if test -f `echo $LISTS/*/$pkg | awk '{print $1}'`; then cat $LISTS/*/$pkg | grep -v TRANS.TBL >> tmp else echo "$0: $col: no such package." fi fi filters= $src || filters="$filters | grep -v share/texmf/source/" $doc || filters="$filters | grep -v share/texmf/doc/" eval sort < tmp $filters | uniq > files if $list; then cat files | grep -v TRANS.TBL exit fi if test -n "$tarfile"; then case $tarfile in /*) : ;; *) tarfile=$thisdir/$tarfile;; esac if test "x$TAROPT" = "x"; then echo "$0: archive option is not supported on this system." >&2 else cd $CDDIR; $TARPROG cf $tarfile $TAROPT $work_dir/files fi exit fi if test "x$TAROPT" = "x"; then (cd $CDDIR; $XARGS sh -c 'tar cf - $* | (cd '"$TEXDIR"'; umask 0; $TARPROG xf -)' sh <$work_dir/files) else (cd $CDDIR; $TARPROG -c -f - $TAROPT $work_dir/files) | (cd $TEXDIR; umask 0; $TARPROG xf -) fi MakeTeXls-R