# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=mailmunge
pkgver=3.16
pkgrel=0
pkgdesc="email filtering framework that uses libmilter to interface with Postfix or Sendmail"
url="https://mailmunge.org"
arch="all"
license="GPL-2.0-only"
pkgusers="mailmunge"
pkggroups="mailmunge"
depends="
	perl-io-socket-ssl
	perl-html-parser
	perl-mail-dkim
	perl-mime-tools
	perl-socket
	perl-time-local
	perl-unix-syslog
	tzdata
	"
makedepends="libmilter-dev"
checkdepends="
	perl-dbi
	perl-file-find-rule
	perl-html-parser
	perl-json-any
	perl-json-xs
	perl-mail-spamassassin
	perl-net-dns
	perl-dbd-sqlite
	perl-test-deep
	perl-test-pod
	perl-test-pod-coverage
	perl-utils
	"
subpackages="$pkgname-openrc $pkgname-doc"
install="$pkgname.pre-install"
source="$pkgname-$pkgver.tar.gz::https://git.skoll.ca/Skollsoft-Public/mailmunge/archive/$pkgver.tar.gz"
builddir="$srcdir/$pkgname"

prepare() {
	default_prepare
	# delete failing mx DNS test (expects some local addresses)
	rm -f perl/t/91-getmx.t
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--with-perlinstalldirs=vendor \
		--disable-perl-build-artifacts
	make
}

check() {
	make test
}

package() {
	make DESTDIR="$pkgdir" install
	# delete systemd and tests
	rm -rf "$pkgdir"/etc/systemd
	rm -rf "$pkgdir"/usr/share/perl*/vendor_perl/Test

	install -dm 750 -o mailmunge -g mailmunge \
		var/spool/mailmunge
}

sha512sums="
e963aee2e1468ce8eb0a2d5a0a382f129072f7fc2d019a26075225998ad6492bc3e5640d7598f8366b78b470f5686f3f7d1731c31174050fb0618b295c79ae8f  mailmunge-3.16.tar.gz
"
