# vim: set syn=sh ai et sw=2 st=2 ts=2 tw=0:
#Packager: JRD <jrd@enialis.net>

pkgname=backintime-kde4
pkgver=1.0.8
pkgrel=2cp
source=(http://backintime.le-web.org/download/$(echo $pkgname|cut -d- -f1)/$(echo $pkgname|cut -d- -f1)-${pkgver}_src.tar.gz)
sourcetemplate=http://people.salixos.org/jrd/salix/$pkgname/$pkgver-\$arch-$pkgrel/
docs=("readme" "install" "copying" "changes" "authors" "news" "todo" "license" "copyright" "version" "translations")
url=http://backintime.le-web.org

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (simple backup tool for Linux)"
"This is the front-end for KDE4."
"All you have to do is configure:"
"  * Where to save snapshot"
"  * What directories to backup"
"  * When backup should be done"
)

build() {
  cd $SRC/$(echo $pkgname|cut -d- -f1)-$pkgver/kde4 || return 1
	install -d $PKG/usr/share/backintime/kde4
	install -d $PKG/usr/share/backintime/plugins
	install -d $PKG/usr/share/man/man1
	install -d $PKG/usr/bin
	install -d $PKG/usr/share/applications
	install --mode=644 *.py $PKG/usr/share/backintime/kde4
	install --mode=644 plugins/*.py $PKG/usr/share/backintime/plugins
	install --mode=644 man/C/*.gz $PKG/usr/share/man/man1
	install backintime-kde4 $PKG/usr/bin
	install --mode=644 *.desktop $PKG/usr/share/applications
  echo 'OnlyShowIn=KDE' >> $PKG/usr/share/applications/backintime-kde4.desktop
  sed '/^Name=/s/$/ (root)/; s/^Exec=/\0kdesu /' $PKG/usr/share/applications/backintime-kde4.desktop > $PKG/usr/share/applications/backintime-kde4-root.desktop
  # optimize/compile python
  cd $PKG/usr/share/backintime
  cat <<'EOF' | python
import compileall
compileall.compile_dir("kde4", force=1)
compileall.compile_dir("plugins", force=1)
EOF
  find . -type f -name '*.py' -exec rm '{}' \;
  # wrapper launcher should use .pyc, not .py
  sed -i 's/\.py /.pyc /' $PKG/usr/bin/backintime-kde4
}
