8291fe7fc50d43762e9d3210b79a6921b73e25e9
[gentoo.git] / dev-db / mongodb / mongodb-3.6.1-r1.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 )
7
8 SCONS_MIN_VERSION="2.5.0"
9 CHECKREQS_DISK_BUILD="2400M"
10 CHECKREQS_DISK_USR="512M"
11 CHECKREQS_MEMORY="1024M"
12
13 inherit check-reqs eutils flag-o-matic multilib multiprocessing pax-utils python-single-r1 scons-utils systemd toolchain-funcs user versionator
14
15 MY_P=${PN}-src-r${PV/_rc/-rc}
16
17 DESCRIPTION="A high-performance, open source, schema-free document-oriented database"
18 HOMEPAGE="https://www.mongodb.com"
19 SRC_URI="https://fastdl.mongodb.org/src/${MY_P}.tar.gz"
20
21 LICENSE="AGPL-3 Apache-2.0"
22 SLOT="0"
23 KEYWORDS="~amd64 ~x86"
24 IUSE="debug kerberos libressl mms-agent ssl test +tools"
25
26 RDEPEND=">=app-arch/snappy-1.1.3
27         >=dev-cpp/yaml-cpp-0.5.3
28         >=dev-libs/boost-1.60:=[threads(+)]
29         >=dev-libs/libpcre-8.41[cxx]
30         dev-libs/snowball-stemmer
31         net-libs/libpcap
32         >=sys-libs/zlib-1.2.8:=
33         mms-agent? ( app-admin/mms-agent )
34         ssl? (
35                 !libressl? ( >=dev-libs/openssl-1.0.1g:0= )
36                 libressl? ( dev-libs/libressl:0= )
37         )"
38 DEPEND="${RDEPEND}
39         ${PYTHON_DEPS}
40         dev-python/cheetah[${PYTHON_USEDEP}]
41         dev-python/pyyaml[${PYTHON_USEDEP}]
42         dev-python/typing[${PYTHON_USEDEP}]
43         <dev-util/scons-3
44         sys-libs/ncurses
45         sys-libs/readline
46         debug? ( dev-util/valgrind )
47         kerberos? ( dev-libs/cyrus-sasl[kerberos] )
48         test? (
49                 dev-python/pymongo[${PYTHON_USEDEP}]
50         )"
51 PDEPEND="tools? ( >=app-admin/mongo-tools-${PV} )"
52
53 PATCHES=(
54         "${FILESDIR}/${PN}-3.4.7-no-boost-check.patch"
55         "${FILESDIR}/${PN}-3.6.1-fix-scons.patch"
56         "${FILESDIR}/${PN}-3.6.1-no-compass.patch"
57 )
58
59 S=${WORKDIR}/${MY_P}
60
61 pkg_pretend() {
62         if [[ -n ${REPLACING_VERSIONS} ]] && [[ ${REPLACING_VERSIONS} < 3.4 ]]; then
63                 ewarn "To upgrade from a version earlier than the 3.4-series, you must"
64                 ewarn "successively upgrade major releases until you have upgraded"
65                 ewarn "to 3.4-series. Then upgrade to 3.6 series."
66         fi
67 }
68
69 pkg_setup() {
70         enewgroup mongodb
71         enewuser mongodb -1 -1 /var/lib/${PN} mongodb
72
73         python-single-r1_pkg_setup
74 }
75
76 src_prepare() {
77         default
78
79         # remove bundled libs
80         rm -rv src/third_party/{boost-*,pcre-*,scons-*,snappy-*,yaml-cpp-*,zlib-*} || die
81
82         # remove compass
83         rm -rv src/mongo/installer/compass || die
84 }
85
86 src_configure() {
87         # --use-system-icu fails tests
88         # --use-system-tcmalloc is strongly NOT recommended:
89         # https://www.mongodb.org/about/contributors/tutorial/build-mongodb-from-source/
90         scons_opts=(
91                 CC="$(tc-getCC)"
92                 CXX="$(tc-getCXX)"
93
94                 --disable-warnings-as-errors
95                 --use-system-boost
96                 --use-system-pcre
97                 --use-system-snappy
98                 --use-system-stemmer
99                 --use-system-yaml
100                 --use-system-zlib
101         )
102
103         use debug && scons_opts+=( --dbg=on )
104         use kerberos && scons_opts+=( --use-sasl-client )
105         use ssl && scons_opts+=( --ssl )
106
107         # wiredtiger not supported on 32bit platforms #572166
108         use x86 && scons_opts+=( --wiredtiger=off )
109
110         # respect mongoDB upstream's basic recommendations
111         # see bug #536688 and #526114
112         if ! use debug; then
113                 filter-flags '-m*'
114                 filter-flags '-O?'
115         fi
116
117         default
118 }
119
120 src_compile() {
121         escons "${scons_opts[@]}" core tools
122 }
123
124 # FEATURES="test -usersandbox" emerge dev-db/mongodb
125 src_test() {
126         "${EPYTHON}" ./buildscripts/resmoke.py --dbpathPrefix=test --suites core --jobs=$(makeopts_jobs) || die "Tests failed"
127 }
128
129 src_install() {
130         escons "${scons_opts[@]}" --nostrip install --prefix="${ED}"/usr
131
132         local x
133         for x in /var/{lib,log}/${PN}; do
134                 keepdir "${x}"
135                 fowners mongodb:mongodb "${x}"
136                 fperms 0750 "${x}"
137         done
138
139         doman debian/mongo*.1
140         dodoc README docs/building.md
141
142         newinitd "${FILESDIR}/${PN}.initd-r3" ${PN}
143         newconfd "${FILESDIR}/${PN}.confd-r3" ${PN}
144         newinitd "${FILESDIR}/${PN/db/s}.initd-r3" ${PN/db/s}
145         newconfd "${FILESDIR}/${PN/db/s}.confd-r3" ${PN/db/s}
146
147         insinto /etc
148         newins "${FILESDIR}/${PN}.conf-r3" ${PN}.conf
149         newins "${FILESDIR}/${PN/db/s}.conf-r2" ${PN/db/s}.conf
150
151         systemd_dounit "${FILESDIR}/${PN}.service"
152
153         insinto /etc/logrotate.d/
154         newins "${FILESDIR}/${PN}.logrotate" ${PN}
155
156         # see bug #526114
157         pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
158 }
159
160 pkg_preinst() {
161         # wrt bug #461466
162         if [[ "$(get_libdir)" == "lib64" ]]; then
163                 rmdir "${ED}"/usr/lib/ &>/dev/null
164         fi
165 }
166
167 pkg_postinst() {
168         ewarn "Make sure to read the release notes and follow the upgrade process:"
169         ewarn "  https://docs.mongodb.com/manual/release-notes/$(get_version_component_range 1-2)/"
170         ewarn "  https://docs.mongodb.com/manual/release-notes/$(get_version_component_range 1-2)/#upgrade-procedures"
171 }