# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=milter-greylist
pkgver=4.6.2
pkgrel=2
pkgdesc="Stand-alone milter written in C that implements the greylist filtering method"
url="http://hcpnet.free.fr/milter-greylist"
arch="all"
license="BSD-3-Clause"
depends=
depends_dev=
makedepends="$depends_dev bison flex geoip-dev libmilter-dev libspf2-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc"
pkgusers="smmsp"
pkggroups="smmsp"
source="ftp://ftp.espci.fr/pub/milter-greylist/$pkgname-$pkgver.tgz
	milter-greylist-conf.patch
	"

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

prepare() {
	cd "$builddir"
        for i in $source; do
                case $i in
                *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
                esac
        done
	#autoreconf -vif
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var/lib \
		--with-libspf2 \
		--with-user=smmsp \
		--with-conffile=/etc/$pkgname/greylist.conf \
		--with-dumpfile=/var/lib/$pkgname/greylist.db \
		--with-thread-safe-resolver \
		--with-libGeoIP \
		--enable-postfix \
		--enable-spamassassin \
		--enable-dnsrbl \
		--disable-rpath
	make -j1 || return 1
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install || return 1
	install -m755 -D ../../$pkgname.initd "$pkgdir"/etc/init.d/$pkgname || return 1
	install -m644 -D greylist2.conf "$pkgdir"/etc/$pkgname/greylist2.conf
	mkdir -p "$pkgdir"/var/lib/$pkgname
	chown -R smmsp:smmsp "$pkgdir"/var/lib/$pkgname
}

md5sums="8872008db2fc6b93dd9ab8576383fec2  milter-greylist-4.6.2.tgz
141e3b79fcea533cdd9ae57f2d731f24  milter-greylist-conf.patch"
sha256sums="5405a71bc8273848a1e14cecc010b95491e754307b005c96d35081ab2f9b8bd5  milter-greylist-4.6.2.tgz
973788cd06c96d7e9c02d9ccfc1dd62f85c3ef635b44873755575033b7a97336  milter-greylist-conf.patch"
sha512sums="458b4e74cadca6cb50838b87a192392cc19bde61062d2b25b2ca0fc515a277b53d177d9605f34aff1671f7722462c31ce419a4e058ca6ea23b80a8debf33079c  milter-greylist-4.6.2.tgz
4057061fae24a8d008c6a8aed82018a4bb9f6e9ce72a13d9369d54b192e9a6e99b0e72db8905aa182879c9522b87a92844d0be92773843773508a21e42dbd447  milter-greylist-conf.patch"
