On Fri, Nov 19, 2004 at 10:00:56PM +0100, Reinhard Kotucha wrote:
> >>>>> "Metod" == Metod Kozelj <[EMAIL PROTECTED]> writes:
> 
>   > On the other hand, it is imensely great to have a directory
>   > structure as it is now. [...]
> 
> Metod,
> I must admit that I misunderstood Werner's first mail.  I thought that
> he wanted teTeX to be changed, but his reply to my mail made clear
> that he just asks for a configure option, as you suggest.
> 
> Werner,
> you mentioned the following directories:
> 
> /etc/texmf/
> /var/lib/texmf/
> /var/cache/fonts/
> /usr/lib/texmf/
> /usr/share/texmf/
> 
> All files in texmf are platform independent and can be on a read-only
> file system.  So we only have

Hmmm ... for an example, most data in the web2c/ directoy are
variable data (e.g. if a format is rebuilded), also the ls-R
files are variable.

> 
> /etc/texmf/
> /var/cache/fonts/
> /usr/share/texmf/

only /usr and all data therein should be usabel even if /usr
is mounted readonly ... even after texconfig was called ;^)

> If Thomas agrees that $VARTEXFONTS should be /var/cache/fonts/ instead
> of /var/tmp/texfonts, what remains is only the symlink to texmf.cnf.
> 
> You wrote:
> 
>   > Hmmm ... the package te_nfs provides a script tetex-import
>   > together with a README for importing the full teTeX structure
>   > from a teTeX server.  Clearly this package conflicts with all
>   > other teTeX packages.
> 
> I use Slackware, so I cannot look into the files.  Can you explain
> what you mean?  Isn't it sufficient to set the $PATH appropriately on
> a client?  I do not understand what you man with "this package
> conflicts with all other teTeX packages.".

Hmmm ... in RPM language a `Conflict' means that you can not install
two conflicting RPM packages on the same system.  And a package is
simply the read to install RPM file, which includes a cpio archive
together with informations about the files of the archive and
cross informations in comparision to other RPM file/packages
(dependcies, conficts, requirements).

See the attachments what I'm doing with the teTeX-nfs package to
import all what is needed.


          Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
     TeTeX over NFS for Clients
     ==========================


Four steps are required:

* First (of all of the clients): Do not install any teTeX packages
  but at least the package te_nfs.

* Second (on the server): Install the teTeX packages your need
  and add the following 4 lines to /etc/export

    /etc/texmf              *.your.domain.here(ro,root_squash)
    /usr/share/texmf        *.your.domain.here(ro,root_squash)
    /var/lib/texmf          *.your.domain.here(ro,root_squash)
    /var/cache/fonts        *.your.domain.here(rw,root_squash)

  and call

       killall -HUP rpc.mountd rpc.nfsd

* Third (of all of the clients): Run the following command:

     tetex-import   your.tetex.server.here

  with `your.tetex.server.here' the IP address or full qualified
  domain name of your teTeX server.

* Fourth (of all of the clients): Add the four lines which the
  script tetex-import has (hopefully) written to standard out
  to the file

             /etc/fstab

#!/bin/bash
#
# This script imports the teTeX system from the same
# server from which /usr/share/texmf is mounted (nfs).
# This script should work with standard bourne shell.
#
# Copyright (c) 1998,2000 SuSE GmbH Nuernberg, Germany.
# please send bugfixes or comments to [EMAIL PROTECTED]
#
# Author: Werner Fink
#

export LC_CTYPE=POSIX

test `whoami` = root || { echo "Permission denied" 1>&2 ; exit 1; }

#
# The teTeX system, main date, variable data, fonts cache,
# and configuration data.
#
texroot=/usr/share/texmf
texvars=/var/lib/texmf
texfont=/var/cache/fonts
texconf=/etc/texmf

#
# Mount options and Internal Field Separator(s)
#
mntopt="exec,nosuid,nodev,hard,bg,intr,rsize=8192,wsize=8192"
action="import"  # otherwise "remove"
OLDIFS="$IFS"
NL='
'

#
# Remember the options given to us
#
we="${0##*/}"
tab="`echo ${we}:| tr '[:print:]' ' '`"
argv="$@"
args=$#

#
# Place holder for the nfs server(s) of the teTeX system
#
server=""
rootserv=""
varsserv=""
fontserv=""
confserv=""
etcfstab=""
num=0

#
# The current system: architecture, operating system, libc
#
  arch="`uname -m| sed 's%i.86%i586%g'`"
system="`uname -s| tr '[:upper:]' '[:lower:]'`"
set -- /lib/libc.so.[0-9]
eval libc=\${${#}##*.}
if test $libc -ge 6 ; then
    libc=libc$libc
else
    libc=libc5
fi
if test $system = linux ; then
    binary=$arch-$system-$libc
else
    binary=$arch-$system
fi

#
# Test the teTeX system: Something is already mounted?
#
test_system ()
{
    IFS="$NL"
    set -- `df -P -t nfs`
    IFS="$OLDIFS"
    shift

    for line ; do
        case "$line" in
            *:${texroot}*) rootserv=${line%%:*} ;;
            *:${texvars}*) varsserv=${line%%:*} ;;
            *:${texfont}*) fontserv=${line%%:*} ;;
            *:${texconf}*) confserv=${line%%:*} ;;
            *)  ;;
        esac
    done
}

#
# At the first time we may need a mount point,
# just do it.
#
mount_dir ()
{
    origin=$1
    mpoint=$2
    rwro=$3

    test -d $mpoint || mkdir -p $mpoint
    set -- `mount -v -t nfs -o ${rwro},$mntopt $origin $mpoint`
    set -- $1 $3 $5 ${6#"("}
    if test -n "$1" ; then
        etcfstab="${etcfstab}`echo $1 $2 $3 ${4%')'} 0 0`\n"
        num=`expr $num + 1`
    fi
}

#
# Try to mount the system from the server
#
mount_system ()
{
    test_system

    IFS="$NL"
    set -- `showmount -e $server`
    IFS="$OLDIFS"

    for line ; do
    fs=${server}:${line%%\ *}
        case "$line" in
            *${texroot}\ *) test -z "$rootserv" && mount_dir ${fs} ${texroot} 
ro ;;
            *${texvars}\ *) test -z "$varsserv" && mount_dir ${fs} ${texvars} 
ro ;;
            *${texfont}\ *) test -z "$fontserv" && mount_dir ${fs} ${texfont} 
rw ;;
            *${texconf}\ *) test -z "$confserv" && mount_dir ${fs} ${texconf} 
ro ;;
            *)  ;;
        esac
    done

    test_system
    test -z "$rootserv" && echo "${we}: Warning, can not mount ${texroot}" 1>&2
    test -z "$varsserv" && echo "${we}: Warning, can not mount ${texvars}" 1>&2
    test -z "$fontserv" && echo "${we}: Warning, can not mount ${texfont}" 1>&2
    test -z "$confserv" && echo "${we}: Warning, can not mount ${texconf}" 1>&2
}

#
# Umount the teTeX system
#
umount_system ()
{
    test_system
    test -n "$rootserv" && umount ${texroot}
    test -n "$varsserv" && umount ${texvars}
    test -n "$fontserv" && umount ${texfont}
    test -n "$confserv" && umount ${texconf}
}

#
# Do not overlink/remove existing files or foreign links.
#
test_file ()
{
    tfl=$1
    tfp=$2
    if test -f $tfl -a ! -L $tfl ; then
        echo "${we}: File $tfl already exists, skipping"  1>&2
        echo "${tab} $tfp"  1>&2
        return 1
    fi
    if test -L $tfl ; then
        set -- `ls -iL $tfl $tfp`
        if test $1 -ne $3 ; then
            echo -e "${we}:\033[1m WARNING symbolic link $tfl does not have 
the" 1>&2
            echo -e "${tab} source $tfp\033[m" 1>&2
            return 1
        fi
    fi
    return 0
}

#
# Integrate the binaries, manual pages, and info descriptions
# into the normal file system hierarchy.
#
linkin ()
{
    relbin=`relpath ${texroot}/teTeX/bin/$binary /usr/bin`
    for prg in ${texroot}/teTeX/bin/$binary/* ; do
        lprg=/usr/bin/${prg##*/}
        test -x $prg || continue
        test_file $lprg $prg || continue
        rm -f $lprg
        ln -sf $relbin/${prg##*/} $lprg
    done
    relman=`relpath ${texroot}/teTeX/man/man1 /usr/share/man/man1`
    for man in ${texroot}/teTeX/man/man1/*.1* ; do
        lman=/usr/share/man/man1/${man##*/}
        test -f $man || continue
        test_file $lman $man || continue
        rm -f $lman
        ln -sf $relman/${man##*/} $lman
    done
    relinf=`relpath ${texroot}/teTeX/info /usr/share/info`
    for inf in ${texroot}/teTeX/info/*info* ; do
        linf=/usr/share/info/${inf##*/}
        test -f $inf || continue
        test_file $linf $inf || continue
        rm -f $linf
        ln -sf $relinf/${inf##*/} $linf
    done
}

#
# Deintegrate the binaries, manual pages, and info descriptions.
#
linkout ()
{
    for prg in ${texroot}/teTeX/bin/$binary/* ; do
        lprg=/usr/bin/${prg##*/}
        test -x $prg || continue
        test_file $lprg $prg || continue
        rm -f $lprg
    done
    for man in ${texroot}/teTeX/man/man1/*.1* ; do
        lman=/usr/share/man/man1/${man##*/}
        test -f $man || continue
        test_file $lman $man || continue
        rm -f $lman
    done
    for inf in ${texroot}/teTeX/info/*info* ; do
        linf=/usr/share/info/${inf##*/}
        test -f $inf || continue
        test_file $linf $inf || continue
        rm -f $linf
    done
}

#
# This calculates the relative path of the source path
# which depends on the destination path. The function
# takes two arguments:
#
#     the full directory path to the source file/dir
#     the full directory path to the destination file/dir
#
# both without the file or directory name its self.
#
# Author: Werner Fink
#
relpath ()
{
    # called by linkin: top down
    IFS='/'
    orgwords="`echo ${1}`"
    locwords="`echo ${2}`"
    IFS="$OLDIFS"

    newpath=""
    symlink="$2"
    relp=0
    deep=0
    set -- `echo $locwords`
    for p in $orgwords ; do
        deep=`expr $deep + 1`
        eval l=\${$deep}
        if test "$l" = "$p" -a $relp -eq 0 ; then
            : nothing
        else
            relp=`expr $relp + 1`
            newpath="${newpath}/$p"
            if test -n "$l" ; then
                if test $relp -eq 1 ; then
                    newpath="..${newpath}"
                else
                    newpath="../${newpath}"
                fi
            fi
        fi
    done
    if test $deep -lt $# ; then
        shift $deep
        while test $# -gt 0  ; do
            newpath="../${newpath}"
            shift
        done
    fi
    echo $newpath
}

#
# Usage
#
usage ()
{
    echo "${we}: Usage:" 1>&2
    echo "${tab} ${we} <NFS server of TeTeX> [-i|-d] -[o <mount options>]" 1>&2
}

#
# Option handling goes here
#
set -- $argv
while test -n "$1" ; do
    case "$1" in
        -o) test -z "$2" && { usage ; exit 1; }
            mntopt="$2"     ;;
        -m) test -z "$2" && { usage ; exit 1; }
            binary="$2"     ;;
        -i) action="import" ;;
        -d) action="remove" ;;
        -h) usage ; exit 0  ;;
        -*) usage ; exit 1  ;;
         *) server="$1"   ;;
    esac
    shift
done

test -z "$server" && { usage ; exit 1; }

if    test "$action" = "import" ; then
    mount_system
    linkin
    if test -n "${etcfstab}" ; then
        echo -e "\033[1m${we}: Please add the following $num lines to 
/etc/fstab\033[m" 1>&2
        echo
        echo -e "${etcfstab}"
        sleep 2
    fi
elif  test "$action" = "remove" ; then
    linkout
    umount_system
    while read line ; do
        set -- $line
        case "$1 $2 $3 $4 $5 $6" in
            *:${texroot}\ *) etcfstab="${etcfstab}`echo $line`\n" ;;
            *:${texvars}\ *) etcfstab="${etcfstab}`echo $line`\n" ;;
            *:${texfont}\ *) etcfstab="${etcfstab}`echo $line`\n" ;;
            *:${texconf}\ *) etcfstab="${etcfstab}`echo $line`\n" ;;
        esac
    done < /etc/fstab
    if test -n "${etcfstab}" ; then
        echo -e "\033[1m${we}: Please remove the following lines from 
/etc/fstab\033[m" 1>&2
        echo
        echo -e "${etcfstab}"
        sleep 2
    fi
else
    echo "${we}: Ohmm ... something strange happens" 1>&2
    exit 1
fi

##
exit 0
.\"
.\"
.TH tetex-import 8 "October22, 1998" "Version 0.1" "Utility for teTeX"
.\"
.UC 8
.SH NAME
.\"
tetex-import \- Utility for teTeX integration over NFS
.SH SYNOPSIS
.\"
.B tetex-import teTeX_NFS_server
.RB [\| \-i \||\| \-d ]
.RB [\| \-o " " mount_options ]
.RB [\| \-m " " machine_binary_type ]
.\" Die Beschreibung
.SH DESCRIPTION
The script
.B tetex-import
helps at the integration of a remote teTeX
system into the local system over NFS.
.\"
.SS General Options
.TP
.IR teTeX_NFS_server
This is the name or IP address of the NFS server providing
the teTeX system.
.TP
.IR \-i
Integrate the teTeX system (default). After mounting
and setting all required symbolic links upto four
lines are written to standard out. These lines should
be added to
.BR /etc/fstab .
.TP
.IR \-d
Deintegration of the teTeX system. After removing
all required symbolic links and unmounting the teTeX system
a few lines are written to standard out. These lines
should be removed from
.BR /etc/fstab .
.TP
.IR \-o\ mount_options
Use these mount options instead of the default
.IR exec,nosuid,nodev,hard,bg,intr,rsize=8192,wsize=8192 .
.TP
.IR \-m\ machine_binary_type
Use this machine binary type. Default is
.IR arch-system-libc .
Some example: i386-linux-libc5, i386-linux-glibc.
.IP
.\"
.SH EXAMPLE
.PP
.B tetex-import tex.mydomain
.\"
.SH FILES
.BR /usr/share/texmf/ ,
.br
.BR /var/lib/texmf/ ,
.br
.BR /var/cache/fonts/ ,
.br
.BR /etc/texmf/
.\"
.SH SEE ALSO
.BR fstab (8),
.BR mount (8),
.BR nfs (8).

Reply via email to