From 8b760e0550fa8a1636f2462b310ce7c2b1636dc7 Mon Sep 17 00:00:00 2001 From: David Griffith Date: Fri, 5 Apr 2019 05:59:38 -0700 Subject: [PATCH] Emerald installer now downloads the package. Both scripts identify themselves. --- .gitignore | 2 ++ tools/install-emerald.sh | 61 +++++++++++++++++++++++++++++++++----- tools/uninstall-emerald.sh | 2 ++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 7ff90f5..b2da6b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ output/* *.pyc *.z5 +tools/emerald.zip +tools/emerald diff --git a/tools/install-emerald.sh b/tools/install-emerald.sh index bdecb19..c374ce6 100755 --- a/tools/install-emerald.sh +++ b/tools/install-emerald.sh @@ -4,24 +4,67 @@ # https://www.ctan.org/tex-archive/fonts/emerald/ # into $TEXMFLOCAL, which is usually /usr/local/share/texmf # -# To use, put emerald.zip in the same directory as this script, unzip -# emerald.zip, and execute this script. +# This script will download emerald.zip if it's not already present. +# It must be run as root. # # Created by David Griffith # Released into the public domain 2016 +# Exit values: +# 0 Script completed installation successfully. +# +# 1 Unable to find kpsewhich(1), maybe TeX isn't installed? +# 2 Unable to find unzip(1). +# 3 Script not run as root. +# 4 Unable to download package. +# - -if [ `ps -o uid= $$` -ne 0 ] ; then - echo "This script must be run as root" - exit 1 -fi +EMERALD_URL="http://mirrors.ctan.org/fonts/emerald.zip" +EMERALD_PKG=emerald.zip PERM=644 DPERM=755 PKGDIR="emerald" TEXMFLOCAL=`kpsewhich -var-value TEXMFLOCAL` +echo "Emerald CTAN package installer..." + +if [ ! $(command -v kpsewhich) ] ; then + echo " ** Cannot find kpsewhich! Is TeX really installed?" + exit 1 +fi + +if [ ! $(command -v unzip) ] ; then + echo " ** Cannot find unzip! Please install it and try again." + exit 2 +fi + +if [ `ps -o uid= $$` -ne 0 ] ; then + echo " ** This script must be run as root" + exit 3 +fi + +if [ -f $EMERALD_PKG ] ; then + echo "Found $EMERALD_PKG right here." +else + echo "Attempting download from $EMERALD_URL..." + if [ $(command -v curl) ] ; then + echo "Downloading $EMERALD_URL using curl." + command curl -L $EMERALD_URL -o $EMERALD_PKG + elif [ $(command -v wget) ] ; then + echo "Downloading $EMERALD_URL using wget." + command wget $EMERALD_URL -O $EMERALD_PKG + else + echo " ** Neither curl nor wget are present." + echo " ** Please download the emerald package manually," + echo " ** put it in this directory, and try again." + exit 4 + fi +fi + +echo "Unpacking $EMERALD_PKG..." +unzip -q $EMERALD_PKG + echo "Installing to $TEXMFLOCAL..." echo "Making directories..." install -m $DPERM -d $TEXMFLOCAL/fonts/afm/emerald \ @@ -45,3 +88,7 @@ install -m $PERM -D $PKGDIR/tex/latex/emerald/* $TEXMFLOCAL/tex/latex/emerald echo "Map emerald.map" >> $TEXMFLOCAL/web2c/updmap.cfg mktexlsr $TEXMFLOCAL updmap-sys + +echo "Done!" + +exit 0 diff --git a/tools/uninstall-emerald.sh b/tools/uninstall-emerald.sh index 096003b..ad1c0f8 100755 --- a/tools/uninstall-emerald.sh +++ b/tools/uninstall-emerald.sh @@ -6,6 +6,8 @@ # Created by David Griffith # Released into the public domain 2016 +echo "Emerald CTAN package uninstaller..." + if [ `ps -o uid= $$` -ne 0 ] ; then echo "This script must be run as root" exit 1 -- 2.31.1