Skip to content

Instantly share code, notes, and snippets.

@vjt
Created July 30, 2010 16:15
Show Gist options
  • Save vjt/500799 to your computer and use it in GitHub Desktop.
Save vjt/500799 to your computer and use it in GitHub Desktop.
# $Id: Portfile 66285 2010-04-08 08:09:09Z [email protected] $
# Tweaked upstream privoxy Portfile to install the latest CVS
# version that fixes hang bugs in the 3.0.16 release -- while
# retaining IPv6 support :-).
#
# [email protected] - Fri Jul 30 18:14:38 CEST 2010
#
PortSystem 1.0
name privoxy-devel
version 3.0-CVS
categories www security net
maintainers openssl.it:vjt
description Advanced filtering web proxy
long_description \
Privoxy is a web proxy with advanced filtering capabilities for \
protecting privacy, modifying web page content, managing cookies, \
controlling access, and removing ads, banners, pop-ups and other \
obnoxious Internet junk. Privoxy has a very flexible configuration and \
can be customized to suit individual needs and tastes. Privoxy has \
application for both stand-alone systems and multi-user networks.
platforms darwin
homepage http://www.privoxy.org/
#master_sites sourceforge:ijbswa
#distname ${name}-${version}-stable-src
fetch.type cvs
cvs.root :pserver:[email protected]:/cvsroot/ijbswa
cvs.module current
worksrcdir current
depends_lib port:pcre port:zlib
set privoxyGroup privoxy
set privoxyUser privoxy
set privoxyName privoxy
pre-configure {
addgroup ${privoxyGroup}
adduser ${privoxyUser} gid=[existsgroup ${privoxyGroup}]
system "cd ${worksrcpath} && aclocal && autoconf && autoheader"
}
use_autoconf yes
configure.args --with-user=${privoxyUser} \
--with-group=${privoxyGroup} \
--sysconfdir=${prefix}/etc/${privoxyName} \
--mandir=${prefix}/share/man \
--enable-dynamic-pcre \
--enable-zlib
destroot.keepdirs ${destroot}${prefix}/var/log/privoxy \
${destroot}${prefix}/var/run
post-destroot {
xinstall -m 755 -d ${destroot}${prefix}/var/run
# Install and fixup startup script (if non-Darwin)
if {${os.platform} != "darwin"} {
xinstall -m 755 -d ${destroot}${prefix}/etc/rc.d
xinstall -m 755 -W ${worksrcpath} privoxy-generic.init \
${destroot}${prefix}/etc/rc.d/privoxy.sh
system "cd ${destroot}${prefix}/etc/rc.d && patch -p0 < ${filespath}/patch-privoxy.sh.diff"
reinplace "s|@@PREFIX@@|${prefix}|g" \
${destroot}${prefix}/etc/rc.d/privoxy.sh
reinplace "s|@@PRIVOXY_USER@@|${privoxyUser}|g" \
${destroot}${prefix}/etc/rc.d/privoxy.sh
}
# Rename these so local modifications are not removed on uninstall
foreach privoxyConf {config.new trust.new user.action.new user.filter.new} {
if [file exists ${destroot}${prefix}/etc/${privoxyName}/${privoxyConf}] {
file rename ${destroot}${prefix}/etc/${privoxyName}/${privoxyConf} \
${destroot}${prefix}/etc/${privoxyName}/${privoxyConf}-dist
}
}
# Remove the preinstalled log files as, otherwise, a rotation script
# will fail when trying to rename and compress due to gzip not liking
# multi-linked files (the one in ${prefix} and the one in
# ${prefix}/var/db/dports/software/...)
eval file delete [glob ${destroot}${prefix}/var/log/privoxy/*]
# Make sure log directory owned by privoxy user/group
file attributes ${destroot}${prefix}/var/log/privoxy \
-group ${privoxyGroup} -owner ${privoxyUser}
}
post-activate {
# Make sure initial log files are present and setup correctly
foreach privoxyLog {jarfile logfile} {
touch ${prefix}/var/log/privoxy/${privoxyLog}
file attributes ${prefix}/var/log/privoxy/${privoxyLog} \
-group ${privoxyGroup} -owner ${privoxyUser} \
-permissions 0660
}
foreach privoxyConf {config trust user.action} {
if ![file exists ${prefix}/etc/${privoxyName}/${privoxyConf}] {
file copy ${prefix}/etc/${privoxyName}/${privoxyConf}.new \
${prefix}/etc/${privoxyName}/${privoxyConf}
file attributes ${prefix}/etc/${privoxyName}/${privoxyConf} \
-group ${privoxyGroup} -owner ${privoxyUser} \
-permissions 0660
}
}
}
platform darwin {
startupitem.create yes
startupitem.name Privoxy
startupitem.start "\[ -f \"${prefix}/etc/${privoxyName}/config\" \] \\"
startupitem.start-append "\t&& ${prefix}/sbin/privoxy \\"
startupitem.start-append "\t\t--pidfile ${prefix}/var/run/privoxy.pid \\"
startupitem.start-append "\t\t--user ${privoxyUser} \\"
startupitem.start-append "\t\t${prefix}/etc/${privoxyName}/config 2>/dev/null"
startupitem.stop "if \[ -f \"${prefix}/var/run/privoxy.pid\" \]; then"
startupitem.stop-append "\tkill `cat ${prefix}/var/run/privoxy.pid` \\"
startupitem.stop-append "\t\t&& rm -f ${prefix}/var/run/privoxy.pid"
startupitem.stop-append "else"
startupitem.stop-append "\t/usr/bin/killall -SIGUSR1 privoxy 2>/dev/null"
startupitem.stop-append "fi"
}
livecheck.type regex
livecheck.url http://www.privoxy.org/announce.txt
livecheck.regex Announcing Privoxy v.(\[0-9.\]+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment