1 # Copyright 1999-2023 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python3_{9..11} )
8 CHECKREQS_DISK_BUILD="27000M"
9 CHECKREQS_DISK_USR="512M"
10 CHECKREQS_MEMORY="4092M"
12 inherit check-reqs multiprocessing pax-utils python-any-r1 systemd toolchain-funcs
16 DESCRIPTION="A high-performance, open source, schema-free document-oriented database"
17 HOMEPAGE="https://www.mongodb.com"
18 LICENSE="Apache-2.0 SSPL-1"
21 CPU_FLAGS="cpu_flags_x86_avx"
22 IUSE="debug kerberos lto mongosh ssl gold +tools ocsp-stapling server-js tcmalloc tcmalloc-experimental"
23 IUSE+=" free-mon http-client runtime-hardening experimental-optimization experimental-runtime-hardening"
25 SRC_URI="https://github.com/mongodb/mongo/archive/r${MY_P}.tar.gz"
28 experimental-runtime-hardening? ( runtime-hardening )
29 tcmalloc? ( !tcmalloc-experimental )
32 # https://github.com/mongodb/mongo/wiki/Test-The-Mongodb-Server
33 # resmoke needs python packages not yet present in Gentoo
36 RDEPEND="acct-group/mongodb
38 >=app-arch/snappy-1.1.3:=
39 >=dev-cpp/yaml-cpp-0.6.2:=
40 >=dev-libs/boost-1.70:=[threads(+),nls]
41 >=dev-libs/libpcre-8.42[cxx]
43 dev-libs/snowball-stemmer:=
45 >=sys-libs/zlib-1.2.11:=
46 kerberos? ( dev-libs/cyrus-sasl[kerberos] )
47 http-client? ( net-misc/curl )
48 gold? ( sys-devel/binutils:=[gold] )
50 >=dev-libs/openssl-1.0.1g:0=
56 $(python_gen_any_dep '
57 >=dev-util/scons-4.3.0[${PYTHON_USEDEP}]
58 dev-python/cheetah3[${PYTHON_USEDEP}]
59 dev-python/psutil[${PYTHON_USEDEP}]
60 dev-python/pyyaml[${PYTHON_USEDEP}]
61 dev-python/packaging[${PYTHON_USEDEP}]
62 dev-python/pymongo[${PYTHON_USEDEP}]
66 debug? ( dev-util/valgrind )
71 mongosh? ( app-admin/mongosh-bin )
72 tools? ( >=app-admin/mongo-tools-100 )
75 #PATCHES=( ${FILESDIR}/mongodb-5.0.2-skip-reqs-check.patch )
78 has_version ">=dev-util/scons-4.3.0[${PYTHON_USEDEP}]" &&
79 has_version "dev-python/cheetah3[${PYTHON_USEDEP}]" &&
80 has_version "dev-python/psutil[${PYTHON_USEDEP}]" &&
81 has_version "dev-python/pyyaml[${PYTHON_USEDEP}]" &&
82 has_version "dev-python/packaging[${PYTHON_USEDEP}]"
85 S=${WORKDIR}/mongo-r${MY_P}
88 if ! use cpu_flags_x86_avx; then
89 eerror "MongoDB ${MY_P} requires use of the AVX instruction set"
90 eerror "https://docs.mongodb.com/v5.0/administration/production-notes/"
91 die "MongoDB requires AVX"
94 check-reqs_pkg_pretend
103 AR="$(command -v ar)" # use realpath because scons cannot find them
104 CC="$(command -v gcc)"
105 CXX="$(command -v g++)"
106 CCFLAGS="-march=native -pipe -DBOOST_LOG_DYN_LINK ${CCFLAGS}"
107 MONGO_VERSION=${MY_P}
109 --jobs=$(makeopts_jobs)
111 --disable-warnings-as-errors
119 --use-diagnostic-latches=on
120 --use-hardware-crc32=on
127 --visibility-support=on
128 --enable-usdt-probes=off
132 scons_opts+=( --ssl=on )
134 scons_opts+=( --ssl=off )
137 if use free-mon; then
138 scons_opts+=( --enable-free-mon=on )
140 scons_opts+=( --enable-free-mon=off )
144 scons_opts+=( --linker=gold )
146 scons_opts+=( --linker=bfd )
149 if use http-client; then
150 scons_opts+=( --enable-http-client=on )
152 scons_opts+=( --enable-http-client=off )
155 if use ocsp-stapling; then
156 scons_opts+=( --ocsp-stapling=on )
158 scons_opts+=( --ocsp-stapling=off )
161 if use kerberos; then
162 scons_opts+=( --use-sasl-client )
165 if use tcmalloc; then
166 scons_opts+=( --allocator=tcmalloc )
167 elif use tcmalloc-experimental; then
168 scons_opts+=( --allocator=tcmalloc-experimental )
170 scons_opts+=( --allocator=system )
173 if use server-js; then
186 scons_opts+=( --lto=on )
188 scons_opts+=( --lto=off )
191 if use experimental-optimization; then
193 --experimental-optimization="*"
194 --experimental-optimization="-sandybridge"
198 if use runtime-hardening; then
199 scons_opts+=( --runtime-hardening=on )
200 if use experimental-runtime-hardening; then
201 scons_opts+=( --experimental-runtime-hardening="*" )
204 scons_opts+=( --runtime-hardening=off )
208 scons_opts+=( --dbg=on )
210 scons_opts+=( --dbg=off )
218 python3 -m pip install --target ./site_scons requirements_parser
219 python3 -m pip install --target ./site_scons -r etc/pip/compile-requirements.txt
221 PREFIX="${EPREFIX}/usr" ./buildscripts/scons.py "${scons_opts[@]}" install-core || die
223 $(tc-getSTRIP) "--strip-unneeded" "${S}/build/install/bin/mongo"
224 $(tc-getSTRIP) "--strip-unneeded" "${S}/build/install/bin/mongod"
225 $(tc-getSTRIP) "--strip-unneeded" "${S}/build/install/bin/mongos"
229 dobin build/install/bin/{mongo,mongod,mongos}
231 doman debian/mongo*.1
232 dodoc build/install/README docs/building.md
234 newinitd "${FILESDIR}/${PN}.initd-r3" ${PN}
235 newconfd "${FILESDIR}/${PN}.confd-r3" ${PN}
236 newinitd "${FILESDIR}/mongos.initd-r3" mongos
237 newconfd "${FILESDIR}/mongos.confd-r3" mongos
240 newins "${FILESDIR}/${PN}.conf-r3" ${PN}.conf
241 newins "${FILESDIR}/mongos.conf-r2" mongos.conf
243 systemd_dounit "${FILESDIR}/${PN}.service"
245 insinto /etc/logrotate.d/
246 newins "${FILESDIR}/${PN}.logrotate" ${PN}
249 pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
252 for x in /var/{lib,log}/${PN}; do
253 diropts -m0750 -o mongodb -g mongodb
259 ewarn "Make sure to read the release notes and follow the upgrade process:"
260 ewarn " https://docs.mongodb.com/manual/release-notes/$(ver_cut 1-2)/"
261 ewarn " https://docs.mongodb.com/manual/release-notes/$(ver_cut 1-2)/#upgrade-procedures"