# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=dcc
pkgver=2.3.169
pkgrel=0
pkgdesc="Distributed Checksum Clearinghouses or DCC spam filter"
url="https://www.dcc-servers.net/dcc/"
arch="all"
license="custom"
pkgusers="dcc"
pkggroups="dcc"
makedepends="libmd-dev libmilter-dev"
subpackages="$pkgname-dccd $pkgname-dccifd $pkgname-dccm
	$pkgname-extras $pkgname-openrc $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://www.dcc-servers.net/src/dcc/old/dcc-$pkgver.tar.Z
	10-$pkgname-alpine.patch
	20-$pkgname-config.patch
	30-pid.patch
	dccd.initd
	dccd-grey.initd
	dccifd.initd
	dccm.initd
	"
install="$pkgname.pre-install $pkgname.post-install $pkgname.post-deinstall"
# there is no test suite
options="!check"

_p=var/dcc/libexec

prepare() {
	chmod 755 configure
	chmod 644 include/dcc_types.h include/dcc_config.h.in homedir/dcc_conf.in LICENSE
	default_prepare
}

build() {
	./configure \
		--with-installroot="$pkgdir" \
		--bindir="/usr/bin" \
		--mandir="/usr/share/man" \
		--with-uid=dcc
	make
}

package() {
	make install

	cd "$pkgdir"
	install -Dm 755 "$srcdir"/dccd.initd "$pkgdir"/etc/init.d/dccd
	install -Dm 755 "$srcdir"/dccd-grey.initd "$pkgdir"/etc/init.d/dccd-grey
	install -Dm 755 "$srcdir"/dccm.initd "$pkgdir"/etc/init.d/dccm
	install -Dm 755 "$srcdir"/dccifd.initd "$pkgdir"/etc/init.d/dccifd

	install -Dm644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

	chmod 755 "$pkgdir/$_p/dccsight"
	cd "$pkgdir"/usr/bin
	chmod 755 cdcc dccproc
}

dccd() {
	pkgdesc="$pkgdesc (dccd server with grey listing)"
	depends="dcc"

	amove "$_p"/dccd "$_p"/start-dccd "$_p"/stop-dccd "$_p"/start-grey \
	"$_p"/dump-clients "$_p"/dblist "$_p"/dccsight
}

dccifd() {
	pkgdesc="$pkgdesc (dccifd server)"
	depends="dcc"

	amove "$_p"/dccifd "$_p"/start-dccifd
}

dccm() {
	pkgdesc="$pkgdesc (dccm server)"
	depends="dcc"

	amove "$_p"/dccm "$_p"/start-dccm
}

extras() {
	pkgdesc="$pkgdesc (dcc user commands)"
	depends="dcc"

	amove "$_p"/updatedcc "$_p"/uninstalldcc "$_p"/rcDCC
	amove usr/bin/dccproc usr/bin/dccif-test
}

sha512sums="
bf8b7f1ac582c5b76879983be17b436eb26029f2bc744ce5c22f45e140050966d3c11bcce819622bbf349a53e23855193e91f1dff07bd6337a8a04afa9e1be07  dcc-2.3.169.tar.gz
8efe22be50da74abdf8fe26de028f13d7ee572c0f1fcfb174bcd8083523c0c5d2b0a5c2580d77d031c23f5ce728e045a6ba8ef9069a19cc6bcfe865142849d41  10-dcc-alpine.patch
8f7455cb8d49f26688fb8110c1a75311d9a8365e384dedbad7ab48bccdce6c0114f0c22d2024d05ab31d7ae5cdacf96972d8a7c0c361b767bde6532e1d9a94c7  20-dcc-config.patch
3a5d0b2cba23a6522fc068d225d3fd1abb68e9494802869e45533d5a9c2aaddf45f75aafbfb98bfb502e44c25c0befc569e20ef2d1884356a608012c73caf45f  30-pid.patch
f95ebeb46f6ae0ca80f94d05356f7ccc1ddad409d63b8780fdc4bea73f32c3df26962829cc82809490cbc12df7c24c7e7220bd6fce94df3660884156b4662c8c  dccd.initd
f5218aaf8b0ac9064ac8b6a892cb408f9bdb73af3bd732314714acbd188839a8b621ab79a97f12354f153a64bbc642266e7489e338d599bc6f0d1cd265fbce35  dccd-grey.initd
65ca7c509b61eebae2a733199afa0f0620a3d3b844cbed37e1667004f5cf50d3483b8fa7ce108eeeddc3c0a479ed8daac3703746ec10d2bd6a5b846c82e9f00f  dccifd.initd
ae2c9dde3260f16bdc38bbcc65a42afb20e6fe61c3ee4849b847d4a5a9a3cfd82d585f0b9bde14b5a9f8454a0a8a984fb63be0712357685869ebfb117b3bfe55  dccm.initd
"
