# $Id: Portfile,v 1.3 2005/08/11 21:33:24 rshaw Exp $
PortSystem		1.0

name			junkbuster
version			2.0.2p1.1
revision		1
categories		net www
platforms		darwin
maintainers		darwinports@opendarwin.org
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/ \
				http://internet.junkbuster.com/
master_sites	http://f2.org/download/
distname		ijb-zlib-11
extract.suffix	.tgz
checksums		md5 891f4a1a475b24b35b33baefd51dac2c
depends_lib		lib:libz.1:zlib \
				lib:libgnuregex:gnuregex

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

build.args		PREFIX=${prefix}

destroot.keepdirs	${destroot}${prefix}/var/log \
					${destroot}${prefix}/var/run/junkbuster
destroot {
	cd ${worksrcpath}
	xinstall -m 0755 junkbuster ${destroot}${prefix}/sbin
	xinstall -m 0755 junkbuster.1 ${destroot}${prefix}/share/man/man1
	xinstall -d -m 0755 ${destroot}${prefix}/etc/junkbuster
	xinstall -m 0644 junkbstr.ini \
		${destroot}${prefix}/etc/junkbuster/configfile.sample
	xinstall -m 0644 sblock.ini \
		${destroot}${prefix}/etc/junkbuster/blockfile.sample
	xinstall -m 0644 saclfile.ini \
		${destroot}${prefix}/etc/junkbuster/aclfile.sample
	xinstall -m 0644 scookie.ini \
		${destroot}${prefix}/etc/junkbuster/cookiefile.sample
	xinstall -m 0644 sforward.ini \
		${destroot}${prefix}/etc/junkbuster/forwardfile.sample
	xinstall -m 0644 strust.ini \
		${destroot}${prefix}/etc/junkbuster/trustfile.sample
	xinstall -d -m 0755 ${destroot}${prefix}/etc/rc.d
	xinstall -m 0755 ${filespath}/junkbuster.sh.in \
		${destroot}${prefix}/etc/rc.d/junkbuster.sh
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/junkbuster
	xinstall -m 0644 README gpl.html ijbman.html ijbfaq.html \
		${destroot}${prefix}/share/doc/junkbuster
	foreach blockfile [glob ${filespath}/blockfile.*] {
		xinstall -m 0644 ${blockfile} ${destroot}${prefix}/share/doc/junkbuster
	}
	reinplace "s%__PREFIX%${prefix}%g" \
		${destroot}${prefix}/etc/rc.d/junkbuster.sh \
		${destroot}${prefix}/etc/junkbuster/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}
		}
	}
}

platform darwin {
	depends_run	path:/Library/StartupItems/DarwinPortsStartup:DarwinPortsStartup
}

