# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0

name			ntop
version			5.0.1
revision        7
categories		net
maintainers		nomaintainer
# COPYING is GPL 3 but the source files say GPL 2 or later
license			GPL-2+

description		network traffic probe
platforms		darwin
long_description	ntop is a network traffic probe that shows the network \
				usage, similar to what the popular top Unix command does.

homepage		https://www.ntop.org/
master_sites		sourceforge:project/ntop/ntop/Stable/

checksums		rmd160  6ca48ded21538e7af895b25da935a3069378de70 \
			sha256  7e8e84cb14d2173beaca4d4cb991a14d84a4bef84ec37b2276bc363f45c52ef8

depends_build		port:gawk \
			port:automake \
			port:autoconf \
			port:libtool \
			port:libevent

depends_lib		port:libpcap \
			port:gd2 \
			port:libpng \
			port:gdbm \
			port:libgeoip \
			port:rrdtool \
			port:py27-rrdtool \
			port:python27

post-extract {
	move ${worksrcpath}/configure.in ${worksrcpath}/configure.ac
}

patchfiles		patch-Makefile.am.diff \
			patch-autogen.sh.diff \
			patch-configure.ac.diff \
			patch-plugins-Makefile.am.diff

post-patch {
	reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/autogen.sh
}

configure.env		LOCALEDIR=${prefix}/share/locale \
			PYTHON=${prefix}/bin/python2.7-config

configure.cmd		${worksrcpath}/autogen.sh

configure.args		--with-rrd-home=${prefix} \
			--without-ssl

startupitem.create	yes
startupitem.executable	${prefix}/bin/ntop @${prefix}/etc/ntop/ntop.conf

destroot.keepdirs ${destroot}${prefix}/var/ntop/rrd

post-destroot	{
	xinstall -m 755 -o nobody -d ${destroot}${prefix}/var/ntop \
		${destroot}${prefix}/var/ntop/rrd

	xinstall -m 755 -d ${destroot}${prefix}/etc/ntop
	xinstall -m 755 \
		${worksrcpath}/packages/FreeBSD-ports/net/ntop/files/ntop.conf.sample \
		${destroot}${prefix}/etc/ntop
	reinplace "s|%%DBDIR%%/ntop|${prefix}/var/ntop|g" \
		${destroot}${prefix}/etc/ntop/ntop.conf.sample
	reinplace "s|#--interface sis0|--interface en0|g" \
		${destroot}${prefix}/etc/ntop/ntop.conf.sample
}

post-activate {
	foreach f {addressQueue.db dnsCache.db macPrefix.db ntop_pw.db prefsCache.db} {
		if {![file exists ${prefix}/var/ntop/${f}]} {
			touch ${prefix}/var/ntop/${f}
			file attributes ${prefix}/var/ntop/${f} -owner nobody
		}
	}
	if {![file exists ${prefix}/etc/ntop/ntop.conf]} {
		copy ${prefix}/etc/ntop/ntop.conf.sample ${prefix}/etc/ntop/ntop.conf
	}
}

universal_variant		no

livecheck.regex		/${name}-(\[0-9.\]+)${extract.suffix}
