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

pkgname=subsonic
pkgver=4.5
pkgrel=1cp
#arch is usually one of x86_64/i486/i686/noarch
arch=noarch
source=(rc.subsonic http://downloads.sourceforge.net/project/$pkgname/$pkgname/$pkgver/$pkgname-$pkgver-standalone.tar.gz)
sourcetemplate=http://enialis.net/~jrd/salix/$pkgname/$pkgver-$arch-$pkgrel/
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo")
url=http://www.subsonic.org
options=('noautodotnew')

doinst() {
  for app in lame ffmpeg flac faad oggdec oggenc; do
    [ ! -e var/subsonic/transcode/$app ] && ln -sf /usr/bin/$app var/subsonic/transcode/
  done
  [ -e var/subsonic/jetty ] && rm -rf var/subsonic/jetty
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (web-based media streamer)"
"Subsonic is a free, web-based media streamer, providing ubiquitous"
"access to your music."
"Use it to share your music with friends, or to listen to your own"
"music while at work."
"You can stream to multiple players simultaneously, for instance to one"
"player in your kitchen and another in your living room."
)


build() {
  cd $startdir/src
  dest=$startdir/pkg
  mkdir -p $dest/var/subsonic/transcode $dest/usr/share/subsonic $dest/usr/bin $dest/etc/rc.d
  sed -i 's:8080:4040:' subsonic.sh
  sed -i 's:`dirname $0`:$(dirname $(readlink -f $0)):' subsonic.sh
  chmod a+x subsonic.sh
  cp *.jar *.war *.sh $dest/usr/share/subsonic/
  ln -s /usr/share/subsonic/subsonic.sh $dest/usr/bin/subsonic
  chmod a+rwX $dest/var/subsonic
  cp rc.subsonic $dest/etc/rc.d/
  chmod +x $dest/etc/rc.d/rc.subsonic
}