Gentoo Archives: gentoo-commits

From: Alexys Jacob <ultrabug@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/rethinkdb/, dev-db/rethinkdb/files/
Date: Fri, 02 Sep 2016 06:45:43
Message-Id: 1472797994.c6ff4058cf235d3fa9754e5fa4484dd43699abbf.ultrabug@gentoo
1 commit: c6ff4058cf235d3fa9754e5fa4484dd43699abbf
2 Author: Ultrabug <ultrabug <AT> gentoo <DOT> org>
3 AuthorDate: Fri Sep 2 06:32:47 2016 +0000
4 Commit: Alexys Jacob <ultrabug <AT> gentoo <DOT> org>
5 CommitDate: Fri Sep 2 06:33:14 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c6ff4058
7
8 dev-db/rethinkdb: new package
9
10 Package-Manager: portage-2.2.27
11
12 dev-db/rethinkdb/Manifest | 1 +
13 dev-db/rethinkdb/files/rethinkdb.confd | 12 +++
14 dev-db/rethinkdb/files/rethinkdb.initd | 50 +++++++++++
15 dev-db/rethinkdb/files/rethinkdb.service | 13 +++
16 dev-db/rethinkdb/files/rethinkdb.tmpfilesd | 1 +
17 dev-db/rethinkdb/metadata.xml | 19 +++++
18 dev-db/rethinkdb/rethinkdb-2.3.4.ebuild | 133 +++++++++++++++++++++++++++++
19 7 files changed, 229 insertions(+)
20
21 diff --git a/dev-db/rethinkdb/Manifest b/dev-db/rethinkdb/Manifest
22 new file mode 100644
23 index 00000000..ae41ede
24 --- /dev/null
25 +++ b/dev-db/rethinkdb/Manifest
26 @@ -0,0 +1 @@
27 +DIST rethinkdb-2.3.4.tgz 76811758 SHA256 93a7927d1ed785d084be3b8bac3f9af2d89c86de16e003848acbe21a32a9e1a7 SHA512 47e62ef57de112129b7409027017882bc31bb2403287845253a0fe0f61d0977f2e37ba487506853ed3421ac57b2558cabde4f8aee4b9723e4c61300b447e1e19 WHIRLPOOL ce956ad5b7f5f6a38500e501b104571d819e0292cfd1a922ef4f6395ad4e48242456759dad399f5ed2048dee6680df645f54b8ef18e2eebc7f904abe5a2be91c
28
29 diff --git a/dev-db/rethinkdb/files/rethinkdb.confd b/dev-db/rethinkdb/files/rethinkdb.confd
30 new file mode 100644
31 index 00000000..af65794
32 --- /dev/null
33 +++ b/dev-db/rethinkdb/files/rethinkdb.confd
34 @@ -0,0 +1,12 @@
35 +# !! IMPORTANT !!
36 +#
37 +# This file is ONLY used to override some of the init script configuration.
38 +#
39 +# You should NOT use this file to configure your rethinkdb instance,
40 +# see the /etc/rethinkdb/default.conf.sample file instead.
41 +#
42 +# Available init script modifiers :
43 +# - config_file : the configuration file to use (default : /etc/rethinkdb/instance.d/<instance-name>.conf)
44 +# - user : the user used to run your rethinkdb instance (default : rethinkdb)
45 +# - group : the group used to run your rethinkdb instance (default : rethinkdb)
46 +# - run_dir : the run directory for your PID files (default : /run/rethinkdb)
47 \ No newline at end of file
48
49 diff --git a/dev-db/rethinkdb/files/rethinkdb.initd b/dev-db/rethinkdb/files/rethinkdb.initd
50 new file mode 100644
51 index 00000000..193f071
52 --- /dev/null
53 +++ b/dev-db/rethinkdb/files/rethinkdb.initd
54 @@ -0,0 +1,50 @@
55 +#!/sbin/openrc-run
56 +# Copyright 1999-2016 Gentoo Foundation
57 +# Distributed under the terms of the GNU General Public License v2
58 +# $Id$
59 +
60 +instance_name=${SVCNAME/*.}
61 +config_file=${config_file:-/etc/rethinkdb/instances.d/${instance_name}.conf}
62 +run_dir=${run_dir:-/run/rethinkdb}
63 +
64 +command="/usr/bin/rethinkdb"
65 +command_args="--config-file ${config_file}"
66 +command_background="true"
67 +pidfile=${run_dir}/${instance_name}.pid
68 +user=${user:-rethinkdb}
69 +group=${group:-rethinkdb}
70 +start_stop_daemon_args="--user ${user} --group ${group} --wait 2000"
71 +
72 +depend() {
73 + use net
74 +}
75 +
76 +start_pre() {
77 + checkpath -d -m 0750 -o "${user}":"${group}" "${run_dir}"
78 + if [ "${instance_name}" == "rethinkdb" ]; then
79 + eerror "You should not run this default init script directly"
80 + eerror "Create a symlink to an instance name"
81 + eerror "and create a configuration file in /etc/rethinkdb/instances.d/"
82 + eerror "then run this instance init script instead."
83 + return 1
84 + fi
85 + if [ ! -f ${config_file} ]; then
86 + eerror "Missing configuration file ${config_file}"
87 + return 1
88 + else
89 + # respect configured directory or set a default
90 + directory=$(egrep -e '^directory=' "${config_file}" | cut -d'=' -f2)
91 + if [ -z "${directory}" ]; then
92 + directory=/var/lib/rethinkdb/instances.d/"${instance_name}"
93 + fi
94 + checkpath -d -m 0750 -o "${user}":"${group}" "${directory}"
95 + command_args="${command_args} --directory ${directory}"
96 +
97 + # respect configured log-file or set a default
98 + log_file=$(egrep -e '^log_file=' "${config_file}" | cut -d'=' -f2)
99 + if [ -z "${log_file}" ]; then
100 + log_file=/var/log/rethinkdb/"${instance_name}".log
101 + fi
102 + command_args="${command_args} --log-file ${log_file}"
103 + fi
104 +}
105
106 diff --git a/dev-db/rethinkdb/files/rethinkdb.service b/dev-db/rethinkdb/files/rethinkdb.service
107 new file mode 100644
108 index 00000000..09645c2
109 --- /dev/null
110 +++ b/dev-db/rethinkdb/files/rethinkdb.service
111 @@ -0,0 +1,13 @@
112 +[Unit]
113 +Description=RethinkDB database server for instance '%i'
114 +
115 +[Service]
116 +User=rethinkdb
117 +Group=rethinkdb
118 +ExecStart=/usr/bin/rethinkdb serve --config-file /etc/rethinkdb/instances.d/%i.conf
119 +KillMode=process
120 +PrivateTmp=true
121 +
122 +[Install]
123 +WantedBy=multi-user.target
124 +
125
126 diff --git a/dev-db/rethinkdb/files/rethinkdb.tmpfilesd b/dev-db/rethinkdb/files/rethinkdb.tmpfilesd
127 new file mode 100644
128 index 00000000..694501e
129 --- /dev/null
130 +++ b/dev-db/rethinkdb/files/rethinkdb.tmpfilesd
131 @@ -0,0 +1 @@
132 +d /run/rethinkdb 0755 rethinkdb rethinkdb -
133 \ No newline at end of file
134
135 diff --git a/dev-db/rethinkdb/metadata.xml b/dev-db/rethinkdb/metadata.xml
136 new file mode 100644
137 index 00000000..91224a4
138 --- /dev/null
139 +++ b/dev-db/rethinkdb/metadata.xml
140 @@ -0,0 +1,19 @@
141 +<?xml version="1.0" encoding="UTF-8"?>
142 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
143 +<pkgmetadata>
144 + <maintainer type="person">
145 + <email>ultrabug@g.o</email>
146 + <name>Ultrabug</name>
147 + </maintainer>
148 + <use>
149 + <flag name="jemalloc">
150 + Use <pkg>dev-libs/jemalloc</pkg> for allocations (default).
151 + </flag>
152 + <flag name="tcmalloc">
153 + Use tcmalloc from <pkg>dev-util/google-perftools</pkg> for allocations.
154 + </flag>
155 + </use>
156 + <upstream>
157 + <bugs-to>https://github.com/rethinkdb/rethinkdb/issues</bugs-to>
158 + </upstream>
159 +</pkgmetadata>
160
161 diff --git a/dev-db/rethinkdb/rethinkdb-2.3.4.ebuild b/dev-db/rethinkdb/rethinkdb-2.3.4.ebuild
162 new file mode 100644
163 index 00000000..cbd2f67
164 --- /dev/null
165 +++ b/dev-db/rethinkdb/rethinkdb-2.3.4.ebuild
166 @@ -0,0 +1,133 @@
167 +# Copyright 1999-2016 Gentoo Foundation
168 +# Distributed under the terms of the GNU General Public License v2
169 +# $Id$
170 +
171 +EAPI="6"
172 +
173 +inherit systemd user
174 +
175 +DESCRIPTION="The open-source database for the realtime web."
176 +HOMEPAGE="http://www.rethinkdb.com"
177 +LICENSE="AGPL-3"
178 +SLOT="0"
179 +SRC_URI="http://download.rethinkdb.com/dist/${P}.tgz"
180 +
181 +KEYWORDS="~amd64 ~x86"
182 +IUSE="doc +jemalloc tcmalloc"
183 +
184 +# TODO: rly need some webui libs ?
185 +DEPEND="dev-cpp/gtest
186 + dev-libs/boost
187 + dev-libs/protobuf-c
188 + >=dev-libs/re2-0.2016.05.01
189 + sys-libs/libunwind
190 + sys-libs/ncurses:=
191 + jemalloc? ( >=dev-libs/jemalloc-3.2 )
192 + tcmalloc? ( dev-util/google-perftools )"
193 +RDEPEND="${DEPEND}"
194 +REQUIRED_USE="?? ( tcmalloc jemalloc )"
195 +
196 +pkg_setup() {
197 + enewgroup rethinkdb
198 + enewuser rethinkdb -1 -1 /var/lib/${PN} rethinkdb
199 +}
200 +
201 +src_prepare() {
202 + eapply_user
203 +
204 + # don't use predefined configuration
205 + rm configure.default
206 +
207 + # fix doc and init script auto installation
208 + sed -e 's/ install-docs / /g' -e 's/ install-init / /g' -i mk/install.mk || die
209 +
210 + # default config for Gentoo
211 + # fix default pid-file path
212 + # fix default directory path
213 + # fix default log-file path
214 + sed -e 's@/var/run/@/run/@g' \
215 + -e 's@/var/lib/rethinkdb/@/var/lib/rethinkdb/instances.d/@g' \
216 + -e 's@/var/log/rethinkdb@/var/log/rethinkdb/default.log@g' \
217 + -i packaging/assets/config/default.conf.sample || die
218 +
219 + # proper CXX declaration
220 + sed -e "s/CXX=\$(.*/CXX=$(tc-getCXX)/g" -i configure || die
221 +
222 + # respect user CXXFLAGS optimizations
223 + sed -e 's/-O3//g' -i src/build.mk || die
224 +}
225 +
226 +src_configure() {
227 + local conf_opts=(
228 + --prefix="/usr"
229 + --sysconfdir="/etc"
230 + --localstatedir="/var"
231 + --static=none
232 + --dynamic=gtest
233 + --dynamic=re2
234 + )
235 + if use jemalloc; then
236 + conf_opts+=(--with-jemalloc)
237 + elif use tcmalloc; then
238 + conf_opts+=(--with-tcmalloc)
239 + else
240 + conf_opts+=(--with-system-malloc)
241 + fi
242 + ./configure "${conf_opts[@]}"
243 +}
244 +
245 +src_compile() {
246 + emake VERBOSE=1
247 +}
248 +
249 +src_install() {
250 + emake DESTDIR="${D}" VERBOSE=1 install
251 +
252 + for x in /var/{lib,log}/${PN}; do
253 + keepdir "${x}"
254 + fowners rethinkdb:rethinkdb "${x}"
255 + done
256 +
257 + newconfd "${FILESDIR}/rethinkdb.confd" rethinkdb
258 + newinitd "${FILESDIR}/rethinkdb.initd" rethinkdb
259 +
260 + systemd_newunit "${FILESDIR}/"${PN}.service "rethinkdb@.service"
261 + systemd_newtmpfilesd "${FILESDIR}"/${PN}.tmpfilesd "rethinkdb.conf"
262 +
263 + use doc && dodoc COPYRIGHT NOTES.md README.md
264 +}
265 +
266 +pkg_config() {
267 + einfo "This will prepare a new RethinkDB instance. Press Control-C to abort."
268 +
269 + einfo "Enter the name for the new instance: "
270 + read instance_name
271 + [[ -z "${instance_name}" ]] && die "Invalid instance name"
272 +
273 + local instance_data="/var/lib/rethinkdb/instances.d/${instance_name}"
274 + local instance_config="/etc/rethinkdb/instances.d/${instance_name}.conf"
275 + if [[ -e "${instance_data}" || -e "${instance_config}" ]]; then
276 + eerror "An instance with the same name already exists:"
277 + eerror "Check ${instance_data} or ${instance_config}."
278 + die "Instance already exists"
279 + fi
280 +
281 + /usr/bin/rethinkdb create -d "${instance_data}" &>/dev/null \
282 + || die "Creating instance failed"
283 + chown -R rethinkdb:rethinkdb "${instance_data}" \
284 + || die "Correcting permissions for instance failed"
285 + cp /etc/rethinkdb/default.conf.sample "${instance_config}" \
286 + || die "Creating configuration file failed"
287 + sed -e "s:^# \(directory=\).*$:\1${instance_data}:" \
288 + -i "${instance_config}" \
289 + || die "Modifying configuration file failed"
290 + ln -s /etc/init.d/rethinkdb "/etc/init.d/rethinkdb.${instance_name}" \
291 + || die "Creating init script symlink failed"
292 +
293 + einfo "Successfully created the instance at ${instance_data}."
294 + einfo "To change the default settings edit the configuration file:"
295 + einfo "${instance_config}"
296 + einfo " "
297 + einfo "To start your instance, run:"
298 + einfo "/etc/init.d/rethinkdb.${instance_name}"
299 +}