# $Id: Portfile 66380 2010-04-10 20:29:38Z febeling@macports.org $

PortSystem 1.0

name                couchdb-devel
svn.revision        916868
version             0.11.0b${svn.revision}

categories          databases
platforms           darwin

description         CouchDB is a document database server
maintainers         jwa
long_description  ${description} with a restful HTTP API, capable of \
	storing arbitrary JSON documents, building powerful data views, \
	defined in JavaScript, and processed in parallel using Map/Reduce. \
	It leaves out SQL and transactions for simplicity's sake, to \
	improve scalability and to relax users' lives.

homepage            http://couchdb.apache.org/
master_sites        ${homepage}

distname            couchdb-${version}
fetch.type          svn
svn.url             http://svn.apache.org/repos/asf/couchdb/trunk
worksrcdir          trunk

depends_lib	port:automake \
    port:autoconf \
    port:libtool \
    port:help2man \
    port:icu \
    port:spidermonkey \
    port:erlang

pre-configure {
    system "cd ${worksrcpath}; ./bootstrap"
}

set dbgroup couchdb
set dbuser couchdb
set logdir ${prefix}/var/log/couchdb
set dbdir ${prefix}/var/lib/couchdb
set plistdir /Library/LaunchDaemons
startupitem.uniquename org.apache.couchdb

post-destroot {
    addgroup ${dbgroup}
    adduser ${dbuser} gid=[existsgroup ${dbgroup}]
    xinstall -m 755 -o ${dbuser} -g ${dbgroup} -d \
	${destroot}${dbdir} \
	${destroot}${logdir} \
	${destroot}${plistdir}
    destroot.keepdirs-append \
        ${destroot}${dbdir} \
        ${destroot}${logdir}
    set plist org.apache.couchdb.plist
    system "cd ${destroot}/Library/LaunchDaemons && ln -sf ${prefix}/Library/LaunchDaemons/${plist}"
}

post-activate {
	ui_msg "########################################################################"
	ui_msg "# Changes in CouchDB r753448 make older database files incompatible."
	ui_msg "# See http://wiki.apache.org/couchdb/BreakingChanges for details"
	ui_msg "#"
	ui_msg "# Run the following command to install the CouchDB launchd"
	ui_msg "# startup item in order to start and re-start service automatically:"
	ui_msg "#"
	ui_msg "# sudo launchctl load -w /Library/LaunchDaemons/org.apache.couchdb.plist"
	ui_msg "########################################################################"
}

livecheck.type	regex
livecheck.url	http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/
livecheck.version	${svn.revision}
livecheck.regex	 (\[0-9\]+)
