Gentoo Archives: gentoo-commits

From: Brian Evans <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sun, 13 Dec 2015 22:08:02
Message-Id: 1450043331.22da07c01732adcf4f7f3c1f700051b5150f6b4c.grknight@gentoo
1 commit: 22da07c01732adcf4f7f3c1f700051b5150f6b4c
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 13 21:48:51 2015 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 13 21:48:51 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=22da07c0
7
8 mysql-multilib-r1.eclass: New Eclass for building mysql servers
9
10 This eclass is a revision to the previous mysql-multilib to clean up
11 the duplicated code.
12 This includes specific dependencies for certain providers.
13
14 Provider specific information will be kept in the provider's ebuilds.
15 Only common items should be placed here and possibly exceptions to those
16 rules.
17
18 Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
19
20 eclass/mysql-multilib-r1.eclass | 1044 +++++++++++++++++++++++++++++++++++++++
21 1 file changed, 1044 insertions(+)
22
23 diff --git a/eclass/mysql-multilib-r1.eclass b/eclass/mysql-multilib-r1.eclass
24 new file mode 100644
25 index 0000000..082f65a
26 --- /dev/null
27 +++ b/eclass/mysql-multilib-r1.eclass
28 @@ -0,0 +1,1044 @@
29 +# Copyright 1999-2015 Gentoo Foundation
30 +# Distributed under the terms of the GNU General Public License v2
31 +# $Id$
32 +
33 +# @ECLASS: mysql-multilib.eclass
34 +# @MAINTAINER:
35 +# Maintainers:
36 +# - MySQL Team <mysql-bugs@g.o>
37 +# - Robin H. Johnson <robbat2@g.o>
38 +# - Jorge Manuel B. S. Vicetto <jmbsvicetto@g.o>
39 +# - Brian Evans <grknight@g.o>
40 +# @BLURB: This eclass provides common functions for mysql ebuilds
41 +# @DESCRIPTION:
42 +# The mysql-multilib-r1.eclass is the base eclass to build the mysql and
43 +# alternative projects (mariadb and percona) ebuilds.
44 +# Provider and version specific settings will be included in each ebuild.
45 +# It provides the src_unpack, src_prepare, src_configure, src_compile,
46 +# src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
47 +# phase hooks.
48 +
49 +MYSQL_EXTRAS=""
50 +
51 +# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
52 +# @DESCRIPTION:
53 +# The version of the MYSQL_EXTRAS repo to use to build mysql
54 +# Use "none" to disable it's use
55 +[[ ${MY_EXTRAS_VER} == "live" ]] && MYSQL_EXTRAS="git-r3"
56 +
57 +# @ECLASS-VARIABLE: MYSQL_CMAKE_NATIVE_DEFINES
58 +# @DESCRIPTION:
59 +# An array of extra CMake arguments for native multilib builds
60 +
61 +# @ECLASS-VARIABLE: MYSQL_CMAKE_NONNATIVE_DEFINES
62 +# @DESCRIPTION:
63 +# An array of extra CMake arguments for non-native multilib builds
64 +
65 +# @ECLASS-VARIABLE: MYSQL_CMAKE_EXTRA_DEFINES
66 +# @DESCRIPTION:
67 +# An array of CMake arguments added to native and non-native
68 +
69 +inherit eutils systemd flag-o-matic ${MYSQL_EXTRAS} mysql_fx versionator \
70 + multilib prefix toolchain-funcs user cmake-utils multilib-minimal
71 +
72 +#
73 +# Supported EAPI versions and export functions
74 +#
75 +
76 +case "${EAPI:-0}" in
77 + 5) ;;
78 + *) die "Unsupported EAPI: ${EAPI}" ;;
79 +esac
80 +
81 +EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config
82 +
83 +#
84 +# VARIABLES:
85 +#
86 +
87 +# Shorten the path because the socket path length must be shorter than 107 chars
88 +# and we will run a mysql server during test phase
89 +S="${WORKDIR}/mysql"
90 +
91 +[[ ${MY_EXTRAS_VER} == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
92 +if [[ ${MY_EXTRAS_VER} == "live" ]]; then
93 + EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
94 + EGIT_CHECKOUT_DIR=${WORKDIR}/mysql-extras
95 + EGIT_CLONE_TYPE=shallow
96 +fi
97 +
98 +# @ECLASS-VARIABLE: MYSQL_PV_MAJOR
99 +# @DESCRIPTION:
100 +# Upstream MySQL considers the first two parts of the version number to be the
101 +# major version. Upgrades that change major version should always run
102 +# mysql_upgrade.
103 +if [[ -z ${MYSQL_PV_MAJOR} ]] ; then MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})" ; fi
104 +
105 +# @ECLASS-VARIABLE: MYSQL_VERSION_ID
106 +# @DESCRIPTION:
107 +# MYSQL_VERSION_ID will be:
108 +# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
109 +# This is an important part, because many of the choices the MySQL ebuild will do
110 +# depend on this variable.
111 +# In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
112 +# We also strip off upstream's trailing letter that they use to respin tarballs
113 +MYSQL_VERSION_ID=""
114 +tpv="${PV%[a-z]}"
115 +tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
116 +for vatom in 0 1 2 3 ; do
117 + # pad to length 2
118 + tpv[${vatom}]="00${tpv[${vatom}]}"
119 + MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
120 +done
121 +# strip leading "0" (otherwise it's considered an octal number by BASH)
122 +MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
123 +
124 +# This eclass should only be used with at least mysql-5.5.35
125 +mysql_version_is_at_least "5.5.35" || die "This eclass should only be used with >=mysql-5.5.35"
126 +
127 +# Work out the default SERVER_URI correctly
128 +if [[ -z ${SERVER_URI} ]]; then
129 + if [[ ${PN} == "mariadb" ]]; then
130 + # Beginning with 5.5, MariaDB stopped putting beta, alpha or rc on their tarball names
131 + MARIA_FULL_PV=$(get_version_component_range 1-3)
132 + MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
133 + SERVER_URI="https://downloads.mariadb.org/interstitial/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz"
134 + elif [[ ${PN} == "percona-server" ]]; then
135 + PERCONA_PN="Percona-Server"
136 + MIRROR_PV=$(get_version_component_range 1-2 ${PV})
137 + MY_PV=$(get_version_component_range 1-3 ${PV})
138 + PERCONA_RELEASE=$(get_version_component_range 4-5 ${PV})
139 + PERCONA_RC=$(get_version_component_range 6 ${PV})
140 + SERVER_URI="http://www.percona.com/redir/downloads/${PERCONA_PN}-${MIRROR_PV}/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}/source/tarball/${PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}.tar.gz"
141 + else
142 + if [[ "${PN}" == "mysql-cluster" ]] ; then
143 + URI_DIR="MySQL-Cluster"
144 + URI_FILE="mysql-cluster-gpl"
145 + else
146 + URI_DIR="MySQL"
147 + URI_FILE="mysql"
148 + fi
149 + [[ -z ${MY_PV} ]] && MY_PV="${PV//_/-}"
150 + URI_A="${URI_FILE}-${MY_PV}.tar.gz"
151 + MIRROR_PV=$(get_version_component_range 1-2 ${PV})
152 + # Recently upstream switched to an archive site, and not on mirrors
153 + SERVER_URI="http://cdn.mysql.com/Downloads/${URI_DIR}-${MIRROR_PV}/${URI_A}
154 + http://downloads.mysql.com/archives/${URI_DIR}-${MIRROR_PV}/${URI_A}"
155 + fi
156 +fi
157 +
158 +# Define correct SRC_URIs
159 +SRC_URI="${SERVER_URI}"
160 +
161 +# Gentoo patches to MySQL
162 +if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then
163 + SRC_URI="${SRC_URI}
164 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
165 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
166 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
167 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
168 +fi
169 +
170 +DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
171 +HOMEPAGE="http://www.mysql.com/"
172 +LICENSE="GPL-2"
173 +SLOT="0/${SUBSLOT:-0}"
174 +
175 +IUSE="debug embedded extraengine jemalloc latin1 libressl +openssl
176 + +perl profiling selinux +server systemtap static static-libs tcmalloc test yassl"
177 +
178 +REQUIRED_USE="^^ ( yassl openssl libressl )"
179 +
180 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
181 +RESTRICT="libressl? ( test )"
182 +
183 +REQUIRED_USE="!server? ( !extraengine !embedded )
184 + ?? ( tcmalloc jemalloc )
185 + static? ( !libressl !openssl yassl )"
186 +
187 +#
188 +# DEPENDENCIES:
189 +#
190 +
191 +# Be warned, *DEPEND are version-dependant
192 +# These are used for both runtime and compiletime
193 +# MULTILIB_USEDEP only set for libraries used by the client library
194 +DEPEND="
195 + kernel_linux? (
196 + sys-process/procps:0=
197 + dev-libs/libaio:0=
198 + )
199 + >=sys-apps/sed-4
200 + >=sys-apps/texinfo-4.7-r1
201 + !dev-db/mariadb-native-client[mysqlcompat]
202 + jemalloc? ( dev-libs/jemalloc:0= )
203 + tcmalloc? ( dev-util/google-perftools:0= )
204 + systemtap? ( >=dev-util/systemtap-1.3:0= )
205 + openssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
206 + libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] )
207 + >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
208 + sys-libs/ncurses:0=
209 +"
210 +
211 +# prefix: first need to implement something for #196294
212 +RDEPEND="${DEPEND}
213 + selinux? ( sec-policy/selinux-mysql )
214 + abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] )
215 +"
216 +
217 +# Having different flavours at the same time is not a good idea
218 +for i in "mysql" "mariadb" "mariadb-galera" "percona-server" "mysql-cluster" ; do
219 + [[ ${i} == ${PN} ]] ||
220 + RDEPEND="${RDEPEND} !dev-db/${i}"
221 +done
222 +
223 +RDEPEND="${RDEPEND}
224 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
225 + !<virtual/mysql-5.6-r4"
226 +
227 +# compile-time-only
228 +# ncurses only needs multilib for compile time due to a binary that will be not installed
229 +DEPEND="${DEPEND}
230 + virtual/yacc
231 + static? ( sys-libs/ncurses[static-libs] )
232 +"
233 +
234 +# For other stuff to bring us in
235 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
236 +PDEPEND="${PDEPEND} perl? ( >=dev-perl/DBD-mysql-2.9004 )
237 + ~virtual/mysql-${MYSQL_PV_MAJOR}"
238 +
239 +# my_config.h includes ABI specific data
240 +MULTILIB_WRAPPED_HEADERS=( /usr/include/mysql/my_config.h /usr/include/mysql/private/embedded_priv.h )
241 +
242 +#
243 +# EBUILD FUNCTIONS
244 +#
245 +
246 +# @FUNCTION: mysql-multilib-r1_pkg_pretend
247 +# @DESCRIPTION:
248 +# Perform some basic tests and tasks during pkg_pretend phase:
249 +mysql-multilib-r1_pkg_pretend() {
250 + if [[ ${MERGE_TYPE} != binary ]] ; then
251 + local GCC_MAJOR_SET=$(gcc-major-version)
252 + local GCC_MINOR_SET=$(gcc-minor-version)
253 + if use_if_iuse tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
254 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
255 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
256 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
257 + die
258 + fi
259 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
260 + # non x86{,_64} arches
261 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
262 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
263 + eerror "${PN} needs to be built with gcc-4.7 or later."
264 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
265 + die
266 + fi
267 + fi
268 +}
269 +
270 +# @FUNCTION: mysql-multilib-r1_pkg_setup
271 +# @DESCRIPTION:
272 +# Perform some basic tests and tasks during pkg_setup phase:
273 +# die if FEATURES="test", USE="server" and not using FEATURES="userpriv"
274 +# create new user and group for mysql
275 +# warn about deprecated features
276 +mysql-multilib-r1_pkg_setup() {
277 +
278 + if has test ${FEATURES} && \
279 + use server && ! has userpriv ${FEATURES} ; then
280 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
281 + fi
282 +
283 + # This should come after all of the die statements
284 + enewgroup mysql 60 || die "problem adding 'mysql' group"
285 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
286 +}
287 +
288 +# @FUNCTION: mysql-multilib-r1_src_unpack
289 +# @DESCRIPTION:
290 +# Unpack the source code
291 +mysql-multilib-r1_src_unpack() {
292 +
293 + # Initialize the proper variables first
294 + mysql_init_vars
295 +
296 + unpack ${A}
297 + # Grab the patches
298 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
299 +
300 + mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
301 +}
302 +
303 +# @FUNCTION: mysql-multilib-r1_src_prepare
304 +# @DESCRIPTION:
305 +# Apply patches to the source code and remove unneeded bundled libs.
306 +mysql-multilib-r1_src_prepare() {
307 +
308 + debug-print-function ${FUNCNAME} "$@"
309 +
310 + cd "${S}"
311 +
312 + if [[ ${MY_EXTRAS_VER} != none ]]; then
313 +
314 + # Apply the patches for this MySQL version
315 + EPATCH_SUFFIX="patch"
316 + mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
317 + # Clean out old items
318 + rm -f "${EPATCH_SOURCE}"/*
319 + # Now link in right patches
320 + mysql_mv_patches
321 + # And apply
322 + epatch
323 + fi
324 +
325 + # last -fPIC fixup, per bug #305873
326 + i="${S}"/storage/innodb_plugin/plug.in
327 + if [[ -f ${i} ]] ; then sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}" || die ; fi
328 +
329 + rm -f "scripts/mysqlbug"
330 + if use jemalloc && [[ ${PN} != "mariadb" ]] ; then
331 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
332 + fi
333 +
334 + if use tcmalloc; then
335 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
336 + fi
337 +
338 + if in_iuse tokudb ; then
339 + # Don't build bundled xz-utils
340 + if [[ -d "${S}/storage/tokudb/ft-index" ]] ; then
341 + rm -f "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die
342 + touch "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die
343 + sed -i 's/ build_lzma//' "${S}/storage/tokudb/ft-index/ft/CMakeLists.txt" || die
344 + elif [[ -d "${S}/storage/tokudb/PerconaFT" ]] ; then
345 + rm "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
346 + touch "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
347 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
348 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
349 + fi
350 +
351 + if [[ -d "${S}/plugin/tokudb-backup-plugin" ]] && ! use tokudb-backup-plugin ; then
352 + rm -r "${S}/plugin/tokudb-backup-plugin/Percona-TokuBackup" || die
353 + fi
354 + fi
355 +
356 + # Remove the bundled groonga if it exists
357 + # There is no CMake flag, it simply checks for existance
358 + if [[ -d "${S}"/storage/mroonga/vendor/groonga ]] ; then
359 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
360 + fi
361 +
362 + epatch_user
363 +}
364 +
365 +# @FUNCTION: mysql-multilib-r1_src_configure
366 +# @DESCRIPTION:
367 +# Configure mysql to build the code for Gentoo respecting the use flags.
368 +mysql-multilib-r1_src_configure() {
369 + # Bug #114895, bug #110149
370 + filter-flags "-O" "-O[01]"
371 +
372 + append-cxxflags -felide-constructors -fno-rtti
373 +
374 + # bug #283926, with GCC4.4, this is required to get correct behavior.
375 + append-flags -fno-strict-aliasing
376 +
377 + multilib-minimal_src_configure
378 +}
379 +
380 +multilib_src_configure() {
381 + debug-print-function ${FUNCNAME} "$@"
382 +
383 + CMAKE_BUILD_TYPE="RelWithDebInfo"
384 +
385 + # debug hack wrt #497532
386 + mycmakeargs=(
387 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
388 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
389 + -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
390 + -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
391 + -DSYSCONFDIR=${EPREFIX}/etc/mysql
392 + -DINSTALL_BINDIR=bin
393 + -DINSTALL_DOCDIR=share/doc/${PF}
394 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
395 + -DINSTALL_INCLUDEDIR=include/mysql
396 + -DINSTALL_INFODIR=share/info
397 + -DINSTALL_LIBDIR=$(get_libdir)
398 + -DINSTALL_ELIBDIR=$(get_libdir)/mysql
399 + -DINSTALL_MANDIR=share/man
400 + -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
401 + -DINSTALL_MYSQLSHAREDIR=share/mysql
402 + -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
403 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
404 + -DINSTALL_SBINDIR=sbin
405 + -DINSTALL_SCRIPTDIR=share/mysql/scripts
406 + -DINSTALL_SQLBENCHDIR=share/mysql
407 + -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
408 + -DWITH_COMMENT="Gentoo Linux ${PF}"
409 + -DWITH_UNIT_TESTS=$(usex test)
410 + -DWITH_LIBEDIT=0
411 + -DWITH_ZLIB=system
412 + -DWITHOUT_LIBWRAP=1
413 + -DENABLED_LOCAL_INFILE=1
414 + -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
415 + -DINSTALL_UNIX_ADDRDIR=${EPREFIX}/var/run/mysqld/mysqld.sock
416 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
417 + -DWITH_DEFAULT_FEATURE_SET=0
418 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_unitdir)"
419 + )
420 +
421 + if in_iuse systemd ; then
422 + mycmakeargs+=( -DWITH_SYSTEMD=$(usex systemd) )
423 + fi
424 +
425 + if use openssl || use libressl ; then
426 + mycmakeargs+=( -DWITH_SSL=system )
427 + else
428 + mycmakeargs+=( -DWITH_SSL=bundled )
429 + fi
430 +
431 + if ! multilib_is_native_abi ; then
432 + mycmakeargs+=( -DWITHOUT_TOOLS=1 )
433 + fi
434 +
435 + if in_iuse bindist ; then
436 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
437 + if multilib_is_native_abi; then
438 + mycmakeargs+=(
439 + -DWITH_READLINE=$(usex bindist 1 0)
440 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
441 + )
442 + else
443 + mycmakeargs+=(
444 + -DWITH_READLINE=1
445 + -DNOT_FOR_DISTRIBUTION=0
446 + )
447 + fi
448 + fi
449 +
450 + ### TODO: make this system but issues with UTF-8 prevent it
451 + mycmakeargs+=( -DWITH_EDITLINE=bundled )
452 +
453 + if multilib_is_native_abi && use server ; then
454 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
455 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
456 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
457 + ewarn "You MUST file bugs without these variables set."
458 +
459 + mycmakeargs+=(
460 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
461 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
462 + )
463 +
464 + elif ! use latin1 ; then
465 + mycmakeargs+=(
466 + -DDEFAULT_CHARSET=utf8
467 + -DDEFAULT_COLLATION=utf8_general_ci
468 + )
469 + else
470 + mycmakeargs+=(
471 + -DDEFAULT_CHARSET=latin1
472 + -DDEFAULT_COLLATION=latin1_swedish_ci
473 + )
474 + fi
475 + mycmakeargs+=(
476 + -DEXTRA_CHARSETS=all
477 + -DMYSQL_USER=mysql
478 + -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
479 + -DDISABLE_SHARED=$(usex static YES NO)
480 + -DWITH_DEBUG=$(usex debug)
481 + -DWITH_EMBEDDED_SERVER=$(usex embedded)
482 + -DWITH_PROFILING=$(usex profiling)
483 + )
484 +
485 + if use static; then
486 + mycmakeargs+=( -DWITH_PIC=1 )
487 + fi
488 +
489 + if use jemalloc || use tcmalloc ; then
490 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
491 + fi
492 +
493 + # Storage engines
494 + mycmakeargs+=(
495 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
496 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
497 + -DWITH_CSV_STORAGE_ENGINE=1
498 + -DWITH_HEAP_STORAGE_ENGINE=1
499 + -DWITH_INNOBASE_STORAGE_ENGINE=1
500 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
501 + -DWITH_MYISAM_STORAGE_ENGINE=1
502 + -DWITH_PARTITION_STORAGE_ENGINE=1
503 + )
504 +
505 + mycmakeargs+=( -DWITH_FEDERATED_STORAGE_ENGINE=$(usex extraengine) )
506 + else
507 + mycmakeargs+=(
508 + -DWITHOUT_SERVER=1
509 + -DWITHOUT_EMBEDDED_SERVER=1
510 + -DEXTRA_CHARSETS=none
511 + -DINSTALL_SQLBENCHDIR=
512 + )
513 + fi
514 +
515 + # systemtap only works on native ABI bug 530132
516 + if multilib_is_native_abi; then
517 + mycmakeargs+=( -DENABLE_DTRACE=$(usex systemtap)
518 + "${MYSQL_CMAKE_NATIVE_DEFINES[@]}" )
519 + else
520 + mycmakeargs+=( -DENABLE_DTRACE=0
521 + "${MYSQL_CMAKE_NONNATIVE_DEFINES[@]}" )
522 + fi
523 +
524 + mycmakeargs+=( "${MYSQL_CMAKE_EXTRA_DEFINES[@]}" )
525 +
526 + cmake-utils_src_configure
527 +}
528 +
529 +mysql-multilib-r1_src_compile() {
530 + local _cmake_args=( "${@}" )
531 +
532 + multilib-minimal_src_compile
533 +}
534 +
535 +multilib_src_compile() {
536 +
537 + cmake-utils_src_compile "${_cmake_args[@]}"
538 +}
539 +
540 +
541 +# @FUNCTION: mysql-multilib_src_install
542 +# @DESCRIPTION:
543 +# Install mysql.
544 +mysql-multilib-r1_src_install() {
545 + # wrap the config script
546 + MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config )
547 +
548 + multilib-minimal_src_install
549 +}
550 +
551 +multilib_src_install() {
552 + debug-print-function ${FUNCNAME} "$@"
553 +
554 + if multilib_is_native_abi; then
555 + # Make sure the vars are correctly initialized
556 + mysql_init_vars
557 +
558 + cmake-utils_src_install
559 +
560 + # Convenience links
561 + einfo "Making Convenience links for mysqlcheck multi-call binary"
562 + dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
563 + dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
564 + dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
565 +
566 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
567 + if [[ -d "${ED}/usr/data" ]] ; then
568 + rm -Rf "${ED}/usr/data" || die
569 + fi
570 +
571 + # Unless they explicitly specific USE=test, then do not install the
572 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
573 + # validation of your database configuration after tuning it.
574 + if ! use test ; then
575 + rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
576 + fi
577 +
578 + # Configuration stuff
579 + case ${MYSQL_PV_MAJOR} in
580 + 5.5) mysql_mycnf_version="5.5" ;;
581 + 5.[6-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.6" ;;
582 + esac
583 + einfo "Building default my.cnf (${mysql_mycnf_version})"
584 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
585 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
586 + mycnf_src="my.cnf-${mysql_mycnf_version}"
587 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
588 + "${FILESDIR}/${mycnf_src}" \
589 + > "${TMPDIR}/my.cnf.ok" || die
590 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
591 + if use latin1 ; then
592 + sed -i \
593 + -e "/character-set/s|utf8|latin1|g" \
594 + "${TMPDIR}/my.cnf.ok" || die
595 + fi
596 + eprefixify "${TMPDIR}/my.cnf.ok"
597 + newins "${TMPDIR}/my.cnf.ok" my.cnf
598 +
599 + if use server ; then
600 + einfo "Creating initial directories"
601 + # Empty directories ...
602 + diropts "-m0750"
603 + if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
604 + dodir "${MY_DATADIR#${EPREFIX}}"
605 + keepdir "${MY_DATADIR#${EPREFIX}}"
606 + chown -R mysql:mysql "${D}/${MY_DATADIR}"
607 + fi
608 +
609 + diropts "-m0755"
610 + for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
611 + dodir "${folder}"
612 + keepdir "${folder}"
613 + chown -R mysql:mysql "${ED}/${folder}"
614 + done
615 +
616 + einfo "Including support files and sample configurations"
617 + docinto "support-files"
618 + for script in \
619 + "${S}"/support-files/my-*.cnf.sh \
620 + "${S}"/support-files/magic \
621 + "${S}"/support-files/ndb-config-2-node.ini.sh
622 + do
623 + [[ -f $script ]] && dodoc "${script}"
624 + done
625 +
626 + docinto "scripts"
627 + for script in "${S}"/scripts/mysql* ; do
628 + [[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}"
629 + done
630 + fi
631 +
632 + #Remove mytop if perl is not selected
633 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
634 +
635 + # Percona has decided to rename libmysqlclient to libperconaserverclient
636 + # Use a symlink to preserve linkages for those who don't use mysql_config
637 + local suffix
638 + for suffix in ".so" "_r.so" ".a" "_r.a" ; do
639 + if [[ -e "${ED}/usr/$(get_libdir)/libperconaserverclient${suffix}" ]] ; then
640 + dosym libperconaserverclient${suffix} /usr/$(get_libdir)/libmysqlclient${suffix}
641 + fi
642 + done
643 + else
644 + cmake-utils_src_install
645 + if [[ "${PN}" == "mariadb" ]] && use server ; then
646 + insinto /usr/include/mysql/private
647 + doins "${S}"/sql/*.h
648 + fi
649 + fi
650 +}
651 +
652 +# @FUNCTION: mysql-multilib_pkg_preinst
653 +# @DESCRIPTION:
654 +mysql-multilib-r1_pkg_preinst() {
655 + debug-print-function ${FUNCNAME} "$@"
656 +
657 + # Here we need to see if the implementation switched client libraries
658 + # We check if this is a new instance of the package and a client library already exists
659 + local SHOW_ABI_MESSAGE
660 + if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
661 + elog "Due to ABI changes when switching between different client libraries,"
662 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
663 + elog "Please run: revdep-rebuild --library libmysqlclient.so.${SUBSLOT:-18}"
664 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
665 + fi
666 +}
667 +
668 +# @FUNCTION: mysql-multilib-r1_pkg_postinst
669 +# @DESCRIPTION:
670 +# Run post-installation tasks:
671 +# create the dir for logfiles if non-existant
672 +# touch the logfiles and secure them
673 +# install scripts
674 +# issue required steps for optional features
675 +# issue deprecation warnings
676 +mysql-multilib-r1_pkg_postinst() {
677 + debug-print-function ${FUNCNAME} "$@"
678 +
679 + # Make sure the vars are correctly initialized
680 + mysql_init_vars
681 +
682 + # Check FEATURES="collision-protect" before removing this
683 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
684 +
685 + # Secure the logfiles
686 + touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
687 + chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
688 + chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
689 +
690 + # Minimal builds don't have the MySQL server
691 + if use server ; then
692 + docinto "support-files"
693 + for script in \
694 + support-files/my-*.cnf \
695 + support-files/magic \
696 + support-files/ndb-config-2-node.ini
697 + do
698 + [[ -f "${script}" ]] \
699 + && dodoc "${script}"
700 + done
701 +
702 + docinto "scripts"
703 + for script in scripts/mysql* ; do
704 + if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then
705 + dodoc "${script}"
706 + fi
707 + done
708 +
709 + if use_if_iuse pam ; then
710 + einfo
711 + elog "This install includes the PAM authentication plugin."
712 + elog "To activate and configure the PAM plugin, please read:"
713 + if [[ ${PN} == "mariadb" ]] ; then
714 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
715 + elif [[ ${PN} == "percona-server" ]] ; then
716 + elog "https://www.percona.com/doc/percona-server/5.6/management/pam_plugin.html"
717 + fi
718 + einfo
719 + fi
720 +
721 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
722 + einfo
723 + elog "You might want to run:"
724 + elog "\"emerge --config =${CATEGORY}/${PF}\""
725 + elog "if this is a new install."
726 + elog
727 + elog "If you are switching server implentations, you should run the"
728 + elog "mysql_upgrade tool."
729 + einfo
730 + else
731 + einfo
732 + elog "If you are upgrading major versions, you should run the"
733 + elog "mysql_upgrade tool."
734 + einfo
735 + fi
736 +
737 + if use_if_iuse galera ; then
738 + einfo
739 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
740 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
741 + elog "The first time the cluster is activated, you should add"
742 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
743 + elog "This option should then be removed for subsequent starts."
744 + einfo
745 + fi
746 + fi
747 +}
748 +
749 +# @FUNCTION: mysql-multilib-r1_getopt
750 +# @DESCRIPTION:
751 +# Use my_print_defaults to extract specific config options
752 +mysql-multilib-r1_getopt() {
753 + local mypd="${EROOT}"/usr/bin/my_print_defaults
754 + section="$1"
755 + flag="--${2}="
756 + "${mypd}" $section | sed -n "/^${flag}/p"
757 +}
758 +
759 +# @FUNCTION: mysql-multilib-r1_getoptval
760 +# @DESCRIPTION:
761 +# Use my_print_defaults to extract specific config options
762 +mysql-multilib-r1_getoptval() {
763 + local mypd="${EROOT}"/usr/bin/my_print_defaults
764 + local section="$1"
765 + local flag="--${2}="
766 + local extra_options="${3}"
767 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
768 +}
769 +
770 +# @FUNCTION: mysql-multilib_pkg_config
771 +# @DESCRIPTION:
772 +# Configure mysql environment.
773 +mysql-multilib-r1_pkg_config() {
774 +
775 + debug-print-function ${FUNCNAME} "$@"
776 +
777 + local old_MY_DATADIR="${MY_DATADIR}"
778 + local old_HOME="${HOME}"
779 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
780 + export HOME=${EPREFIX}/root
781 +
782 + # Make sure the vars are correctly initialized
783 + mysql_init_vars
784 +
785 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
786 + if ! built_with_use ${CATEGORY}/${PN} server ; then
787 + die "Minimal builds do NOT include the MySQL server"
788 + fi
789 +
790 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
791 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
792 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
793 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
794 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
795 +
796 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
797 + if [[ -d "${MY_DATADIR_s}" ]]; then
798 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
799 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
800 + else
801 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
802 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
803 + || die "Moving MY_DATADIR failed"
804 + fi
805 + else
806 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
807 + if [[ -d "${MY_DATADIR_s}" ]]; then
808 + ewarn "Attempting to use ${MY_DATADIR_s}"
809 + else
810 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
811 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
812 + fi
813 + fi
814 + fi
815 +
816 + local pwd1="a"
817 + local pwd2="b"
818 + local maxtry=15
819 +
820 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
821 + MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password)"
822 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
823 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
824 + MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password --show)"
825 + fi
826 + fi
827 + MYSQL_TMPDIR="$(mysql-multilib-r1_getoptval mysqld tmpdir)"
828 + # These are dir+prefix
829 + MYSQL_RELAY_LOG="$(mysql-multilib-r1_getoptval mysqld relay-log)"
830 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
831 + MYSQL_LOG_BIN="$(mysql-multilib-r1_getoptval mysqld log-bin)"
832 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
833 +
834 + if [[ ! -d "${ROOT}"/$MYSQL_TMPDIR ]]; then
835 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
836 + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
837 + fi
838 + if [[ ! -d "${ROOT}"/$MYSQL_LOG_BIN ]]; then
839 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
840 + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
841 + fi
842 + if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
843 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
844 + install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
845 + fi
846 +
847 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
848 + ewarn "You have already a MySQL database in place."
849 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
850 + ewarn "Please rename or delete it if you wish to replace it."
851 + die "MySQL database already exists!"
852 + fi
853 +
854 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
855 + # localhost. Also causes weird failures.
856 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
857 +
858 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
859 +
860 + einfo "Please provide a password for the mysql 'root' user now"
861 + einfo "or through the ${HOME}/.my.cnf file."
862 + ewarn "Avoid [\"'\\_%] characters in the password"
863 + read -rsp " >" pwd1 ; echo
864 +
865 + einfo "Retype the password"
866 + read -rsp " >" pwd2 ; echo
867 +
868 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
869 + die "Passwords are not the same"
870 + fi
871 + MYSQL_ROOT_PASSWORD="${pwd1}"
872 + unset pwd1 pwd2
873 + fi
874 +
875 + local options
876 + local sqltmp="$(emktemp)"
877 +
878 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
879 + # see http://bugs.mysql.com/bug.php?id=31312
880 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
881 +
882 + local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
883 + [[ -r "${help_tables}" ]] \
884 + && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
885 + || touch "${TMPDIR}/fill_help_tables.sql"
886 + help_tables="${TMPDIR}/fill_help_tables.sql"
887 +
888 + # Figure out which options we need to disable to do the setup
889 + local helpfile="${TMPDIR}/mysqld-help"
890 + ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
891 + for opt in grant-tables host-cache name-resolve networking slave-start \
892 + federated ssl log-bin relay-log slow-query-log external-locking \
893 + ndbcluster log-slave-updates \
894 + ; do
895 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
896 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
897 + done
898 + # But some options changed names
899 + egrep -sq external-locking "${helpfile}" && \
900 + options="${options/skip-locking/skip-external-locking}"
901 +
902 + use prefix || options="${options} --user=mysql"
903 +
904 + einfo "Creating the mysql database and setting proper permissions on it ..."
905 +
906 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
907 + PID_DIR="${EROOT}/var/run/mysqld"
908 + if [[ ! -d "${PID_DIR}" ]]; then
909 + mkdir -p "${PID_DIR}" || die "Could not create pid directory"
910 + chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
911 + chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
912 + fi
913 +
914 + pushd "${TMPDIR}" &>/dev/null
915 +
916 + # Filling timezones, see
917 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
918 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
919 +
920 + local cmd
921 + local initialize_options
922 + if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.7.6" ; then
923 + # --initialize-insecure will not set root password
924 + # --initialize would set a random one in the log which we don't need as we set it ourselves
925 + cmd="${EROOT}usr/sbin/mysqld"
926 + initialize_options="--initialize-insecure '--init-file=${sqltmp}'"
927 + sqltmp="" # the initialize will take care of it
928 + else
929 + cmd="${EROOT}usr/share/mysql/scripts/mysql_install_db"
930 + [[ -f "${cmd}" ]] || cmd="${EROOT}usr/bin/mysql_install_db"
931 + if [[ -r "${help_tables}" ]] ; then
932 + cat "${help_tables}" >> "${sqltmp}"
933 + fi
934 + fi
935 + cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${ROOT}/${MY_DATADIR}' '--tmpdir=${ROOT}/${MYSQL_TMPDIR}' ${initialize_options}"
936 + einfo "Command: $cmd"
937 + eval $cmd \
938 + >"${TMPDIR}"/mysql_install_db.log 2>&1
939 + if [ $? -ne 0 ]; then
940 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
941 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
942 + fi
943 + popd &>/dev/null
944 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
945 + || die "MySQL databases not installed"
946 + chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
947 + chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
948 +
949 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
950 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
951 + local mysqld="${EROOT}/usr/sbin/mysqld \
952 + ${options} \
953 + $(use prefix || echo --user=mysql) \
954 + --log-warnings=0 \
955 + --basedir=${EROOT}/usr \
956 + --datadir=${ROOT}/${MY_DATADIR} \
957 + --max_allowed_packet=8M \
958 + --net_buffer_length=16K \
959 + --default-storage-engine=MyISAM \
960 + --socket=${socket} \
961 + --pid-file=${pidfile}
962 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
963 + #einfo "About to start mysqld: ${mysqld}"
964 + ebegin "Starting mysqld"
965 + einfo "Command ${mysqld}"
966 + ${mysqld} &
967 + rc=$?
968 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
969 + maxtry=$((${maxtry}-1))
970 + echo -n "."
971 + sleep 1
972 + done
973 + eend $rc
974 +
975 + if ! [[ -S "${socket}" ]]; then
976 + die "Completely failed to start up mysqld with: ${mysqld}"
977 + fi
978 +
979 + ebegin "Setting root password"
980 + # Do this from memory, as we don't want clear text passwords in temp files
981 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
982 + "${EROOT}/usr/bin/mysql" \
983 + --socket=${socket} \
984 + -hlocalhost \
985 + -e "${sql}"
986 + eend $?
987 +
988 + if [[ -n "${sqltmp}" ]] ; then
989 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
990 + "${EROOT}/usr/bin/mysql" \
991 + --socket=${socket} \
992 + -hlocalhost \
993 + -uroot \
994 + --password="${MYSQL_ROOT_PASSWORD}" \
995 + mysql < "${sqltmp}"
996 + rc=$?
997 + eend $?
998 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
999 + fi
1000 +
1001 + # Stop the server and cleanup
1002 + einfo "Stopping the server ..."
1003 + kill $(< "${pidfile}" )
1004 + rm -f "${sqltmp}"
1005 + wait %1
1006 + einfo "Done"
1007 +}
1008 +
1009 +
1010 +#
1011 +# HELPER FUNCTIONS:
1012 +#
1013 +
1014 +# @FUNCTION: mysql-multilib-r1_disable_test
1015 +# @DESCRIPTION:
1016 +# Helper function to disable specific tests.
1017 +mysql-multilib-r1_disable_test() {
1018 +
1019 + local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
1020 + rawtestname="${1}" ; shift
1021 + reason="${@}"
1022 + ewarn "test '${rawtestname}' disabled: '${reason}'"
1023 +
1024 + testsuite="${rawtestname/.*}"
1025 + testname="${rawtestname/*.}"
1026 + for mysql_disabled_file in \
1027 + ${S}/mysql-test/disabled.def \
1028 + ${S}/mysql-test/t/disabled.def ; do
1029 + [[ -f ${mysql_disabled_file} ]] && break
1030 + done
1031 + #mysql_disabled_file="${S}/mysql-test/t/disabled.def"
1032 + #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
1033 + echo ${testname} : ${reason} >> "${mysql_disabled_file}"
1034 +
1035 + if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then
1036 + for mysql_disabled_file in \
1037 + ${S}/mysql-test/suite/${testsuite}/disabled.def \
1038 + ${S}/mysql-test/suite/${testsuite}/t/disabled.def \
1039 + FAILED ; do
1040 + [[ -f ${mysql_disabled_file} ]] && break
1041 + done
1042 + if [[ ${mysql_disabled_file} != "FAILED" ]]; then
1043 + echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
1044 + else
1045 + for mysql_disabled_dir in \
1046 + ${S}/mysql-test/suite/${testsuite} \
1047 + ${S}/mysql-test/suite/${testsuite}/t \
1048 + FAILED ; do
1049 + [[ -d ${mysql_disabled_dir} ]] && break
1050 + done
1051 + if [[ ${mysql_disabled_dir} != "FAILED" ]]; then
1052 + echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
1053 + else
1054 + ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
1055 + fi
1056 + fi
1057 + fi
1058 +}
1059 +
1060 +# @FUNCTION: mysql-cmake_use_plugin
1061 +# @DESCRIPTION:
1062 +# Helper function to enable/disable plugins by use flags
1063 +# cmake-utils_use_with is not enough as some references check WITH_ (0|1)
1064 +# and some check WITHOUT_. Also, this can easily extend to non-storage plugins.
1065 +mysql-cmake_use_plugin() {
1066 + [[ -z $2 ]] && die "mysql-cmake_use_plugin <USE flag> <flag name>"
1067 + if use_if_iuse $1 ; then
1068 + echo "-DWITH_$2=1 -DPLUGIN_$2=YES"
1069 + else
1070 + echo "-DWITHOUT_$2=1 -DWITH_$2=0 -DPLUGIN_$2=NO"
1071 + fi
1072 +}