1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: mysql-multilib.eclass
8 # - MySQL Team <mysql-bugs@gentoo.org>
9 # - Robin H. Johnson <robbat2@gentoo.org>
10 # - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
11 # - Brian Evans <grknight@gentoo.org>
12 # @BLURB: This eclass provides most of the functions for mysql ebuilds
14 # The mysql-multilib.eclass is the base eclass to build the mysql and
15 # alternative projects (mariadb and percona) ebuilds.
16 # This eclass uses the mysql-cmake eclass for the
17 # specific bits related to the build system.
18 # It provides the src_unpack, src_prepare, src_configure, src_compile,
19 # src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
24 # @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
26 # The version of the MYSQL_EXTRAS repo to use to build mysql
27 # Use "none" to disable it's use
28 [[ ${MY_EXTRAS_VER} == "live" ]] && MYSQL_EXTRAS="git-r3"
30 inherit eutils systemd flag-o-matic ${MYSQL_EXTRAS} mysql-cmake mysql_fx versionator \
31 toolchain-funcs user cmake-utils multilib-minimal
34 # Supported EAPI versions and export functions
39 *) die "Unsupported EAPI: ${EAPI}" ;;
42 EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config
48 # @ECLASS-VARIABLE: MYSQL_CMAKE_NATIVE_DEFINES
50 # Add extra CMake arguments for native multilib builds
52 # @ECLASS-VARIABLE: MYSQL_CMAKE_NONNATIVE_DEFINES
54 # Add extra CMake arguments for non-native multilib builds
56 # @ECLASS-VARIABLE: MYSQL_CMAKE_EXTRA_DEFINES
58 # Add extra CMake arguments
60 # Shorten the path because the socket path length must be shorter than 107 chars
61 # and we will run a mysql server during test phase
64 [[ ${MY_EXTRAS_VER} == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
65 if [[ ${MY_EXTRAS_VER} == "live" ]]; then
66 EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
67 EGIT_CHECKOUT_DIR=${WORKDIR}/mysql-extras
68 EGIT_CLONE_TYPE=shallow
71 # @ECLASS-VARIABLE: MYSQL_PV_MAJOR
73 # Upstream MySQL considers the first two parts of the version number to be the
74 # major version. Upgrades that change major version should always run
76 MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
78 # Cluster is a special case...
79 if [[ "${PN}" == "mysql-cluster" ]]; then
81 7.2*) MYSQL_PV_MAJOR=5.5 ;;
82 7.3*) MYSQL_PV_MAJOR=5.6 ;;
86 # MariaDB has left the numbering schema but keeping compatibility
87 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
89 10.0*) MYSQL_PV_MAJOR="5.6" ;;
90 10.1*) MYSQL_PV_MAJOR="5.6" ;;
94 # @ECLASS-VARIABLE: MYSQL_VERSION_ID
96 # MYSQL_VERSION_ID will be:
97 # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
98 # This is an important part, because many of the choices the MySQL ebuild will do
99 # depend on this variable.
100 # In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
101 # We also strip off upstream's trailing letter that they use to respin tarballs
104 tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
105 for vatom in 0 1 2 3 ; do
107 tpv[${vatom}]="00${tpv[${vatom}]}"
108 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
110 # strip leading "0" (otherwise it's considered an octal number by BASH)
111 MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
113 # This eclass should only be used with at least mysql-5.5.35
114 mysql_version_is_at_least "5.5.35" || die "This eclass should only be used with >=mysql-5.5.35"
116 # Work out the default SERVER_URI correctly
117 if [[ -z ${SERVER_URI} ]]; then
118 [[ -z ${MY_PV} ]] && MY_PV="${PV//_/-}"
119 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
120 # Beginning with 5.5, MariaDB stopped putting beta, alpha or rc on their tarball names
121 mysql_version_is_at_least "5.5" && MARIA_FULL_PV=$(get_version_component_range 1-3) || \
122 MARIA_FULL_PV=$(replace_version_separator 3 '-' ${MY_PV})
123 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
125 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
126 http://mirror.jmu.edu/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
127 http://mirrors.coreix.net/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
128 http://mirrors.syringanetworks.net/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
129 http://mirrors.fe.up.pt/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
130 http://mirror2.hs-esslingen.de/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
131 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
132 http://mirror.jmu.edu/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
133 http://mirrors.coreix.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
134 http://mirrors.syringanetworks.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
135 http://mirrors.fe.up.pt/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
136 http://mirror2.hs-esslingen.de/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
138 if [[ ${PN} == "mariadb-galera" ]]; then
139 MY_SOURCEDIR="${PN%%-galera}-${MARIA_FULL_PV}"
141 elif [[ ${PN} == "percona-server" ]]; then
142 PERCONA_PN="Percona-Server"
143 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
144 MY_PV=$(get_version_component_range 1-3 ${PV})
145 PERCONA_RELEASE=$(get_version_component_range 4-5 ${PV})
146 PERCONA_RC=$(get_version_component_range 6 ${PV})
147 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"
148 # http://www.percona.com/redir/downloads/Percona-Server-5.5/LATEST/source/tarball/Percona-Server-5.5.30-rel30.2.tar.gz
149 # 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
151 if [[ "${PN}" == "mysql-cluster" ]] ; then
152 URI_DIR="MySQL-Cluster"
153 URI_FILE="mysql-cluster-gpl"
158 URI_A="${URI_FILE}-${MY_PV}.tar.gz"
159 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
160 # Recently upstream switched to an archive site, and not on mirrors
161 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
162 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
166 # Define correct SRC_URIs
167 SRC_URI="${SERVER_URI}"
169 # Gentoo patches to MySQL
170 if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then
172 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
173 https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
174 https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
175 https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
178 DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
179 HOMEPAGE="http://www.mysql.com/"
180 if [[ ${PN} == "mariadb" ]]; then
181 HOMEPAGE="http://mariadb.org/"
182 DESCRIPTION="An enhanced, drop-in replacement for MySQL"
184 if [[ ${PN} == "mariadb-galera" ]]; then
185 HOMEPAGE="http://mariadb.org/"
186 DESCRIPTION="An enhanced, drop-in replacement for MySQL with Galera Replication"
188 if [[ ${PN} == "percona-server" ]]; then
189 HOMEPAGE="http://www.percona.com/software/percona-server"
190 DESCRIPTION="An enhanced, drop-in replacement for MySQL from the Percona team"
193 SLOT="0/${SUBSLOT:-0}"
195 IUSE="debug embedded extraengine jemalloc latin1 libressl +openssl
196 +perl profiling selinux systemtap static static-libs tcmalloc test yassl"
198 REQUIRED_USE="^^ ( yassl openssl libressl )"
200 ### Begin readline/libedit
201 ### If the world was perfect, we would use external libedit on both to have a similar experience
202 ### However libedit does not seem to support UTF-8 keyboard input
204 # This probably could be simplified, but the syntax would have to be just right
205 #if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && \
206 # mysql_check_version_range "5.5.37 to 10.0.13.99" ; then
207 # IUSE="bindist ${IUSE}"
208 #elif [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
209 # mysql_check_version_range "5.5.37 to 5.6.11.99" ; then
210 # IUSE="bindist ${IUSE}"
211 #elif [[ ${PN} == "mysql-cluster" ]] && \
212 # mysql_check_version_range "7.2 to 7.2.99.99" ; then
213 # IUSE="bindist ${IUSE}"
216 # Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
217 RESTRICT="libressl? ( test )"
219 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
220 IUSE="bindist ${IUSE}"
221 RESTRICT="${RESTRICT} !bindist? ( bindist )"
224 ### End readline/libedit
226 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
227 IUSE="${IUSE} oqgraph pam sphinx tokudb"
228 # 5.5.33 and 10.0.5 add TokuDB. Authors strongly recommend jemalloc or perfomance suffers
229 mysql_version_is_at_least "10.0.5" && IUSE="${IUSE} odbc xml"
230 if [[ ${HAS_TOOLS_PATCH} ]] ; then
231 REQUIRED_USE="${REQUIRED_USE} !server? ( !oqgraph !sphinx ) tokudb? ( jemalloc )"
233 REQUIRED_USE="${REQUIRED_USE} minimal? ( !oqgraph !sphinx ) tokudb? ( jemalloc )"
235 # MariaDB 10.1 introduces InnoDB/XtraDB compression with external libraries
236 # Choices are bzip2, lz4, lzma, lzo. bzip2 and lzma enabled by default as they are system libraries
237 mysql_version_is_at_least "10.1.1" && IUSE="${IUSE} innodb-lz4 innodb-lzo"
239 # It can also compress with app-arch/snappy
240 mysql_version_is_at_least "10.1.7" && IUSE="${IUSE} innodb-snappy"
242 # 10.1.2 introduces a cracklib password checker
243 mysql_version_is_at_least "10.1.1" && IUSE="${IUSE} cracklib"
246 if [[ -n "${WSREP_REVISION}" ]]; then
247 if [[ ${PN} == "mariadb" ]]; then
248 IUSE="${IUSE} galera sst-rsync sst-xtrabackup"
249 REQUIRED_USE="${REQUIRED_USE} sst-rsync? ( galera ) sst-xtrabackup? ( galera )"
251 IUSE="${IUSE} +sst-rsync sst-xtrabackup"
255 if [[ ${PN} == "percona-server" ]]; then
259 if [[ ${HAS_TOOLS_PATCH} ]] ; then
260 IUSE="${IUSE} client-libs +server +tools"
261 REQUIRED_USE="${REQUIRED_USE} !server? ( !extraengine !embedded ) server? ( tools ) || ( client-libs server tools )"
263 IUSE="${IUSE} minimal"
264 REQUIRED_USE="${REQUIRED_USE} minimal? ( !extraengine !embedded )"
268 ${REQUIRED_USE} tcmalloc? ( !jemalloc ) jemalloc? ( !tcmalloc )
275 # Be warned, *DEPEND are version-dependant
276 # These are used for both runtime and compiletime
277 # MULTILIB_USEDEP only set for libraries used by the client library
280 sys-process/procps:0=
284 >=sys-apps/texinfo-4.7-r1
285 !dev-db/mariadb-native-client[mysqlcompat]
286 jemalloc? ( dev-libs/jemalloc:0= )
287 tcmalloc? ( dev-util/google-perftools:0= )
288 systemtap? ( >=dev-util/systemtap-1.3:0= )
291 if [[ ${HAS_TOOLS_PATCH} ]] ; then
294 openssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
295 libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] )
296 >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
299 openssl? ( >=dev-libs/openssl-1.0.0:0=[static-libs?] )
300 libressl? ( dev-libs/libressl:0=[static-libs?] )
301 >=sys-libs/zlib-1.2.3:0=[static-libs?]
303 tools? ( sys-libs/ncurses:0= ) embedded? ( sys-libs/ncurses:0= )
307 openssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
308 libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] )
309 >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
310 sys-libs/ncurses:0=[${MULTILIB_USEDEP}]
314 ### Begin readline/libedit
315 ### If the world was perfect, we would use external libedit on both to have a similar experience
316 ### However libedit does not seem to support UTF-8 keyboard input
318 # dev-db/mysql-5.6.12+ only works with dev-libs/libedit
319 # mariadb 10.0.14 fixes libedit detection. changed to follow mysql
320 # This probably could be simplified
321 #if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
322 # mysql_version_is_at_least "5.6.12" ; then
323 # DEPEND="${DEPEND} dev-libs/libedit:0=[${MULTILIB_USEDEP}]"
324 #elif [[ ${PN} == "mysql-cluster" ]] && mysql_version_is_at_least "7.3"; then
325 # DEPEND="${DEPEND} dev-libs/libedit:0=[${MULTILIB_USEDEP}]"
326 #elif [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && \
327 # mysql_version_is_at_least "10.0.14" ; then
328 # DEPEND="${DEPEND} dev-libs/libedit:0=[${MULTILIB_USEDEP}]"
330 # DEPEND="${DEPEND} !bindist? ( >=sys-libs/readline-4.1:0=[${MULTILIB_USEDEP}] )"
333 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
334 # Readline is only used for the command-line and embedded example
335 if [[ ${HAS_TOOLS_PATCH} ]] ; then
336 DEPEND="${DEPEND} !bindist? ( tools? ( >=sys-libs/readline-4.1:0= ) embedded? ( >=sys-libs/readline-4.1:0= ) )"
338 DEPEND="${DEPEND} !bindist? ( >=sys-libs/readline-4.1:0=[${MULTILIB_USEDEP}] )"
342 ### End readline/libedit
344 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] ; then
345 if mysql_version_is_at_least "5.7.6" ; then DEPEND="${DEPEND} >=dev-libs/boost-1.57.0:0=" ; else
346 mysql_version_is_at_least "5.7.5" && DEPEND="${DEPEND} >=dev-libs/boost-1.56.0:0="
350 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
351 # Bug 441700 MariaDB >=5.3 include custom mytop
352 if [[ ${HAS_TOOLS_PATCH} ]] ; then
353 DEPEND="${DEPEND} server? ( pam? ( virtual/pam:0= ) )"
355 DEPEND="${DEPEND} !minimal? ( pam? ( virtual/pam:0= ) )"
358 oqgraph? ( >=dev-libs/boost-1.40.0:0= )
359 perl? ( !dev-db/mytop )"
360 if mysql_version_is_at_least "10.0.5" ; then
363 odbc? ( dev-db/unixODBC:0= )
364 xml? ( dev-libs/libxml2:2= )
368 mysql_version_is_at_least "10.0.7" && DEPEND="${DEPEND} oqgraph? ( dev-libs/judy:0= )"
369 mysql_version_is_at_least "10.0.9" && DEPEND="${DEPEND} >=dev-libs/libpcre-8.35:3="
371 mysql_version_is_at_least "10.1.1" && DEPEND="${DEPEND}
372 innodb-lz4? ( app-arch/lz4 )
373 innodb-lzo? ( dev-libs/lzo )
376 mysql_version_is_at_least "10.1.2" && DEPEND="${DEPEND} cracklib? ( sys-libs/cracklib:0= )"
377 mysql_version_is_at_least "10.1.7" && DEPEND="${DEPEND} innodb-snappy? ( app-arch/snappy )"
380 if [[ ${PN} == "percona-server" ]] ; then
381 if [[ ${HAS_TOOLS_PATCH} ]] ; then
382 DEPEND="${DEPEND} server? ( pam? ( virtual/pam:0= ) )"
384 DEPEND="${DEPEND} !minimal? ( pam? ( virtual/pam:0= ) )"
388 # Having different flavours at the same time is not a good idea
389 for i in "mysql" "mariadb" "mariadb-galera" "percona-server" "mysql-cluster" ; do
390 [[ ${i} == ${PN} ]] ||
391 DEPEND="${DEPEND} !dev-db/${i}"
394 if [[ ${PN} == "mysql-cluster" ]] ; then
395 # TODO: This really should include net-misc/memcached
396 # but the package does not install the files it seeks.
397 mysql_version_is_at_least "7.2.3" && \
398 DEPEND="${DEPEND} dev-libs/libevent:0="
401 # prefix: first need to implement something for #196294
402 # TODO: check emul-linux-x86-db dep when it is multilib enabled
404 selinux? ( sec-policy/selinux-mysql )
405 abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] )
408 if [[ ${HAS_TOOLS_PATCH} ]] ; then
410 server? ( !prefix? ( dev-db/mysql-init-scripts ) )
411 !client-libs? ( virtual/libmysqlclient )
412 !<virtual/mysql-5.6-r4"
414 RDEPEND="${RDEPEND} !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )"
417 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
418 # Bug 455016 Add dependencies of mytop
419 RDEPEND="${RDEPEND} perl? (
420 virtual/perl-Getopt-Long
422 virtual/perl-Term-ANSIColor
423 virtual/perl-Time-HiRes ) "
426 # @ECLASS-VARIABLE: WSREP_REVISION
429 # Version of the sys-cluster/galera API (major version in portage) to use for galera clustering
431 if [[ -n "${WSREP_REVISION}" ]] ; then
432 # The wsrep API version must match between the ebuild and sys-cluster/galera.
433 # This will be indicated by WSREP_REVISION in the ebuild and the first number
434 # in the version of sys-cluster/galera
436 # lsof is required as of 5.5.38 and 10.0.11 for the rsync sst
438 GALERA_RDEPEND="sys-apps/iproute2
439 =sys-cluster/galera-${WSREP_REVISION}*
441 if [[ ${PN} == "mariadb" ]]; then
442 GALERA_RDEPEND="galera? ( ${GALERA_RDEPEND} )"
444 RDEPEND="${RDEPEND} ${GALERA_RDEPEND}
445 sst-rsync? ( sys-process/lsof )
450 # Causes a circular dependency if DBD-mysql is not already installed
451 PDEPEND="${PDEPEND} sst-xtrabackup? ( >=dev-db/xtrabackup-bin-2.2.4 )"
454 if [[ ${PN} == "mysql-cluster" ]] ; then
455 mysql_version_is_at_least "7.2.9" && RDEPEND="${RDEPEND} java? ( >=virtual/jre-1.6 )" && \
456 DEPEND="${DEPEND} java? ( >=virtual/jdk-1.6 )"
460 # ncurses only needs multilib for compile time due to a binary that will be not installed
463 static? ( sys-libs/ncurses[static-libs] )
464 >=dev-util/cmake-2.8.9
467 # Transition dep until all ebuilds have client-libs patch and USE
468 if ! [[ ${HAS_TOOLS_PATCH} ]] ; then
469 DEPEND="${DEPEND} sys-libs/ncurses[${MULTILIB_USEDEP}]"
472 # For other stuff to bring us in
473 # dev-perl/DBD-mysql is needed by some scripts installed by MySQL
474 PDEPEND="${PDEPEND} perl? ( >=dev-perl/DBD-mysql-2.9004 )
475 ~virtual/mysql-${MYSQL_PV_MAJOR}"
477 # my_config.h includes ABI specific data
478 MULTILIB_WRAPPED_HEADERS=( /usr/include/mysql/my_config.h /usr/include/mysql/private/embedded_priv.h )
480 [[ ${PN} == "mysql-cluster" ]] && \
481 MULTILIB_WRAPPED_HEADERS+=( /usr/include/mysql/storage/ndb/ndb_types.h )
483 [[ ${PN} == "mariadb" ]] && mysql_version_is_at_least "10.1.1" && \
484 MULTILIB_WRAPPED_HEADERS+=( /usr/include/mysql/mysql_version.h )
490 # @FUNCTION: mysql-multilib_disable_test
492 # Helper function to disable specific tests.
493 mysql-multilib_disable_test() {
494 mysql-cmake_disable_test "$@"
501 # @FUNCTION: mysql-multilib_pkg_pretend
503 # Perform some basic tests and tasks during pkg_pretend phase:
504 mysql-multilib_pkg_pretend() {
505 if [[ ${MERGE_TYPE} != binary ]] ; then
506 local GCC_MAJOR_SET=$(gcc-major-version)
507 local GCC_MINOR_SET=$(gcc-minor-version)
508 if use_if_iuse tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
509 ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
510 eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
511 eerror "Please use gcc-config to switch to gcc-4.7 or later version."
514 # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
515 # non x86{,_64} arches
516 if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
517 ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
518 eerror "${PN} needs to be built with gcc-4.7 or later."
519 eerror "Please use gcc-config to switch to gcc-4.7 or later version."
525 # @FUNCTION: mysql-multilib_pkg_setup
527 # Perform some basic tests and tasks during pkg_setup phase:
528 # die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
529 # create new user and group for mysql
530 # warn about deprecated features
531 mysql-multilib_pkg_setup() {
533 if has test ${FEATURES} ; then
534 if use_if_iuse minimal ; then
536 elif ! in_iuse server || use_if_iuse server ; then
537 if ! has userpriv ${FEATURES} ; then
538 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
543 # This should come after all of the die statements
544 enewgroup mysql 60 || die "problem adding 'mysql' group"
545 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
547 if [[ ${PN} == "mysql-cluster" ]] ; then
548 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_setup
552 # @FUNCTION: mysql-multilib_src_unpack
554 # Unpack the source code
555 mysql-multilib_src_unpack() {
557 # Initialize the proper variables first
562 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
564 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
567 # @FUNCTION: mysql-multilib_src_prepare
569 # Apply patches to the source code and remove unneeded bundled libs.
570 mysql-multilib_src_prepare() {
571 mysql-cmake_src_prepare "$@"
572 if [[ ${PN} == "mysql-cluster" ]] ; then
573 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_src_prepare
578 # @FUNCTION: mysql-multilib_src_configure
580 # Configure mysql to build the code for Gentoo respecting the use flags.
581 mysql-multilib_src_configure() {
582 # Bug #114895, bug #110149
583 filter-flags "-O" "-O[01]"
585 CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
586 CXXFLAGS="${CXXFLAGS} -felide-constructors"
587 # Causes linkage failures. Upstream bug #59607 removes it
588 if ! mysql_version_is_at_least "5.6" ; then
589 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
591 # As of 5.7, exceptions are used!
592 if [[ ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.6.26" ; then
593 CXXFLAGS="${CXXFLAGS} -fno-rtti"
594 elif ! mysql_version_is_at_least "5.7" ; then
595 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
599 # bug #283926, with GCC4.4, this is required to get correct behavior.
600 append-flags -fno-strict-aliasing
602 # bug 508724 mariadb cannot use ld.gold
603 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
607 multilib-minimal_src_configure
610 multilib_src_configure() {
612 debug-print-function ${FUNCNAME} "$@"
614 CMAKE_BUILD_TYPE="RelWithDebInfo"
616 if ! multilib_is_native_abi && in_iuse client-libs ; then
617 if ! use client-libs ; then
618 einfo "Skipping multilib build due to client-libs USE disabled"
623 # debug hack wrt #497532
625 -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
626 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
627 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
628 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
629 -DSYSCONFDIR=${EPREFIX}/etc/mysql
631 -DINSTALL_DOCDIR=share/doc/${PF}
632 -DINSTALL_DOCREADMEDIR=share/doc/${PF}
633 -DINSTALL_INCLUDEDIR=include/mysql
634 -DINSTALL_INFODIR=share/info
635 -DINSTALL_LIBDIR=$(get_libdir)
636 -DINSTALL_ELIBDIR=$(get_libdir)/mysql
637 -DINSTALL_MANDIR=share/man
638 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
639 -DINSTALL_MYSQLSHAREDIR=share/mysql
640 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
641 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
642 -DINSTALL_SBINDIR=sbin
643 -DINSTALL_SCRIPTDIR=share/mysql/scripts
644 -DINSTALL_SQLBENCHDIR=share/mysql
645 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
646 -DWITH_COMMENT="Gentoo Linux ${PF}"
647 $(cmake-utils_use_with test UNIT_TESTS)
651 -DENABLED_LOCAL_INFILE=1
652 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
653 -DINSTALL_UNIX_ADDRDIR=${EPREFIX}/var/run/mysqld/mysqld.sock
654 -DWITH_DEFAULT_COMPILER_OPTIONS=0
655 -DWITH_DEFAULT_FEATURE_SET=0
656 -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_unitdir)"
659 if in_iuse systemd ; then
660 mycmakeargs+=( -DWITH_SYSTEMD=$(usex systemd) )
663 if use openssl || use libressl ; then
664 mycmakeargs+=( -DWITH_SSL=system )
666 mycmakeargs+=( -DWITH_SSL=bundled )
669 if in_iuse client-libs ; then
670 mycmakeargs+=( -DWITHOUT_CLIENTLIBS=$(usex client-libs 0 1) )
673 if in_iuse tools ; then
674 if multilib_is_native_abi ; then
675 mycmakeargs+=( -DWITHOUT_TOOLS=$(usex tools 0 1) )
677 mycmakeargs+=( -DWITHOUT_TOOLS=1 )
681 if in_iuse bindist ; then
682 # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
683 if multilib_is_native_abi; then
685 -DWITH_READLINE=$(usex bindist 1 0)
686 -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
688 elif ! in_iuse client-libs ; then
691 -DNOT_FOR_DISTRIBUTION=0
696 ### TODO: make this system but issues with UTF-8 prevent it
697 mycmakeargs+=( -DWITH_EDITLINE=bundled )
699 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && multilib_is_native_abi ; then
701 -DWITH_JEMALLOC=$(usex jemalloc system)
704 mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
707 configure_cmake_locale
709 if use_if_iuse minimal ; then
710 configure_cmake_minimal
711 elif in_iuse server ; then
712 if multilib_is_native_abi && use server ; then
713 configure_cmake_standard
715 configure_cmake_minimal
718 if multilib_is_native_abi ; then
719 configure_cmake_standard
721 configure_cmake_minimal
725 # systemtap only works on native ABI bug 530132
726 if multilib_is_native_abi; then
727 mycmakeargs+=( $(cmake-utils_use_enable systemtap DTRACE) )
728 [[ ${MYSQL_CMAKE_NATIVE_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_NATIVE_DEFINES} )
730 mycmakeargs+=( -DENABLE_DTRACE=0 )
731 [[ ${MYSQL_CMAKE_NONNATIVE_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_NONNATIVE_DEFINES} )
734 [[ ${MYSQL_CMAKE_EXTRA_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_EXTRA_DEFINES} )
736 # Always build NDB with mysql-cluster for libndbclient
737 [[ ${PN} == "mysql-cluster" ]] && mycmakeargs+=(
738 -DWITH_NDBCLUSTER=1 -DWITH_PARTITION_STORAGE_ENGINE=1
739 -DWITHOUT_PARTITION_STORAGE_ENGINE=0 )
741 cmake-utils_src_configure
744 mysql-multilib_src_compile() {
745 local _cmake_args=( "${@}" )
747 multilib-minimal_src_compile
750 multilib_src_compile() {
751 if ! multilib_is_native_abi && in_iuse client-libs ; then
752 if ! use client-libs ; then
757 cmake-utils_src_compile "${_cmake_args[@]}"
761 # @FUNCTION: mysql-multilib_src_install
764 mysql-multilib_src_install() {
765 if ! in_iuse client-libs || use_if_iuse client-libs ; then
766 # wrap the config script
767 MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config )
770 if in_iuse client-libs && ! use client-libs ; then
771 multilib_foreach_abi multilib_src_install
773 multilib-minimal_src_install
777 multilib_src_install() {
778 debug-print-function ${FUNCNAME} "$@"
780 if ! multilib_is_native_abi && in_iuse client-libs ; then
781 if ! use client-libs ; then
786 if multilib_is_native_abi; then
787 mysql-cmake_src_install
789 cmake-utils_src_install
790 if [[ "${PN}" == "mariadb" || "${PN}" == "mariadb-galera" ]] ; then
791 if use_if_iuse minimal ; then
793 elif use_if_iuse server || ! in_iuse server ; then
794 insinto /usr/include/mysql/private
801 # @FUNCTION: mysql-multilib_pkg_preinst
803 # Call java-pkg-opt-2 eclass when mysql-cluster is installed
804 mysql-multilib_pkg_preinst() {
805 debug-print-function ${FUNCNAME} "$@"
807 if [[ ${PN} == "mysql-cluster" ]] ; then
808 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_preinst
810 # Here we need to see if the implementation switched client libraries
811 # First, we check if this is a new instance of the package and a client library already exists
812 # Then, we check if this package is rebuilt but the previous instance did not
813 # have the client-libs USE set.
814 # Instances which do not have a client-libs USE can only be replaced by a different provider
815 local SHOW_ABI_MESSAGE
816 if ! in_iuse client-libs || use_if_iuse client-libs ; then
817 if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
819 elif [[ ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] && \
820 in_iuse client-libs && has_version "${CATEGORY}/${PN}[-client-libs(+)]" ; then
825 if [[ ${SHOW_ABI_MESSAGE} ]] ; then
826 elog "Due to ABI changes when switching between different client libraries,"
827 elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
828 elog "Please run: revdep-rebuild --library libmysqlclient.so.${SUBSLOT:-18}"
829 ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
833 # @FUNCTION: mysql-multilib_pkg_postinst
835 # Run post-installation tasks:
836 # create the dir for logfiles if non-existant
837 # touch the logfiles and secure them
839 # issue required steps for optional features
840 # issue deprecation warnings
841 mysql-multilib_pkg_postinst() {
842 debug-print-function ${FUNCNAME} "$@"
844 # Make sure the vars are correctly initialized
847 # Check FEATURES="collision-protect" before removing this
848 [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
850 # Secure the logfiles
851 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
852 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
853 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
855 # Minimal builds don't have the MySQL server
856 if use_if_iuse minimal ; then
858 elif ! in_iuse server || use_if_iuse server ; then
859 docinto "support-files"
861 support-files/my-*.cnf \
862 support-files/magic \
863 support-files/ndb-config-2-node.ini
865 [[ -f "${script}" ]] \
870 for script in scripts/mysql* ; do
871 if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then
876 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
877 if use_if_iuse pam ; then
879 elog "This install includes the PAM authentication plugin."
880 elog "To activate and configure the PAM plugin, please read:"
881 elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
887 elog "You might want to run:"
888 elog "\"emerge --config =${CATEGORY}/${PF}\""
889 elog "if this is a new install."
893 elog "If you are upgrading major versions, you should run the"
894 elog "mysql_upgrade tool."
897 if [[ ${PN} == "mariadb-galera" ]] || use_if_iuse galera ; then
899 elog "Be sure to edit the my.cnf file to activate your cluster settings."
900 elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
901 elog "The first time the cluster is activated, you should add"
902 elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
903 elog "This option should then be removed for subsequent starts."
909 # @FUNCTION: mysql-multilib_getopt
911 # Use my_print_defaults to extract specific config options
912 mysql-multilib_getopt() {
913 local mypd="${EROOT}"/usr/bin/my_print_defaults
916 "${mypd}" $section | sed -n "/^${flag}/p"
919 # @FUNCTION: mysql-multilib_getoptval
921 # Use my_print_defaults to extract specific config options
922 mysql-multilib_getoptval() {
923 local mypd="${EROOT}"/usr/bin/my_print_defaults
926 local extra_options="${3}"
927 "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
930 # @FUNCTION: mysql-multilib_pkg_config
932 # Configure mysql environment.
933 mysql-multilib_pkg_config() {
935 debug-print-function ${FUNCNAME} "$@"
937 local old_MY_DATADIR="${MY_DATADIR}"
938 local old_HOME="${HOME}"
939 # my_print_defaults needs to read stuff in $HOME/.my.cnf
940 export HOME=${EPREFIX}/root
942 # Make sure the vars are correctly initialized
945 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
946 if [[ ${HAS_TOOLS_PATCH} ]] ; then
947 if ! built_with_use ${CATEGORY}/${PN} server ; then
948 die "Minimal builds do NOT include the MySQL server"
951 if built_with_use ${CATEGORY}/${PN} minimal ; then
952 die "Minimal builds do NOT include the MySQL server"
956 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
957 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
958 MY_DATADIR_s="${MY_DATADIR_s%%/}"
959 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
960 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
962 if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
963 if [[ -d "${MY_DATADIR_s}" ]]; then
964 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
965 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
967 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
968 mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
969 || die "Moving MY_DATADIR failed"
972 ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
973 if [[ -d "${MY_DATADIR_s}" ]]; then
974 ewarn "Attempting to use ${MY_DATADIR_s}"
976 eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
977 die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
986 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
987 MYSQL_ROOT_PASSWORD="$(mysql-multilib_getoptval 'client mysql' password)"
988 # Sometimes --show is required to display passwords in some implementations of my_print_defaults
989 if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
990 MYSQL_ROOT_PASSWORD="$(mysql-multilib_getoptval 'client mysql' password --show)"
993 MYSQL_TMPDIR="$(mysql-multilib_getoptval mysqld tmpdir)"
994 # These are dir+prefix
995 MYSQL_RELAY_LOG="$(mysql-multilib_getoptval mysqld relay-log)"
996 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
997 MYSQL_LOG_BIN="$(mysql-multilib_getoptval mysqld log-bin)"
998 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
1000 if [[ ! -d "${ROOT}"/$MYSQL_TMPDIR ]]; then
1001 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
1002 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
1004 if [[ ! -d "${ROOT}"/$MYSQL_LOG_BIN ]]; then
1005 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
1006 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
1008 if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
1009 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
1010 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
1013 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
1014 ewarn "You have already a MySQL database in place."
1015 ewarn "(${ROOT}/${MY_DATADIR}/*)"
1016 ewarn "Please rename or delete it if you wish to replace it."
1017 die "MySQL database already exists!"
1020 # Bug #213475 - MySQL _will_ object strenously if your machine is named
1021 # localhost. Also causes weird failures.
1022 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1024 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1026 einfo "Please provide a password for the mysql 'root' user now"
1027 einfo "or through the ${HOME}/.my.cnf file."
1028 ewarn "Avoid [\"'\\_%] characters in the password"
1029 read -rsp " >" pwd1 ; echo
1031 einfo "Retype the password"
1032 read -rsp " >" pwd2 ; echo
1034 if [[ "x$pwd1" != "x$pwd2" ]] ; then
1035 die "Passwords are not the same"
1037 MYSQL_ROOT_PASSWORD="${pwd1}"
1042 local sqltmp="$(emktemp)"
1044 # Fix bug 446200. Don't reference host my.cnf, needs to come first,
1045 # see http://bugs.mysql.com/bug.php?id=31312
1046 use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
1048 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
1049 [[ -r "${help_tables}" ]] \
1050 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
1051 || touch "${TMPDIR}/fill_help_tables.sql"
1052 help_tables="${TMPDIR}/fill_help_tables.sql"
1054 # Figure out which options we need to disable to do the setup
1055 local helpfile="${TMPDIR}/mysqld-help"
1056 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
1057 for opt in grant-tables host-cache name-resolve networking slave-start \
1058 federated ssl log-bin relay-log slow-query-log external-locking \
1059 ndbcluster log-slave-updates \
1061 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1062 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
1064 # But some options changed names
1065 egrep -sq external-locking "${helpfile}" && \
1066 options="${options/skip-locking/skip-external-locking}"
1068 use prefix || options="${options} --user=mysql"
1070 # MySQL 5.6+ needs InnoDB
1071 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] ; then
1072 mysql_version_is_at_least "5.6" || options="${options} --loose-skip-innodb"
1075 einfo "Creating the mysql database and setting proper permissions on it ..."
1077 # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
1078 PID_DIR="${EROOT}/var/run/mysqld"
1079 if [[ ! -d "${PID_DIR}" ]]; then
1080 mkdir -p "${PID_DIR}" || die "Could not create pid directory"
1081 chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
1082 chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
1085 pushd "${TMPDIR}" &>/dev/null
1086 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
1087 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
1088 [[ -f ${cmd} ]] || cmd=${EROOT}usr/bin/mysql_install_db
1089 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${ROOT}/${MY_DATADIR}' '--tmpdir=${ROOT}/${MYSQL_TMPDIR}'"
1090 einfo "Command: $cmd"
1092 >"${TMPDIR}"/mysql_install_db.log 2>&1
1093 if [ $? -ne 0 ]; then
1094 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1095 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1098 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1099 || die "MySQL databases not installed"
1100 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
1101 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
1103 # Filling timezones, see
1104 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1105 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
1107 if [[ -r "${help_tables}" ]] ; then
1108 cat "${help_tables}" >> "${sqltmp}"
1111 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1112 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1113 local mysqld="${EROOT}/usr/sbin/mysqld \
1115 $(use prefix || echo --user=mysql) \
1117 --basedir=${EROOT}/usr \
1118 --datadir=${ROOT}/${MY_DATADIR} \
1119 --max_allowed_packet=8M \
1120 --net_buffer_length=16K \
1121 --default-storage-engine=MyISAM \
1122 --socket=${socket} \
1123 --pid-file=${pidfile}
1124 --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
1125 #einfo "About to start mysqld: ${mysqld}"
1126 ebegin "Starting mysqld"
1127 einfo "Command ${mysqld}"
1130 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1131 maxtry=$((${maxtry}-1))
1137 if ! [[ -S "${socket}" ]]; then
1138 die "Completely failed to start up mysqld with: ${mysqld}"
1141 ebegin "Setting root password"
1142 # Do this from memory, as we don't want clear text passwords in temp files
1143 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
1144 "${EROOT}/usr/bin/mysql" \
1145 --socket=${socket} \
1150 ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1151 "${EROOT}/usr/bin/mysql" \
1152 --socket=${socket} \
1155 --password="${MYSQL_ROOT_PASSWORD}" \
1159 [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1161 # Stop the server and cleanup
1162 einfo "Stopping the server ..."
1163 kill $(< "${pidfile}" )