# -*- 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 119558 2014-04-30 12:42:40Z stromnov@macports.org $

PortSystem          1.0

name                redis
version             2.8.9
categories          databases
platforms           darwin
license             BSD

maintainers         gmail.com:brianjlandau openmaintainer

description         Redis is an open source, advanced key-value store.
long_description    ${description}

homepage            http://redis.io/
master_sites        http://download.redis.io/releases/

checksums           rmd160  e14dca13e50dda3e3515b213cfa5cbd4b99d671e \
                    sha256  7834c37f2ff186c46aef8e4a066dfbf1d6772a285aa31c19c58162f264f1007f

patchfiles          patch-redis.conf.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/redis.conf
}

use_configure       no

variant universal {}

build.args-append   CC="${configure.cc} [get_canonical_archflags cc]"

# disable silent rules
build.args-append   V=1

destroot.keepdirs   ${destroot}${prefix}/var/db/redis

destroot {
    xinstall -d ${destroot}${prefix}/var/db/redis
    xinstall -m 0755 -W ${worksrcpath}/src \
        redis-benchmark \
        redis-check-aof \
        redis-check-dump \
        redis-cli \
        redis-server \
        ${destroot}${prefix}/bin
    xinstall -m 0644 ${worksrcpath}/redis.conf \
        ${destroot}${prefix}/etc/redis.conf.sample
}

post-activate {
    if {![file exists ${prefix}/etc/redis.conf]} {
        file copy ${prefix}/etc/redis.conf.sample ${prefix}/etc/redis.conf
    }
    xinstall -d ${prefix}/var/log
    touch ${prefix}/var/log/redis.log
}

startupitem.create  yes
startupitem.executable  ${prefix}/bin/redis-server ${prefix}/etc/redis.conf

notes "
If you prefer to start a redis server manually, rather than using 'port load', then use this command:

    redis-server ${prefix}/etc/redis.conf
"

livecheck.url       http://download.redis.io/releases/
livecheck.regex     ${name}-(\\d+.\\d+.\\d+)
