# Contributor: Mika Havela <mika.havela@gmail.com>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
_luaver=5.2
pkgname=prosody
pkgver=0.10.0
pkgrel=2
pkgdesc="Lua based Jabber/XMPP server"
url="http://prosody.im/"
arch="all"
license="MIT"
depends="lua${_luaver}-socket lua${_luaver}-expat lua${_luaver}-filesystem
	lua${_luaver}-sec lua${_luaver} lua"
makedepends="linux-headers lua${_luaver}-dev libidn-dev libressl-dev"
install="prosody.pre-install"
subpackages="$pkgname-doc"
pkgusers="prosody"
pkggroups="prosody"
source="http://prosody.im/downloads/source/$pkgname-$pkgver.tar.gz
	prosody.cfg.lua.patch
	mallinfo.patch
	$pkgname.initd
	"

builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc/prosody \
		--ostype=linux \
		--with-lua-lib=/usr/lib \
		--with-lua-include=/usr/include \
		--lua-version=${_luaver} \
		--no-example-certs
	# Don't generate certs
	rm -f "$builddir"/certs/Makefile

	make
}

check() {
	cd "$builddir"
	make test
}

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

	install -d -o prosody -g prosody "$pkgdir/var/log/prosody"
	install -d -o prosody -g prosody "$pkgdir/var/run/prosody"
	install -d -m750 -o prosody -g prosody "$pkgdir/var/lib/prosody"

	install -D -m755 "$srcdir"/"$pkgname".initd "$pkgdir"/etc/init.d/"$pkgname"
}

sha512sums="ee66e240afba6a8cb286623da48d9b535798153fb65e32070cec93aafe360e91f7087eeb49dec0f7d145e24f04339ed0878e50835b52f682130b204e22990ce9  prosody-0.10.0.tar.gz
a6ca168fe3d11ee3b05295fb36dfaf8240c60a85507032b2502f9a97d3fd055f7eee38ba6efbb8f79472fc7cdd3556922194d0bd7099f7fb809be01890acc511  prosody.cfg.lua.patch
b07498cd42677d09f1a3fd4a5d91a085e90dd10cee7d6ee7c5e41438cfc2f4049ab9948c0fd0f7e148dd81f6a25c64c6ae832ea4864cee2329d3c6735216b78b  mallinfo.patch
11b0f5e4fa488e047c26aa5e51c35983100cdbf7ebbf7c8b6d003c8db7f52e797f93e4744d54b3094c82d722d5e4de62b5734376cb5e69a4c6127f8cb07a4347  prosody.initd"
