summaryrefslogtreecommitdiff
path: root/dev-db/rethinkdb
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
committerV3n3RiX <venerix@redcorelinux.org>2018-07-14 21:03:06 +0100
commit8376ef56580626e9c0f796d5b85b53a0a1c7d5f5 (patch)
tree7681bbd4e8b05407772df40a4bf04cbbc8afc3fa /dev-db/rethinkdb
parent30a9caf154332f12ca60756e1b75d2f0e3e1822d (diff)
gentoo resync : 14.07.2018
Diffstat (limited to 'dev-db/rethinkdb')
-rw-r--r--dev-db/rethinkdb/Manifest9
-rw-r--r--dev-db/rethinkdb/files/rethinkdb-2.3.5-gcc6.patch37
-rw-r--r--dev-db/rethinkdb/files/rethinkdb-2.3.5-libressl.patch162
-rw-r--r--dev-db/rethinkdb/files/rethinkdb.confd12
-rw-r--r--dev-db/rethinkdb/files/rethinkdb.initd49
-rw-r--r--dev-db/rethinkdb/files/rethinkdb.service13
-rw-r--r--dev-db/rethinkdb/files/rethinkdb.tmpfilesd1
-rw-r--r--dev-db/rethinkdb/metadata.xml19
-rw-r--r--dev-db/rethinkdb/rethinkdb-2.3.6.ebuild139
9 files changed, 441 insertions, 0 deletions
diff --git a/dev-db/rethinkdb/Manifest b/dev-db/rethinkdb/Manifest
new file mode 100644
index 000000000000..95b7ff5998e4
--- /dev/null
+++ b/dev-db/rethinkdb/Manifest
@@ -0,0 +1,9 @@
+AUX rethinkdb-2.3.5-gcc6.patch 1588 BLAKE2B 01770dbba244a9f8b914ca25d97aec97c733988c563b1e6438d42a901bfd35e9df7c9713d3f9d8dab23acc832d15a1954c7d1dbe69fbcaabf49a13954cf2cbed SHA512 ac902b1eea3dd5d5c2c76bf9aa1b513553624cccfbda282e9be50589f9f74f01cf4b9968f08b22c139af80e92f4e5a4930364c4af2977359ee95b7587c8f292c
+AUX rethinkdb-2.3.5-libressl.patch 4365 BLAKE2B 83487fb920acc136e37d0823a52de943f629560f37b2b8434ea4599fd4d02e4c548841da3d892da168bf50b640a5562b335252f532cf65e5ac359d9228e87bf2 SHA512 ec18f3916def1f76ef58fcb1f077c8f405e86b3bc0ab660d547d5c4b4e7132495d35b4003d21ff019d660d03a14b205b74d1defb7e69f359903b4a9004f558f8
+AUX rethinkdb.confd 606 BLAKE2B 5fae810572fb4edcc55e0f20fb2c2c8e933fbcb6221ad6a398f74e24f099787f924f489c0185bb899b10e365f8e7d1384f00ceaf61921e88138dbaec5d1b0efe SHA512 3a07f9c78ef96b2ca37fca508ee14a644d3c08612f662ba5260182fbfcceba064d20253f1261f56dc0a2c28d1a4d5e2320872c3c4e7595cb7ab4e202eb28ad42
+AUX rethinkdb.initd 1645 BLAKE2B 762589fe4c4b4a73b88f0777f092c5e4b6746c4da3ac9bb738c114f2dde1bb6457d7d29e3ab7c1097faea72a18e379684d862da8d4cac537a0983caad9353203 SHA512 4449b8a4d25232a1d8f375f161d3801d67d93756bd9b3e2f33b58a87e8a257e2e94e47f8aa4a74b69df3da528ffc349f15198a939552c3b5b9ffaacc18a096a9
+AUX rethinkdb.service 261 BLAKE2B ac1f760843ebe249a5066031b5637c1375f84ee63ee23076dfcd68c3baafcf89e468bae3632e38a07fa49831f48b4751e9190e510ce9f649415edc4a332e5bf2 SHA512 70389797ae79481b7d47b45f1676bd0531bc830a2f2daf7baec87533a7a6a0e67177572bab7d42324fe719f8a056899babc5ab2358a679c6a59899ed1272374b
+AUX rethinkdb.tmpfilesd 43 BLAKE2B a294bf834c883ebca33fb289328007e144d14f0fd9c685f3f10bb209af01100347334d21e49243e83f0cf6d5ac1bcc07f49071dc2017f2606f06c9304f67e296 SHA512 5996f72b8e08aac80285373e8e1b5a664177e9d0e8d13e5638c6b821fe5b7a0368001fbfa9ef3f6709dabf0616abcabea40adc4808d176572f8f99b7a3255bae
+DIST rethinkdb-2.3.6.tgz 76787356 BLAKE2B 291f5ff7f2574329e3c96a838a2b4a5f801fae5221612f97d9c6ac250f07e8b8495ce55e9b59fa6085328ef9b9061f63c90db088175458102d2ab319b08c3be1 SHA512 653177750f7439fa1d61a121e488d578be1eab90f87c7d17ad52b9793d8543f22bbe98f8d501c2ab2d7048c65118096430fe7bde945d87c7a3228905af801af2
+EBUILD rethinkdb-2.3.6.ebuild 3887 BLAKE2B dbc1ed84b0c50ac172d9b8e2e36f2f75ce831f1c9043de5e654908a4a2789442e4c25dede7cf07c94bf4b29002c369e750834edce8596c2605e29898085fce57 SHA512 593edaccf511e503382a40cfd2e637a49706b3cb9f5235fdcb93abed619987042e785fdae795eae97d06b8ca9c630a15b3b79de2b58d3020b26b76660953e5d9
+MISC metadata.xml 584 BLAKE2B 33c0de170a389d6a2a4d705786c5534881977fe779facc6e647b30d2c4c3cd66d7b7bd5669b58623af766b69f5c86c744ef9ba89489bca1a6b5df1912512fd98 SHA512 50641820a4f298ad66ceedafcb388b8f99d2732e0e7de9c0aa412d75482488a9d382845802ea55a451c39890ff5167715f47e3346aad29992fd3bc069d097dae
diff --git a/dev-db/rethinkdb/files/rethinkdb-2.3.5-gcc6.patch b/dev-db/rethinkdb/files/rethinkdb-2.3.5-gcc6.patch
new file mode 100644
index 000000000000..e3d5eac88a45
--- /dev/null
+++ b/dev-db/rethinkdb/files/rethinkdb-2.3.5-gcc6.patch
@@ -0,0 +1,37 @@
+Bug: https://bugs.gentoo.org/594220
+Commit: https://github.com/rethinkdb/rethinkdb/commit/871bd3705a1f29c4ab07a096d562a4b06231a97c
+
+From 871bd3705a1f29c4ab07a096d562a4b06231a97c Mon Sep 17 00:00:00 2001
+From: Etienne Laurin <etienne@atnnn.com>
+Date: Wed, 16 Nov 2016 04:17:41 +0000
+Subject: [PATCH] Workaround for building V8 with GCC 6.2
+
+---
+ mk/support/pkg/v8.sh | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/mk/support/pkg/v8.sh b/mk/support/pkg/v8.sh
+index dc339ad0715..97f4d336c03 100644
+--- a/mk/support/pkg/v8.sh
++++ b/mk/support/pkg/v8.sh
+@@ -44,8 +44,10 @@ pkg_install () {
+ arm*) arch=arm; arch_gypflags=$raspberry_pi_gypflags ;;
+ *) arch=native ;;
+ esac
++
+ mode=release
+- pkg_make $arch.$mode CXX=$CXX LINK=$CXX LINK.target=$CXX GYPFLAGS="-Dwerror= $arch_gypflags" V=1
++ pkg_make $arch.$mode CXX=$CXX LINK=$CXX LINK.target=$CXX GYPFLAGS="-Dwerror= -Dv8_use_snapshot=false $arch_gypflags" V=1
++
+ for lib in `find "$build_dir/out/$arch.$mode" -maxdepth 1 -name \*.a` `find "$build_dir/out/$arch.$mode/obj.target" -name \*.a`; do
+ name=`basename $lib`
+ cp $lib "$install_dir/lib/${name/.$arch/}"
+@@ -56,7 +58,7 @@ pkg_install () {
+ pkg_link-flags () {
+ # These are the necessary libraries recommended by the docs:
+ # https://developers.google.com/v8/get_started#hello
+- for lib in libv8_{base,libbase,snapshot,libplatform}; do
++ for lib in libv8_{base,nosnapshot,libbase,libplatform}; do
+ echo "$install_dir/lib/$lib.a"
+ done
+ for lib in libicu{i18n,uc,data}; do
diff --git a/dev-db/rethinkdb/files/rethinkdb-2.3.5-libressl.patch b/dev-db/rethinkdb/files/rethinkdb-2.3.5-libressl.patch
new file mode 100644
index 000000000000..b79850b0b6b3
--- /dev/null
+++ b/dev-db/rethinkdb/files/rethinkdb-2.3.5-libressl.patch
@@ -0,0 +1,162 @@
+Bug: https://bugs.gentoo.org/594998
+Issue: https://github.com/rethinkdb/rethinkdb/issues/6336
+Patch: https://git.alpinelinux.org/cgit/aports/tree/community/rethinkdb/libressl.patch?id=146fb0d67a1b861d5c776d97f533efe0bb26af7a
+
+From d52a694a806c1a8b6dd4d7d17d0671a96240449a Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Wed, 4 Jan 2017 15:31:40 +0100
+Subject: [PATCH] Improve OpenSSL compatibility
+
+Refactor the conditionals for openssl 1.1 support so we avoid multiple
+if/else and add a check for LibreSSL as well.
+---
+ src/crypto/hash.cc | 13 +++++--------
+ src/crypto/hmac.cc | 34 ++++++++++++++++++----------------
+ src/crypto/initialization_guard.cc | 15 ++++++---------
+ 3 files changed, 29 insertions(+), 33 deletions(-)
+
+diff --git a/src/crypto/hash.cc b/src/crypto/hash.cc
+index 4427dfddeb..e035f695fc 100644
+--- a/src/crypto/hash.cc
++++ b/src/crypto/hash.cc
+@@ -8,27 +8,24 @@
+
+ #include "crypto/error.hpp"
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
++#define EVP_MD_CTX_new EVP_MD_CTX_create
++#define EVP_MD_CTX_free EVP_MD_CTX_destroy
++#endif
++
+ namespace crypto {
+
+ class evp_md_ctx_wrapper_t {
+ public:
+ evp_md_ctx_wrapper_t() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- m_evp_md_ctx = EVP_MD_CTX_create();
+-#else
+ m_evp_md_ctx = EVP_MD_CTX_new();
+-#endif
+ if (m_evp_md_ctx == nullptr) {
+ throw openssl_error_t(ERR_get_error());
+ }
+ }
+
+ ~evp_md_ctx_wrapper_t() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- EVP_MD_CTX_destroy(m_evp_md_ctx);
+-#else
+ EVP_MD_CTX_free(m_evp_md_ctx);
+-#endif
+ }
+
+ EVP_MD_CTX *get() {
+diff --git a/src/crypto/hmac.cc b/src/crypto/hmac.cc
+index 2ac4314e24..0e3f91a0c1 100644
+--- a/src/crypto/hmac.cc
++++ b/src/crypto/hmac.cc
+@@ -7,43 +7,45 @@
+
+ #include "crypto/error.hpp"
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
++
++inline HMAC_CTX *HMAC_CTX_new() {
++ HMAC_CTX *tmp = (HMAC_CTX *)OPENSSL_malloc(sizeof(HMAC_CTX));
++ if (tmp)
++ HMAC_CTX_init(tmp);
++ return tmp;
++}
++
++inline void HMAC_CTX_free(HMAC_CTX *ctx) {
++ if (ctx) {
++ HMAC_CTX_cleanup(ctx);
++ OPENSSL_free(ctx);
++ }
++}
++
++#endif
++
+ namespace crypto {
+
+ class hmac_ctx_wrapper_t {
+ public:
+ hmac_ctx_wrapper_t() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- HMAC_CTX_init(&m_hmac_ctx);
+-#else
+ m_hmac_ctx = HMAC_CTX_new();
+ if (m_hmac_ctx == nullptr) {
+ throw openssl_error_t(ERR_get_error());
+ }
+-#endif
+ }
+
+ ~hmac_ctx_wrapper_t() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- HMAC_CTX_cleanup(&m_hmac_ctx);
+-#else
+ HMAC_CTX_free(m_hmac_ctx);
+-#endif
+ }
+
+ HMAC_CTX *get() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- return &m_hmac_ctx;
+-#else
+ return m_hmac_ctx;
+-#endif
+ }
+
+ private:
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- HMAC_CTX m_hmac_ctx;
+-#else
+ HMAC_CTX *m_hmac_ctx;
+-#endif
+ };
+
+ std::array<unsigned char, SHA256_DIGEST_LENGTH> detail::hmac_sha256(
+diff --git a/src/crypto/initialization_guard.cc b/src/crypto/initialization_guard.cc
+index ba0503efc6..f76ffd96da 100644
+--- a/src/crypto/initialization_guard.cc
++++ b/src/crypto/initialization_guard.cc
+@@ -14,16 +14,17 @@
+ #include "arch/io/concurrency.hpp"
+ #include "arch/runtime/runtime.hpp"
+
++#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
++#define OPENSSL_init_ssl(x, y) SSL_library_init()
++#define OPENSSL_init_crypto(x, y) SSL_load_error_strings()
++#define OPENSSL_cleanup ERR_free_strings
++#endif
++
+ namespace crypto {
+
+ initialization_guard_t::initialization_guard_t() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- SSL_library_init();
+- SSL_load_error_strings();
+-#else
+ OPENSSL_init_ssl(0, nullptr);
+ OPENSSL_init_crypto(0, nullptr);
+-#endif
+
+ // Make OpenSSL thread-safe by registering the required callbacks
+ CRYPTO_THREADID_set_callback([](CRYPTO_THREADID *thread_out) {
+@@ -49,11 +50,7 @@ initialization_guard_t::initialization_guard_t() {
+ }
+
+ initialization_guard_t::~initialization_guard_t() {
+-#if OPENSSL_VERSION_NUMBER < 0x10100000L
+- ERR_free_strings();
+-#else
+ OPENSSL_cleanup();
+-#endif
+ }
+
+ } // namespace crypto
+--
+2.11.0
+
diff --git a/dev-db/rethinkdb/files/rethinkdb.confd b/dev-db/rethinkdb/files/rethinkdb.confd
new file mode 100644
index 000000000000..af65794a44bd
--- /dev/null
+++ b/dev-db/rethinkdb/files/rethinkdb.confd
@@ -0,0 +1,12 @@
+# !! IMPORTANT !!
+#
+# This file is ONLY used to override some of the init script configuration.
+#
+# You should NOT use this file to configure your rethinkdb instance,
+# see the /etc/rethinkdb/default.conf.sample file instead.
+#
+# Available init script modifiers :
+# - config_file : the configuration file to use (default : /etc/rethinkdb/instance.d/<instance-name>.conf)
+# - user : the user used to run your rethinkdb instance (default : rethinkdb)
+# - group : the group used to run your rethinkdb instance (default : rethinkdb)
+# - run_dir : the run directory for your PID files (default : /run/rethinkdb) \ No newline at end of file
diff --git a/dev-db/rethinkdb/files/rethinkdb.initd b/dev-db/rethinkdb/files/rethinkdb.initd
new file mode 100644
index 000000000000..9f55aa49c8e6
--- /dev/null
+++ b/dev-db/rethinkdb/files/rethinkdb.initd
@@ -0,0 +1,49 @@
+#!/sbin/openrc-run
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+instance_name=${SVCNAME/*.}
+config_file=${config_file:-/etc/rethinkdb/instances.d/${instance_name}.conf}
+run_dir=${run_dir:-/run/rethinkdb}
+
+command="/usr/bin/rethinkdb"
+command_args="--config-file ${config_file}"
+command_background="true"
+pidfile=${run_dir}/${instance_name}.pid
+user=${user:-rethinkdb}
+group=${group:-rethinkdb}
+start_stop_daemon_args="--user ${user} --group ${group} --wait 2000"
+
+depend() {
+ use net
+}
+
+start_pre() {
+ checkpath -d -m 0750 -o "${user}":"${group}" "${run_dir}"
+ if [ "${instance_name}" == "rethinkdb" ]; then
+ eerror "You should not run this default init script directly"
+ eerror "Create a symlink to an instance name"
+ eerror "and create a configuration file in /etc/rethinkdb/instances.d/"
+ eerror "then run this instance init script instead."
+ return 1
+ fi
+ if [ ! -f ${config_file} ]; then
+ eerror "Missing configuration file ${config_file}"
+ return 1
+ else
+ # respect configured directory or set a default
+ directory=$(egrep -e '^directory=' "${config_file}" | cut -d'=' -f2)
+ if [ -z "${directory}" ]; then
+ directory=/var/lib/rethinkdb/instances.d/"${instance_name}"
+ fi
+ checkpath -d -m 0750 -o "${user}":"${group}" "${directory}"
+ command_args="${command_args} --directory ${directory}"
+
+ # respect configured log-file or set a default
+ log_file=$(egrep -e '^log_file=' "${config_file}" | cut -d'=' -f2)
+ if [ -z "${log_file}" ]; then
+ log_file=/var/log/rethinkdb/"${instance_name}".log
+ fi
+ command_args="${command_args} --log-file ${log_file}"
+ fi
+}
diff --git a/dev-db/rethinkdb/files/rethinkdb.service b/dev-db/rethinkdb/files/rethinkdb.service
new file mode 100644
index 000000000000..09645c2ae6ab
--- /dev/null
+++ b/dev-db/rethinkdb/files/rethinkdb.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=RethinkDB database server for instance '%i'
+
+[Service]
+User=rethinkdb
+Group=rethinkdb
+ExecStart=/usr/bin/rethinkdb serve --config-file /etc/rethinkdb/instances.d/%i.conf
+KillMode=process
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
+
diff --git a/dev-db/rethinkdb/files/rethinkdb.tmpfilesd b/dev-db/rethinkdb/files/rethinkdb.tmpfilesd
new file mode 100644
index 000000000000..694501e8ab55
--- /dev/null
+++ b/dev-db/rethinkdb/files/rethinkdb.tmpfilesd
@@ -0,0 +1 @@
+d /run/rethinkdb 0755 rethinkdb rethinkdb - \ No newline at end of file
diff --git a/dev-db/rethinkdb/metadata.xml b/dev-db/rethinkdb/metadata.xml
new file mode 100644
index 000000000000..91224a49a819
--- /dev/null
+++ b/dev-db/rethinkdb/metadata.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <email>ultrabug@gentoo.org</email>
+ <name>Ultrabug</name>
+ </maintainer>
+ <use>
+ <flag name="jemalloc">
+ Use <pkg>dev-libs/jemalloc</pkg> for allocations (default).
+ </flag>
+ <flag name="tcmalloc">
+ Use tcmalloc from <pkg>dev-util/google-perftools</pkg> for allocations.
+ </flag>
+ </use>
+ <upstream>
+ <bugs-to>https://github.com/rethinkdb/rethinkdb/issues</bugs-to>
+ </upstream>
+</pkgmetadata>
diff --git a/dev-db/rethinkdb/rethinkdb-2.3.6.ebuild b/dev-db/rethinkdb/rethinkdb-2.3.6.ebuild
new file mode 100644
index 000000000000..3c1b8ac0ee83
--- /dev/null
+++ b/dev-db/rethinkdb/rethinkdb-2.3.6.ebuild
@@ -0,0 +1,139 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="6"
+
+inherit python-utils-r1 systemd user
+
+DESCRIPTION="The open-source database for the realtime web."
+HOMEPAGE="https://www.rethinkdb.com"
+LICENSE="AGPL-3"
+SLOT="0"
+SRC_URI="https://download.rethinkdb.com/dist/${P}.tgz"
+
+KEYWORDS="~amd64 ~x86"
+IUSE="doc +jemalloc tcmalloc"
+
+# TODO: rly need some webui libs ?
+DEPEND=">=dev-libs/re2-0.2016.05.01
+ dev-cpp/gtest
+ dev-libs/boost
+ dev-libs/protobuf-c
+ net-misc/curl
+ sys-libs/libunwind
+ sys-libs/ncurses:=
+ jemalloc? ( >=dev-libs/jemalloc-4.0 )
+ tcmalloc? ( dev-util/google-perftools )"
+RDEPEND="${DEPEND}"
+REQUIRED_USE="?? ( tcmalloc jemalloc )"
+
+pkg_setup() {
+ enewgroup rethinkdb
+ enewuser rethinkdb -1 -1 /var/lib/${PN} rethinkdb
+}
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-2.3.5-gcc6.patch
+ "${FILESDIR}"/${PN}-2.3.5-libressl.patch
+)
+
+src_prepare() {
+ default
+
+ # don't use predefined configuration
+ rm configure.default
+
+ # fix doc and init script auto installation
+ sed -e 's/ install-docs / /g' -e 's/ install-init / /g' -i mk/install.mk || die
+
+ # default config for Gentoo
+ # fix default pid-file path
+ # fix default directory path
+ # fix default log-file path
+ sed -e 's@/var/run/@/run/@g' \
+ -e 's@/var/lib/rethinkdb/@/var/lib/rethinkdb/instances.d/@g' \
+ -e 's@/var/log/rethinkdb@/var/log/rethinkdb/default.log@g' \
+ -i packaging/assets/config/default.conf.sample || die
+
+ # proper CXX declaration
+ sed -e "s/CXX=\$(.*/CXX=$(tc-getCXX)/g" -i configure || die
+
+ # respect user CXXFLAGS optimizations
+ sed -e 's/-O3//g' -i src/build.mk || die
+}
+
+src_configure() {
+ local conf_opts=(
+ --prefix="/usr"
+ --sysconfdir="/etc"
+ --localstatedir="/var"
+ --static=none
+ --dynamic=gtest
+ --dynamic=re2
+ )
+ if use jemalloc; then
+ conf_opts+=(--with-jemalloc)
+ elif use tcmalloc; then
+ conf_opts+=(--with-tcmalloc)
+ else
+ conf_opts+=(--with-system-malloc)
+ fi
+ ./configure "${conf_opts[@]}"
+}
+
+src_compile() {
+ python_export python2.7 EPYTHON
+ emake VERBOSE=1
+}
+
+src_install() {
+ emake DESTDIR="${D}" VERBOSE=1 install
+
+ for x in /var/{lib,log}/${PN}; do
+ keepdir "${x}"
+ fowners rethinkdb:rethinkdb "${x}"
+ done
+
+ newconfd "${FILESDIR}/rethinkdb.confd" rethinkdb
+ newinitd "${FILESDIR}/rethinkdb.initd" rethinkdb
+
+ systemd_newunit "${FILESDIR}/"${PN}.service "rethinkdb@.service"
+ systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd "rethinkdb.conf"
+
+ use doc && dodoc COPYRIGHT NOTES.md README.md
+}
+
+pkg_config() {
+ einfo "This will prepare a new RethinkDB instance. Press Control-C to abort."
+
+ einfo "Enter the name for the new instance: "
+ read instance_name
+ [[ -z "${instance_name}" ]] && die "Invalid instance name"
+
+ local instance_data="/var/lib/rethinkdb/instances.d/${instance_name}"
+ local instance_config="/etc/rethinkdb/instances.d/${instance_name}.conf"
+ if [[ -e "${instance_data}" || -e "${instance_config}" ]]; then
+ eerror "An instance with the same name already exists:"
+ eerror "Check ${instance_data} or ${instance_config}."
+ die "Instance already exists"
+ fi
+
+ /usr/bin/rethinkdb create -d "${instance_data}" &>/dev/null \
+ || die "Creating instance failed"
+ chown -R rethinkdb:rethinkdb "${instance_data}" \
+ || die "Correcting permissions for instance failed"
+ cp /etc/rethinkdb/default.conf.sample "${instance_config}" \
+ || die "Creating configuration file failed"
+ sed -e "s:^# \(directory=\).*$:\1${instance_data}:" \
+ -i "${instance_config}" \
+ || die "Modifying configuration file failed"
+ ln -s /etc/init.d/rethinkdb "/etc/init.d/rethinkdb.${instance_name}" \
+ || die "Creating init script symlink failed"
+
+ einfo "Successfully created the instance at ${instance_data}."
+ einfo "To change the default settings edit the configuration file:"
+ einfo "${instance_config}"
+ einfo " "
+ einfo "To start your instance, run:"
+ einfo "/etc/init.d/rethinkdb.${instance_name} start"
+}