net-im/tencent-qq: bump version to 3.2.15_p241224
[gentoo-zh.git] / dev-db / mongodb / mongodb-6.2.0-r4.ebuild
blob795027ead7d20550e9fa0314f824626290431263
1 # Copyright 1999-2023 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 EAPI=8
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
14 MY_P=${PVR/-r/-rc}
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"
19 SLOT="rapid"
20 KEYWORDS="~amd64"
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"
24 IUSE+=" ${CPU_FLAGS}"
25 SRC_URI="https://github.com/mongodb/mongo/archive/r${MY_P}.tar.gz"
27 REQUIRED_USE="
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
34 RESTRICT="test"
36 RDEPEND="acct-group/mongodb
37 acct-user/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]
42 app-arch/zstd:=
43 dev-libs/snowball-stemmer:=
44 net-libs/libpcap
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] )
49 ssl? (
50 >=dev-libs/openssl-1.0.1g:0=
54 DEPEND="${RDEPEND}
55 ${PYTHON_DEPS}
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}]
64 sys-libs/ncurses:0=
65 sys-libs/readline:0=
66 debug? ( dev-util/valgrind )
67 !dev-db/mongodb:0
70 PDEPEND="
71 mongosh? ( app-admin/mongosh-bin )
72 tools? ( >=app-admin/mongo-tools-100 )
75 #PATCHES=( ${FILESDIR}/mongodb-5.0.2-skip-reqs-check.patch )
77 python_check_deps() {
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}
87 pkg_pretend() {
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
97 src_prepare() {
98 default
101 src_configure() {
102 scons_opts=(
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)
110 --release
111 --disable-warnings-as-errors
112 --use-system-boost
113 --use-system-pcre2
114 --use-system-snappy
115 --use-system-stemmer
116 --use-system-yaml
117 --use-system-zlib
118 --use-system-zstd
119 --use-diagnostic-latches=on
120 --use-hardware-crc32=on
121 --wiredtiger=on
122 --link-model=auto
123 --opt=on
124 --use-libunwind=auto
125 --build-tools=next
126 --cxx-std=20
127 --visibility-support=on
128 --enable-usdt-probes=off
131 if use ssl; then
132 scons_opts+=( --ssl=on )
133 else
134 scons_opts+=( --ssl=off )
137 if use free-mon; then
138 scons_opts+=( --enable-free-mon=on )
139 else
140 scons_opts+=( --enable-free-mon=off )
143 if use gold; then
144 scons_opts+=( --linker=gold )
145 else
146 scons_opts+=( --linker=bfd )
149 if use http-client; then
150 scons_opts+=( --enable-http-client=on )
151 else
152 scons_opts+=( --enable-http-client=off )
155 if use ocsp-stapling; then
156 scons_opts+=( --ocsp-stapling=on )
157 else
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 )
169 else
170 scons_opts+=( --allocator=system )
173 if use server-js; then
174 scons_opts+=(
175 --js-engine=mozjs
176 --server-js=on
178 else
179 scons_opts+=(
180 --js-engine=none
181 --server-js=off
185 if use lto; then
186 scons_opts+=( --lto=on )
187 else
188 scons_opts+=( --lto=off )
191 if use experimental-optimization; then
192 scons_opts+=(
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="*" )
203 else
204 scons_opts+=( --runtime-hardening=off )
207 if use debug; then
208 scons_opts+=( --dbg=on )
209 else
210 scons_opts+=( --dbg=off )
213 default
216 src_compile() {
217 set -x
218 python3 -m pip install --target ./site_scons requirements_parser
219 python3 -m pip install --target ./site_scons -r etc/pip/compile-requirements.txt
220 export
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"
228 src_install() {
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
239 insinto /etc
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}
248 # see bug #526114
249 pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
251 local x
252 for x in /var/{lib,log}/${PN}; do
253 diropts -m0750 -o mongodb -g mongodb
254 keepdir "${x}"
255 done
258 pkg_postinst() {
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"