# -*- 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
# $Id: Portfile 84297 2011-09-22 03:35:24Z jmr@macports.org $

PortSystem              1.0

name                    simplevoc-open
version                 1.8.0
revision                1
set branch              [join [lrange [split ${version} .] 0 1] .]
categories              databases
platforms               darwin
maintainers             triagens.de:f.celler \
                        triagens.de:k.salewski \
                        triagens.de:w.helisch

description             Versatile object cache

long_description        SimpleVoc-OPEN is an open source version of a \
                        key/value based in memory object cache software. \
                        (See the WWW page for details.)
                        
supported_archs         i386 x86_64

homepage                http://www.worldofvoc.com/
master_sites            ${homepage}downloads/SimpleVoc/OPEN/${branch}/

distname                SimpleVoc-${version}-OPEN

checksums               md5     bf94886c73f08f6361860543873a9576 \
                        sha1    f5c5ea5f0143e0036af6a719416e5a5cf014410b

depends_build           port:boost \
                        port:libev \
                        port:autoconf \
                        port:automake

configure.args          --enable-static-libev \
                        --enable-static-boost

build.target            touch all

post-destroot {
    xinstall -m 755 -d \
        ${destroot}${prefix}/share/simplevoc \
        ${destroot}${prefix}/share/doc/simplevoc \
        ${destroot}${prefix}/Library/LaunchDaemons
    
    xinstall -m 644 -W ${worksrcpath} NOTICE NOTICE.boost NOTICE.getaddrinfo NOTICE.libev \
        ${destroot}${prefix}/share/doc/simplevoc
        
    xinstall -m 644 ${worksrcpath}/NOTICE.jquery ${destroot}${prefix}/share/doc/simplevoc/NOTICE.json
    
    xinstall -m 755 ${worksrcpath}/Demo/exampleRequest.sh ${destroot}${prefix}/share/doc/simplevoc/exampleRequest.sh
    xinstall -m 755 ${worksrcpath}/SimpleVoc/simplevoc ${destroot}${prefix}/sbin/simplevoc
    xinstall -m 644 ${worksrcpath}/initscripts/simplevoc.conf ${destroot}${prefix}/etc/simplevoc.conf.sample
    xinstall -m 644 ${worksrcpath}/initscripts/de.triagens.simplevoc.plist ${destroot}${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist.sample
    
    file copy ${worksrcpath}/WebAdmin ${destroot}${prefix}/share/simplevoc
    
    reinplace "s|/usr/sbin|${prefix}/sbin|g"   ${destroot}${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist.sample
    reinplace "s|/etc|${prefix}/etc|g"         ${destroot}${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist.sample
    reinplace "s|/usr/share|${prefix}/share|g" ${destroot}${prefix}/etc/simplevoc.conf.sample
    reinplace "s|/var/log|${prefix}/var/log|g" ${destroot}${prefix}/etc/simplevoc.conf.sample
}

post-activate {
    if {![file exists ${prefix}/etc/simplevoc.conf]} {
        file copy ${prefix}/etc/simplevoc.conf.sample \
            ${prefix}/etc/simplevoc.conf
    }
    if {![file exists ${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist]} {
        file copy ${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist.sample \
            ${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist
    }
}

notes "
To start up the simplevoc-open server instance, use

    launchctl load ${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist

To stop up the simplevoc-open server instance, use

    launchctl unload ${prefix}/Library/LaunchDaemons/org.macports.simplevoc.plist
"
