This question is not on how to manually install packages but how to install packages automatically via script. This question is not about MikTeX or the limited tex package management in certain linux distributions (e.g.Ubuntu).
This question is about the cases where those management tools are not available or when we don't want to mess with them or where they are not sufficient.
Question: Is there a script or tool that can install an arbitrary package by downloading it and installing it in the local tree?
The closest I got to that is the following script (which has lots of drawbacks):
PACKAGE=$1
mkdir -p ~/texmf
cd ~/texmf
wget http://mirror.ctan.org/macros/latex/contrib/$PACKAGE.zip
unzip $PACKAGE.zip
mkdir -p tex/latex/$PACKAGE
cd $PACKAGE
for a in *.dtx; do if [ -a $a ]; then latex $a; fi; done
for a in *.ins; do if [ -a $a ]; then latex $a; fi; done
cd -
cp -vf $PACKAGE/*.{sty,def,cls,cfg} tex/latex/$PACKAGE
texhash
It is pretty generic BUT the drawbacks include: not error resilient, does not track dependencies, it doesn't work for all packages, it can produce a mess of files sometimes if the script fails, it doesn't work for packages outside of contrib. Also it doesn't work for complicated packages and bundles.
The idea is to be able to just type, for example:
$ install_package pdfcomment
Improvements to this script, or alternative tools or scripts are greatly appreciated. I'll be really happy for example, if it works for all these packages that are not available in the cluster (i.e. no root access) I use:
xkeyval oberdiek pgf pgfplots acrotex movie15 datetime filecontents
changepage paralist textcase placeins cool coollist coolstr coolstr
forloop bbm type1cm lastpage pdfmarginpar standalone tufte-latex ifpdf
EDIT: Thanks Seamus for the answer, it seems that a more robust script for TDS prepackaged packages is the following:
$PACKAGE=$1
mkdir -p ~/texmf
cd ~/texmf
wget http://www.ctan.org/tex-archive/install/macros/latex/contrib/$PACKAGE.tds.zip
unzip $PACKAGE.tds.zip
texhash
(not all packages have a TDS version.)
\RequirePackageor\usepackagelines. That would not be fool-proof, though. – Joseph Wright Mar 26 '11 at 07:15