# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=dansguardian
pkgver=2.12.0.3
pkgrel=8
pkgdesc="Web content filter"
url="http://dansguardian.org"
arch="all"
license="GPL-2.0-only"
depends="logrotate"
makedepends="zlib-dev pcre-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="dansguar"
pkggroups="dansguar"
source="https://downloads.sourceforge.net/project/dansguardian/dansguardian-$pkgver.tar.bz2
	dansguardian.initd
	dansguardian.logrotate
	ftp-credential.patch
	dansguardian-2.10.1.1-pcre830.patch
	fix-includes.patch
	cstring.patch
	"
options="!check"

prepare() {
	default_prepare
	update_config_sub

	# do not block "microsoft...clustimg=..." and similar
	sed -i -e 's:\.\*:.{1,10}:g' configs/lists/bannedregexpurllist

	# bind to 127.0.0.1 by default
	sed -i -e 's:^filterip =.*:filterip = 127.0.0.1:' \
		configs/dansguardian.conf.in
}

build() {
	CXXFLAGS="$CXXFLAGS -std=gnu++11" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--with-proxyuser=dansguar \
		--with-proxygroup=dansguar \
		--with-logdir=/var/log/dansguardian \
		--with-piddir=/var/run/ \
		--enable-ntlm
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/dansguardian.initd \
		"$pkgdir"/etc/init.d/dansguardian
	install -Dm644 "$srcdir"/dansguardian.logrotate \
		"$pkgdir"/etc/logrotate.d/dansguardian
	install -d -o dansguar -g dansguar "$pkgdir"/var/log/dansguardian
}

sha512sums="
37155ef4f1a6dd6bdd87f79c7199b77de49746e4bff0631c239a569c21bf26240cbc9eae5a2436653bfc3d170a664710af9d80c4cfac3082a0620caeaac6740b  dansguardian-2.12.0.3.tar.bz2
b4e7d052171ae2ff85aebcdba093f4abb244df5046bb8787b3f2f6771ced506be4038fb12d35bb8db64b9248a4148f437a519b01f99cf8cde7144dec0038db00  dansguardian.initd
cc23178755365a3cceff08d9eb5c26dd440648b22af15377a30d2032f71cf0bd8ed3ab59c8a671f2cc3f4cdcaebff5d6c9e412f2271b00ac6ce1be5178a32087  dansguardian.logrotate
07b62441363534f39a1400389c702bbd5a53317526a18b3fc929f00bd854706c56b891d7fecb4151e200448f8ba012729e712e9cfdbbd683a3d2634fdc095bd1  ftp-credential.patch
d3d9af038ff5a91d1f9dc6cf4175b0da2a791386ca624f4a639338ed189a274eba720e9771986e7ded517e2623185e8b61ef3689414197c47a6ae3220be99d57  dansguardian-2.10.1.1-pcre830.patch
2eb17ef01a0b7d626f50197e0ddd160ae4ed17a813af00ceb9f6c54610d84b03b5c819bc2d8799f683e68dc16a65cbac5a8e36f0c43737d8ea82c7354e852d78  fix-includes.patch
77257cd290bfa91a6af7aaf6e58a4280e75a1a7ea5dc7e89fd418cd7509263533e4133f447f02f77410da1533502c9011921288d05b5d4cf33aac1e66467eaa6  cstring.patch
"
