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