# $Id: PKGBUILD 241529 2015-06-30 20:28:21Z arojas $
# Maintainer: Felix Yan <felixonamrs@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=kstars
pkgver=15.04.3
pkgrel=1
pkgdesc="Desktop Planetarium"
url="http://kde.org/applications/education/kstars/"
arch=('i686' 'x86_64')
license=('GPL' 'LGPL' 'FDL')
groups=('kde-applications' 'kdeedu')
depends=('wcslib' 'libindi' 'kplotting' 'knewstuff' 'qt5-multimedia' 'kinit' 'ktexteditor')
makedepends=('extra-cmake-modules' 'python' 'kdoctools' 'eigen' 'xplanet')
optdepends=('xplanet: XPlanet support')
install=${pkgname}.install
replaces=('kdeedu-kstars')
conflicts=('kdeedu-kstars')
source=("http://download.kde.org/stable/applications/${pkgver}/src/kstars-${pkgver}.tar.xz")
sha1sums=('8f99047d6eb58caada3d957775bfb4b012a8476f')

prepare() {
  mkdir build

# Use python2
  cd $pkgname-$pkgver
  sed -e 's|"python"|"python2"|' -i kstars/skycomponents/supernovaecomponent.cpp 
}

build() {
  cd build
  cmake ../kstars-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTING=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DKDE_INSTALL_USE_QT_SYS_PATHS=ON
  make
}

package() {
  cd build
  make DESTDIR="${pkgdir}" install

  sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python2|g' \
    "${pkgdir}"/usr/share/kstars/scripts/supernova_updates_parser.py
}
