# Contributor: Bartłomiej Piotrowski <nospam@bpiotrowski.pl>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=vnstat
pkgver=2.12
pkgrel=0
pkgdesc="Console-based network traffic monitor"
url="https://humdi.net/vnstat"
arch="all"
license="GPL-2.0-or-later"
install="$pkgname.pre-install"
options="!check" # make check is usesless
makedepends="sqlite-dev gd-dev"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://humdi.net/vnstat/vnstat-$pkgver.tar.gz
	vnstatd.initd
	vnstatd.confd
	"

prepare() {
	default_prepare

	update_config_guess
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

package() {
	make DESTDIR="$pkgdir" install

	install -D -m0755 "$srcdir"/vnstatd.initd \
		"$pkgdir"/etc/init.d/vnstatd
	install -D -m0644 "$srcdir"/vnstatd.confd \
		"$pkgdir"/etc/conf.d/vnstatd

	install -D -m0755 examples/vnstat.cgi \
		"$pkgdir"/usr/share/doc/vnstat/examples/vnstat.cgi
}

check() {
	make check
}

sha512sums="
68f8b7d8f30338fdd444621bf68a9157dd7b9be04b2156e27399f2a8b7ef67b5015067bf71370994da1b3aeaf88264205e797926e18a6e51fa9b963dcdd6d969  vnstat-2.12.tar.gz
f419af7075ba423fd2a28f27c520c9833a0ad994f471df5ab56b8175d02bf7d885718d2781a5538e32d19256e4518b06629a87670380db8a5cc780b76b4f0465  vnstatd.initd
bde20cffcfe6e2f7f7924ad7e7b4c7c2fdd6b92bacb7ec7c670413354c3b5a0bb07321444c4bd8ff07b55cb861bf6442a7065eee856f74658be1f25a451c8109  vnstatd.confd
"
