# $Id: PKGBUILD 131088 2015-04-10 07:09:24Z alucryd $
# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Alexander 'gridcol' Griesbaum <agrsbm@gmail.com>
# Contributor: Ravenman <correo.cuervo@gmail.com>
# Contributor: Anton Bazhenov <anton.bazhenov@gmail>
# Contributor: Angel 'angvp' Velasquez <angvp@archlinux.com.ve>

pkgname=mantisbt
pkgver=1.2.19
pkgrel=2
pkgdesc='Web-based issue tracking system'
arch=('any')
url='http://www.mantisbt.org/'
license=('GPL')
depends=('php')
optdepends=('apache: Web server to run MantisBT'
            'curl: Twitter integration'
            'gd: Graphs support'
            'lighttpd: Web server to run MantisBT'
            'mariadb: SQL database'
            'nginx: Web server to run MantisBT'
            'php-pgsql: PostgreSQL database')
backup=('etc/webapps/mantisbt/config_inc.php')
install='mantisbt.install'
source=("http://downloads.sourceforge.net/mantisbt/mantisbt-${pkgver}.tar.gz"
        'CVE-2014-8986.patch')
sha256sums=('0814d2113de4a53498bb67fa531ca36dee821e5c22df150deb75dc918eed86de'
            '9e1b5bb831e6bbbfa8c3a61e91c339928b428147bcf609d2abca78b67140c6ab')

prepare() {
  cd mantisbt-${pkgver}

  patch -Np1 -i ../CVE-2014-8986.patch
}

package() {
  install -dm 755 "${pkgdir}"/{etc/webapps/mantisbt,usr/share/webapps}
  cp -dr --no-preserve='ownership' mantisbt-${pkgver} "${pkgdir}"/usr/share/webapps/mantisbt

  for f in {config_inc.php,custom_strings_inc.php,custom_constants_inc.php,custom_functions_inc.php}; do
    ln -s /etc/webapps/mantisbt/${f} "${pkgdir}"/usr/share/webapps/mantisbt/
  done
  cp "${pkgdir}"/usr/share/webapps/mantisbt/config_inc.php.sample "${pkgdir}"/etc/webapps/mantisbt/config_inc.php

  find "${pkgdir}" -type d -exec chmod 755 {} +
  find "${pkgdir}" -type f -exec chmod 644 {} +
  chown http:http -R "${pkgdir}"/usr/share/webapps/mantisbt
}

# vim: ts=2 sw=2 et:
