Merge remote-tracking branch 'github/pr/694'.
[gentoo.git] / dev-db / mongodb / mongodb-3.0.6-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 SCONS_MIN_VERSION="2.3.0"
7 CHECKREQS_DISK_BUILD="2400M"
8 CHECKREQS_DISK_USR="512M"
9 CHECKREQS_MEMORY="1024M"
10
11 inherit eutils flag-o-matic multilib pax-utils scons-utils systemd user versionator check-reqs
12
13 MY_P=${PN}-src-r${PV/_rc/-rc}
14
15 DESCRIPTION="A high-performance, open source, schema-free document-oriented database"
16 HOMEPAGE="http://www.mongodb.org"
17 SRC_URI="http://downloads.mongodb.org/src/${MY_P}.tar.gz"
18
19 LICENSE="AGPL-3 Apache-2.0"
20 SLOT="0"
21 KEYWORDS="~amd64 ~x86"
22 IUSE="debug kerberos libressl mms-agent ssl +tools"
23
24 RDEPEND="app-arch/snappy
25         >=dev-cpp/yaml-cpp-0.5.1
26         >=dev-libs/boost-1.57[threads(+)]
27         >=dev-libs/libpcre-8.30[cxx]
28         dev-libs/snowball-stemmer
29         net-libs/libpcap
30         sys-libs/zlib
31         mms-agent? ( app-admin/mms-agent )
32         ssl? (
33                 !libressl? ( >=dev-libs/openssl-1.0.1g:0= )
34                 libressl? ( dev-libs/libressl:= )
35         )"
36 DEPEND="${RDEPEND}
37         >=sys-devel/gcc-4.8.2:*
38         sys-libs/ncurses
39         sys-libs/readline
40         kerberos? ( dev-libs/cyrus-sasl[kerberos] )"
41 PDEPEND="tools? ( >=app-admin/mongo-tools-${PV} )"
42
43 S=${WORKDIR}/${MY_P}
44
45 pkg_setup() {
46         enewgroup mongodb
47         enewuser mongodb -1 -1 /var/lib/${PN} mongodb
48
49         # Maintainer notes
50         #
51         # --use-system-tcmalloc is strongly NOT recommended:
52         # https://www.mongodb.org/about/contributors/tutorial/build-mongodb-from-source/
53         #
54         # --c++11 is required by scons instead of auto detection:
55         # https://jira.mongodb.org/browse/SERVER-19661
56
57         scons_opts="--variant-dir=build --cc=$(tc-getCC) --cxx=$(tc-getCXX) --c++11"
58         scons_opts+=" --disable-warnings-as-errors"
59         scons_opts+=" --use-system-boost"
60         scons_opts+=" --use-system-pcre"
61         scons_opts+=" --use-system-snappy"
62         scons_opts+=" --use-system-stemmer"
63         scons_opts+=" --use-system-yaml"
64
65         if use debug; then
66                 scons_opts+=" --dbg=on"
67         fi
68
69         if use prefix; then
70                 scons_opts+=" --cpppath=${EPREFIX}/usr/include"
71                 scons_opts+=" --libpath=${EPREFIX}/usr/$(get_libdir)"
72         fi
73
74         if use kerberos; then
75                 scons_opts+=" --use-sasl-client"
76         fi
77
78         if use ssl; then
79                 scons_opts+=" --ssl"
80         fi
81 }
82
83 src_prepare() {
84         epatch "${FILESDIR}/${PN}-3.0.0-fix-scons.patch"
85 }
86
87 src_compile() {
88         # respect mongoDB upstream's basic recommendations
89         # see bug #536688 and #526114
90         if ! use debug; then
91                 filter-flags '-m*'
92                 filter-flags '-O?'
93         fi
94         escons ${scons_opts} core tools
95 }
96
97 src_install() {
98         escons ${scons_opts} --nostrip install --prefix="${ED}"/usr
99
100         for x in /var/{lib,log}/${PN}; do
101                 keepdir "${x}"
102                 fowners mongodb:mongodb "${x}"
103         done
104
105         doman debian/mongo*.1
106         dodoc README docs/building.md
107
108         newinitd "${FILESDIR}/${PN}.initd-r2" ${PN}
109         newconfd "${FILESDIR}/${PN}.confd-r2" ${PN}
110         newinitd "${FILESDIR}/${PN/db/s}.initd-r2" ${PN/db/s}
111         newconfd "${FILESDIR}/${PN/db/s}.confd-r2" ${PN/db/s}
112
113         insinto /etc
114         newins "${FILESDIR}/${PN}.conf-r3" ${PN}.conf
115         newins "${FILESDIR}/${PN/db/s}.conf-r2" ${PN/db/s}.conf
116
117         systemd_dounit "${FILESDIR}/${PN}.service"
118
119         insinto /etc/logrotate.d/
120         newins "${FILESDIR}/${PN}.logrotate" ${PN}
121
122         # see bug #526114
123         pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
124 }
125
126 pkg_preinst() {
127         # wrt bug #461466
128         if [[ "$(get_libdir)" == "lib64" ]]; then
129                 rmdir "${ED}"/usr/lib/ &>/dev/null
130         fi
131 }
132
133 src_test() {
134         escons ${scons_opts} dbtest
135         "${S}"/dbtest --dbpath=unittest || die "dbtest failed"
136         escons ${scons_opts} smokeCppUnittests --smokedbprefix="smokecpptest" || die "smokeCppUnittests tests failed"
137 }
138
139 pkg_postinst() {
140         if [[ ${REPLACING_VERSIONS} < 3.0 ]]; then
141                 ewarn "!! IMPORTANT !!"
142                 ewarn " "
143                 ewarn "${PN} configuration files have changed !"
144                 ewarn " "
145                 ewarn "Make sure you migrate from /etc/conf.d/${PN} to the new YAML standard in /etc/${PN}.conf"
146                 ewarn "  http://docs.mongodb.org/manual/reference/configuration-options/"
147                 ewarn " "
148                 ewarn "Make sure you also follow the upgrading process :"
149                 ewarn "  http://docs.mongodb.org/master/release-notes/3.0-upgrade/"
150                 ewarn " "
151                 ewarn "MongoDB 3.0 introduces the WiredTiger storage engine."
152                 ewarn "WiredTiger is incompatible with MMAPv1 and you need to dump/reload your data if you want to use it."
153                 ewarn "Once you have your data dumped, you need to set storage.engine: wiredTiger in /etc/${PN}.conf"
154                 ewarn "  http://docs.mongodb.org/master/release-notes/3.0-upgrade/#change-storage-engine-to-wiredtiger"
155         fi
156 }