Name: Anonymous 2010-08-19 11:24
i wrote a script that installs a latex package (e.g. downloaded from ctan.org) from .ins, .dtx or .sty files for texlive distributions. it creates a directory in /usr/share/texmf-texlive/tex/latex/, moves the .sty files there and runs mktexlsr.
it WorksForMe, but it's probably badly written because i have no experience with writing shell scripts.
so if you want to you can
A) modify the script so it becomes better
B) tell me how some program already does this way better/easier
C) berate me for something else
D) sage/post a meme
it WorksForMe, but it's probably badly written because i have no experience with writing shell scripts.
so if you want to you can
A) modify the script so it becomes better
B) tell me how some program already does this way better/easier
C) berate me for something else
D) sage/post a meme
#!/bin/bash
PROGNAME="install-latex-package.sh"
if [ -z $1 ]; then
echo "$PROGNAME: .ins, .dtx or .sty file needed as argument"
exit
fi
FILENAME=$1
SUFFIX=`expr "$FILENAME" : '.*\(\.ins$\)'`
if [ -z $SUFFIX ]; then
SUFFIX=`expr "$FILENAME" : '.*\(\.dtx$\)'`
if [ -z $SUFFIX ]; then
SUFFIX=`expr "$FILENAME" : '.*\(\.sty$\)'`
if [ -z $SUFFIX ]; then
echo "$PROGNAME: .ins, .dtx or .sty file needed as argument"
exit
fi
fi
fi
if [ ! -e $FILENAME ]; then
echo "$PROGNAME: $FILENAME does not exist"
exit
fi
PREFIX=${FILENAME:0:(${#FILENAME} - 4)}
echo "$PROGNAME: installing package \"$PREFIX\""
if [ "$SUFFIX" == ".ins" ]; then
latex $FILENAME
elif [ "$SUFFIX" == ".dtx" ]; then
tex $FILENAME
fi
if [ $? != 0 ]; then
echo "$PROGNAME: failed to install package"
exit
fi
PACKAGEPATH="/usr/share/texmf-texlive/tex/latex/"
echo "$PROGNAME: creating folder $PACKAGEPATH$PREFIX"
sudo mkdir $PACKAGEPATH$PREFIX
if [ $? != 0 ]; then
echo "$PROGNAME: failed to create folder"
exit
fi
echo "$PROGNAME: copying *.sty to $PACKAGEPATH$PREFIX"
sudo cp *.sty $PACKAGEPATH$PREFIX
if [ $? != 0 ]; then
echo "$PROGNAME: failed to copy .sty files"
exit
fi
if [ -e *.def ]; then
echo "$PROGNAME: copying *.def to $PACKAGEPATH$PREFIX"
sudo cp *.def $PACKAGEPATH$PREFIX
if [ $? != 0 ]; then
echo "$PROGNAME: failed to copy .def files"
exit
fi
fi
echo "$PROGNAME: updating latex package library"
sudo mktexlsr
if [ $? != 0 ]; then
echo "$PROGNAME: failed to update library"
exit
fi
echo "$PROGNAME: package \"$PREFIX\" successfully installed"