# $Id: PKGBUILD 102786 2013-12-20 01:24:21Z heftig $
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Mateusz Herych <heniekk@gmail.com>
# Contributor: Charles Lindsay <charles@chaoslizard.org>

pkgname=cdemu-client
pkgver=2.1.1
pkgrel=1
pkgdesc="Simple command-line client for controlling cdemu-daemon"
arch=(any)
url="http://cdemu.sourceforge.net/"
license=(GPL)
depends=(python2 dbus-python cdemu-daemon desktop-file-utils)
makedepends=(intltool cmake)
conflicts=('cdemu')
install=cdemu-client.install
source=("http://downloads.sourceforge.net/cdemu/$pkgname-$pkgver.tar.bz2")
sha256sums=('204e626994f61d36423f3b732e180e3b3b20624effdfe91aabffd439c76d3964')

prepare() {
  mkdir build
  cd $pkgname-$pkgver

  # python2 fix
  sed -i '1s|^#!.*python$|&2|' src/cdemu

  # fix text domain
  sed -i '/^project /s/cdemu/&-client/' CMakeLists.txt

  # bash completion dir change
  sed -i CMakeLists.txt -e "s|\
DESTINATION \${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d|\
DESTINATION \${CMAKE_INSTALL_DATADIR}/bash-completion/completions|"
}

build() {
  cd build
  cmake ../$pkgname-$pkgver \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/usr
  make
}

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