dev-db/mysql: amd64 stable wrt bug #717628
[gentoo.git] / dev-db / mongodb / mongodb-3.6.16.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=( 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 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 mms-agent 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.5.3:=
31         >=dev-libs/boost-1.60:=[threads(+)]
32         >=dev-libs/libpcre-8.41[cxx]
33         dev-libs/snowball-stemmer
34         net-libs/libpcap
35         >=sys-libs/zlib-1.2.8:=
36         kerberos? ( dev-libs/cyrus-sasl[kerberos] )
37         mms-agent? ( app-admin/mms-agent )
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/cheetah[${PYTHON_USEDEP}]
46                 dev-python/pyyaml[${PYTHON_USEDEP}]
47                 dev-python/typing[${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}-3.6.1-fix-scons.patch"
59         "${FILESDIR}/${PN}-3.6.1-no-compass.patch"
60         "${FILESDIR}/${PN}-4.0.12-boost-1.71-cxxabi-include.patch"
61 )
62
63 S="${WORKDIR}/${MY_P}"
64
65 pkg_pretend() {
66         if [[ -n ${REPLACING_VERSIONS} ]]; then
67                 if ver_test "$REPLACING_VERSIONS" -lt 3.4; then
68                         ewarn "To upgrade from a version earlier than the 3.4-series, you must"
69                         ewarn "successively upgrade major releases until you have upgraded"
70                         ewarn "to 3.4-series. Then upgrade to 3.6 series."
71                 else
72                         ewarn "Be sure to set featureCompatibilityVersion to 3.4 before upgrading."
73                 fi
74         fi
75 }
76
77 src_prepare() {
78         default
79
80         # remove bundled libs
81         rm -r src/third_party/{boost-*,pcre-*,scons-*,snappy-*,yaml-cpp-*,zlib-*} || die
82
83         # remove compass
84         rm -r src/mongo/installer/compass || die
85 }
86
87 src_configure() {
88         # https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source
89         # --use-system-icu fails tests
90         # --use-system-tcmalloc is strongly NOT recommended:
91         scons_opts=(
92                 CC="$(tc-getCC)"
93                 CXX="$(tc-getCXX)"
94
95                 --disable-warnings-as-errors
96                 --use-system-boost
97                 --use-system-pcre
98                 --use-system-snappy
99                 --use-system-stemmer
100                 --use-system-yaml
101                 --use-system-zlib
102         )
103
104         use debug && scons_opts+=( --dbg=on )
105         use kerberos && scons_opts+=( --use-sasl-client )
106         use lto && scons_opts+=( --lto=on )
107         use ssl && scons_opts+=( --ssl )
108
109         # respect mongoDB upstream's basic recommendations
110         # see bug #536688 and #526114
111         if ! use debug; then
112                 filter-flags '-m*'
113                 filter-flags '-O?'
114         fi
115
116         default
117 }
118
119 src_compile() {
120         escons "${scons_opts[@]}" core tools
121 }
122
123 # FEATURES="test -usersandbox" emerge dev-db/mongodb
124 src_test() {
125         "${EPYTHON}" ./buildscripts/resmoke.py --dbpathPrefix=test --suites core --jobs=$(makeopts_jobs) || die "Tests failed"
126 }
127
128 src_install() {
129         escons "${scons_opts[@]}" --nostrip install --prefix="${ED}"/usr
130
131         doman debian/mongo*.1
132         dodoc README docs/building.md
133
134         newinitd "${FILESDIR}/${PN}.initd-r3" ${PN}
135         newconfd "${FILESDIR}/${PN}.confd-r3" ${PN}
136         newinitd "${FILESDIR}/mongos.initd-r3" mongos
137         newconfd "${FILESDIR}/mongos.confd-r3" mongos
138
139         insinto /etc
140         newins "${FILESDIR}/${PN}.conf-r3" ${PN}.conf
141         newins "${FILESDIR}/mongos.conf-r2" mongos.conf
142
143         systemd_dounit "${FILESDIR}/${PN}.service"
144
145         insinto /etc/logrotate.d/
146         newins "${FILESDIR}/${PN}.logrotate" ${PN}
147
148         # see bug #526114
149         pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
150
151         local x
152         for x in /var/{lib,log}/${PN}; do
153                 diropts -m0750 -o mongodb -g mongodb
154                 keepdir "${x}"
155         done
156 }
157
158 pkg_postinst() {
159         ewarn "Make sure to read the release notes and follow the upgrade process:"
160         ewarn "  https://docs.mongodb.com/manual/release-notes/$(ver_cut 1-2)/"
161         ewarn "  https://docs.mongodb.com/manual/release-notes/$(ver_cut 1-2)/#upgrade-procedures"
162 }