# Contributor: Juraj Sujan <sujan@sofy.sk>
# Maintainer: Juraj Sujan <sujan@sofy.sk>
pkgname=maildrop
pkgver=2.5.2
pkgrel=1
pkgdesc="Mail delivery agent with filtering abilities"
url="http://courier-mta.org/maildrop/"
arch="all"
license="GPL3"
depends=
makedepends="perl pcre-dev"
install=
subpackages="$pkgname-doc"
source="http://downloads.sourceforge.net/project/courier/$pkgname/$pkgver/$pkgname-$pkgver.tar.bz2
	maildrop-2.3.0-dovecotauth.patch"

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

prepare() {
	cd "$_builddir"
	# apply patches here
	if ! patch --verbose -p1 -i ../maildrop-2.3.0-dovecotauth.patch; then
		error "dovecotauth patch failed"
		return 1
	fi
}

build() {
	cd "$_builddir"
	# workaround for strange detection of default mailbox file/dir
	export QMAIL="foo"
	./configure --prefix=/usr \
	    --disable-authlib \
	    --without-db \
	    --enable-syslog=1 \
	    --with-default-maildrop=./Maildir || return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install
	mkdir "$pkgdir"/usr/share/doc
	mv "$pkgdir"/usr/share/maildrop "$pkgdir"/usr/share/doc/
	cp README.dovecotauth "$pkgdir"/usr/share/doc/maildrop/
}
md5sums="3edb56534ae442a494255db6c8aaab99  maildrop-2.5.2.tar.bz2
8e56645ecf8ddb52550ab69103ae8d43  maildrop-2.3.0-dovecotauth.patch"
sha256sums="c1996773baf2d0147299f2ae3d588937e350b175d60bd7efb4551d39cd0a4190  maildrop-2.5.2.tar.bz2
0a75ec0b8f9797712bbdc695f9b3043b85c2480c1d627f657336439b6e9eecfe  maildrop-2.3.0-dovecotauth.patch"
sha512sums="b2ab4f1a600e6e45eb2e130e61501d30df8474232a6e95aa7b282cb28f362b017fc84a72ae6f39c6d0fe75682441ee9a83133a3cd2d705a8894657dc15ab3cdd  maildrop-2.5.2.tar.bz2
9425d3ac875414044e6258788eacd7fb80de68a83cf7ac91912044dc897f14d6f9dbc5d9e9148251ea7f3f9ec8cffca756dc76fca2be56d3acb96453b4a5d21f  maildrop-2.3.0-dovecotauth.patch"