Skip to content

Instantly share code, notes, and snippets.

@brabect1
Created November 18, 2015 13:40
Show Gist options
  • Save brabect1/36853fa0e73216744c45 to your computer and use it in GitHub Desktop.
Save brabect1/36853fa0e73216744c45 to your computer and use it in GitHub Desktop.
This script tries to automate installation of packagaes directly from CTAN. This may come handy when the latex distro lacks package manager and users have non-root privileges.
PKGS="tabu caption adjustbox collectbox"; \
for p in ${PKGS}; do \
(url=http://mirrors.ctan.org/install/macros/latex/contrib/$p.tds.zip && \
if [[ ! `wget -S --spider ${url} 2>&1 | grep 'HTTP/1.1 200 OK'` ]]; then \
url=http://mirrors.ctan.org/macros/latex/contrib/$p.zip && \
wget ${url} && \
unzip ${url##*/} && \
if [ "$(expr $p/*.sty)" = "$p/*.sty" ]; then \
cd $p && latex $p.ins && cd ..; \
fi && \
mkdir -p $(kpsewhich -var-value=TEXMFHOME)/tex/latex/$p && \
cp $p/*.sty $(kpsewhich -var-value=TEXMFHOME)/tex/latex/$p/ && \
rm -rf $p ${url##*/} && \
echo -e "\n** INFO: Package $p installed\n"; \
else \
wget ${url} && \
unzip ${url##*/} -d $(kpsewhich -var-value=TEXMFHOME) && \
rm -rf ${url##*/} && \
echo -e "\n** INFO: Package $p installed\n"; \
fi) || break; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment