# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=squidanalyzer
pkgver=5.2
pkgrel=0
pkgdesc="Squid proxy log analyzer and report generator"
url="http://squidanalyzer.darold.net/"
arch="noarch"
license="GPLv3"
depends="perl"
depends_dev=""
makedepends="$depends_dev perl-dev"
install=""
subpackages="$pkgname-doc"
source="http://downloads.sourceforge.net/project/squid-report/squid-report/$pkgver/squidanalyzer-$pkgver.tar.gz"

_builddir="$srcdir"/squidanalyzer-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
}

build() {
	cd "$_builddir"
	PERL_MM_USE_DEFAULT=1 perl Makefile.PL \
		INSTALLDIRS=vendor \
		BINDIR=/usr/sbin \
		MANDIR=/usr/share/man/man3 \
		HTMLDIR=/var/lib/squidanalyzer \
		LOGFILE=/var/log/squid/access.log \
		DESTDIR="$pkgdir" || return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
	find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete
	install -d "$pkgdir"/etc/periodic/daily
	echo -e "#!/bin/sh\nexec /usr/sbin/squid-analyzer" \
		> "$pkgdir"/etc/periodic/daily/squid-analyzer || return 1
	chmod +x "$pkgdir"/etc/periodic/daily/squid-analyzer || return 1

}

md5sums="f716bbb106bde6c8dbe568a6d6f7d0a7  squidanalyzer-5.2.tar.gz"
sha256sums="1f708e0c2baeb27e229039372bc80ea10c845495eca2bd8b3b099ce2ea2a244b  squidanalyzer-5.2.tar.gz"
sha512sums="e9b559db7333c2c8ec46a4c46b8b9182c6728f69cbeaf0378ccf2be737a35d8271b736010de23505655dd178e96fde2f8c8d1e4ef5a1dfbd1ba8e552b7f3780a  squidanalyzer-5.2.tar.gz"