dev-db/mysql: amd64 stable wrt bug #717628
[gentoo.git] / dev-db / mongodb / mongodb-4.2.3.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python3_{6,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 flag-o-matic multiprocessing pax-utils python-any-r1 scons-utils systemd toolchain-funcs
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="Apache-2.0 SSPL-1"
22 SLOT="0"
23 KEYWORDS="~amd64"
24 IUSE="debug kerberos libressl lto ssl test +tools"
25 RESTRICT="!test? ( test )"
26
27 RDEPEND="acct-group/mongodb
28         acct-user/mongodb
29         >=app-arch/snappy-1.1.3
30         >=dev-cpp/yaml-cpp-0.6.2:=
31         >=dev-libs/boost-1.70:=[threads(+)]
32         >=dev-libs/libpcre-8.42[cxx]
33         app-arch/zstd
34         dev-libs/snowball-stemmer
35         net-libs/libpcap
36         >=sys-libs/zlib-1.2.11:=
37         kerberos? ( dev-libs/cyrus-sasl[kerberos] )
38         ssl? (
39                 !libressl? ( >=dev-libs/openssl-1.0.1g:0= )
40                 libressl? ( dev-libs/libressl:0= )
41         )"
42 DEPEND="${RDEPEND}
43         ${PYTHON_DEPS}
44         $(python_gen_any_dep '
45                 dev-python/cheetah3[${PYTHON_USEDEP}]
46                 dev-python/psutil[${PYTHON_USEDEP}]
47                 dev-python/pyyaml[${PYTHON_USEDEP}]
48         ')
49         sys-libs/ncurses:0=
50         sys-libs/readline:0=
51         debug? ( dev-util/valgrind )
52         test? (
53                 $(python_gen_any_dep 'dev-python/pymongo[${PYTHON_USEDEP}]')
54         )"
55 PDEPEND="tools? ( >=app-admin/mongo-tools-${PV} )"
56
57 PATCHES=(
58         "${FILESDIR}/${PN}-4.2.0-fix-scons.patch"
59         "${FILESDIR}/${PN}-4.0.0-no-compass.patch"
60 )
61
62 S="${WORKDIR}/${MY_P}"
63
64 pkg_pretend() {
65         if [[ -n ${REPLACING_VERSIONS} ]]; then
66                 if ver_test "$REPLACING_VERSIONS" -lt 4.0; then
67                         ewarn "To upgrade from a version earlier than the 4.0-series, you must"
68                         ewarn "successively upgrade major releases until you have upgraded"
69                         ewarn "to 4.0-series. Then upgrade to 4.2 series."
70                 else
71                         ewarn "Be sure to set featureCompatibilityVersion to 4.0 before upgrading."
72                 fi
73         fi
74 }
75
76 src_prepare() {
77         default
78
79         # remove bundled libs
80         rm -r src/third_party/{boost-*,pcre-*,scons-*,snappy-*,yaml-cpp-*,zlib-*,zstandard-*} || die
81
82         # remove compass
83         rm -r src/mongo/installer/compass || die
84 }
85
86 src_configure() {
87         # https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source
88         # --use-system-icu fails tests
89         # --use-system-tcmalloc is strongly NOT recommended:
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                 --use-system-zstd
102         )
103
104         use arm64 && scons_opts+=( --use-hardware-crc32=off ) # Bug 701300
105         use debug && scons_opts+=( --dbg=on )
106         use kerberos && scons_opts+=( --use-sasl-client )
107         use lto && scons_opts+=( --lto=on )
108         use ssl && scons_opts+=( --ssl )
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         doman debian/mongo*.1
133         dodoc README docs/building.md
134
135         newinitd "${FILESDIR}/${PN}.initd-r3" ${PN}
136         newconfd "${FILESDIR}/${PN}.confd-r3" ${PN}
137         newinitd "${FILESDIR}/mongos.initd-r3" mongos
138         newconfd "${FILESDIR}/mongos.confd-r3" mongos
139
140         insinto /etc
141         newins "${FILESDIR}/${PN}.conf-r3" ${PN}.conf
142         newins "${FILESDIR}/mongos.conf-r2" mongos.conf
143
144         systemd_dounit "${FILESDIR}/${PN}.service"
145
146         insinto /etc/logrotate.d/
147         newins "${FILESDIR}/${PN}.logrotate" ${PN}
148
149         # see bug #526114
150         pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
151
152         local x
153         for x in /var/{lib,log}/${PN}; do
154                 diropts -m0750 -o mongodb -g mongodb
155                 keepdir "${x}"
156         done
157 }
158
159 pkg_postinst() {
160         ewarn "Make sure to read the release notes and follow the upgrade process:"
161         ewarn "  https://docs.mongodb.com/manual/release-notes/$(ver_cut 1-2)/"
162         ewarn "  https://docs.mongodb.com/manual/release-notes/$(ver_cut 1-2)/#upgrade-procedures"
163 }