# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: William Rea <sillywilly@gmail.com>
# Contributor: Cory Farmer <rbgkofi@ameritech.net>

pkgname=gramps
pkgver=5.1.0
pkgrel=1
epoch=2
pkgdesc="Genealogy program, which helps you track your family tree"
arch=('any')
url="https://gramps-project.org/"
license=('GPL')
depends=('gtk3' 'python-bsddb' 'python-cairo' 'python-gobject' 'xdg-utils')
makedepends=('intltool')
optdepends=('osm-gps-map: show maps in the geography view'
            'graphviz: enable creation of graphs (required for tree reports)'
            'python-pyicu: improves localised sorting'
            'gtkspell3: enable spell checking in the notes'
            'rcs: manage multiple revisions of your family trees'
            'python-pillow: crop and convert images to JPG'
            'libgexiv2: manage Exif metadata embedded in your media'
            'geocode-glib: associate a geographical position to a place name')
source=("$pkgname-$pkgver.tar.gz::https://github.com/gramps-project/$pkgname/archive/v$pkgver.tar.gz")
sha256sums=('9e09ab9f196e66858b62a35f5387b4b0a9ce13c0cb0bf4fd78257be77b45abf3')

build() {
  cd $pkgname-$pkgver
  python3 setup.py build
}

package() {
  cd $pkgname-$pkgver
  python3 setup.py install --root="$pkgdir" --optimize=1
  echo -n '/usr/share' >"$pkgdir"/usr/lib/python*/site-packages/gramps/gen/utils/resource-path

  # Install application icon to its correct place
  install -dm755 "$pkgdir"/usr/share/icons/hicolor/{16x16,22x22,24x24,48x48,scalable}/apps
  mv "$pkgdir"/usr/share/gramps/images/hicolor/16x16/actions/gramps.png "$pkgdir"/usr/share/icons/hicolor/16x16/apps/gramps.png
  mv "$pkgdir"/usr/share/gramps/images/hicolor/22x22/actions/gramps.png "$pkgdir"/usr/share/icons/hicolor/22x22/apps/gramps.png
  mv "$pkgdir"/usr/share/gramps/images/hicolor/24x24/actions/gramps.png "$pkgdir"/usr/share/icons/hicolor/24x24/apps/gramps.png
  mv "$pkgdir"/usr/share/gramps/images/hicolor/48x48/actions/gramps.png "$pkgdir"/usr/share/icons/hicolor/48x48/apps/gramps.png
  mv "$pkgdir"/usr/share/gramps/images/hicolor/scalable/actions/gramps.svg "$pkgdir"/usr/share/icons/hicolor/scalable/apps/gramps.svg
  rm "$pkgdir"/usr/share/icons/gramps.png
}
