--- /dev/null
+#!/sbin/runscript
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+VER=1.6.0.1
+NODE_NAME=ns_1@127.0.0.1
+MEMBASE_USER=membase
+MEMBASE_PATH=/opt/membase/$VER
+MEMBASE_LOGS=/var/log/membase/$VER
+MNESIA_PATH=/var/lib/membase/$VER/mnesia
+CONFIG_PATH=/etc/membase/$VER/config
+PIDFILE=/var/run/membase-server.pid
+
+depend() {
+ need net membase-epmd
+}
+
+start() {
+ ebegin "Starting membase"
+
+ touch $PIDFILE
+ chown membase:daemon $PIDFILE
+
+ # pam-limits (/etc/security/limits.d and limits.conf) aren't working with start-stop-daemon
+ ulimit -n 10240
+
+ start-stop-daemon --start --oknodo --chdir $MEMBASE_PATH/ns_server -c "$MEMBASE_USER" --exec /usr/bin/erl -- \
+ +A 16 \
+ -pa `find $MEMBASE_PATH/ns_server -type d -name ebin` \
+ -setcookie nocookie \
+ -ns_server error_logger_mf_dir \"$MEMBASE_LOGS\" \
+ -ns_server error_logger_mf_maxbytes 10485760 \
+ -ns_server error_logger_mf_maxfiles 10 \
+ -kernel inet_dist_listen_min 21100 inet_dist_listen_max 21199 \
+ -ns_server pidfile \"$PIDFILE\" \
+ -ns_server ns_server_config \"$CONFIG_PATH\" \
+ -mnesia dir \"$MNESIA_PATH\" \
+ -detached \
+ -noshell -noinput \
+ -run ns_bootstrap
+ #-name $NODE_NAME \ # causing things to break?
+ eend $? "Failed to start membase"
+}
+
+stop() {
+ ebegin "Stopping membase"
+ start-stop-daemon --stop --pidfile ${PIDFILE}
+ eend $? "Failed to stop membase"
+ rm -f ${PIDFILE}
+}
--- /dev/null
+# Copyright 1999-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header$
+
+EAPI=2
+inherit eutils
+
+MY_PV="${PV/_rc/-rc}"
+MY_P="${PN}_${MY_PV}"
+
+DESCRIPTION="Distributed key-value database management system"
+HOMEPAGE="http://www.membase.org/"
+SRC_URI="http://c2512712.cdn.cloudfiles.rackspacecloud.com/${MY_P}_src.tar.gz"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+KEYWORDS="-ia64 -x86"
+IUSE=""
+
+RDEPEND=">=dev-libs/libevent-2.0.7
+ >=net-misc/curl-7.21.1
+ >=dev-lang/erlang-13.2.4
+ >=sys-devel/gcc-4.3.0
+ >=dev-libs/check-0.9.4"
+DEPEND="${RDEPEND}
+ !>=dev-lang/erlang-14"
+ # Erlang 14A no longer allows compile option nowarn_bif_clash
+
+S="${WORKDIR}/${MY_P}_src"
+
+src_configure() {
+ dodir lib doc
+
+ einfo "Configuring and building memcached"
+ cd "${S}/memcached" || die
+ econf --enable-isasl && emake || die
+
+ einfo "Configuring bucket_engine"
+ cd "${S}/bucket_engine" || die
+ econf --with-memcached="${S}/memcached" || die
+
+ einfo "Configuring ep-engine"
+ cd "${S}/ep-engine" || die
+ econf --with-memcached="${S}/memcached" || die
+
+ # Some libs are depended on during the config process so build them now
+
+ einfo "Configuring and building libmemcached"
+ cd "${S}/libmemcached" || die
+ econf --prefix="${S}/lib" \
+ --mandir="${S}/doc" \
+ --disable-shared \
+ --disable-dtrace \
+ --enable-static \
+ --with-memcached="${S}/memcached/memcached" || die
+ emake && emake install || die
+
+ einfo "Configuring and building libvbucket"
+ cd "${S}/libvbucket" || die
+ econf --prefix="${S}/lib" \
+ --mandir="${S}/doc" \
+ --disable-shared \
+ --enable-static || die
+ emake && emake install || die
+
+ einfo "Configuring and building vbucketmigrator"
+ cd "${S}/vbucketmigrator" || die
+ econf --prefix="${S}/lib" \
+ --mandir="${S}/doc" \
+ --without-sasl \
+ --with-isasl \
+ --with-memcached="${S}/memcached" || die
+ emake || die
+
+ einfo "Configuring and building libconflate"
+ cd "${S}/libconflate" || die
+ econf --prefix="${S}/lib" \
+ --mandir="${S}/doc" \
+ --disable-shared \
+ --enable-static || die
+ emake && emake install || die
+
+ einfo "Configuring moxi"
+ cd "${S}/moxi" || die
+ econf --prefix="${S}/lib" \
+ --mandir="${S}/doc" \
+ --with-memcached="${S}/memcached/memcached" \
+ --enable-moxi-libvbucket \
+ --enable-moxi-libmemcached \
+ CFLAGS="-I${S}/lib/include -Wno-error" \
+ LDFLAGS="-L${S}/lib/lib" || die
+}
+
+src_compile() {
+ echo "Building bucket_engine"
+ cd "${S}/bucket_engine" || die
+ emake || die
+
+ echo "Building ep-engine"
+ cd "${S}/ep-engine" || die
+ emake || die
+
+ echo "Building moxi"
+ cd "${S}/moxi" || die
+ emake || die
+
+ echo "Building ns-server"
+ cd "${S}/ns_server"
+ emake || die
+}
+
+src_install() {
+ # Just copy the whole directory over to /opt until we split out packages
+ # more efficiently (and/or respect the Makefile destinations)
+ dodir opt/membase
+ cp -a "${S}"/{bucket_engine,ep-engine,libconflate,libmemcached,libvbucket,membase-cli,memcached,moxi,ns_server,vbucketmigrator} \
+ "${D}/opt/membase" || die "Install failed!"
+
+ # Setup keeps for the data, config, and log dirs
+ dodir "etc/membase/${PV}"
+ keepdir "etc/membase/${PV}"
+ cp "${FILESDIR}/${PV}/config" "${D}/etc/membase/${PV}" || \
+ die "Install failed!"
+ dosym "etc/membase/${PV}/priv" "/etc/membase/${PV}"
+ chown -R membase:daemon "${D}/etc/membase" || \
+ die "Install failed!"
+
+ dodir "var/lib/membase/${PV}/mnesia" "var/lib/membase/${PV}/data"
+ keepdir "var/lib/membase/${PV}/mnesia" "var/lib/membase/${PV}/data"
+ chown -R membase:daemon "${D}/var/lib/membase" || \
+ die "Install failed!"
+
+ dodir "var/log/membase/${PV}"
+ keepdir "var/log/membase/${PV}"
+ chown -R membase:daemon "${D}/var/log/membase/${PV}" || \
+ die "Install failed!"
+
+ # TODO: Sort through all the misc docs in the different subprojects and
+ # dodoc them
+ doman doc/man1/* || die
+ doman doc/man3/* || die
+ doman doc/man4/* || die
+
+ # Install the initscripts
+ newinitd "${FILESDIR}/${PV}/init-epmd" membase-epmd
+ newinitd "${FILESDIR}/${PV}/init-server" membase-server
+}
+
+pkg_setup() {
+ enewuser membase -1 -1 /var/lib/membase daemon
+}