# $Id: PKGBUILD 27088 2009-02-16 05:16:38Z eric $
# Maintainer: Juergen Hoetzel <juergen@archlinux.org> 
# Contributor: kleptophobiac@gmail.com

pkgname=('mytharchive' 'mythbrowser' 'mythflix' 'mythgallery' 'mythgame' 'mythmovies'
	 'mythmusic' 'mythvideo' 'mythweather' 'mythweb')
pkgver=0.22
pkgrel=1
pkgdesc="MythTV plugin that lets you create DVDs from or archive your recorded shows."
arch=('i686' 'x86_64')
url="http://www.mythtv.org"
license=('GPL')
makedepends=("mythtv>=${pkgver}" 'libxmu' 'mysql-python' 'pil' 'dvdauthor' 'wget' 'libexif' 'libtiff' 'zlib'
	 'cdparanoia' 'faad2' 'fftw' 'flac' 'lame' 'libcdaudio' 'libid3tag' 'libmad' 'libvorbis' 'sdl'
	 'taglib' 'ffmpeg' 'mplayer' 'perl-libwww' 'perl-uri' 'perl-xml-simple' 'perlxml')
source=("ftp://ftp.osuosl.org/pub/mythtv/mythplugins-$pkgver.tar.bz2"
	mtd mythweb.conf.apache mythweb.conf.lighttpd)
md5sums=('09c8fa1058399a0c5db169a71561e985'
         '476c12ba074794ad7f4ae092bdf949d6'
         'ca0729c9c5523366471884470d5500a4'
         '4599647099629afa11c19f5f87da4d5b')
groups=('mythtv-extras')

build() {
  cd ${srcdir}/mythplugins-${pkgver}

  ./configure --prefix=/usr --enable-all --disable-mythzoneminder \
    --enable-opengl --enable-aac --enable-opengl --enable-fftw || return 1

  make || return 1
  }

package_mytharchive() {
  pkgdesc="MythTV plugin that lets you create DVDs from or archive your recorded shows"
  depends=("mythtv>=${pkgver}" 'libxmu' 'mysql-python' 'pil' 'dvdauthor')

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mytharchive-install_subtargets
  }

package_mythbrowser() {
  pkgdesc="Mini web browser for MythTV"
  depends=("mythtv>=${pkgver}" 'wget')

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythbrowser-install_subtargets
  }

package_mythflix() {
  pkgdesc="Netflix access plugin for MythTV"
  depends=("mythtv>=${pkgver}")

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythflix-install_subtargets
  }

package_mythgallery() {
  pkgdesc="Image gallery plugin for MythTV"
  depends=("mythtv>=${pkgver}" 'libexif' 'libtiff')

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythgallery-install_subtargets
  }

package_mythgame() {
  pkgdesc="Emulation plugin for MythTV"
  depends=("mythtv>=${pkgver}" 'zlib')

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythgame-install_subtargets
  }

package_mythmovies() {
  pkgdesc="Mythtv plugin for looking up movie showtimes in a given area"
  depends=("mythtv>=${pkgver}")

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythmovies-install_subtargets
  }

package_mythmusic() {
  pkgdesc="Music playing plugin for MythTV"
  depends=("mythtv>=${pkgver}" 'cdparanoia' 'faad2' 'fftw' 'flac' 'lame' 
	   'libcdaudio' 'libid3tag' 'libmad' 'libvorbis' 'sdl' 'taglib')

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythmusic-install_subtargets
  }

package_mythvideo() {
  pkgdesc="Video playback and browsing plugin for MythTV"
  depends=("mythtv>=${pkgver}" 'ffmpeg' 'mplayer' 'perl-libwww' 'perl-uri'
	   'perl-xml-simple' 'perlxml')

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythvideo-install_subtargets
  install -D -m755 ${srcdir}/mtd ${pkgdir}/etc/rc.d/mtd
  }

package_mythweather() {
  pkgdesc="Weather checking plugin for MythTV"
  depends=("mythtv>=${pkgver}" 'wget')

  cd ${srcdir}/mythplugins-${pkgver}

  make INSTALL_ROOT=${pkgdir} sub-mythweather-install_subtargets
  }

package_mythweb() {
  pkgdesc="Web interface for MythTV's backend"
  depends=("mythtv>=${pkgver}")
  optdepends=('php-apache: Run mythweb on apache' 'lighttpd: Run mythweb on lighttpd' 'php-cgi: Run mythweb on lighttpd')
  install=mythweb.install

  mkdir -p ${pkgdir}/srv/http/mythweb/{image_cache,php_sessions}
  cp -r ${srcdir}/mythplugins-$pkgver/mythweb/* ${pkgdir}/srv/http/mythweb
  rm ${pkgdir}/srv/http/mythweb/README
  install -D -m644 ${srcdir}/mythweb.conf.apache ${pkgdir}/srv/http/mythweb/mythweb.conf.apache
  install -D -m644 ${srcdir}/mythweb.conf.lighttpd ${pkgdir}/srv/http/mythweb/mythweb.conf.lighttpd
  chown -R http:http ${pkgdir}/srv/http/mythweb
  chmod g+rw ${pkgdir}/srv/http/mythweb/{image_cache,php_sessions,data}
  }