dev-db/mongodb: fix REPLACING_VERSION detection #589458
[gentoo.git] / dev-db / mongodb / mongodb-2.6.8.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6 SCONS_MIN_VERSION="1.2.0"
7 CHECKREQS_DISK_BUILD="2400M"
8 CHECKREQS_DISK_USR="512M"
9 CHECKREQS_MEMORY="1024M"
10
11 inherit eutils flag-o-matic multilib pax-utils scons-utils systemd user versionator check-reqs
12
13 MY_P=${PN}-src-r${PV/_rc/-rc}
14
15 DESCRIPTION="A high-performance, open source, schema-free document-oriented database"
16 HOMEPAGE="http://www.mongodb.org"
17 SRC_URI="http://downloads.mongodb.org/src/${MY_P}.tar.gz
18         mms-agent? ( https://dev.gentoo.org/~ultrabug/20140409-mms-monitoring-agent.zip )"
19
20 LICENSE="AGPL-3 Apache-2.0"
21 SLOT="0"
22 KEYWORDS="amd64 x86"
23 IUSE="debug kerberos mms-agent ssl static-libs"
24
25 PDEPEND="mms-agent? ( dev-python/pymongo app-arch/unzip )"
26 RDEPEND="
27         app-arch/snappy
28         >=dev-cpp/yaml-cpp-0.5.1
29         >=dev-libs/boost-1.50[threads(+)]
30         >=dev-libs/libpcre-8.30[cxx]
31         dev-libs/snowball-stemmer
32         dev-util/google-perftools[-minimal]
33         net-libs/libpcap
34         ssl? ( >=dev-libs/openssl-1.0.1g )"
35 DEPEND="${RDEPEND}
36         sys-libs/ncurses
37         sys-libs/readline
38         kerberos? ( dev-libs/cyrus-sasl[kerberos] )"
39
40 S=${WORKDIR}/${MY_P}
41
42 pkg_setup() {
43         enewgroup mongodb
44         enewuser mongodb -1 -1 /var/lib/${PN} mongodb
45
46         scons_opts="--variant-dir=build --cc=$(tc-getCC) --cxx=$(tc-getCXX)"
47         scons_opts+=" --disable-warnings-as-errors"
48         scons_opts+=" --use-system-boost"
49         scons_opts+=" --use-system-pcre"
50         scons_opts+=" --use-system-snappy"
51         scons_opts+=" --use-system-stemmer"
52         scons_opts+=" --use-system-tcmalloc"
53         scons_opts+=" --use-system-yaml"
54         scons_opts+=" --usev8"
55
56         if use debug; then
57                 scons_opts+=" --dbg=on"
58         fi
59
60         if use prefix; then
61                 scons_opts+=" --cpppath=${EPREFIX}/usr/include"
62                 scons_opts+=" --libpath=${EPREFIX}/usr/$(get_libdir)"
63         fi
64
65         if use kerberos; then
66                 scons_opts+=" --use-sasl-client"
67         fi
68
69         if use ssl; then
70                 scons_opts+=" --ssl"
71         fi
72 }
73
74 src_prepare() {
75         epatch "${FILESDIR}/${PN}-2.6.2-fix-scons.patch"
76         epatch "${FILESDIR}/${PN}-2.4-fix-v8-pythonpath.patch"
77         epatch "${FILESDIR}/${PN}-2.6.10-fix-boost-1.57.patch"
78
79         # fix yaml-cpp detection
80         sed -i -e "s/\[\"yaml\"\]/\[\"yaml-cpp\"\]/" SConstruct || die
81
82         # bug #462606
83         sed -i -e "s@\$INSTALL_DIR/lib@\$INSTALL_DIR/$(get_libdir)@g" src/SConscript.client || die
84
85         # bug #482576
86         sed -i -e "/-Werror/d" src/third_party/v8/SConscript || die
87 }
88
89 src_configure() {
90         # filter some problematic flags
91         filter-flags "-march=*"
92         filter-flags -O?
93 }
94
95 src_compile() {
96         escons ${scons_opts} all
97 }
98
99 src_install() {
100         escons ${scons_opts} --full --nostrip install --prefix="${ED}"/usr
101
102         use static-libs || find "${ED}"/usr/ -type f -name "*.a" -delete
103
104         for x in /var/{lib,log}/${PN}; do
105                 keepdir "${x}"
106                 fowners mongodb:mongodb "${x}"
107         done
108
109         doman debian/mongo*.1
110         dodoc README docs/building.md
111
112         newinitd "${FILESDIR}/${PN}.initd-r2" ${PN}
113         newconfd "${FILESDIR}/${PN}.confd-r2" ${PN}
114         newinitd "${FILESDIR}/${PN/db/s}.initd-r2" ${PN/db/s}
115         newconfd "${FILESDIR}/${PN/db/s}.confd-r2" ${PN/db/s}
116
117         insinto /etc
118         newins "${FILESDIR}/${PN}.conf-r2" ${PN}.conf
119         newins "${FILESDIR}/${PN/db/s}.conf-r2" ${PN/db/s}.conf
120
121         systemd_dounit "${FILESDIR}/${PN}.service"
122
123         insinto /etc/logrotate.d/
124         newins "${FILESDIR}/${PN}.logrotate" ${PN}
125
126         # see bug #526114
127         pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
128
129         if use mms-agent; then
130                 local MY_PN="mms-agent"
131                 local MY_D="/opt/${MY_PN}"
132
133                 insinto /etc
134                 newins "${WORKDIR}/${MY_PN}/settings.py" mms-agent.conf
135                 rm "${WORKDIR}/${MY_PN}/settings.py"
136
137                 insinto ${MY_D}
138                 doins "${WORKDIR}/${MY_PN}/"*
139                 dosym /etc/mms-agent.conf ${MY_D}/settings.py
140
141                 fowners -R mongodb:mongodb ${MY_D}
142                 newinitd "${FILESDIR}/${MY_PN}.initd-r2" ${MY_PN}
143         fi
144 }
145
146 pkg_preinst() {
147         # wrt bug #461466
148         if [[ "$(get_libdir)" == "lib64" ]]; then
149                 rmdir "${ED}"/usr/lib/ &>/dev/null
150         fi
151 }
152
153 src_test() {
154         escons ${scons_opts} test
155         "${S}"/test --dbpath=unittest || die
156 }
157
158 pkg_postinst() {
159         local v
160         for v in ${REPLACING_VERSIONS}; do
161                 if ! version_is_at_least 2.6 ${v}; then
162                         ewarn "!! IMPORTANT !!"
163                         ewarn " "
164                         ewarn "${PN} configuration files have changed !"
165                         ewarn " "
166                         ewarn "Make sure you migrate from /etc/conf.d/${PN} to the new YAML standard in /etc/${PN}.conf"
167                         ewarn "  http://docs.mongodb.org/manual/reference/configuration-options/"
168                         ewarn " "
169                         ewarn "Make sure you also follow the upgrading process :"
170                         ewarn "  http://docs.mongodb.org/master/release-notes/2.6-upgrade/"
171                         ewarn " "
172                         if use mms-agent; then
173                                 ewarn "MMS Agent configuration file has been moved to :"
174                                 ewarn "  /etc/mms-agent.conf"
175                         fi
176                         break
177                 else
178                         if use mms-agent; then
179                                 elog "Edit your MMS Agent configuration file :"
180                                 elog "  /etc/mms-agent.conf"
181                         fi
182                 fi
183         done
184 }