summaryrefslogtreecommitdiff
path: root/community-testing/sage-mathematics/sage-mathematics.install
blob: 6caa5299eef0698201b0a16099787ec6920e32de (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
post_install() {
  cd /opt/sage

  # set HOME because when sage updates its sage_root (after being moved) it will write files to ~/.sage with root ownership
  # the files it writes to ~/.sage can be safely ignored
  HOME=/tmp ./sage -c

  # add sagemath user for the daemon
  useradd -r -c 'Sage daemon' -d /opt/sage -s /bin/false sagemath

  # Update LaTeX db to point to SageTeX
  if [ -f /usr/bin/texhash ]; then
    /usr/bin/texhash /usr/share/texmf
  else
    echo 'Warning: could not find /usr/bin/texhash'
    echo 'SageTeX has been installed but you need to run:'
    echo '# texhash /usr/share/texmf'
    echo 'So that LaTeX will be able to find it.'
  fi

echo '
 ___                       
/ (_)        o            |
\__   _  _      __        |
/    / |/ |  | /  \_|   | |
\___/  |  |_/|/\__/  \_/|/o
            /|         /|  
            \|         \|  
 ________________________________ 
< sage-mathematics, I mean, MOO! >
 -------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
'

}

post_upgrade() {
  post_install $1
}

post_remove() {
  # Update LaTeX db to remove SageTeX entries
  if [ -f /usr/bin/texhash ]; then
    /usr/bin/texhash /usr/share/texmf
  fi

  # remove the sagemath daemon user
  userdel sagemath

  # clean up left overs
  rm -rf /opt/sage
}