PortSystem		1.0

name			junkbuster
version			2.0.2p1.1
revision		1
categories		net www
license			GPL-2+
platforms		darwin
maintainers		nomaintainer
description		Internet Junkbuster Proxy with zlib compression support
long_description	This is a port of The Internet Junkbuster Proxy(TM). \
					An excelent way to enhance your privacy while \
					browsing the web.  And it also happens to do a great \
					job of filtering out all those annoying banner ads! \
					This modified version allows one to specify \
					appearance of blocked GIFs.  It can automatically \
					compress text/html and text/plain documents for \
					clients which support Accept-Encoding: gzip (e.g. \
					Netscape 4.7, Internet Explorer 5, Lynx 2.8.3) to \
					save downstream modem/network bandwidth.  It uses \
					the zlib compression library to perform on-the-fly \
					compression of HTML documents.
homepage		http://f2.org/products/ijb-zlib/
master_sites	http://f2.org/download/
distname		ijb-zlib-11
extract.suffix	.tgz
checksums		md5 891f4a1a475b24b35b33baefd51dac2c
depends_lib		port:zlib \
				port:gnuregex

startupitem.create     yes
startupitem.name       junkbuster
startupitem.executable ${prefix}/sbin/junkbuster

pre-patch {
	foreach  file [glob ${worksrcpath}/*.ini] { reinplace "s%\r%%g" $file }
}
patchfiles		patch-Makefile \
				patch-acl.c \
				patch-bind.c \
				patch-conn.c \
				patch-encode.c \
				patch-filters.c \
				patch-jcc.c \
				patch-jcc.h \
				patch-junkbstr.ini \
				patch-junkbuster.1 \
				patch-loaders.c \
				patch-loaders.h \
				patch-parsers.c \
				patch-socks4.c \
				patch-ssplit.c \
				patch-win32.c

post-patch {
	reinplace "s%__PREFIX%${prefix}%g" ${worksrcpath}/junkbstr.ini
}

use_configure	no

variant universal {}

build.args		PREFIX=${prefix} \
				CC="${configure.cc} [get_canonical_archflags cc]"

destroot.keepdirs	${destroot}${prefix}/var/log \
					${destroot}${prefix}/var/run/junkbuster
destroot {
	xinstall -m 0755 ${worksrcpath}/junkbuster ${destroot}${prefix}/sbin
	
	xinstall -m 0755 ${worksrcpath}/junkbuster.1 ${destroot}${prefix}/share/man/man1
	
	set etcpath ${destroot}${prefix}/etc/junkbuster
	xinstall -d -m 0755 ${etcpath}
	xinstall -m 0644 ${worksrcpath}/junkbstr.ini ${etcpath}/configfile.sample
	xinstall -m 0644 ${worksrcpath}/sblock.ini ${etcpath}/blockfile.sample
	xinstall -m 0644 ${worksrcpath}/saclfile.ini ${etcpath}/aclfile.sample
	xinstall -m 0644 ${worksrcpath}/scookie.ini ${etcpath}/cookiefile.sample
	xinstall -m 0644 ${worksrcpath}/sforward.ini ${etcpath}/forwardfile.sample
	xinstall -m 0644 ${worksrcpath}/strust.ini ${etcpath}/trustfile.sample
	
	set rcddir ${destroot}${prefix}/etc/rc.d
	xinstall -d -m 0755 ${rcddir}
	xinstall -m 0755 ${filespath}/junkbuster.sh.in ${rcddir}/junkbuster.sh
	
	set docdir ${destroot}${prefix}/share/doc/junkbuster
	xinstall -d -m 0755 ${docdir}
	xinstall -W ${worksrcpath} -m 0644 README gpl.html ijbman.html ijbfaq.html ${docdir}
	xinstall -m 0644 {*}[glob ${filespath}/blockfile.*] ${docdir}
	
#	reinplace "s%__PREFIX%${prefix}%g" \
#		${rcddir}/junkbuster.sh \
#		${etcdir}/configfile.sample
	
	xinstall -o nobody -g nobody -d -m 0755 \
		${destroot}${prefix}/var/run/junkbuster
}

post-activate {
	# Make sure initial log file is present
	if ![file exists ${prefix}/var/log/junkbuster.log] {
		xinstall -m 0644 -o nobody -g nobody /dev/null \
			${prefix}/var/log/junkbuster.log
	}
	# Make sure initial config files are present
	foreach conf {configfile blockfile cookiefile} {
		if ![file exists ${prefix}/etc/junkbuster/${conf}] {
			xinstall -m 0644 ${prefix}/etc/junkbuster/${conf}.sample \
				${prefix}/etc/junkbuster/${conf}
		}
	}
}