summaryrefslogtreecommitdiff
path: root/community/sage-mathematics/PKGBUILD
blob: f6564a9a50e5c6587732f7967bd69b335290445f (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# $Id: PKGBUILD 111528 2014-05-19 16:10:30Z anatolik $
# Maintainer: Evgeniy Alekseev <arcanis.arch at gmail dot com>
# Contributor: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: Antonio Rojas <nqn1976 at gmail dot com>
# Contributor: Thomas Dziedzic <gostrc at gmail dot com>
# Contributor: Osman Ugus <ugus11 at yahoo dot com>
# Contributor: Stefan Husmann <stefan-husmann at t-online dot de>
# Special thanks to Nareto for moving the compile from the .install to the PKGBUILD

pkgname=sage-mathematics
pkgver=6.2
pkgrel=2
pkgdesc="Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab"
arch=('i686' 'x86_64')
url="http://www.sagemath.org"
license=('GPL')
#depends=('desktop-file-utils' 'java-environment=7' 'libjpeg-turbo' 'libtiff' 'libxmu' 'sqlite' 'xz')
depends=('freetype2' 'libatomic_ops')
makedepends=('desktop-file-utils' 'gcc-fortran' 'gendesk')
optdepends=('imagemagick: some plotting functionality benefits from it'
            'texlive-core: some plotting functionality benefits from it, also to use SageTeX'
            'openssh: to use the notebook in secure mode'
            'ffmpeg: to show animations'
            'cairo: R plots')
source=("http://sage.math.washington.edu/home/release/sage-${pkgver}/sage-${pkgver}.tar"
        "sage.service"
        "gf2x-sse2-i686.patch"
        "python-readline.patch")
install="${pkgname}.install"
md5sums=('71aa49875797c001ce0a31409f5a1762'
         '985da1c1d1dcdc3ea9aa73035cb7996b'
         'f9d7aba4f758f4605164eb84b9e1e3ba'
         '9b27884ba756eb7990728baedf162665')

prepare() {
  # create *.desktop file
  gendesk -f -n \
          --pkgname="sage-notebook" \
          --pkgdesc="Sage notebook" \
          --name="Sage" \
          --exec="/opt/sage/sage -notebook" \
          --terminal=true \
          --categories="Education;Science;Math" \
          --custom="X-DCOP-ServiceType=
X-KDE-SubstituteUID=false
X-KDE-Username="

  # create DOT_SAGE directory
  if [[ -d ${srcdir}/build ]]; then
    rm -rf "${srcdir}/build"
  fi
  mkdir "${srcdir}/build"

  # according to FS#34769
  sed -e 's/FREETYPE/#FREETYPE/' -i "${srcdir}/sage-${pkgver}/build/install"
  # according to FS#39533
  cp "${srcdir}/python-readline.patch" "${srcdir}/sage-${pkgver}/build/pkgs/python/patches/readline.patch"
  sed -e 's/READLINE/#READLINE/' -i "${srcdir}/sage-${pkgver}/build/install"
  # disable building gf2x with sse2 for i686
  if [ "${CARCH}" == "i686" ]; then
    cp "${srcdir}/gf2x-sse2-i686.patch" "${srcdir}/sage-${pkgver}/build/pkgs/gf2x/patches/sse2.patch"
  fi
}

build() {
  cd "sage-${pkgver}"

  # disable default makepkg flags (needed for singular and libgap)
  unset CFLAGS
  unset CXXFLAGS
  unset LDFLAGS
  ## flags
  # do not build own gcc
  export SAGE_INSTALL_GCC='no'
  # disable debug
  export SAGE_DEBUG='no'
  # enable fat binaries
  export SAGE_FAT_BINARY='yes'
  # can't write to root in a clean chroot
  export DOT_SAGE="${srcdir}/build"
  # singular is broken
  export CPP='/usr/bin/cpp'

  make
}

<< COMMENT
check() {
  cd "sage-${pkgver}"

  make test
  #make ptestlong
}
COMMENT

package() {
  cd "${srcdir}/sage-${pkgver}/"
  # remove build logs
  rm -f *.log
  rm -rf "${srcdir}/sage-${pkgver}/"{logs,upstream}
  # do NOT remove build directory!

  # cp because make install is experimental and will corrupt the install
  install -dm755 "${pkgdir}/opt/sage"
  cp -r * "${pkgdir}/opt/sage/"

  # move SageTeX files to more appropriate directory
  install -dm755 "${pkgdir}/usr/share"
  mv "${pkgdir}/opt/sage/local/share/texmf" "${pkgdir}/usr/share"

  # according to FS#37090
  # install scripts
  install -dm755 "${pkgdir}/usr/bin"
  ./sage -c "install_scripts('${pkgdir}/usr/bin', ignore_existing=True)"
  # rename scripts to avoid conflicts
  for ITEM in $(ls "${pkgdir}/usr/bin"); do
    mv "${pkgdir}/usr/bin/${ITEM}" "${pkgdir}/usr/bin/sage-${ITEM}"
  done
  ln -s "/opt/sage/sage" "${pkgdir}/usr/bin/sage"

  # install a systemd user unit
  install -Dm644 "${srcdir}/sage.service" "${pkgdir}/usr/lib/systemd/user/sage.service"
  # install *.desktop and icon files
  install -Dm644 "${srcdir}/sage-notebook.desktop" \
                 "${pkgdir}/usr/share/applications/sage-notebook.desktop"
  install -Dm644 "${pkgdir}/opt/sage/local/lib/python2.7/site-packages/sagenb-0.10.8.2-py2.7.egg/sagenb/data/sage/images/icon48x48.png" \
                 "${pkgdir}/usr/share/pixmaps/sage-notebook.png"
}

# vim :set ts=2 sw=2 et: