#Maintainer: Thorsten Muehlfelder <thenktor(at)gmx.de>

pkgname=prosody
pkgver=0.7.0
pkgrel=1tm
source=("http://prosody.im/tmp/$pkgver/prosody-$pkgver.tar.gz" "rc.prosody" "prosody.logrotate" "prosody.cfg.lua.example" "README.Slackware" "config-helper.sh")
url="http://prosody.im/"
options=("noautodotnew")
docs=('AUTHORS' 'COPYING' 'DEPENDS' 'HACKERS' 'INSTALL' 'README' 'README.Slackware' 'TODO')

# extradepends: lua,luaexpat,luafilesystem,luasec,luasocket

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (a Jabber/XMPP server)"
"Prosody is a flexible communications server for Jabber/XMPP written in"
"Lua. It aims to be easy to use, and light on resources. For developers"
"it aims to be easy to extend and give a flexible system on which to"
"rapidly develop added functionality, or prototype new protocols."
"Prosody is licensed under the permissive MIT/X11 license."
""
"Make sure you read the documentation about how to set this up,"
"especially the info about creating $pkgname user and groups in"
"/usr/doc/$pkgname-$pkgver/README.Slackware"
)

build() {
	cd $startdir/src/${pkgname}-${pkgver}
	if [ $arch = x86_64 ]; then
		sed -i "s#/lib/prosody#/lib64/prosody#" Makefile
	fi
	./configure --prefix=/usr --sysconfdir=/etc/prosody --datadir=/var/lib/prosody --require-config || return 1
	sed -i "s#CFLAGS=-fPIC\ -Wall#CFLAGS=-fPIC\ -Wall\ $CFLAGS#" config.unix || return 1
	make || return 1
	make DESTDIR=$startdir/pkg/ install || return 1

	# remove the default config
	rm $startdir/pkg/etc/prosody/prosody.cfg.lua
	rm $startdir/pkg/etc/prosody/certs/*

	# remove data dir, should be created by hand
	rm -r $startdir/pkg/var/lib/prosody/

	cd $startdir/src/

	# copy example config
	install -m644 prosody.cfg.lua.example $startdir/pkg/etc/prosody/ || return 1

	# install rc script
	install -D -m755 rc.prosody $startdir/pkg/etc/rc.d/rc.prosody || return 1

	# logrotate script
	install -Dm 644 prosody.logrotate $startdir/pkg/etc/logrotate.d/prosody || return 1

	# config helper
	install -D config-helper.sh $startdir/pkg/usr/doc/$pkgname-$pkgver/config-helper.sh || return 1
}
