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