c374ce654abc086f7222dda902aaa5f6b9de601d
[ibg.git] / tools / install-emerald.sh
1 #!/bin/sh
2
3 # This script installs the Emerald CTAN package from
4 # https://www.ctan.org/tex-archive/fonts/emerald/
5 # into $TEXMFLOCAL, which is usually /usr/local/share/texmf
6 #
7 # This script will download emerald.zip if it's not already present.
8 # It must be run as root.
9 #
10 # Created by David Griffith <dave@661.org>
11 # Released into the public domain 2016
12
13 # Exit values:
14 #       0       Script completed installation successfully.
15 #
16 #       1       Unable to find kpsewhich(1), maybe TeX isn't installed?
17 #       2       Unable to find unzip(1).
18 #       3       Script not run as root.
19 #       4       Unable to download package.
20 #
21
22 EMERALD_URL="http://mirrors.ctan.org/fonts/emerald.zip"
23 EMERALD_PKG=emerald.zip
24
25 PERM=644
26 DPERM=755
27 PKGDIR="emerald"
28 TEXMFLOCAL=`kpsewhich -var-value TEXMFLOCAL`
29
30 echo "Emerald CTAN package installer..."
31
32 if [ ! $(command -v kpsewhich) ] ; then
33         echo "  ** Cannot find kpsewhich!  Is TeX really installed?"
34         exit 1
35 fi
36
37 if [ ! $(command -v unzip) ] ; then
38         echo "  ** Cannot find unzip!  Please install it and try again."
39         exit 2
40 fi
41
42 if [ `ps -o uid= $$` -ne 0 ] ; then
43         echo "  ** This script must be run as root"
44         exit 3
45 fi
46
47 if [ -f $EMERALD_PKG ] ; then
48         echo "Found $EMERALD_PKG right here."
49 else
50         echo "Attempting download from $EMERALD_URL..."
51         if [ $(command -v curl) ] ; then
52                 echo "Downloading $EMERALD_URL using curl."
53                 command curl -L $EMERALD_URL -o $EMERALD_PKG
54         elif [ $(command -v wget) ] ; then
55                 echo "Downloading $EMERALD_URL using wget."
56                 command wget $EMERALD_URL -O $EMERALD_PKG
57         else
58                 echo "  ** Neither curl nor wget are present."
59                 echo "  ** Please download the emerald package manually,"
60                 echo "  ** put it in this directory, and try again."
61                 exit 4
62         fi
63 fi
64
65 echo "Unpacking $EMERALD_PKG..."
66 unzip -q $EMERALD_PKG
67
68 echo "Installing to $TEXMFLOCAL..."
69 echo "Making directories..."
70 install -m $DPERM -d    $TEXMFLOCAL/fonts/afm/emerald \
71                         $TEXMFLOCAL/fonts/map/dvips \
72                         $TEXMFLOCAL/fonts/tfm/emerald \
73                         $TEXMFLOCAL/fonts/type1/emerald \
74                         $TEXMFLOCAL/fonts/vf/emerald
75
76 install -m $DPERM -d    $TEXMFLOCAL/other $TEXMFLOCAL/tex/latex/emerald
77 install -m $DPERM -d    $TEXMFLOCAL $TEXMFLOCAL/web2c
78
79 echo "Installing stuff..."
80 install -m $PERM -D $PKGDIR/fonts/afm/emerald/* $TEXMFLOCAL/fonts/afm/emerald
81 install -m $PERM -D $PKGDIR/fonts/map/dvips/emerald.map $TEXMFLOCAL/fonts/map/dvips
82 install -m $PERM -D $PKGDIR/fonts/tfm/emerald/* $TEXMFLOCAL/fonts/tfm/emerald
83 install -m $PERM -D $PKGDIR/fonts/type1/emerald/* $TEXMFLOCAL/fonts/type1/emerald
84 install -m $PERM -D $PKGDIR/fonts/vf/emerald/* $TEXMFLOCAL/fonts/vf/emerald
85 install -m $PERM -D $PKGDIR/other/* $TEXMFLOCAL/other
86 install -m $PERM -D $PKGDIR/tex/latex/emerald/* $TEXMFLOCAL/tex/latex/emerald
87
88 echo "Map emerald.map" >> $TEXMFLOCAL/web2c/updmap.cfg
89 mktexlsr $TEXMFLOCAL
90 updmap-sys
91
92 echo "Done!"
93
94 exit 0