Gentoo Archives: gentoo-commits

From: "Robin H. Johnson (robbat2)" <robbat2@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: mysql-autotools.eclass mysql-cmake.eclass mysql.eclass mysql_fx.eclass mysql-multilib.eclass mysql-v2.eclass ChangeLog
Date: Tue, 29 Jul 2014 17:59:28
Message-Id: 20140729175922.C7E1F2004C@flycatcher.gentoo.org
1 robbat2 14/07/29 17:59:21
2
3 Modified: mysql-autotools.eclass mysql-cmake.eclass
4 mysql.eclass mysql_fx.eclass mysql-v2.eclass
5 ChangeLog
6 Added: mysql-multilib.eclass
7 Log:
8 Sync mysql eclass from overlay.
9
10 Revision Changes Path
11 1.20 eclass/mysql-autotools.eclass
12
13 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-autotools.eclass?rev=1.20&view=markup
14 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-autotools.eclass?rev=1.20&content-type=text/plain
15 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-autotools.eclass?r1=1.19&r2=1.20
16
17 Index: mysql-autotools.eclass
18 ===================================================================
19 RCS file: /var/cvsroot/gentoo-x86/eclass/mysql-autotools.eclass,v
20 retrieving revision 1.19
21 retrieving revision 1.20
22 diff -p -w -b -B -u -u -r1.19 -r1.20
23 --- mysql-autotools.eclass 19 Jul 2014 10:18:41 -0000 1.19
24 +++ mysql-autotools.eclass 29 Jul 2014 17:59:21 -0000 1.20
25 @@ -1,6 +1,6 @@
26 # Copyright 1999-2014 Gentoo Foundation
27 # Distributed under the terms of the GNU General Public License v2
28 -# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-autotools.eclass,v 1.19 2014/07/19 10:18:41 grobian Exp $
29 +# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-autotools.eclass,v 1.20 2014/07/29 17:59:21 robbat2 Exp $
30
31 # @ECLASS: mysql-autotools.eclass
32 # @MAINTAINER:
33 @@ -377,6 +377,8 @@ mysql-autotools_src_prepare() {
34
35 cd "${S}"
36
37 + if [[ ${MY_EXTRAS_VER} != none ]]; then
38 +
39 # Apply the patches for this MySQL version
40 EPATCH_SUFFIX="patch"
41 mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
42 @@ -386,14 +388,18 @@ mysql-autotools_src_prepare() {
43 mysql_mv_patches
44 # And apply
45 epatch
46 + fi
47
48 # last -fPIC fixup, per bug #305873
49 i="${S}"/storage/innodb_plugin/plug.in
50 [[ -f ${i} ]] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
51
52 - # Additional checks, remove bundled zlib
53 + # Additional checks, remove bundled zlib (Cluster needs this, for static
54 + # memory management in zlib, leave available for Cluster)
55 + if [[ "${PN}" != "mysql-cluster" ]] ; then
56 rm -f "${S}/zlib/"*.[ch]
57 sed -i -e "s/zlib\/Makefile dnl/dnl zlib\/Makefile/" "${S}/configure.in"
58 + fi
59 rm -f "scripts/mysqlbug"
60
61 # Make charsets install in the right place
62 @@ -606,7 +612,7 @@ mysql-autotools_src_install() {
63 -e "s!= /var!= ${EPREFIX}/var!" \
64 "${FILESDIR}/${mycnf_src}" \
65 > "${TMPDIR}/my.cnf.ok"
66 - use prefix && sed -i -e '/^user[ ]*= mysql$/d' "${TMPDIR}/my.cnf.ok"
67 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
68 if use latin1 ; then
69 sed -i \
70 -e "/character-set/s|utf8|latin1|g" \
71
72
73
74 1.23 eclass/mysql-cmake.eclass
75
76 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-cmake.eclass?rev=1.23&view=markup
77 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-cmake.eclass?rev=1.23&content-type=text/plain
78 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-cmake.eclass?r1=1.22&r2=1.23
79
80 Index: mysql-cmake.eclass
81 ===================================================================
82 RCS file: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v
83 retrieving revision 1.22
84 retrieving revision 1.23
85 diff -p -w -b -B -u -u -r1.22 -r1.23
86 --- mysql-cmake.eclass 19 Jul 2014 10:18:41 -0000 1.22
87 +++ mysql-cmake.eclass 29 Jul 2014 17:59:21 -0000 1.23
88 @@ -1,6 +1,6 @@
89 # Copyright 1999-2014 Gentoo Foundation
90 # Distributed under the terms of the GNU General Public License v2
91 -# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v 1.22 2014/07/19 10:18:41 grobian Exp $
92 +# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-cmake.eclass,v 1.23 2014/07/29 17:59:21 robbat2 Exp $
93
94 # @ECLASS: mysql-cmake.eclass
95 # @MAINTAINER:
96 @@ -76,9 +76,9 @@ mysql-cmake_disable_test() {
97 mysql-cmake_use_plugin() {
98 [[ -z $2 ]] && die "mysql-cmake_use_plugin <USE flag> <flag name>"
99 if use_if_iuse $1 ; then
100 - echo "-DWITH_$2=1"
101 + echo "-DWITH_$2=1 -DPLUGIN_$2=YES"
102 else
103 - echo "-DWITHOUT_$2=1 -DWITH_$2=0"
104 + echo "-DWITHOUT_$2=1 -DWITH_$2=0 -DPLUGIN_$2=NO"
105 fi
106 }
107
108 @@ -129,7 +129,15 @@ configure_cmake_minimal() {
109 -DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1
110 -DWITHOUT_MYISAM_STORAGE_ENGINE=1
111 -DWITHOUT_PARTITION_STORAGE_ENGINE=1
112 - -DWITHOUT_INNOBASE_STORAGE_ENGINE=1
113 + -DPLUGIN_ARCHIVE=NO
114 + -DPLUGIN_BLACKHOLE=NO
115 + -DPLUGIN_CSV=NO
116 + -DPLUGIN_FEDERATED=NO
117 + -DPLUGIN_HEAP=NO
118 + -DPLUGIN_INNOBASE=NO
119 + -DPLUGIN_MYISAMMRG=NO
120 + -DPLUGIN_MYISAM=NO
121 + -DPLUGIN_PARTITION=NO
122 )
123 }
124
125 @@ -191,10 +199,12 @@ configure_cmake_standard() {
126 # CassandraSE needs Apache Thrift which is not in portage
127 mycmakeargs+=(
128 -DWITHOUT_CASSANDRA=1 -DWITH_CASSANDRA=0
129 + -DPLUGIN_CASSANDRA=NO
130 $(mysql-cmake_use_plugin extraengine SEQUENCE)
131 $(mysql-cmake_use_plugin extraengine SPIDER)
132 $(mysql-cmake_use_plugin extraengine CONNECT)
133 -DCONNECT_WITH_MYSQL=1
134 + -DPLUGIN_CONNECT_WITH_MYSQL=YES
135 $(cmake-utils_use xml CONNECT_WITH_LIBXML2)
136 $(cmake-utils_use odbc CONNECT_WITH_ODBC)
137 )
138 @@ -309,9 +319,7 @@ mysql-cmake_src_configure() {
139 -DWITH_SSL=$(usex ssl system bundled)
140 )
141
142 - if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.6.12" ; then
143 - mycmakeargs+=( -DWITH_EDITLINE=system )
144 - else
145 + if in_iuse bindist ; then
146 mycmakeargs+=(
147 -DWITH_READLINE=$(usex bindist 1 0)
148 -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
149 @@ -319,6 +327,8 @@ mysql-cmake_src_configure() {
150 )
151 fi
152
153 + mycmakeargs+=( -DWITH_EDITLINE=system )
154 +
155 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
156 mycmakeargs+=(
157 -DWITH_JEMALLOC=$(usex jemalloc system)
158 @@ -411,7 +421,7 @@ mysql-cmake_src_install() {
159 sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
160 "${FILESDIR}/${mycnf_src}" \
161 > "${TMPDIR}/my.cnf.ok" || die
162 - use prefix && sed -i -e '/^user[ ]*= mysql$/d' "${TMPDIR}/my.cnf.ok"
163 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
164 if use latin1 ; then
165 sed -i \
166 -e "/character-set/s|utf8|latin1|g" \
167
168
169
170 1.180 eclass/mysql.eclass
171
172 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql.eclass?rev=1.180&view=markup
173 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql.eclass?rev=1.180&content-type=text/plain
174 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql.eclass?r1=1.179&r2=1.180
175
176 Index: mysql.eclass
177 ===================================================================
178 RCS file: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v
179 retrieving revision 1.179
180 retrieving revision 1.180
181 diff -p -w -b -B -u -u -r1.179 -r1.180
182 --- mysql.eclass 19 Jul 2014 10:18:41 -0000 1.179
183 +++ mysql.eclass 29 Jul 2014 17:59:21 -0000 1.180
184 @@ -1,6 +1,6 @@
185 # Copyright 1999-2014 Gentoo Foundation
186 # Distributed under the terms of the GNU General Public License v2
187 -# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.179 2014/07/19 10:18:41 grobian Exp $
188 +# $Header: /var/cvsroot/gentoo-x86/eclass/mysql.eclass,v 1.180 2014/07/29 17:59:21 robbat2 Exp $
189
190 # @ECLASS: mysql.eclass
191 # @MAINTAINER:
192 @@ -19,7 +19,7 @@
193 WANT_AUTOCONF="latest"
194 WANT_AUTOMAKE="latest"
195
196 -inherit eutils flag-o-matic gnuconfig autotools multilib mysql_fx versionator toolchain-funcs user
197 +inherit eutils flag-o-matic gnuconfig autotools multilib mysql_fx versionator toolchain-funcs
198
199 # Shorten the path because the socket path length must be shorter than 107 chars
200 # and we will run a mysql server during test phase
201 @@ -878,7 +878,7 @@ mysql_src_unpack() {
202
203 unpack ${A}
204 # Grab the patches
205 - [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git_src_unpack
206 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-2_src_unpack
207
208 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
209
210 @@ -1153,7 +1153,7 @@ mysql_src_install() {
211 -e "s!= /var!= ${EPREFIX}/var!" \
212 "${FILESDIR}/${mycnf_src}" \
213 > "${TMPDIR}/my.cnf.ok"
214 - use prefix && sed -i -e '/^user[ ]*= mysql$/d' "${TMPDIR}/my.cnf.ok"
215 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
216 if use latin1 ; then
217 sed -i \
218 -e "/character-set/s|utf8|latin1|g" \
219
220
221
222 1.32 eclass/mysql_fx.eclass
223
224 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql_fx.eclass?rev=1.32&view=markup
225 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql_fx.eclass?rev=1.32&content-type=text/plain
226 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql_fx.eclass?r1=1.31&r2=1.32
227
228 Index: mysql_fx.eclass
229 ===================================================================
230 RCS file: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v
231 retrieving revision 1.31
232 retrieving revision 1.32
233 diff -p -w -b -B -u -u -r1.31 -r1.32
234 --- mysql_fx.eclass 18 May 2014 19:08:34 -0000 1.31
235 +++ mysql_fx.eclass 29 Jul 2014 17:59:21 -0000 1.32
236 @@ -1,6 +1,6 @@
237 -# Copyright 1999-2012 Gentoo Foundation
238 +# Copyright 1999-2014 Gentoo Foundation
239 # Distributed under the terms of the GNU General Public License v2
240 -# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.31 2014/05/18 19:08:34 grknight Exp $
241 +# $Header: /var/cvsroot/gentoo-x86/eclass/mysql_fx.eclass,v 1.32 2014/07/29 17:59:21 robbat2 Exp $
242
243 # Author: Francesco Riosa (Retired) <vivo@g.o>
244 # Maintainer:
245
246
247
248 1.33 eclass/mysql-v2.eclass
249
250 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-v2.eclass?rev=1.33&view=markup
251 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-v2.eclass?rev=1.33&content-type=text/plain
252 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-v2.eclass?r1=1.32&r2=1.33
253
254 Index: mysql-v2.eclass
255 ===================================================================
256 RCS file: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v
257 retrieving revision 1.32
258 retrieving revision 1.33
259 diff -p -w -b -B -u -u -r1.32 -r1.33
260 --- mysql-v2.eclass 19 Jul 2014 10:18:41 -0000 1.32
261 +++ mysql-v2.eclass 29 Jul 2014 17:59:21 -0000 1.33
262 @@ -1,6 +1,6 @@
263 # Copyright 1999-2014 Gentoo Foundation
264 # Distributed under the terms of the GNU General Public License v2
265 -# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.32 2014/07/19 10:18:41 grobian Exp $
266 +# $Header: /var/cvsroot/gentoo-x86/eclass/mysql-v2.eclass,v 1.33 2014/07/29 17:59:21 robbat2 Exp $
267
268 # @ECLASS: mysql-v2.eclass
269 # @MAINTAINER:
270 @@ -83,10 +83,18 @@ fi
271 MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
272
273 # Cluster is a special case...
274 -if [[ "${PN}" == "mysql-cluster" ]]; then
275 - case $PV in
276 +if [[ ${PN} == "mysql-cluster" ]]; then
277 + case ${PV} in
278 6.1*|7.0*|7.1*) MYSQL_PV_MAJOR=5.1 ;;
279 - 7.2*|7.3*) MYSQL_PV_MAJOR=5.5 ;;
280 + 7.2*) MYSQL_PV_MAJOR=5.5 ;;
281 + 7.3*) MYSQL_PV_MAJOR=5.6 ;;
282 + esac
283 +fi
284 +
285 +# MariaDB has left the numbering schema but keeping compatibility
286 +if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
287 + case ${PV} in
288 + 10.0*|10.1*) MYSQL_PV_MAJOR="5.6" ;;
289 esac
290 fi
291
292 @@ -209,8 +217,15 @@ esac
293 # Common IUSE
294 IUSE="${IUSE} latin1 extraengine cluster max-idx-128 +community profiling"
295
296 +# This probably could be simplified, but the syntax would have to be just right
297 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && \
298 - mysql_version_is_at_least "5.5" || mysql_check_version_range "5.5.37 to 5.6.11.99" ; then
299 + mysql_version_is_at_least "5.5" ; then
300 + IUSE="bindist ${IUSE}"
301 +elif [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
302 + mysql_check_version_range "5.5.37 to 5.6.11.99" ; then
303 + IUSE="bindist ${IUSE}"
304 +elif [[ ${PN} == "mysql-cluster" ]] && \
305 + mysql_check_version_range "7.2 to 7.2.99.99" ; then
306 IUSE="bindist ${IUSE}"
307 fi
308
309 @@ -260,7 +275,11 @@ DEPEND="
310 # !dev-db/mariadb-native-client[mysqlcompat]
311
312 # dev-db/mysql-5.6.12+ only works with dev-libs/libedit
313 -if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.6.12" ; then
314 +# This probably could be simplified
315 +if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
316 + mysql_version_is_at_least "5.6.12" ; then
317 + DEPEND="${DEPEND} dev-libs/libedit"
318 +elif [[ ${PN} == "mysql-cluster" ]] && mysql_version_is_at_least "7.3"; then
319 DEPEND="${DEPEND} dev-libs/libedit"
320 else
321 if mysql_version_is_at_least "5.5" ; then
322
323
324
325 1.1331 eclass/ChangeLog
326
327 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1331&view=markup
328 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1331&content-type=text/plain
329 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1330&r2=1.1331
330
331 Index: ChangeLog
332 ===================================================================
333 RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
334 retrieving revision 1.1330
335 retrieving revision 1.1331
336 diff -p -w -b -B -u -u -r1.1330 -r1.1331
337 --- ChangeLog 29 Jul 2014 16:42:59 -0000 1.1330
338 +++ ChangeLog 29 Jul 2014 17:59:21 -0000 1.1331
339 @@ -1,6 +1,11 @@
340 # ChangeLog for eclass directory
341 # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2
342 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1330 2014/07/29 16:42:59 robbat2 Exp $
343 +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1331 2014/07/29 17:59:21 robbat2 Exp $
344 +
345 + 29 Jul 2014; Robin H. Johnson <robbat2@g.o> +mysql-multilib.eclass,
346 + mysql.eclass, mysql-autotools.eclass, mysql-cmake.eclass, mysql-v2.eclass,
347 + mysql_fx.eclass:
348 + Sync mysql eclass from overlay.
349
350 28 Jul 2014; Davide Pesavento <pesa@g.o> qmake-utils.eclass:
351 Set also QMAKE_LINK_{C_,}SHLIB
352
353
354
355 1.1 eclass/mysql-multilib.eclass
356
357 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-multilib.eclass?rev=1.1&view=markup
358 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/mysql-multilib.eclass?rev=1.1&content-type=text/plain
359
360 Index: mysql-multilib.eclass
361 ===================================================================
362 # Copyright 1999-2014 Gentoo Foundation
363 # Distributed under the terms of the GNU General Public License v2
364 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-multilib.eclass,v 1.1 2014/07/29 17:59:21 robbat2 Exp $
365
366 # @ECLASS: mysql-multilib.eclass
367 # @MAINTAINER:
368 # Maintainers:
369 # - MySQL Team <mysql-bugs@g.o>
370 # - Robin H. Johnson <robbat2@g.o>
371 # - Jorge Manuel B. S. Vicetto <jmbsvicetto@g.o>
372 # @BLURB: This eclass provides most of the functions for mysql ebuilds
373 # @DESCRIPTION:
374 # The mysql-multilib.eclass is the base eclass to build the mysql and
375 # alternative projects (mariadb and percona) ebuilds.
376 # This eclass uses the mysql-cmake eclass for the
377 # specific bits related to the build system.
378 # It provides the src_unpack, src_prepare, src_configure, src_compile,
379 # src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
380 # phase hooks.
381
382 MYSQL_EXTRAS=""
383
384 # @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
385 # @DESCRIPTION:
386 # The version of the MYSQL_EXTRAS repo to use to build mysql
387 # Use "none" to disable it's use
388 [[ ${MY_EXTRAS_VER} == "live" ]] && MYSQL_EXTRAS="git-2"
389
390 inherit eutils flag-o-matic ${MYSQL_EXTRAS} mysql-cmake mysql_fx versionator \
391 toolchain-funcs user cmake-utils multilib-minimal
392
393 #
394 # Supported EAPI versions and export functions
395 #
396
397 case "${EAPI:-0}" in
398 5) ;;
399 *) die "Unsupported EAPI: ${EAPI}" ;;
400 esac
401
402 EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config
403
404 #
405 # VARIABLES:
406 #
407
408 # Shorten the path because the socket path length must be shorter than 107 chars
409 # and we will run a mysql server during test phase
410 S="${WORKDIR}/mysql"
411
412 [[ ${MY_EXTRAS_VER} == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
413 if [[ ${MY_EXTRAS_VER} == "live" ]]; then
414 EGIT_PROJECT=mysql-extras
415 EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/mysql-extras.git"
416 RESTRICT="userpriv"
417 fi
418
419 # @ECLASS-VARIABLE: MYSQL_PV_MAJOR
420 # @DESCRIPTION:
421 # Upstream MySQL considers the first two parts of the version number to be the
422 # major version. Upgrades that change major version should always run
423 # mysql_upgrade.
424 MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
425
426 # Cluster is a special case...
427 if [[ "${PN}" == "mysql-cluster" ]]; then
428 case $PV in
429 7.2*|7.3*) MYSQL_PV_MAJOR=5.5 ;;
430 esac
431 fi
432
433 # MariaDB has left the numbering schema but keeping compatibility
434 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
435 case ${PV} in
436 10.0*|10.1*) MYSQL_PV_MAJOR="5.6" ;;
437 esac
438 fi
439
440 # @ECLASS-VARIABLE: MYSQL_VERSION_ID
441 # @DESCRIPTION:
442 # MYSQL_VERSION_ID will be:
443 # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
444 # This is an important part, because many of the choices the MySQL ebuild will do
445 # depend on this variable.
446 # In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
447 # We also strip off upstream's trailing letter that they use to respin tarballs
448 MYSQL_VERSION_ID=""
449 tpv="${PV%[a-z]}"
450 tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
451 for vatom in 0 1 2 3 ; do
452 # pad to length 2
453 tpv[${vatom}]="00${tpv[${vatom}]}"
454 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
455 done
456 # strip leading "0" (otherwise it's considered an octal number by BASH)
457 MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
458
459 # This eclass should only be used with at least mysql-5.5.35
460 mysql_version_is_at_least "5.5.35" || die "This eclass should only be used with >=mysql-5.5.35"
461
462 # @ECLASS-VARIABLE: XTRADB_VER
463 # @DEFAULT_UNSET
464 # @DESCRIPTION:
465 # Version of the XTRADB storage engine
466
467 # @ECLASS-VARIABLE: PERCONA_VER
468 # @DEFAULT_UNSET
469 # @DESCRIPTION:
470 # Designation by PERCONA for a MySQL version to apply an XTRADB release
471
472 # Work out the default SERVER_URI correctly
473 if [[ -z ${SERVER_URI} ]]; then
474 [[ -z ${MY_PV} ]] && MY_PV="${PV//_/-}"
475 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
476 # Beginning with 5.5, MariaDB stopped putting beta, alpha or rc on their tarball names
477 mysql_version_is_at_least "5.5" && MARIA_FULL_PV=$(get_version_component_range 1-3) || \
478 MARIA_FULL_PV=$(replace_version_separator 3 '-' ${MY_PV})
479 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
480 SERVER_URI="
481 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
482 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
483 http://mirror.jmu.edu/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
484 http://mirrors.coreix.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
485 http://mirrors.syringanetworks.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
486 http://mirrors.fe.up.pt/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
487 http://mirror2.hs-esslingen.de/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
488 "
489 if [[ ${PN} == "mariadb-galera" ]]; then
490 MY_SOURCEDIR="${PN%%-galera}-${MARIA_FULL_PV}"
491 fi
492 elif [[ ${PN} == "percona-server" ]]; then
493 PERCONA_PN="Percona-Server"
494 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
495 MY_PV=$(get_version_component_range 1-3 ${PV})
496 PERCONA_RELEASE=$(get_version_component_range 4-5 ${PV})
497 PERCONA_RC=$(get_version_component_range 6 ${PV})
498 SERVER_URI="http://www.percona.com/redir/downloads/${PERCONA_PN}-${MIRROR_PV}/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}/source/tarball/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}.tar.gz"
499 # http://www.percona.com/redir/downloads/Percona-Server-5.5/LATEST/source/tarball/Percona-Server-5.5.30-rel30.2.tar.gz
500 # http://www.percona.com/redir/downloads/Percona-Server-5.6/Percona-Server-5.6.13-rc60.5/source/tarball/Percona-Server-5.6.13-rc60.5.tar.gz
501 else
502 if [[ "${PN}" == "mysql-cluster" ]] ; then
503 URI_DIR="MySQL-Cluster"
504 URI_FILE="mysql-cluster-gpl"
505 else
506 URI_DIR="MySQL"
507 URI_FILE="mysql"
508 fi
509 URI_A="${URI_FILE}-${MY_PV}.tar.gz"
510 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
511 # Recently upstream switched to an archive site, and not on mirrors
512 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
513 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
514 fi
515 fi
516
517 # Define correct SRC_URIs
518 SRC_URI="${SERVER_URI}"
519
520 # Gentoo patches to MySQL
521 if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then
522 SRC_URI="${SRC_URI}
523 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
524 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
525 http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
526 http://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
527 fi
528
529 DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
530 HOMEPAGE="http://www.mysql.com/"
531 if [[ ${PN} == "mariadb" ]]; then
532 HOMEPAGE="http://mariadb.org/"
533 DESCRIPTION="An enhanced, drop-in replacement for MySQL"
534 fi
535 if [[ ${PN} == "mariadb-galera" ]]; then
536 HOMEPAGE="http://mariadb.org/"
537 DESCRIPTION="An enhanced, drop-in replacement for MySQL with Galera Replication"
538 fi
539 if [[ ${PN} == "percona-server" ]]; then
540 HOMEPAGE="http://www.percona.com/software/percona-server"
541 DESCRIPTION="An enhanced, drop-in replacement for MySQL from the Percona team"
542 fi
543 LICENSE="GPL-2"
544 SLOT="0"
545
546 IUSE="+community cluster debug embedded extraengine jemalloc latin1 max-idx-128 minimal
547 +perl profiling selinux ssl systemtap static static-libs tcmalloc test"
548
549 # This probably could be simplified, but the syntax would have to be just right
550 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
551 IUSE="bindist ${IUSE}"
552 elif [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
553 mysql_check_version_range "5.5.37 to 5.6.11.99" ; then
554 IUSE="bindist ${IUSE}"
555 elif [[ ${PN} == "mysql-cluster" ]] && \
556 mysql_check_version_range "7.2 to 7.2.99.99" ; then
557 IUSE="bindist ${IUSE}"
558 fi
559
560 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
561 IUSE="${IUSE} oqgraph pam sphinx tokudb"
562 # 5.5.33 and 10.0.5 add TokuDB. Authors strongly recommend jemalloc or perfomance suffers
563 mysql_version_is_at_least "10.0.5" && IUSE="${IUSE} odbc xml" && \
564 REQUIRED_USE="odbc? ( extraengine !minimal ) xml? ( extraengine !minimal )"
565 REQUIRED_USE="${REQUIRED_USE} minimal? ( !oqgraph !sphinx ) tokudb? ( jemalloc )"
566 fi
567
568 if [[ ${PN} == "percona-server" ]]; then
569 IUSE="${IUSE} pam"
570 fi
571
572 REQUIRED_USE="
573 ${REQUIRED_USE} tcmalloc? ( !jemalloc ) jemalloc? ( !tcmalloc )
574 minimal? ( !cluster !extraengine !embedded ) static? ( !ssl )"
575
576 #
577 # DEPENDENCIES:
578 #
579
580 # Be warned, *DEPEND are version-dependant
581 # These are used for both runtime and compiletime
582 # MULTILIB_USEDEP only set for libraries used by the client library
583 DEPEND="
584 ssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
585 kernel_linux? (
586 sys-process/procps:0=
587 dev-libs/libaio:0=
588 )
589 >=sys-apps/sed-4
590 >=sys-apps/texinfo-4.7-r1
591 >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
592 !dev-db/mariadb-native-client[mysqlcompat]
593 jemalloc? ( dev-libs/jemalloc:0=[${MULTILIB_USEDEP}] )
594 tcmalloc? ( dev-util/google-perftools:0= )
595 systemtap? ( >=dev-util/systemtap-1.3:0= )
596 "
597
598 # dev-db/mysql-5.6.12+ only works with dev-libs/libedit
599 # This probably could be simplified
600 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
601 mysql_version_is_at_least "5.6.12" ; then
602 DEPEND="${DEPEND} dev-libs/libedit"
603 elif [[ ${PN} == "mysql-cluster" ]] && mysql_version_is_at_least "7.3"; then
604 DEPEND="${DEPEND} dev-libs/libedit"
605 else
606 DEPEND="${DEPEND} !bindist? ( >=sys-libs/readline-4.1:0=[${MULTILIB_USEDEP}] )"
607 fi
608
609 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
610 # Bug 441700 MariaDB >=5.3 include custom mytop
611 DEPEND="${DEPEND}
612 oqgraph? ( >=dev-libs/boost-1.40.0:0= )
613 !minimal? ( pam? ( virtual/pam:0= ) )
614 perl? ( !dev-db/mytop )"
615 if mysql_version_is_at_least "10.0.5" ; then
616 DEPEND="${DEPEND}
617 odbc? ( dev-db/unixODBC:0= )
618 xml? ( dev-libs/libxml2:2= )
619 "
620 fi
621 mysql_version_is_at_least "10.0.7" && DEPEND="${DEPEND} oqgraph? ( dev-libs/judy:0= )"
622 if mysql_version_is_at_least "10.0.9" ; then
623 DEPEND="${DEPEND} >=dev-libs/libpcre-8.35:3="
624 fi
625 fi
626
627 # Having different flavours at the same time is not a good idea
628 for i in "mysql" "mariadb" "mariadb-galera" "percona-server" "mysql-cluster" ; do
629 [[ ${i} == ${PN} ]] ||
630 DEPEND="${DEPEND} !dev-db/${i}"
631 done
632
633 if [[ ${PN} == "mysql-cluster" ]] ; then
634 # TODO: This really should include net-misc/memcached
635 # but the package does not install the files it seeks.
636 mysql_version_is_at_least "7.2.3" && \
637 DEPEND="${DEPEND} dev-libs/libevent:0="
638 fi
639
640 # prefix: first need to implement something for #196294
641 # TODO: check emul-linux-x86-db dep when it is multilib enabled
642 RDEPEND="${DEPEND}
643 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
644 selinux? ( sec-policy/selinux-mysql )
645 abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] )
646 "
647
648 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
649 # Bug 455016 Add dependencies of mytop
650 RDEPEND="${RDEPEND} perl? (
651 virtual/perl-Getopt-Long
652 dev-perl/TermReadKey
653 virtual/perl-Term-ANSIColor
654 virtual/perl-Time-HiRes ) "
655 fi
656
657 if [[ ${PN} == "mariadb-galera" ]] ; then
658 # The wsrep API version must match between the ebuild and sys-cluster/galera.
659 # This will be indicated by WSREP_REVISION in the ebuild and the first number
660 # in the version of sys-cluster/galera
661 RDEPEND="${RDEPEND}
662 =sys-cluster/galera-${WSREP_REVISION}*
663 "
664 fi
665
666 if [[ ${PN} == "mysql-cluster" ]] ; then
667 mysql_version_is_at_least "7.2.9" && RDEPEND="${RDEPEND} java? ( >=virtual/jre-1.6 )" && \
668 DEPEND="${DEPEND} java? ( >=virtual/jdk-1.6 )"
669 fi
670
671 # compile-time-only
672 DEPEND="${DEPEND}
673 virtual/yacc
674 static? ( sys-libs/ncurses[static-libs] )
675 >=dev-util/cmake-2.8.9
676 "
677
678 # For other stuff to bring us in
679 # dev-perl/DBD-mysql is needed by some scripts installed by MySQL
680 PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
681 ~virtual/mysql-${MYSQL_PV_MAJOR}"
682
683 # my_config.h includes ABI specific data
684 MULTILIB_WRAPPED_HEADERS=( /usr/include/mysql/my_config.h /usr/include/mysql/private/embedded_priv.h )
685
686 #
687 # HELPER FUNCTIONS:
688 #
689
690 # @FUNCTION: mysql-multilib_disable_test
691 # @DESCRIPTION:
692 # Helper function to disable specific tests.
693 mysql-multilib_disable_test() {
694 mysql-cmake_disable_test "$@"
695 }
696
697 #
698 # EBUILD FUNCTIONS
699 #
700
701 # @FUNCTION: mysql-multilib_pkg_setup
702 # @DESCRIPTION:
703 # Perform some basic tests and tasks during pkg_setup phase:
704 # die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
705 # create new user and group for mysql
706 # warn about deprecated features
707 mysql-multilib_pkg_setup() {
708
709 if has test ${FEATURES} ; then
710 if ! use minimal ; then
711 if ! has userpriv ${FEATURES} ; then
712 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
713 fi
714 fi
715 fi
716
717 # This should come after all of the die statements
718 enewgroup mysql 60 || die "problem adding 'mysql' group"
719 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
720
721 if use cluster && [[ "${PN}" != "mysql-cluster" ]]; then
722 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
723 ewarn "5.1 series should NOT be put into production. In the near"
724 ewarn "future, it will be disabled from building."
725 fi
726
727 if [[ ${PN} == "mysql-cluster" ]] ; then
728 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_setup
729 fi
730
731 if use_if_iuse tokudb && [[ $(gcc-major-version) -lt 4 || $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 7 ]] ; then
732 eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
733 eerror "Please use gcc-config to switch to gcc-4.7 or later version."
734 die
735 fi
736
737 }
738
739 # @FUNCTION: mysql-multilib_src_unpack
740 # @DESCRIPTION:
741 # Unpack the source code
742 mysql-multilib_src_unpack() {
743
744 # Initialize the proper variables first
745 mysql_init_vars
746
747 unpack ${A}
748 # Grab the patches
749 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-2_src_unpack
750
751 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
752 }
753
754 # @FUNCTION: mysql-multilib_src_prepare
755 # @DESCRIPTION:
756 # Apply patches to the source code and remove unneeded bundled libs.
757 mysql-multilib_src_prepare() {
758 mysql-cmake_src_prepare "$@"
759 if [[ ${PN} == "mysql-cluster" ]] ; then
760 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_src_prepare
761 fi
762 }
763
764
765 # @FUNCTION: mysql-multilib_src_configure
766 # @DESCRIPTION:
767 # Configure mysql to build the code for Gentoo respecting the use flags.
768 mysql-multilib_src_configure() {
769 multilib-minimal_src_configure
770 }
771
772 multilib_src_configure() {
773
774 debug-print-function ${FUNCNAME} "$@"
775
776 CMAKE_BUILD_TYPE="RelWithDebInfo"
777
778 # debug hack wrt #497532
779 mycmakeargs=(
780 -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
781 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
782 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
783 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
784 -DSYSCONFDIR=${EPREFIX}/etc/mysql
785 -DINSTALL_BINDIR=bin
786 -DINSTALL_DOCDIR=share/doc/${P}
787 -DINSTALL_DOCREADMEDIR=share/doc/${P}
788 -DINSTALL_INCLUDEDIR=include/mysql
789 -DINSTALL_INFODIR=share/info
790 -DINSTALL_LIBDIR=$(get_libdir)
791 -DINSTALL_ELIBDIR=$(get_libdir)/mysql
792 -DINSTALL_MANDIR=share/man
793 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
794 -DINSTALL_MYSQLSHAREDIR=share/mysql
795 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
796 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
797 -DINSTALL_SBINDIR=sbin
798 -DINSTALL_SCRIPTDIR=share/mysql/scripts
799 -DINSTALL_SQLBENCHDIR=share/mysql
800 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
801 -DWITH_COMMENT="Gentoo Linux ${PF}"
802 $(cmake-utils_use_with test UNIT_TESTS)
803 -DWITH_LIBEDIT=0
804 -DWITH_ZLIB=system
805 -DWITHOUT_LIBWRAP=1
806 -DENABLED_LOCAL_INFILE=1
807 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
808 -DWITH_SSL=$(usex ssl system bundled)
809 )
810
811 if in_iuse bindist ; then
812 mycmakeargs+=(
813 -DWITH_READLINE=$(usex bindist 1 0)
814 -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
815 $(usex bindist -DHAVE_BFD_H=0 '')
816 )
817 fi
818
819 mycmakeargs+=( -DWITH_EDITLINE=system )
820
821 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
822 mycmakeargs+=(
823 -DWITH_JEMALLOC=$(usex jemalloc system)
824 )
825
826 mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
827 fi
828
829 configure_cmake_locale
830
831 if multilib_is_native_abi && ! use minimal ; then
832 configure_cmake_standard
833 else
834 configure_cmake_minimal
835 fi
836
837 # Bug #114895, bug #110149
838 filter-flags "-O" "-O[01]"
839
840 CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
841 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
842 # Causes linkage failures. Upstream bug #59607 removes it
843 if ! mysql_version_is_at_least "5.6" ; then
844 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
845 fi
846 # As of 5.7, exceptions are used!
847 if ! mysql_version_is_at_least "5.7" ; then
848 CXXFLAGS="${CXXFLAGS} -fno-exceptions"
849 fi
850 export CXXFLAGS
851
852 # bug #283926, with GCC4.4, this is required to get correct behavior.
853 append-flags -fno-strict-aliasing
854
855 cmake-utils_src_configure
856 }
857
858 mysql-multilib_src_compile() {
859 local _cmake_args=( "${@}" )
860
861 multilib-minimal_src_compile
862 }
863
864 multilib_src_compile() {
865 cmake-utils_src_compile "${_cmake_args[@]}"
866 }
867
868
869 # @FUNCTION: mysql-multilib_src_install
870 # @DESCRIPTION:
871 # Install mysql.
872 mysql-multilib_src_install() {
873 multilib-minimal_src_install
874 }
875
876 multilib_src_install() {
877 debug-print-function ${FUNCNAME} "$@"
878
879 if multilib_is_native_abi; then
880 mysql-cmake_src_install
881 else
882 cmake-utils_src_install
883 if ! use minimal && [[ "${PN}" == "mariadb" || "${PN}" == "mariadb-galera" ]] ; then
884 insinto /usr/include/mysql/private
885 doins "${S}"/sql/*.h
886 fi
887 fi
888 }
889
890 # @FUNCTION: mysql-multilib_pkg_preinst
891 # @DESCRIPTION:
892 # Call java-pkg-opt-2 eclass when mysql-cluster is installed
893 mysql-multilib_pkg_preinst() {
894 debug-print-function ${FUNCNAME} "$@"
895
896 if [[ ${PN} == "mysql-cluster" ]] ; then
897 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_preinst
898 fi
899 }
900
901 # @FUNCTION: mysql-multilib_pkg_postinst
902 # @DESCRIPTION:
903 # Run post-installation tasks:
904 # create the dir for logfiles if non-existant
905 # touch the logfiles and secure them
906 # install scripts
907 # issue required steps for optional features
908 # issue deprecation warnings
909 mysql-multilib_pkg_postinst() {
910 debug-print-function ${FUNCNAME} "$@"
911
912 # Make sure the vars are correctly initialized
913 mysql_init_vars
914
915 # Check FEATURES="collision-protect" before removing this
916 [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
917
918 # Secure the logfiles
919 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
920 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
921 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
922
923 # Minimal builds don't have the MySQL server
924 if ! use minimal ; then
925 docinto "support-files"
926 for script in \
927 support-files/my-*.cnf \
928 support-files/magic \
929 support-files/ndb-config-2-node.ini
930 do
931 [[ -f "${script}" ]] \
932 && dodoc "${script}"
933 done
934
935 docinto "scripts"
936 for script in scripts/mysql* ; do
937 if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then
938 dodoc "${script}"
939 fi
940 done
941
942 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
943 if use_if_iuse pam ; then
944 einfo
945 elog "This install includes the PAM authentication plugin."
946 elog "To activate and configure the PAM plugin, please read:"
947 elog "https://kb.askmonty.org/en/pam-authentication-plugin/"
948 einfo
949 fi
950 fi
951
952 einfo
953 elog "You might want to run:"
954 elog "\"emerge --config =${CATEGORY}/${PF}\""
955 elog "if this is a new install."
956 einfo
957
958 einfo
959 elog "If you are upgrading major versions, you should run the"
960 elog "mysql_upgrade tool."
961 einfo
962
963 if [[ ${PN} == "mariadb-galera" ]] ; then
964 einfo
965 elog "Be sure to edit the my.cnf file to activate your cluster settings."
966 elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
967 elog "The first time the cluster is activated, you should add"
968 elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
969 elog "This option should then be removed for subsequent starts."
970 einfo
971 fi
972 fi
973 }
974
975 # @FUNCTION: mysql-multilib_getopt
976 # @DESCRIPTION:
977 # Use my_print_defaults to extract specific config options
978 mysql-multilib_getopt() {
979 local mypd="${EROOT}"/usr/bin/my_print_defaults
980 section="$1"
981 flag="--${2}="
982 "${mypd}" $section | sed -n "/^${flag}/p"
983 }
984
985 # @FUNCTION: mysql-multilib_getoptval
986 # @DESCRIPTION:
987 # Use my_print_defaults to extract specific config options
988 mysql-multilib_getoptval() {
989 local mypd="${EROOT}"/usr/bin/my_print_defaults
990 section="$1"
991 flag="--${2}="
992 "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
993 }
994
995 # @FUNCTION: mysql-multilib_pkg_config
996 # @DESCRIPTION:
997 # Configure mysql environment.
998 mysql-multilib_pkg_config() {
999
1000 debug-print-function ${FUNCNAME} "$@"
1001
1002 local old_MY_DATADIR="${MY_DATADIR}"
1003 local old_HOME="${HOME}"
1004 # my_print_defaults needs to read stuff in $HOME/.my.cnf
1005 export HOME=/root
1006
1007 # Make sure the vars are correctly initialized
1008 mysql_init_vars
1009
1010 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
1011
1012 if built_with_use ${CATEGORY}/${PN} minimal ; then
1013 die "Minimal builds do NOT include the MySQL server"
1014 fi
1015
1016 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
1017 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
1018 MY_DATADIR_s="${MY_DATADIR_s%%/}"
1019 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
1020 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
1021
1022 if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
1023 if [[ -d "${MY_DATADIR_s}" ]]; then
1024 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
1025 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
1026 else
1027 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
1028 mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
1029 || die "Moving MY_DATADIR failed"
1030 fi
1031 else
1032 ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
1033 if [[ -d "${MY_DATADIR_s}" ]]; then
1034 ewarn "Attempting to use ${MY_DATADIR_s}"
1035 else
1036 eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
1037 die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
1038 fi
1039 fi
1040 fi
1041
1042 local pwd1="a"
1043 local pwd2="b"
1044 local maxtry=15
1045
1046 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1047 MYSQL_ROOT_PASSWORD="$(mysql-multilib_getoptval 'client mysql' password)"
1048 fi
1049 MYSQL_TMPDIR="$(mysql-multilib_getoptval mysqld tmpdir)"
1050 # These are dir+prefix
1051 MYSQL_RELAY_LOG="$(mysql-multilib_getoptval mysqld relay-log)"
1052 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
1053 MYSQL_LOG_BIN="$(mysql-multilib_getoptval mysqld log-bin)"
1054 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
1055
1056 if [[ ! -d "${EROOT}"/$MYSQL_TMPDIR ]]; then
1057 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
1058 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
1059 fi
1060 if [[ ! -d "${EROOT}"/$MYSQL_LOG_BIN ]]; then
1061 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
1062 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
1063 fi
1064 if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
1065 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
1066 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
1067 fi
1068
1069 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
1070 ewarn "You have already a MySQL database in place."
1071 ewarn "(${ROOT}/${MY_DATADIR}/*)"
1072 ewarn "Please rename or delete it if you wish to replace it."
1073 die "MySQL database already exists!"
1074 fi
1075
1076 # Bug #213475 - MySQL _will_ object strenously if your machine is named
1077 # localhost. Also causes weird failures.
1078 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1079
1080 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1081
1082 einfo "Please provide a password for the mysql 'root' user now, in the"
1083 einfo "MYSQL_ROOT_PASSWORD env var or through the /root/.my.cnf file."
1084 ewarn "Avoid [\"'\\_%] characters in the password"
1085 read -rsp " >" pwd1 ; echo
1086
1087 einfo "Retype the password"
1088 read -rsp " >" pwd2 ; echo
1089
1090 if [[ "x$pwd1" != "x$pwd2" ]] ; then
1091 die "Passwords are not the same"
1092 fi
1093 MYSQL_ROOT_PASSWORD="${pwd1}"
1094 unset pwd1 pwd2
1095 fi
1096
1097 local options="--log-warnings=0"
1098 local sqltmp="$(emktemp)"
1099
1100 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
1101 [[ -r "${help_tables}" ]] \
1102 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
1103 || touch "${TMPDIR}/fill_help_tables.sql"
1104 help_tables="${TMPDIR}/fill_help_tables.sql"
1105
1106 # Figure out which options we need to disable to do the setup
1107 helpfile="${TMPDIR}/mysqld-help"
1108 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
1109 for opt in grant-tables host-cache name-resolve networking slave-start \
1110 federated ssl log-bin relay-log slow-query-log external-locking \
1111 ndbcluster log-slave-updates \
1112 ; do
1113 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1114 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
1115 done
1116 # But some options changed names
1117 egrep -sq external-locking "${helpfile}" && \
1118 options="${options/skip-locking/skip-external-locking}"
1119
1120 use prefix || options="${options} --user=mysql"
1121
1122 # Fix bug 446200. Don't reference host my.cnf
1123 use prefix && [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] \
1124 && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
1125
1126 # MySQL 5.6+ needs InnoDB
1127 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] ; then
1128 mysql_version_is_at_least "5.6" || options="${options} --loose-skip-innodb"
1129 fi
1130
1131 einfo "Creating the mysql database and setting proper"
1132 einfo "permissions on it ..."
1133
1134 # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
1135 PID_DIR="${EROOT}/var/run/mysqld"
1136 if [[ ! -d "${PID_DIR}" ]]; then
1137 mkdir -p "${PID_DIR}" || die "Could not create pid directory"
1138 chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
1139 chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
1140 fi
1141
1142 pushd "${TMPDIR}" &>/dev/null
1143 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
1144 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
1145 [[ -f ${cmd} ]] || cmd=${EROOT}usr/bin/mysql_install_db
1146 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${EROOT}/${MY_DATADIR}' '--tmpdir=${EROOT}/${MYSQL_TMPDIR}'"
1147 einfo "Command: $cmd"
1148 eval $cmd \
1149 >"${TMPDIR}"/mysql_install_db.log 2>&1
1150 if [ $? -ne 0 ]; then
1151 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1152 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1153 fi
1154 popd &>/dev/null
1155 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1156 || die "MySQL databases not installed"
1157 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
1158 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
1159
1160 # Filling timezones, see
1161 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1162 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
1163
1164 if [[ -r "${help_tables}" ]] ; then
1165 cat "${help_tables}" >> "${sqltmp}"
1166 fi
1167
1168 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1169 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1170 local mysqld="${EROOT}/usr/sbin/mysqld \
1171 ${options} \
1172 --user=mysql \
1173 --log-warnings=0 \
1174 --basedir=${EROOT}/usr \
1175 --datadir=${EROOT}/${MY_DATADIR} \
1176 --max_allowed_packet=8M \
1177 --net_buffer_length=16K \
1178 --default-storage-engine=MyISAM \
1179 --socket=${socket} \
1180 --pid-file=${pidfile}
1181 --tmpdir=${EROOT}/${MYSQL_TMPDIR}"
1182 #einfo "About to start mysqld: ${mysqld}"
1183 ebegin "Starting mysqld"
1184 einfo "Command ${mysqld}"
1185 ${mysqld} &
1186 rc=$?
1187 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1188 maxtry=$((${maxtry}-1))
1189 echo -n "."
1190 sleep 1
1191 done
1192 eend $rc
1193
1194 if ! [[ -S "${socket}" ]]; then
1195 die "Completely failed to start up mysqld with: ${mysqld}"
1196 fi
1197
1198 ebegin "Setting root password"
1199 # Do this from memory, as we don't want clear text passwords in temp files
1200 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
1201 "${EROOT}/usr/bin/mysql" \
1202 --socket=${socket} \
1203 -hlocalhost \
1204 -e "${sql}"
1205 eend $?
1206
1207 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
1208 "${EROOT}/usr/bin/mysql" \
1209 --socket=${socket} \
1210 -hlocalhost \
1211 -uroot \
1212 --password="${MYSQL_ROOT_PASSWORD}" \
1213 mysql < "${sqltmp}"
1214 rc=$?
1215 eend $?
1216 [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1217
1218 # Stop the server and cleanup
1219 einfo "Stopping the server ..."
1220 kill $(< "${pidfile}" )
1221 rm -f "${sqltmp}"
1222 wait %1
1223 einfo "Done"
1224 }