summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/thailatex/scripts/sync-thailatex.in
blob: 2f5e01db1b8b34eaf6517321299b6dea6e26e3a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
# Register/unregister thailatex
# Written by Theppitak Karoonboonyanan <thep@linux.thai.net>
# License: GPL

prefix=@prefix@

THAI_MAP=@texmfdir@/fonts/map/dvips/thai/thai.map
EMACSLISPDIR=@emacsdir@/site-lisp

is_thai_map_enabled()
{
  @UPDMAP@ --quiet --listmaps | grep -v '^#' | grep thai.map >/dev/null
}

do_install()
{
  echo "Regenerating TeX ls-R ..."
  @TEXHASH@

  # thai.map exists -> do install
  if is_thai_map_enabled; then
    echo "Thai fontmap already enabled, refreshing fontmaps ..."
    @UPDMAP@ --quiet --nohash
  else
    echo "Thai fontmap is not enabled, enabling it ..."
    @UPDMAP@ --quiet --nohash --enable Map thai.map
  fi

  # add Emacs macro for activating Thai LaTeX filter
  echo "Installing emacs macro ..."
  if test -f $EMACSLISPDIR/site-start.el; then
    sed -i -e '/thai-latex-setup/d' $EMACSLISPDIR/site-start.el
  fi
  if test -f $EMACSLISPDIR/thai-latex-setup.el; then
    echo '(load-library "thai-latex-setup")' >> $EMACSLISPDIR/site-start.el
  fi
}

do_uninstall()
{
  echo "Regenerating TeX ls-R ..."
  @TEXHASH@

  # thai.map doesn't exist -> do uninstall
  if is_thai_map_enabled; then
    echo "Thai fontmap is enabled, disabling it ..."
    @UPDMAP@ --disable thai.map
  else
    echo "Thai fontmap is not enabled, just refreshing fontmaps ..."
    @UPDMAP@
  fi

  # remove Emacs macro for activating Thai LaTeX filter
  echo "Uninstalling emacs macro ..."
  if test -f $EMACSLISPDIR/site-start.el; then
    sed -i -e '/thai-latex-setup/d' $EMACSLISPDIR/site-start.el
  fi
}

# Main script

if test -f $THAI_MAP; then
  echo "Thai fontmap exists, so we will enable it."
  do_install
else
  echo "Thai fontmap no longer exists, so we will disable it."
  do_uninstall
fi