# $Id: Portfile 80219 2011-07-07 06:30:05Z jmr@macports.org $

PortSystem              1.0

name                    tinyproxy
version                 1.8.2
set branch              [join [lrange [split ${version} .] 0 1] .]
categories              net www
platforms               darwin
maintainers             nomaintainer
license                 GPL-2

description             fast, lightweight HTTP proxy

long_description        tinyproxy is a lightweight HTTP proxy. Designed from \
                        the ground up to be fast and yet small, it is an ideal \
                        solution for sites where a full-featured HTTP proxy is \
                        required, but the system resources required to run a \
                        more demanding HTTP proxy are unavailable.

homepage                https://banu.com/tinyproxy/
master_sites            https://banu.com/pub/${name}/${branch}

checksums               sha1    9ac7977b0f385ef0a48d40a7aac9396e4cd8820f \
                        rmd160  f468b6ce1bc38127a84c58bfacdd3e90e777388d

depends_build-append    port:asciidoc port:libxml2

patchfiles              patch-configure.diff

configure.ldflags-append -undefined error
configure.args          --disable-regexcheck

post-destroot {
    xinstall -d -o nobody -g nobody ${destroot}${prefix}/var/run/tinyproxy

    move ${destroot}${prefix}/etc/tinyproxy.conf ${destroot}${prefix}/etc/tinyproxy.conf.default

    set docdir ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS \
        ChangeLog \
        COPYING \
        docs/filter-howto.txt \
        docs/http-error-codes.txt \
        docs/http-rfcs.txt \
        README \
        TODO \
        ${docdir}
}

startupitem.create      yes
startupitem.netchange   yes
startupitem.executable  ${prefix}/sbin/tinyproxy -c ${prefix}/tinyproxy.conf -d

# TODO: variants: reverse proxy

livecheck.type          regex
livecheck.url           ${master_sites}
livecheck.regex         "${name}-(\\d+(?:\\.\\d+)*)"
