# $Id: PKGBUILD 237519 2015-04-19 15:53:56Z arojas $
# Maintainer: Felix Yan <felixonamrs@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgname=kstars
pkgver=15.04.0
pkgrel=2
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=('94b7124e803d41af4bf9e7ed53f7b4735471cf20')

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
}
