Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/mysql/
Date: Sat, 26 Jan 2019 19:24:17
Message-Id: 1548530629.dfef360c35d4e9d197837d3d57258fca41adf785.whissi@gentoo
1 commit: dfef360c35d4e9d197837d3d57258fca41adf785
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 26 19:23:31 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 26 19:23:49 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dfef360c
7
8 dev-db/mysql: bump to v5.7.25
9
10 Closes: https://bugs.gentoo.org/671722
11 Package-Manager: Portage-2.3.58, Repoman-2.3.12
12 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
13
14 dev-db/mysql/Manifest | 2 +
15 dev-db/mysql/mysql-5.7.25.ebuild | 946 +++++++++++++++++++++++++++++++++++++++
16 2 files changed, 948 insertions(+)
17
18 diff --git a/dev-db/mysql/Manifest b/dev-db/mysql/Manifest
19 index 4932e7433c2..3c4090a608e 100644
20 --- a/dev-db/mysql/Manifest
21 +++ b/dev-db/mysql/Manifest
22 @@ -4,6 +4,8 @@ DIST mysql-5.6.40.tar.gz 32083035 BLAKE2B efcc078341bae239df28ac0504111aa3492688
23 DIST mysql-5.6.42.tar.gz 32201731 BLAKE2B c573328b37225dac090c32178f90e1419fc1848612e304bddc11eafdd48228981a846857be680978b72ef76edbd5d2422a98b5d20b4d082fabcc2b072e2b8fde SHA512 3104e6a3145a119f2b012de6af2a92fc37134aa402b889a562f5fc2391705d0bc2f718166c5fa8387d973fff5ecd9544c8b389b6d0c81d98bdcaf2acfb9b55e8
24 DIST mysql-boost-5.7.23.tar.gz 49025014 BLAKE2B 669f10779bc2cda866d6bd876b4efe55fb4b0c796f596f66513a3ca85f322e2a03e9879eecd72a69729a0cb71d408c46cdd9086ae456712b4adff6ae7c584c97 SHA512 e4317f89d108a68652cd95e41ffd670c37b6663aabd6af3985d18052fb7e8d8879b5822399caf9091cecc0a949ec588c121c87cfd60d69941f68d0ecbedd0953
25 DIST mysql-boost-5.7.24.tar.gz 49110448 BLAKE2B 1cf64712d84cbb2dfd31f2a530470b6f7cbf5ae9107106d86705575ea9739fa582e1f079447d9a58c4762fffc636d69e448ebdec9172ee15dc09245bc39c3525 SHA512 bbd411e15cd9e6053a353146808b74881d2d950f09e94794a699e7604dadf767b58b661a8321fbe1424f2c2e6cfc3adaa388242183e759082eae47b64cbfbcde
26 +DIST mysql-boost-5.7.25.tar.gz 49107578 BLAKE2B 8a43479c496ce45e71df905b0cb6da442340b691caa15f9862a8c981e7189c50e73b1701c393fe46ab580c508f785d5f15259c2331c77e0790191f3d41bb385c SHA512 b111c64bfcd49dba584bed71a0c7ce33b2b0654654d8f4eaa1a2b7a5daed9674ebfd4a0dfb93c20ffee028feead4709eaf600bb5469f81c86b743d395dfe27a9
27 DIST mysql-extras-20180804-2323Z.tar.bz2 322215 BLAKE2B cca9e502e375bf43473335868517f6c450fc7bcf03e55de5a294c8bdcfcac2bb783dec09bbb3b6c30a561ba7e3a943543c017e2d42b61d466e699acdef4c0231 SHA512 efd9d416f394cc61b977ab76f05ab3acc5803ff8bdee8e1dbc65cc5b3f07e4f9742140d9586c028908b10fcc44f21c98ebffdebcc5c3578acbe05b07526bcb3d
28 DIST mysql-extras-20181023-0012Z.tar.bz2 327834 BLAKE2B 91a82cbcecbbbe94933da0d8c26cdfee0171602785b2f717fbfec7da422f0ec36f26e897a3c21695f4748017d36c9956cbef03d0852246468368b812a604df82 SHA512 94996708a9da4d55c3aab74f75b74fa4aa80e3fbbb87d9dfe6c1596a934aceed466b7c853e38d9b63f59660763ccef617defc4e6e8770451c21a252250f4e7fa
29 DIST mysql-extras-20181111-2314Z.tar.bz2 329013 BLAKE2B fa928b699ef0e6f092e028fc1331cc33953d9855e784998fb2f8c1f1712e9424567b2d2b6b7c5ca375f178309522b3596fcba7babdbed7c85b87ae4b85e5db22 SHA512 5cc4d16c5c6b0491fb9532469ec0b9c65e27e1514d561ea4180845a1578fc8e7ba00fca479b9a784646846f5147e4f676340f639b78c3f5ee140dda26bd5bff2
30 +DIST mysql-extras-20190126-1919Z.tar.bz2 331144 BLAKE2B 27fe6846a2c98a3027d0a63ad08d72e29f0dfff456de2ad942760a5d1005ea6fe5bbebacacf44308975eacd3ed824883b74e1be3930bd329965e2ec1a4d0384f SHA512 e3a54f721e71cbd9db2b907500cb42c526914be1307a316bbba27e8124580b574c1c9a1fe6d30228cc6d2a1a6ba0797cee3628a69f1536e0467bbcb5151986cd
31
32 diff --git a/dev-db/mysql/mysql-5.7.25.ebuild b/dev-db/mysql/mysql-5.7.25.ebuild
33 new file mode 100644
34 index 00000000000..80d8e5aaeeb
35 --- /dev/null
36 +++ b/dev-db/mysql/mysql-5.7.25.ebuild
37 @@ -0,0 +1,946 @@
38 +# Copyright 1999-2019 Gentoo Authors
39 +# Distributed under the terms of the GNU General Public License v2
40 +
41 +EAPI="6"
42 +MY_EXTRAS_VER="20190126-1919Z"
43 +
44 +CMAKE_MAKEFILE_GENERATOR=emake
45 +
46 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
47 +
48 +inherit cmake-utils eutils flag-o-matic linux-info \
49 + prefix toolchain-funcs user multilib-minimal
50 +
51 +SRC_URI="https://cdn.mysql.com/Downloads/MySQL-5.7/${PN}-boost-${PV}.tar.gz
52 + https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${PV}.tar.gz
53 + http://downloads.mysql.com/archives/MySQL-5.7/${PN}-boost-${PV}.tar.gz"
54 +
55 +# Gentoo patches to MySQL
56 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]] ; then
57 + SRC_URI="${SRC_URI}
58 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
59 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
60 +fi
61 +
62 +HOMEPAGE="https://www.mysql.com/"
63 +DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
64 +LICENSE="GPL-2"
65 +SLOT="0/18"
66 +IUSE="cjk client-libs cracklib debug experimental jemalloc latin1 libressl numa +perl profiling
67 + selinux +server static static-libs systemtap tcmalloc test yassl"
68 +
69 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
70 +RESTRICT="libressl? ( test )"
71 +
72 +REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )"
73 +
74 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
75 +
76 +# Shorten the path because the socket path length must be shorter than 107 chars
77 +# and we will run a mysql server during test phase
78 +S="${WORKDIR}/mysql"
79 +
80 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
81 + inherit git-r3
82 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git"
83 + EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras"
84 + EGIT_CLONE_TYPE=shallow
85 + MY_PATCH_DIR="${WORKDIR}/mysql-extras"
86 +else
87 + MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}"
88 +fi
89 +
90 +PATCHES=(
91 + "${MY_PATCH_DIR}"/20001_all_fix-minimal-build-cmake-mysql-5.7.23.patch
92 + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.7.patch
93 + "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.7.10.patch
94 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.21-without-clientlibs-tools.patch
95 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.23-fix-libressl-support.patch
96 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.23-add-missing-gcc-8-fix.patch
97 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.23-fix-grant_user_lock-a-root.patch
98 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.23-round-off-test-values-for-same-output-on-all-architectures.patch
99 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.23-fix-mips-ASM.patch
100 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.25-fix-build-without-server.patch
101 +)
102 +
103 +# Be warned, *DEPEND are version-dependant
104 +# These are used for both runtime and compiletime
105 +# MULTILIB_USEDEP only set for libraries used by the client library
106 +COMMON_DEPEND="net-misc/curl:=
107 + >=sys-apps/sed-4
108 + >=sys-apps/texinfo-4.7-r1
109 + sys-libs/ncurses:0=
110 + client-libs? ( >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?] )
111 + !client-libs? (
112 + dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?]
113 + >=sys-libs/zlib-1.2.3:0=
114 + )
115 + jemalloc? ( dev-libs/jemalloc:0= )
116 + kernel_linux? (
117 + dev-libs/libaio:0=
118 + sys-process/procps:0=
119 + )
120 + server? (
121 + >=app-arch/lz4-0_p131:=
122 + cjk? ( app-text/mecab:= )
123 + experimental? (
124 + dev-libs/libevent:=
125 + dev-libs/protobuf:=
126 + net-libs/libtirpc:=
127 + )
128 + numa? ( sys-process/numactl )
129 + )
130 + systemtap? ( >=dev-util/systemtap-1.3:0= )
131 + tcmalloc? ( dev-util/google-perftools:0= )
132 + !yassl? (
133 + client-libs? (
134 + !libressl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
135 + libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] )
136 + )
137 + !client-libs? (
138 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
139 + libressl? ( dev-libs/libressl:0= )
140 + )
141 + )
142 +"
143 +DEPEND="${COMMON_DEPEND}
144 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
145 + dev-libs/protobuf
146 + virtual/yacc
147 + server? (
148 + dev-libs/libevent
149 + experimental? ( net-libs/rpcsvc-proto )
150 + )
151 + static? ( sys-libs/ncurses[static-libs] )
152 + test? ( dev-perl/JSON )
153 +"
154 +RDEPEND="${COMMON_DEPEND}
155 + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
156 + client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c dev-libs/protobuf:= )
157 + selinux? ( sec-policy/selinux-mysql )
158 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
159 +"
160 +# For other stuff to bring us in
161 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
162 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
163 +
164 +mysql_init_vars() {
165 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX%/}/usr/share/mysql"}
166 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX%/}/etc/mysql"}
167 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX%/}/var/lib/mysql"}
168 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX%/}/var/log/mysql"}
169 +
170 + if [[ -z "${MY_DATADIR}" ]] ; then
171 + MY_DATADIR=""
172 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
173 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
174 + | sed -ne '/datadir/s|^--datadir=||p' \
175 + | tail -n1`
176 + if [[ -z "${MY_DATADIR}" ]] ; then
177 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
178 + | sed -e 's/.*=\s*//' \
179 + | tail -n1`
180 + fi
181 + fi
182 + if [[ -z "${MY_DATADIR}" ]] ; then
183 + MY_DATADIR="${MY_LOCALSTATEDIR}"
184 + einfo "Using default MY_DATADIR"
185 + fi
186 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
187 +
188 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
189 + if [[ -e "${MY_DATADIR}" ]] ; then
190 + # If you get this and you're wondering about it, see bug #207636
191 + elog "MySQL datadir found in ${MY_DATADIR}"
192 + elog "A new one will not be created."
193 + PREVIOUS_DATADIR="yes"
194 + else
195 + PREVIOUS_DATADIR="no"
196 + fi
197 + export PREVIOUS_DATADIR
198 + fi
199 + else
200 + if [[ ${EBUILD_PHASE} == "config" ]] ; then
201 + local new_MY_DATADIR
202 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
203 + | sed -ne '/datadir/s|^--datadir=||p' \
204 + | tail -n1`
205 +
206 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]] ; then
207 + ewarn "MySQL MY_DATADIR has changed"
208 + ewarn "from ${MY_DATADIR}"
209 + ewarn "to ${new_MY_DATADIR}"
210 + MY_DATADIR="${new_MY_DATADIR}"
211 + fi
212 + fi
213 + fi
214 +
215 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
216 + export MY_LOCALSTATEDIR MY_LOGDIR
217 + export MY_DATADIR
218 +}
219 +
220 +pkg_pretend() {
221 + if use numa ; then
222 + local CONFIG_CHECK="~NUMA"
223 +
224 + local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
225 + WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
226 +
227 + check_extra_config
228 + fi
229 +}
230 +
231 +pkg_setup() {
232 + if [[ ${MERGE_TYPE} != binary ]] ; then
233 + local GCC_MAJOR_SET=$(gcc-major-version)
234 + local GCC_MINOR_SET=$(gcc-minor-version)
235 + # Bug 565584: InnoDB now requires atomic functions introduced with gcc-4.7 on
236 + # non x86{,_64} arches
237 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
238 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
239 + eerror "${PN} needs to be built with gcc-4.7 or later."
240 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
241 + die
242 + fi
243 + fi
244 +
245 + if has test ${FEATURES} && \
246 + use server && ! has userpriv ${FEATURES} ; then
247 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
248 + fi
249 +
250 + # This should come after all of the die statements
251 + enewgroup mysql 60 || die "problem adding 'mysql' group"
252 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
253 +}
254 +
255 +pkg_preinst() {
256 + # Here we need to see if the implementation switched client libraries
257 + # We check if this is a new instance of the package and a client library already exists
258 + local SHOW_ABI_MESSAGE libpath
259 + if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
260 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
261 + elog "Due to ABI changes when switching between different client libraries,"
262 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
263 + elog "Please run: revdep-rebuild --library ${libpath}"
264 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
265 + fi
266 +}
267 +
268 +pkg_postinst() {
269 + # Make sure the vars are correctly initialized
270 + mysql_init_vars
271 +
272 + # Create log directory securely if it does not exist
273 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
274 +
275 + if use server ; then
276 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
277 + einfo
278 + elog "You might want to run:"
279 + elog "\"emerge --config =${CATEGORY}/${PF}\""
280 + elog "if this is a new install."
281 + elog
282 + elog "If you are switching server implentations, you should run the"
283 + elog "mysql_upgrade tool."
284 + einfo
285 + else
286 + einfo
287 + elog "If you are upgrading major versions, you should run the"
288 + elog "mysql_upgrade tool."
289 + einfo
290 + fi
291 + fi
292 +
293 + # Note about configuration change
294 + einfo
295 + elog "This version of ${PN} reorganizes the configuration from a single my.cnf"
296 + elog "to several files in /etc/mysql/mysql.d."
297 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
298 + elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension."
299 + elog "You may have as many files as needed and they are read alphabetically."
300 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
301 + einfo
302 +}
303 +
304 +src_unpack() {
305 + unpack ${A}
306 + # Grab the patches
307 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
308 +
309 + mv -f "${WORKDIR}/${P}" "${S}" || die
310 +}
311 +
312 +src_prepare() {
313 + cmake-utils_src_prepare
314 +
315 + if use jemalloc ; then
316 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
317 + fi
318 +
319 + if use tcmalloc ; then
320 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die
321 + fi
322 +
323 + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
324 + if [[ -d "${S}/support-files/SELinux" ]] ; then
325 + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
326 + fi
327 +
328 + # Remove bundled libs so we cannot accidentally use them
329 + # We keep extra/lz4 directory because we use extra/lz4/xxhash.c via sql/CMakeLists.txt:394
330 + rm -rv \
331 + "${S}"/extra/protobuf \
332 + "${S}"/libevent \
333 + "${S}"/zlib \
334 + || die
335 +
336 + if use libressl ; then
337 + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \
338 + "${S}/cmake/ssl.cmake" || die
339 + fi
340 +
341 + sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die
342 +}
343 +
344 +src_configure(){
345 + # Bug #114895, bug #110149
346 + filter-flags "-O" "-O[01]"
347 +
348 + append-cxxflags -felide-constructors
349 +
350 + # bug #283926, with GCC4.4, this is required to get correct behavior.
351 + append-flags -fno-strict-aliasing
352 +
353 + if use client-libs ; then
354 + multilib-minimal_src_configure
355 + else
356 + multilib_src_configure
357 + fi
358 +}
359 +
360 +multilib_src_configure() {
361 + debug-print-function ${FUNCNAME} "$@"
362 +
363 + if ! multilib_is_native_abi && ! use client-libs ; then
364 + return
365 + fi
366 +
367 + CMAKE_BUILD_TYPE="RelWithDebInfo"
368 +
369 + # debug hack wrt #497532
370 + mycmakeargs=(
371 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
372 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
373 + -DCMAKE_INSTALL_PREFIX="${EPREFIX%/}/usr"
374 + -DMYSQL_DATADIR="${EPREFIX%/}/var/lib/mysql"
375 + -DSYSCONFDIR="${EPREFIX%/}/etc/mysql"
376 + -DINSTALL_BINDIR=bin
377 + -DINSTALL_DOCDIR=share/doc/${PF}
378 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
379 + -DINSTALL_INCLUDEDIR=include/mysql
380 + -DINSTALL_INFODIR=share/info
381 + -DINSTALL_LIBDIR=$(get_libdir)
382 + -DINSTALL_MANDIR=share/man
383 + -DINSTALL_MYSQLSHAREDIR=share/mysql
384 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
385 + -DINSTALL_SCRIPTDIR=share/mysql/scripts
386 + -DINSTALL_MYSQLDATADIR="${EPREFIX%/}/var/lib/mysql"
387 + -DINSTALL_SBINDIR=sbin
388 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX%/}/usr/share/mysql"
389 + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
390 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
391 + ### TODO: make this system but issues with UTF-8 prevent it
392 + -DWITH_EDITLINE=bundled
393 + -DWITH_ZLIB=system
394 + -DWITH_LIBWRAP=0
395 + -DENABLED_LOCAL_INFILE=1
396 + -DMYSQL_UNIX_ADDR="${EPREFIX%/}/var/run/mysqld/mysqld.sock"
397 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
398 + -DWITH_DEFAULT_FEATURE_SET=0
399 + # The build forces this to be defined when cross-compiling. We pass it
400 + # all the time for simplicity and to make sure it is actually correct.
401 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
402 + -DWITH_CURL=system
403 + -DWITH_BOOST="${S}/boost"
404 + )
405 + if use test ; then
406 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
407 + else
408 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
409 + fi
410 +
411 + if ! use yassl ; then
412 + mycmakeargs+=( -DWITH_SSL=system )
413 + else
414 + mycmakeargs+=( -DWITH_SSL=bundled )
415 + fi
416 +
417 + if ! use client-libs ; then
418 + mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
419 + fi
420 +
421 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
422 + # systemtap only works on native ABI, bug 530132
423 + if multilib_is_native_abi ; then
424 + mycmakeargs+=(
425 + -DENABLE_DTRACE=$(usex systemtap)
426 + )
427 + else
428 + mycmakeargs+=(
429 + -DWITHOUT_TOOLS=1
430 + -DWITH_READLINE=1
431 + -DENABLE_DTRACE=0
432 + )
433 + fi
434 +
435 + if multilib_is_native_abi && use server ; then
436 + mycmakeargs+=(
437 + -DWITH_LIBEVENT=system
438 + -DWITH_LZ4=system
439 + -DWITH_PROTOBUF=system
440 + -DWITH_MECAB=$(usex cjk system OFF)
441 + -DWITH_NUMA=$(usex numa ON OFF)
442 + -DWITH_RAPID=$(usex experimental ON OFF)
443 + )
444 +
445 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]] ; then
446 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
447 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
448 + ewarn "You MUST file bugs without these variables set."
449 +
450 + mycmakeargs+=(
451 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
452 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
453 + )
454 + elif ! use latin1 ; then
455 + mycmakeargs+=(
456 + -DDEFAULT_CHARSET=utf8
457 + -DDEFAULT_COLLATION=utf8_general_ci
458 + )
459 + else
460 + mycmakeargs+=(
461 + -DDEFAULT_CHARSET=latin1
462 + -DDEFAULT_COLLATION=latin1_swedish_ci
463 + )
464 + fi
465 +
466 + mycmakeargs+=(
467 + -DEXTRA_CHARSETS=all
468 + -DDISABLE_SHARED=$(usex static YES NO)
469 + -DWITH_DEBUG=$(usex debug)
470 + -DWITH_EMBEDDED_SERVER=OFF
471 + )
472 +
473 + if use profiling ; then
474 + # Setting to OFF doesn't work: Once set, profiling options will be added
475 + # to `mysqld --help` output via sql/sys_vars.cc causing
476 + # "main.mysqld--help-notwin" test to fail
477 + mycmakeargs+=( -DENABLED_PROFILING=ON )
478 + fi
479 +
480 + if use static ; then
481 + mycmakeargs+=( -DWITH_PIC=1 )
482 + fi
483 +
484 + # Storage engines
485 + mycmakeargs+=(
486 + -DWITH_EXAMPLE_STORAGE_ENGINE=0
487 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
488 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
489 + -DWITH_CSV_STORAGE_ENGINE=1
490 + -DWITH_FEDERATED_STORAGE_ENGINE=1
491 + -DWITH_HEAP_STORAGE_ENGINE=1
492 + -DWITH_INNOBASE_STORAGE_ENGINE=1
493 + -DWITH_INNODB_MEMCACHED=0
494 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
495 + -DWITH_MYISAM_STORAGE_ENGINE=1
496 + -DWITH_PARTITION_STORAGE_ENGINE=1
497 + )
498 +
499 + else
500 + mycmakeargs+=(
501 + -DWITHOUT_SERVER=1
502 + -DWITH_EMBEDDED_SERVER=OFF
503 + -DEXTRA_CHARSETS=none
504 + )
505 + fi
506 +
507 + cmake-utils_src_configure
508 +}
509 +
510 +src_compile() {
511 + if use client-libs ; then
512 + multilib-minimal_src_compile
513 + else
514 + multilib_src_compile
515 + fi
516 +}
517 +
518 +multilib_src_compile() {
519 + cmake-utils_src_compile
520 +}
521 +
522 +# Official test instructions:
523 +# ulimit -n 16500 && \
524 +# USE='latin1 perl server' \
525 +# FEATURES='test userpriv -usersandbox' \
526 +# ebuild mysql-X.X.XX.ebuild \
527 +# digest clean package
528 +src_test() {
529 + _disable_test() {
530 + local rawtestname reason
531 + rawtestname="${1}" ; shift
532 + reason="${@}"
533 + ewarn "test '${rawtestname}' disabled: '${reason}'"
534 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
535 + }
536 +
537 + local TESTDIR="${BUILD_DIR}/mysql-test"
538 + local retstatus_unit
539 + local retstatus_tests
540 +
541 + if ! use server ; then
542 + einfo "Skipping server tests due to minimal build."
543 + return 0
544 + fi
545 +
546 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
547 + # localhost. Also causes weird failures.
548 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
549 +
550 + if [[ $UID -eq 0 ]] ; then
551 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
552 + fi
553 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
554 +
555 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
556 +
557 + # Run CTest (test-units)
558 + cmake-utils_src_test
559 + retstatus_unit=$?
560 +
561 + # Ensure that parallel runs don't die
562 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
563 + # Enable parallel testing, auto will try to detect number of cores
564 + # You may set this by hand.
565 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
566 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
567 +
568 + # create directories because mysqladmin might run out of order
569 + mkdir -p "${T}"/var-tests{,/log} || die
570 +
571 + # Run mysql tests
572 + pushd "${TESTDIR}" &>/dev/null || die
573 +
574 + touch "${T}/disabled.def"
575 + # These are failing in MySQL 5.7 for now and are believed to be
576 + # false positives:
577 + #
578 + local t
579 +
580 + for t in auth_sec.keyring_udf ; do
581 + _disable_test "$t" "False positives in Gentoo"
582 + done
583 +
584 + # Unstable tests
585 + # - main.xa_prepared_binlog_off: https://bugs.mysql.com/bug.php?id=83340
586 + # - rpl.rpl_non_direct_stm_mixing_engines: MDEV-14489
587 + for t in main.xa_prepared_binlog_off rpl.rpl_non_direct_stm_mixing_engines ; do
588 + _disable_test "$t" "Unstable test"
589 + done
590 +
591 + if ! use amd64 ; then
592 + # fixed in >=mysql-8 via commit 0a417e84
593 + _disable_test "gis.gis_bugs_crashes" "Unstable results on non-amd64 architectures due to floating-point operation"
594 + fi
595 +
596 + if use numa && use kernel_linux ; then
597 + # bug 584880
598 + if ! linux_config_exists || ! linux_chkconfig_present NUMA ; then
599 + for t in sys_vars.innodb_numa_interleave_basic ; do
600 + _disable_test "$t" "Test $t requires system with NUMA support"
601 + done
602 + fi
603 + fi
604 +
605 + if ! use latin1 ; then
606 + # The following tests will fail if DEFAULT_CHARSET
607 + # isn't set to latin1:
608 + for t in \
609 + binlog.binlog_mysqlbinlog_filter \
610 + binlog.binlog_xa_prepared_disconnect \
611 + funcs_1.is_columns_mysql \
612 + funcs_1.is_tables_mysql \
613 + funcs_1.is_triggers \
614 + innodb.innodb_pagesize_max_recordsize \
615 + innodb.innodb-system-table-view \
616 + innodb.mysqldump_max_recordsize \
617 + main.mysql_client_test \
618 + main.mysqld--help-notwin \
619 + main.type_string \
620 + main.information_schema \
621 + perfschema.binlog_edge_mix \
622 + perfschema.binlog_edge_stmt \
623 + rpl.rpl_xa_survive_disconnect \
624 + rpl.rpl_xa_survive_disconnect_lsu_off \
625 + rpl.rpl_xa_survive_disconnect_table \
626 + ; do
627 + _disable_test "$t" "requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set"
628 + done
629 + fi
630 +
631 + # Try to increase file limits to increase test coverage
632 + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
633 + # Upper limit comes from parts.partition_* tests
634 + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
635 +
636 + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
637 + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
638 + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
639 +
640 + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
641 + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
642 + else
643 + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
644 + fi
645 + else
646 + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
647 + fi
648 + else
649 + einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
650 + fi
651 +
652 + # run mysql-test tests
653 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
654 + retstatus_tests=$?
655 +
656 + popd &>/dev/null || die
657 +
658 + # Cleanup is important for these testcases.
659 + pkill -9 -f "${S}/ndb" 2>/dev/null
660 + pkill -9 -f "${S}/sql" 2>/dev/null
661 +
662 + local failures=""
663 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
664 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
665 +
666 + [[ -z "$failures" ]] || die "Test failures: $failures"
667 + einfo "Tests successfully completed"
668 +}
669 +
670 +src_install() {
671 + local MULTILIB_WRAPPED_HEADERS
672 + local MULTILIB_CHOST_TOOLS
673 + if use client-libs ; then
674 + # headers with ABI specific data
675 + MULTILIB_WRAPPED_HEADERS=(
676 + /usr/include/mysql/server/my_config.h
677 + /usr/include/mysql/server/mysql_version.h )
678 +
679 + # wrap the config scripts
680 + MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config )
681 + multilib-minimal_src_install
682 + else
683 + multilib_src_install
684 + multilib_src_install_all
685 + fi
686 +}
687 +
688 +# Intentionally override eclass function
689 +multilib_src_install() {
690 +
691 + cmake-utils_src_install
692 +
693 + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
694 + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
695 +}
696 +
697 +multilib_src_install_all() {
698 + # Make sure the vars are correctly initialized
699 + mysql_init_vars
700 +
701 + # Convenience links
702 + einfo "Making Convenience links for mysqlcheck multi-call binary"
703 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
704 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
705 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
706 +
707 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
708 + if [[ -d "${ED}/usr/data" ]] ; then
709 + rm -Rf "${ED}/usr/data" || die
710 + fi
711 +
712 + # Unless they explicitly specific USE=test, then do not install the
713 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
714 + # validation of your database configuration after tuning it.
715 + if ! use test ; then
716 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
717 + fi
718 +
719 + # Configuration stuff
720 + einfo "Building default configuration ..."
721 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
722 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
723 + cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
724 + eprefixify "${TMPDIR}/my.cnf"
725 + doins "${TMPDIR}/my.cnf"
726 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
727 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
728 + eprefixify "${TMPDIR}/50-distro-client.cnf"
729 + doins "${TMPDIR}/50-distro-client.cnf"
730 +
731 + if use server ; then
732 + mycnf_src="my.cnf.distro-server"
733 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
734 + "${FILESDIR}/${mycnf_src}" \
735 + > "${TMPDIR}/my.cnf.ok" || die
736 +
737 + if use prefix ; then
738 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
739 + "${TMPDIR}/my.cnf.ok" || die
740 + fi
741 +
742 + if use latin1 ; then
743 + sed -i \
744 + -e "/character-set/s|utf8|latin1|g" \
745 + "${TMPDIR}/my.cnf.ok" || die
746 + fi
747 +
748 + eprefixify "${TMPDIR}/my.cnf.ok"
749 +
750 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
751 + fi
752 +
753 + #Remove mytop if perl is not selected
754 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
755 +}
756 +
757 +pkg_config() {
758 + _getoptval() {
759 + local mypd="${EROOT%/}"/usr/bin/my_print_defaults
760 + local section="$1"
761 + local flag="--${2}="
762 + local extra_options="${3}"
763 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
764 + }
765 + local old_MY_DATADIR="${MY_DATADIR}"
766 + local old_HOME="${HOME}"
767 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
768 + export HOME=${EPREFIX%/}/root
769 +
770 + # Make sure the vars are correctly initialized
771 + mysql_init_vars
772 +
773 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
774 + if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then
775 + die "Minimal builds do NOT include the MySQL server"
776 + fi
777 +
778 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]] ; then
779 + local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}"
780 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
781 + local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}"
782 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
783 +
784 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]] ; then
785 + if [[ -d "${MY_DATADIR_s}" ]] ; then
786 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
787 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
788 + else
789 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
790 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
791 + || die "Moving MY_DATADIR failed"
792 + fi
793 + else
794 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
795 + if [[ -d "${MY_DATADIR_s}" ]] ; then
796 + ewarn "Attempting to use ${MY_DATADIR_s}"
797 + else
798 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
799 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
800 + fi
801 + fi
802 + fi
803 +
804 + local pwd1="a"
805 + local pwd2="b"
806 + local maxtry=15
807 +
808 + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
809 + local tmp_mysqld_password_source=
810 +
811 + for tmp_mysqld_password_source in mysql client ; do
812 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
813 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
814 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
815 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
816 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
817 + MYSQL_ROOT_PASSWORD=
818 + continue
819 + fi
820 +
821 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
822 + break
823 + fi
824 + done
825 +
826 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
827 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
828 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
829 + fi
830 +
831 + unset tmp_mysqld_password_source
832 + fi
833 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
834 + # These are dir+prefix
835 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
836 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
837 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
838 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
839 +
840 + if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]] ; then
841 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
842 + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR"
843 + fi
844 +
845 + if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]] ; then
846 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
847 + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN"
848 + fi
849 +
850 + if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]] ; then
851 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
852 + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG"
853 + fi
854 +
855 + if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then
856 + ewarn "You have already a MySQL database in place."
857 + ewarn "(${ROOT%/}/${MY_DATADIR}/*)"
858 + ewarn "Please rename or delete it if you wish to replace it."
859 + die "MySQL database already exists!"
860 + fi
861 +
862 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
863 + # localhost. Also causes weird failures.
864 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
865 +
866 + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
867 +
868 + einfo "Please provide a password for the mysql 'root' user now"
869 + einfo "or through the ${HOME}/.my.cnf file."
870 + ewarn "Avoid [\"'\\_%] characters in the password"
871 + read -rsp " >" pwd1 ; echo
872 +
873 + einfo "Retype the password"
874 + read -rsp " >" pwd2 ; echo
875 +
876 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
877 + die "Passwords are not the same"
878 + fi
879 + MYSQL_ROOT_PASSWORD="${pwd1}"
880 + unset pwd1 pwd2
881 + fi
882 +
883 + local options
884 + local sqltmp="$(emktemp)"
885 +
886 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
887 + # see http://bugs.mysql.com/bug.php?id=31312
888 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
889 +
890 + # Figure out which options we need to disable to do the setup
891 + local helpfile="${TMPDIR%/}/mysqld-help"
892 + "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
893 + for opt in host-cache name-resolve networking slave-start \
894 + federated ssl log-bin relay-log slow-query-log external-locking \
895 + log-slave-updates \
896 + ; do
897 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
898 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
899 + done
900 +
901 + einfo "Creating the mysql database and setting proper permissions on it ..."
902 +
903 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
904 + PID_DIR="${EROOT%/}/var/run/mysqld"
905 + if [[ ! -d "${PID_DIR}" ]] ; then
906 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
907 + fi
908 +
909 + if [[ ! -d "${MY_DATADIR}" ]] ; then
910 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
911 + fi
912 +
913 + pushd "${TMPDIR}" &>/dev/null || die
914 +
915 + # Filling timezones, see
916 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
917 + echo "USE mysql;" >"${sqltmp}"
918 + "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null
919 + chown mysql "${sqltmp}" || die
920 +
921 + # --initialize-insecure will not set root password
922 + # --initialize would set a random one in the log which we don't need as we set it ourselves
923 + local cmd=( "${EROOT%/}/usr/sbin/mysqld" "--initialize-insecure" "--init-file='${sqltmp}'" )
924 + cmd+=( "--basedir=${EPREFIX%/}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" )
925 + einfo "Command: ${cmd[*]}"
926 + su -s /bin/sh -c "${cmd[*]}" mysql \
927 + >"${TMPDIR%/}"/mysql_install_db.log 2>&1
928 + if [[ $? -ne 0 ]] ; then
929 + grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2
930 + die "Failed to initialize mysqld. Please review ${EPREFIX%/}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log"
931 + fi
932 + popd &>/dev/null || die
933 + [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \
934 + || die "MySQL databases not installed"
935 +
936 + use prefix || options="${options} --user=mysql"
937 +
938 + local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock"
939 + local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid"
940 + local mysqld="${EROOT%/}/usr/sbin/mysqld \
941 + ${options} \
942 + $(use prefix || echo --user=mysql) \
943 + --log-warnings=0 \
944 + --basedir=${EROOT%/}/usr \
945 + --datadir=${ROOT%/}/${MY_DATADIR} \
946 + --max_allowed_packet=8M \
947 + --net_buffer_length=16K \
948 + --socket=${socket} \
949 + --pid-file=${pidfile} \
950 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
951 + #einfo "About to start mysqld: ${mysqld}"
952 + ebegin "Starting mysqld"
953 + einfo "Command ${mysqld}"
954 + ${mysqld} &
955 + rc=$?
956 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
957 + maxtry=$((${maxtry}-1))
958 + echo -n "."
959 + sleep 1
960 + done
961 + eend $rc
962 +
963 + if ! [[ -S "${socket}" ]] ; then
964 + die "Completely failed to start up mysqld with: ${mysqld}"
965 + fi
966 +
967 + ebegin "Setting root password"
968 + # Do this from memory, as we don't want clear text passwords in temp files
969 + local sql="ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${MYSQL_ROOT_PASSWORD}'"
970 + "${EROOT%/}/usr/bin/mysql" \
971 + --no-defaults \
972 + "--socket=${socket}" \
973 + -hlocalhost \
974 + -e "${sql}"
975 + eend $?
976 +
977 + # Stop the server and cleanup
978 + einfo "Stopping the server ..."
979 + kill $(< "${pidfile}" )
980 + rm -f "${sqltmp}"
981 + wait %1
982 + einfo "Done"
983 +}