# Contributor: Noel Kuntze <noel.kuntze@thermi.consulting>
# Maintainer: Noel Kuntze <noel.kuntze@thermi.consulting>
pkgname=e2guardian
pkgver=5.5.6r
pkgrel=0
pkgdesc="fork of dansguardian, an open source web content filter"
url="http://e2guardian.org/"
arch="all"
license="GPL-2.0-only"
depends="logrotate"
makedepends="autoconf automake libtool zlib-dev pcre-dev openssl-dev>3"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="e2guard"
pkggroups="e2guard"
source="$pkgname-$pkgver.tar.gz::https://github.com/e2guardian/e2guardian/archive/v$pkgver.tar.gz
	e2guardian.initd
	e2guardian.logrotate
	0001-musl-stdio-fix.patch
	"

# secfixes:
#   5.4.5r-r0:
#     - CVE-2021-44273

prepare() {
	# bind to 127.0.0.1 by default
	sed -i -e 's:^filterip =.*:filterip = 127.0.0.1:' \
			configs/e2guardian.conf.in
	default_prepare
	./autogen.sh
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--sbindir=/usr/bin \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--with-proxyuser=e2guard \
		--with-proxygroup=e2guard \
		--enable-clamd=yes \
		--enable-icap=yes \
		--enable-commandline=yes \
		--enable-email=yes \
		--enable-ntlm=yes \
		--enable-pcre=yes \
		--enable-sslmitm=yes
	make
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m 755 "$srcdir"/e2guardian.initd \
		"$pkgdir"/etc/init.d/e2guardian
	install -D -m 644 "$srcdir"/e2guardian.logrotate \
		"$pkgdir"/etc/logrotate.d/e2guardian
	install -d -o e2guard -g e2guard "$pkgdir"/var/log/e2guardian
}

sha512sums="
3446cfa51ee9f1d6bfb897c5dca639c9cbf25d2a3c03f5722dd6c51a542aa830e504bb03b53fe58cb2d4e8354a393b8668391dd97a626f54a7a7d4bdbc2d6634  e2guardian-5.5.6r.tar.gz
0be16552e4a4b5541d11de50bef1122462bce71a2ad619d9308a8b92afd6bf350acdf1e3a2ccb40442dd5a70d3ca2c40ba70111798f7d356d5c68a0615aebf1a  e2guardian.initd
480188f7f94e0a08707d4c79ff259f0514b8071499e6112a61df56e7bea6407c0d7f323dcdf998cff17c7187d7eafbf0da5d29ce2ab6f819bf0ba38774f43da5  e2guardian.logrotate
00dc957a8407fe6c17e91ebd60a472a4da48b7e34d78f9f962c91b5db8157ceabe632dc4ddb468241fa0b7a305a4d86d28ff5c49d0f11bcac4ddd5da1256799e  0001-musl-stdio-fix.patch
"
