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, 22 Jan 2020 20:26:05
Message-Id: 1579724749.6a89c9796d557e4611248fe359578cf3210c7ec8.whissi@gentoo
1 commit: 6a89c9796d557e4611248fe359578cf3210c7ec8
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 22 20:11:32 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 22 20:25:49 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6a89c979
7
8 dev-db/percona-server: bump to v8.0.18-9
9
10 Closes: https://bugs.gentoo.org/699010
11 Package-Manager: Portage-2.3.84, Repoman-2.3.20
12 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
13
14 dev-db/percona-server/Manifest | 3 +
15 .../percona-server/percona-server-8.0.18.9.ebuild | 1147 ++++++++++++++++++++
16 2 files changed, 1150 insertions(+)
17
18 diff --git a/dev-db/percona-server/Manifest b/dev-db/percona-server/Manifest
19 index 27e6e7919bb..bee9002e731 100644
20 --- a/dev-db/percona-server/Manifest
21 +++ b/dev-db/percona-server/Manifest
22 @@ -1,7 +1,10 @@
23 DIST boost_1_59_0.tar.gz 83709983 BLAKE2B 8c6676fa05fa401a6ecb3b890d95aceb4421ec48dd0eab38ce8d170c618e177c82dc67a165938f6be1a01daab24ce41888f5442dbc19ad3dd41368a01a6f89e4 SHA512 05fdbe5637543defdbc630b921515425885593d16db14534ed7b9aa60925ade8fb598d50cb894aed6dae688e789047216daa1bf03fa1aeb6b531060d9dae52ae
24 DIST boost_1_69_0.tar.bz2 95078138 BLAKE2B ccab52b911066ed41db6555fe13fbc142cd51250ad620665d3fcf25508e158b7b766f4f3654333b4a19517215ebe4a6ce14e64395b093b9604b3f0e570419841 SHA512 d0e9bb858c44880d56c0291afef6a1b011a62f659a2d8f58dcb6147ea0899f9157bd8db3097896618fee0116847ebeac78b6d0f0fec8a92c3469500828bbe552
25 +DIST boost_1_70_0.tar.bz2 97887058 BLAKE2B dc7a974c6dc2662b767dbd87cb832cd1749c24fb745779d1059b73f19f7e52b33b645adfe72b0296c5e098e5cdb3b9f5eddd382374f33fbcd2ad5739287b2206 SHA512 7f2ea9636baf0210e8ed1d21ee798efb6ce23c0710ff8228b285e2214f82193bcd2d912fd435929c554289a59101c7be2e27ce798f93833f307976f0dd070b49
26 DIST mysql-extras-20190822-1908Z.tar.bz2 338830 BLAKE2B bc197f8e541206548d8982814e82e028d699ba9c41aec8d5191bcc46581f7880ed2741dbe2206fde44a5e8d8d54bbcf40efbd0709b357636c4c8fdb2ccc3a7bb SHA512 be469e55f7e9966638600d6836a44258c74e5600240fafe2d79eaeebe7d1695b043678184b5d18ee9946f28154bc2529586a7f860b510180a30c82454ed575c8
27 DIST mysql-extras-20191031-0134Z.tar.bz2 340718 BLAKE2B 8c228d6953aa888449a006ab1000ef3ecb1747fd055f58a8eaa5f5680b223fa840debbb7fce7404aa7ef4524ce71144a6a970483ad6536ff7521bd949f4dfa90 SHA512 6d61c4a70980759ac90fc3ac35a677a340d88f63260fb2c130ef70de0c05654895fe17b5f4915ca6d96f2406f215559182af61f7d88c1a4157e9bcbcc0f4d4e2
28 +DIST mysql-extras-20200122-2007Z.tar.bz2 344188 BLAKE2B e12a9886bb0c55f1af1ea979c9b1491b65195a54f927f0060f466fe858ea9dd2faffb6eeb7acb7efd28dfb37383b6730c314ea54fbaed2ec3e54655546c883e3 SHA512 ef43324b70081214f3e02eb677bde0e4e3575d2b3b1cb7fb8da18f50ff43a9554e13d13594c0d875bd1438695725ed28a586e4f67f4f4e39054d54671f9525de
29 DIST percona-server-5.7.26-29.tar.gz 84327421 BLAKE2B beedb4b5025c337a63ae56644e47991e90c2c0e57c6d03f1562095f9470cef4b67c8df6c3774d88dfc6ed6dfb81f9dd4b62325db30bc26802651279921bd3a2d SHA512 c8100e69f7e29a5aa2de9dddbc1a3cba9836fe485b7f829a8db0a7e5ac1d1bdabfb1360dacad90665f4c9c78ac91226209c6c15158ef449e84519e36bb06f0a1
30 DIST percona-server-5.7.27-30.tar.gz 84672298 BLAKE2B 8431d231f602b704195868110e8eb73adb3db7c761906c15eff182e54634ef091a3ffa0d4f3498a93dbfbf65cd5cdd12102871abaaaa0f32378ba3068d083b2b SHA512 d62c66de3128df87dce52292ad1671e01fe2c923e668ef0faf9cb663c11c9cd0b976345aea1de6ea2bc458d0e1066b42c022849e422121d96cea082ed12c8f4b
31 DIST percona-server-8.0.17-8.tar.gz 249562136 BLAKE2B d3bf20d9fee43f17b8aef3e403e74d9c5924a5a012d0c4208b22ffffce37f48867a2a1fb7992d7837f35492d5c5871901f3e0f68cde54793090bb2c089cee310 SHA512 c875492e8b67307aef439ae54b8ff6320464ac495a2d06029f1b33b2117e56bd1c2b3ce4ba7b406c1bd6604d0016d04a5c3f36643097cbf36425d60a44b6adc3
32 +DIST percona-server-8.0.18-9.tar.gz 256867152 BLAKE2B 34c7b7b320f973313ecd95e658999a17748fc70ff46b1dc58144df02c17b7870cf33d68a555ee8aaaecb66c5b1003e6023154f7100a6f413514e89d495330dd2 SHA512 ce537a160b48e7c3dc35b15a293c39142a5b633111b5c9c5f9c1150476f0faa5e9cf81b34c9ca85286463455e3ae3fce7a200d253d880e3b67b3c71eefdbdcd4
33
34 diff --git a/dev-db/percona-server/percona-server-8.0.18.9.ebuild b/dev-db/percona-server/percona-server-8.0.18.9.ebuild
35 new file mode 100644
36 index 00000000000..86ea26ade39
37 --- /dev/null
38 +++ b/dev-db/percona-server/percona-server-8.0.18.9.ebuild
39 @@ -0,0 +1,1147 @@
40 +# Copyright 1999-2020 Gentoo Authors
41 +# Distributed under the terms of the GNU General Public License v2
42 +
43 +EAPI="7"
44 +MY_EXTRAS_VER="20200122-2007Z"
45 +
46 +CMAKE_MAKEFILE_GENERATOR=emake
47 +
48 +inherit cmake-utils flag-o-matic linux-info \
49 + multiprocessing prefix toolchain-funcs check-reqs
50 +
51 +MY_BOOST_VERSION="1.70.0"
52 +MY_PV=$(ver_rs 3 '-')
53 +MY_PV="${MY_PV//_pre*}"
54 +MY_PN="Percona-Server"
55 +MY_P="${PN}-${MY_PV}"
56 +MY_MAJOR_PV=$(ver_cut 1-2)
57 +MY_RELEASE_NOTES_URI="https://www.percona.com/doc/percona-server/${MY_MAJOR_PV}/"
58 +
59 +S="${WORKDIR}/${PN}-${MY_PV}"
60 +
61 +SRC_URI="https://www.percona.com/downloads/${MY_PN}-${MY_MAJOR_PV}/${MY_PN}-${MY_PV}/source/tarball/${PN}-${MY_PV}.tar.gz
62 + https://dl.bintray.com/boostorg/release/${MY_BOOST_VERSION}/source/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION}).tar.bz2
63 +"
64 +
65 +# Gentoo patches to MySQL
66 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]] ; then
67 + SRC_URI="${SRC_URI}
68 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
69 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
70 +fi
71 +
72 +HOMEPAGE="https://www.percona.com/software/mysql-database/percona-server"
73 +DESCRIPTION="Fully compatible, enhanced and open source drop-in replacement for MySQL"
74 +LICENSE="GPL-2"
75 +SLOT="0"
76 +IUSE="cjk cracklib debug jemalloc latin1 libressl numa pam +perl profiling
77 + rocksdb router selinux +server tcmalloc test tokudb tokudb-backup-plugin"
78 +
79 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
80 +RESTRICT="!test? ( test ) libressl? ( test )"
81 +
82 +REQUIRED_USE="?? ( tcmalloc jemalloc )
83 + cjk? ( server )
84 + jemalloc? ( server )
85 + numa? ( server )
86 + profiling? ( server )
87 + router? ( server )
88 + tcmalloc? ( server )"
89 +
90 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
91 +
92 +# Shorten the path because the socket path length must be shorter than 107 chars
93 +# and we will run a mysql server during test phase
94 +S="${WORKDIR}/mysql"
95 +
96 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
97 + inherit git-r3
98 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git"
99 + EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras"
100 + EGIT_CLONE_TYPE=shallow
101 + MY_PATCH_DIR="${WORKDIR}/mysql-extras"
102 +else
103 + MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}"
104 +fi
105 +
106 +PATCHES=(
107 + "${MY_PATCH_DIR}"/20001_all_fix-minimal-build-cmake-mysql-8.0.17.patch
108 + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-8.0.18.patch
109 + "${MY_PATCH_DIR}"/20018_all_mysql-5.7.23-fix-grant_user_lock-a-root.patch
110 + "${MY_PATCH_DIR}"/20018_all_percona-server-8.0.18-without-clientlibs-tools.patch
111 + "${MY_PATCH_DIR}"/20018_all_mysql-8.0.17-add-protobuf-3.8+-support.patch
112 + "${MY_PATCH_DIR}"/20018_all_percona-server-8.0.18-fix-libressl-support.patch
113 + "${MY_PATCH_DIR}"/20018_all_percona-server-8.0.16-dont-install-tokudb-misc-files.patch
114 + "${MY_PATCH_DIR}"/20038_all_percona-server-8.0.16-PS-5873.patch
115 + "${MY_PATCH_DIR}"/20018_all_mysql-8.0.19-fix-events_bugs-test.patch
116 + "${MY_PATCH_DIR}"/20018_all_percona-server-8.0.18-fix-building-with-make-4.3.patch
117 +)
118 +
119 +# Be warned, *DEPEND are version-dependant
120 +# These are used for both runtime and compiletime
121 +COMMON_DEPEND="
122 + >=app-arch/lz4-0_p131:=
123 + sys-libs/ncurses:0=
124 + >=sys-libs/zlib-1.2.3:0=
125 + libressl? ( dev-libs/libressl:0= )
126 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
127 + server? (
128 + dev-libs/icu:=
129 + dev-libs/libevent:=
130 + >=dev-libs/protobuf-3.8:=
131 + net-libs/libtirpc:=
132 + net-misc/curl:=
133 + cjk? ( app-text/mecab:= )
134 + jemalloc? ( dev-libs/jemalloc:0= )
135 + kernel_linux? (
136 + dev-libs/libaio:0=
137 + sys-process/procps:0=
138 + )
139 + numa? ( sys-process/numactl )
140 + pam? ( sys-libs/pam:0= )
141 + tcmalloc? ( dev-util/google-perftools:0= )
142 + )
143 +"
144 +DEPEND="${COMMON_DEPEND}
145 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
146 + virtual/yacc
147 + server? ( net-libs/rpcsvc-proto )
148 + test? (
149 + acct-group/mysql acct-user/mysql
150 + dev-perl/JSON
151 + )
152 +"
153 +RDEPEND="${COMMON_DEPEND}
154 + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/mysql !dev-db/mysql-cluster
155 + selinux? ( sec-policy/selinux-mysql )
156 + !prefix? (
157 + acct-group/mysql acct-user/mysql
158 + dev-db/mysql-init-scripts
159 + )
160 +"
161 +# For other stuff to bring us in
162 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
163 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
164 +
165 +CHECKREQS_DISK_BUILD="8G"
166 +
167 +mysql_init_vars() {
168 + : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
169 + : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
170 + : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
171 + : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
172 + MY_DATADIR="${MY_LOCALSTATEDIR}"
173 +
174 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
175 + export MY_LOCALSTATEDIR MY_LOGDIR
176 + export MY_DATADIR
177 +}
178 +
179 +pkg_pretend() {
180 + [[ ${MERGE_TYPE} == binary ]] && return
181 + use server && check-reqs_pkg_pretend
182 +}
183 +
184 +pkg_setup() {
185 + [[ ${MERGE_TYPE} == binary ]] && return
186 +
187 + if has test ${FEATURES} ; then
188 + # Bug #213475 - MySQL _will_ object strenuously if your machine is named
189 + # localhost. Also causes weird failures.
190 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
191 +
192 + if ! has userpriv ${FEATURES} ; then
193 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
194 + fi
195 +
196 + local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null)
197 + [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \
198 + && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!"
199 +
200 + if use latin1 ; then
201 + # Upstream only supports tests with default charset
202 + die "Testing with USE=latin1 is not supported."
203 + fi
204 + fi
205 +
206 + if use kernel_linux ; then
207 + if use numa ; then
208 + linux-info_get_any_version
209 +
210 + local CONFIG_CHECK="~NUMA"
211 +
212 + local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
213 + WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
214 +
215 + check_extra_config
216 + fi
217 + fi
218 +
219 + use server && check-reqs_pkg_setup
220 +}
221 +
222 +src_unpack() {
223 + unpack ${A}
224 +
225 + # Grab the patches
226 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
227 +
228 + mv -f "${WORKDIR}/${MY_P}" "${S}" || die
229 +}
230 +
231 +src_prepare() {
232 + # Avoid rpm call which would trigger sandbox, #692368
233 + sed -i \
234 + -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \
235 + CMakeLists.txt || die
236 +
237 + if use jemalloc ; then
238 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
239 + fi
240 +
241 + if use tcmalloc ; then
242 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die
243 + fi
244 +
245 + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
246 + if [[ -d "${S}/support-files/SELinux" ]] ; then
247 + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
248 + fi
249 +
250 + # Remove man pages for client-lib tools we don't install
251 + rm \
252 + man/my_print_defaults.1 \
253 + man/perror.1 \
254 + man/zlib_decompress.1 \
255 + || die
256 +
257 + cmake-utils_src_prepare
258 +}
259 +
260 +src_configure(){
261 + # Bug #114895, bug #110149
262 + filter-flags "-O" "-O[01]"
263 +
264 + append-cxxflags -felide-constructors
265 +
266 + # bug #283926, with GCC4.4, this is required to get correct behavior.
267 + append-flags -fno-strict-aliasing
268 +
269 + CMAKE_BUILD_TYPE="RelWithDebInfo"
270 +
271 + # debug hack wrt #497532
272 + mycmakeargs=(
273 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
274 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
275 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
276 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
277 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
278 + -DINSTALL_BINDIR=bin
279 + -DINSTALL_DOCDIR=share/doc/${PF}
280 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
281 + -DINSTALL_INCLUDEDIR=include/mysql
282 + -DINSTALL_INFODIR=share/info
283 + -DINSTALL_LIBDIR=$(get_libdir)
284 + -DINSTALL_MANDIR=share/man
285 + -DINSTALL_MYSQLSHAREDIR=share/mysql
286 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
287 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
288 + -DINSTALL_SBINDIR=sbin
289 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
290 + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
291 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
292 + # Using bundled editline to get CTRL+C working
293 + -DWITH_EDITLINE=bundled
294 + -DWITH_ZLIB=system
295 + -DWITH_SSL=system
296 + -DWITH_LIBWRAP=0
297 + -DENABLED_LOCAL_INFILE=1
298 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
299 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
300 + -DWITH_DEFAULT_FEATURE_SET=0
301 + # The build forces this to be defined when cross-compiling. We pass it
302 + # all the time for simplicity and to make sure it is actually correct.
303 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
304 + -DCMAKE_POSITION_INDEPENDENT_CODE=ON
305 + -DWITH_CURL=system
306 + -DWITH_BOOST="${WORKDIR}/boost_$(ver_rs 1- _ ${MY_BOOST_VERSION})"
307 + -DWITH_ROUTER=$(usex router ON OFF)
308 + )
309 +
310 + if is-flagq -fno-lto ; then
311 + einfo "LTO disabled via {C,CXX,F,FC}FLAGS"
312 + mycmakeargs+=( -DWITH_LTO=OFF )
313 + elif is-flagq -flto ; then
314 + einfo "LTO forced via {C,CXX,F,FC}FLAGS"
315 + myconf+=( -DWITH_LTO=ON )
316 + else
317 + # Disable automagic
318 + myconf+=( -DWITH_LTO=OFF )
319 + fi
320 +
321 + if use test ; then
322 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
323 + else
324 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
325 + fi
326 +
327 + mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
328 +
329 + mycmakeargs+=(
330 + -DWITH_ICU=system
331 + -DWITH_LZ4=system
332 + # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex
333 + -DWITH_RAPIDJSON=bundled
334 + )
335 +
336 + if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then
337 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
338 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
339 + ewarn "You MUST file bugs without these variables set."
340 + ewarn "Tests will probably fail!"
341 +
342 + mycmakeargs+=(
343 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
344 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
345 + )
346 + elif use latin1 ; then
347 + mycmakeargs+=(
348 + -DDEFAULT_CHARSET=latin1
349 + -DDEFAULT_COLLATION=latin1_swedish_ci
350 + )
351 + else
352 + mycmakeargs+=(
353 + -DDEFAULT_CHARSET=utf8mb4
354 + -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
355 + )
356 + fi
357 +
358 + if use server ; then
359 + mycmakeargs+=(
360 + -DWITH_EXTRA_CHARSETS=all
361 + -DWITH_DEBUG=$(usex debug)
362 + -DWITH_LIBEVENT=system
363 + -DWITH_MECAB=$(usex cjk system OFF)
364 + -DWITH_NUMA=$(usex numa ON OFF)
365 + -DWITH_PAM=$(usex pam)
366 + -DWITH_PROTOBUF=system
367 + )
368 +
369 + if use profiling ; then
370 + # Setting to OFF doesn't work: Once set, profiling options will be added
371 + # to `mysqld --help` output via sql/sys_vars.cc causing
372 + # "main.mysqld--help-notwin" test to fail
373 + mycmakeargs+=( -DENABLED_PROFILING=ON )
374 + fi
375 +
376 + # Storage engines
377 + mycmakeargs+=(
378 + -DWITH_EXAMPLE_STORAGE_ENGINE=0
379 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
380 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
381 + -DWITH_CSV_STORAGE_ENGINE=1
382 + -DWITH_FEDERATED_STORAGE_ENGINE=1
383 + -DWITH_HEAP_STORAGE_ENGINE=1
384 + -DWITH_INNOBASE_STORAGE_ENGINE=1
385 + -DWITH_INNODB_MEMCACHED=0
386 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
387 + -DWITH_MYISAM_STORAGE_ENGINE=1
388 + -DWITH_ROCKSDB=$(usex rocksdb 1 0)
389 + -DWITH_TOKUDB=$(usex tokudb 1 0)
390 + )
391 + else
392 + mycmakeargs+=(
393 + -DWITHOUT_SERVER=1
394 + -DWITH_SYSTEMD=no
395 + )
396 + fi
397 +
398 + cmake-utils_src_configure
399 +}
400 +
401 +# Official test instructions:
402 +# ulimit -n 16500 && \
403 +# USE='perl server' \
404 +# FEATURES='test userpriv' \
405 +# ebuild mysql-X.X.XX.ebuild \
406 +# digest clean package
407 +src_test() {
408 + _disable_test() {
409 + local rawtestname bug reason
410 + rawtestname="${1}" ; shift
411 + bug="${1}" ; shift
412 + reason="${@}"
413 + ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
414 + echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def"
415 + }
416 +
417 + local TESTDIR="${BUILD_DIR}/mysql-test"
418 + local retstatus_unit
419 + local retstatus_tests
420 +
421 + # Run CTest (test-units)
422 + cmake-utils_src_test
423 + retstatus_unit=$?
424 +
425 + # Ensure that parallel runs don't die
426 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
427 +
428 + if [[ -z "${MTR_PARALLEL}" ]] ; then
429 + local -x MTR_PARALLEL=$(makeopts_jobs)
430 +
431 + if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
432 + # Running multiple tests in parallel usually require higher ulimit
433 + # and fs.aio-max-nr setting. In addition, tests like main.multi_update
434 + # are known to hit timeout when system is busy.
435 + # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
436 + # using "auto".
437 + local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
438 + info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
439 + einfo "${info_msg}"
440 + unset info_msg
441 + MTR_PARALLEL=4
442 + fi
443 + else
444 + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
445 + fi
446 +
447 + # create directories because mysqladmin might run out of order
448 + mkdir -p "${T}"/var-tests{,/log} || die
449 +
450 + # Run mysql tests
451 + pushd "${TESTDIR}" &>/dev/null || die
452 +
453 + touch "${T}/disabled.def"
454 +
455 + local -a disabled_tests
456 + disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges")
457 + disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)")
458 + disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)")
459 + disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)")
460 + disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)")
461 + disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)")
462 + disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)")
463 + disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)")
464 + disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)")
465 + disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)")
466 + disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)")
467 + disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet")
468 + disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet")
469 + disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" )
470 + disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Know failure - no upstream bug yet" )
471 + disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware")
472 + disabled_tests+=( "main.mysqlpump_basic_lz4;6042;Extra tool output causes false positive" )
473 + disabled_tests+=( "main.ssl_bug75311;5996;Known test failure" )
474 + disabled_tests+=( "x.message_protobuf_nested;6803;False positive caused by protobuff-3.11+" )
475 + disabled_tests+=( "main.ssl_san;6808;False positive on IPv6-enabled hosts" )
476 +
477 + local test_ds
478 + for test_infos_str in "${disabled_tests[@]}" ; do
479 + IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
480 +
481 + if [[ ${#test_infos_arr[@]} != 3 ]] ; then
482 + die "Invalid test data set, not matching format: ${test_infos_str}"
483 + fi
484 +
485 + _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
486 + done
487 + unset test_ds test_infos_str test_infos_arr
488 +
489 + # Try to increase file limits to increase test coverage
490 + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
491 + # Upper limit comes from parts.partition_* tests
492 + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
493 +
494 + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
495 + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
496 + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
497 +
498 + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
499 + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
500 + else
501 + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
502 + fi
503 + else
504 + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
505 + fi
506 + else
507 + einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
508 + fi
509 +
510 + # run mysql-test tests
511 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
512 + retstatus_tests=$?
513 +
514 + popd &>/dev/null || die
515 +
516 + # Cleanup is important for these testcases.
517 + pkill -9 -f "${S}/ndb" 2>/dev/null
518 + pkill -9 -f "${S}/sql" 2>/dev/null
519 +
520 + local failures=""
521 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
522 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
523 +
524 + [[ -z "$failures" ]] || die "Test failures: $failures"
525 + einfo "Tests successfully completed"
526 +}
527 +
528 +src_install() {
529 + cmake-utils_src_install
530 +
531 + # Make sure the vars are correctly initialized
532 + mysql_init_vars
533 +
534 + # Convenience links
535 + einfo "Making Convenience links for mysqlcheck multi-call binary"
536 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
537 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
538 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
539 +
540 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
541 + if [[ -d "${ED}/usr/data" ]] ; then
542 + rm -Rf "${ED}/usr/data" || die
543 + fi
544 +
545 + # Unless they explicitly specific USE=test, then do not install the
546 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
547 + # validation of your database configuration after tuning it.
548 + if ! use test ; then
549 + rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test"
550 + fi
551 +
552 + # Configuration stuff
553 + einfo "Building default configuration ..."
554 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
555 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
556 + cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
557 + eprefixify "${TMPDIR}/my.cnf"
558 + doins "${TMPDIR}/my.cnf"
559 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
560 + cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
561 + eprefixify "${TMPDIR}/50-distro-client.cnf"
562 + doins "${TMPDIR}/50-distro-client.cnf"
563 +
564 + mycnf_src="my.cnf-8.0.distro-server"
565 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
566 + "${FILESDIR}/${mycnf_src}" \
567 + > "${TMPDIR}/my.cnf.ok" || die
568 +
569 + if use prefix ; then
570 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
571 + "${TMPDIR}/my.cnf.ok" || die
572 + fi
573 +
574 + if use latin1 ; then
575 + sed -i \
576 + -e "/character-set/s|utf8mb4|latin1|g" \
577 + "${TMPDIR}/my.cnf.ok" || die
578 + fi
579 +
580 + eprefixify "${TMPDIR}/my.cnf.ok"
581 +
582 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
583 +
584 + #Remove mytop if perl is not selected
585 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
586 +
587 + if use router ; then
588 + rm -rf \
589 + "${ED}/usr/LICENSE.router" \
590 + "${ED}/usr/README.router" \
591 + "${ED}/usr/run" \
592 + "${ED}/usr/var" \
593 + || die
594 + fi
595 +
596 + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
597 + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
598 +}
599 +
600 +pkg_postinst() {
601 + # Make sure the vars are correctly initialized
602 + mysql_init_vars
603 +
604 + # Create log directory securely if it does not exist
605 + # NOTE: $MY_LOGDIR contains $EPREFIX by default
606 + [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}"
607 +
608 + # Note about configuration change
609 + einfo
610 + elog "This version of ${PN} reorganizes the configuration from a single my.cnf"
611 + elog "to several files in /etc/mysql/mysql.d."
612 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
613 + elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension."
614 + elog "You may have as many files as needed and they are read alphabetically."
615 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
616 + einfo
617 +
618 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
619 + einfo
620 + elog "You might want to run:"
621 + elog " \"emerge --config =${CATEGORY}/${PF}\""
622 + elog "if this is a new install."
623 + einfo
624 + else
625 + einfo
626 + elog "Upgrade process for ${PN}-8.x has changed. Please read"
627 + elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html"
628 + einfo
629 + fi
630 +}
631 +
632 +pkg_config() {
633 + local mysqld_binary="${EROOT}/usr/sbin/mysqld"
634 + if [[ ! -x "${mysqld_binary}" ]] ; then
635 + die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
636 + fi
637 +
638 + local mysql_binary="${EROOT}/usr/bin/mysql"
639 + if [[ ! -x "${mysql_binary}" ]] ; then
640 + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
641 + fi
642 +
643 + local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults"
644 + if [[ ! -x "${my_print_defaults_binary}" ]] ; then
645 + die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!"
646 + fi
647 +
648 + if [[ -z "${MYSQL_USER}" ]] ; then
649 + MYSQL_USER=mysql
650 + if use prefix ; then
651 + MYSQL_USER=$(id -u -n 2>/dev/null)
652 + if [[ -z "${MYSQL_USER}" ]] ; then
653 + die "Failed to determine current username!"
654 + fi
655 + fi
656 + fi
657 +
658 + if [[ -z "${MYSQL_GROUP}" ]] ; then
659 + MYSQL_GROUP=mysql
660 + if use prefix ; then
661 + MYSQL_GROUP=$(id -g -n 2>/dev/null)
662 + if [[ -z "${MYSQL_GROUP}" ]] ; then
663 + die "Failed to determine current user groupname!"
664 + fi
665 + fi
666 + fi
667 +
668 + einfo "Will use username '${MYSQL_USER}' and group '${MYSQL_GROUP}' ..."
669 +
670 + _getoptval() {
671 + local section="$1"
672 + local flag="--${2}="
673 + local extra_options="${3}"
674 + local cmd=(
675 + "${my_print_defaults_binary}"
676 + "${extra_options}"
677 + "${section}"
678 + )
679 + local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") )
680 +
681 + if [[ ${#results[@]} -gt 0 ]] ; then
682 + # When option is set multiple times only return last value
683 + echo "${results[-1]}"
684 + fi
685 + }
686 +
687 + _mktemp_dry() {
688 + # emktemp has no --dry-run option
689 + local template="${1}"
690 +
691 + if [[ -z "${template}" ]] ; then
692 + if [[ -z "${T}" ]] ; then
693 + template="/tmp/XXXXXXX"
694 + else
695 + template="${T}/XXXXXXX"
696 + fi
697 + fi
698 +
699 + local template_wo_X=${template//X/}
700 + local n_X
701 + let n_X=${#template}-${#template_wo_X}
702 + if [[ ${n_X} -lt 3 ]] ; then
703 + echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2
704 + return
705 + fi
706 +
707 + local attempts=0
708 + local character tmpfile
709 + while [[ true ]] ; do
710 + let attempts=attempts+1
711 +
712 + new_file=
713 + while read -n1 character ; do
714 + if [[ "${character}" == "X" ]] ; then
715 + tmpfile+="${RANDOM:0:1}"
716 + else
717 + tmpfile+="${character}"
718 + fi
719 + done < <(echo -n "${template}")
720 +
721 + if [[ ! -f "${tmpfile}" ]]
722 + then
723 + echo "${tmpfile}"
724 + return
725 + fi
726 +
727 + if [[ ${attempts} -ge 100 ]] ; then
728 + echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2
729 + return
730 + fi
731 + done
732 + }
733 +
734 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
735 + local -x HOME="${EROOT}/root"
736 +
737 + # Make sure the vars are correctly initialized
738 + mysql_init_vars
739 +
740 + # Read currently set data directory
741 + MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
742 +
743 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
744 + # localhost. Also causes weird failures.
745 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
746 +
747 + if [[ -z "${MY_DATADIR}" ]] ; then
748 + die "Sorry, unable to find MY_DATADIR!"
749 + elif [[ -d "${MY_DATADIR}/mysql" ]] ; then
750 + ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!"
751 + ewarn "Please rename or delete its content if you wish to initialize a new data directory."
752 + die "${PN} data directory at '${MY_DATADIR}' looks already initialized!"
753 + else
754 + einfo "${PN} data directory detected as '${MY_DATADIR}' ..."
755 + fi
756 +
757 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
758 + # These are dir+prefix
759 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
760 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
761 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
762 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
763 +
764 + # Create missing directories.
765 + # Always check if mysql user can write to directory even if we just
766 + # created directory because a parent directory might be not
767 + # accessible for that user.
768 + PID_DIR="${EROOT}/run/mysqld"
769 + if [[ ! -d "${PID_DIR}" ]] ; then
770 + einfo "Creating ${PN} PID directory '${PID_DIR}' ..."
771 + install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \
772 + || die "Failed to create PID directory '${PID_DIR}'!"
773 + fi
774 +
775 + local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")"
776 + [[ -z "${_pid_dir_testfile}" ]] \
777 + && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
778 +
779 + if use prefix ; then
780 + touch "${_pid_dir_testfile}" &>/dev/null
781 + else
782 + su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null
783 + fi
784 +
785 + if [[ $? -ne 0 ]] ; then
786 + die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!"
787 + else
788 + rm "${_pid_dir_testfile}" || die
789 + unset _pid_dir_testfile
790 + fi
791 +
792 + if [[ ! -d "${MY_DATADIR}" ]] ; then
793 + einfo "Creating ${PN} data directory '${MY_DATADIR}' ..."
794 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \
795 + || die "Failed to create ${PN} data directory '${MY_DATADIR}'!"
796 + fi
797 +
798 + local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")"
799 + [[ -z "${_my_datadir_testfile}" ]] \
800 + && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
801 +
802 + if use prefix ; then
803 + touch "${_my_datadir_testfile}" &>/dev/null
804 + else
805 + su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null
806 + fi
807 +
808 + if [[ $? -ne 0 ]]; then
809 + die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!"
810 + else
811 + rm "${_my_datadir_testfile}" || die
812 + unset _my_datadir_testfile
813 + fi
814 +
815 + if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then
816 + einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..."
817 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \
818 + || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!"
819 + fi
820 +
821 + if [[ -n "${MYSQL_TMPDIR}" ]] ; then
822 + local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")"
823 + [[ -z "${_my_tmpdir_testfile}" ]] \
824 + && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
825 +
826 + if use prefix ; then
827 + touch "${_my_tmpdir_testfile}" &>/dev/null
828 + else
829 + su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null
830 + fi
831 +
832 + if [[ $? -ne 0 ]]; then
833 + die "${MYSQL_USER} user cannot write into data directory '${MYSQL_TMPDIR}'!"
834 + else
835 + rm "${_my_tmpdir_testfile}" || die
836 + unset _my_tmpdir_testfile
837 + fi
838 + else
839 + # If no tmpdir is set, mysqld will use default system tmpdir.
840 + # However, we are using tmpdir from package manager at the
841 + # moment which maybe isn't writeable for $MYSQL_USER...
842 + MYSQL_TMPDIR="$(_mktemp_dry "${T}/mysqld-tmp.XXXXXXXXX")"
843 + [[ -z "${MYSQL_TMPDIR}" ]] \
844 + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!"
845 +
846 + mkdir "${MYSQL_TMPDIR}" || die
847 + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die
848 + fi
849 +
850 + if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then
851 + einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..."
852 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \
853 + || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'"
854 + fi
855 +
856 + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
857 + local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")"
858 + [[ -z "${_my_logbin_testfile}" ]] \
859 + && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!"
860 +
861 + if use prefix ; then
862 + touch "${_my_logbin_testfile}" &>/dev/null
863 + else
864 + su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null
865 + fi
866 +
867 + if [[ $? -ne 0 ]]; then
868 + die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!"
869 + else
870 + rm "${_my_logbin_testfile}" || die
871 + unset _my_logbin_testfile
872 + fi
873 + fi
874 +
875 + if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then
876 + einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..."
877 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \
878 + || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!"
879 + fi
880 +
881 + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
882 + local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")"
883 + [[ -z "${_my_relaylog_testfile}" ]] \
884 + && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!"
885 +
886 + if use prefix ; then
887 + touch "${_my_relaylog_testfile}" &>/dev/null
888 + else
889 + su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null
890 + fi
891 +
892 + if [[ $? -ne 0 ]]; then
893 + die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!"
894 + else
895 + rm "${_my_relaylog_testfile}" || die
896 + unset _my_relaylog_testfile
897 + fi
898 + fi
899 +
900 + local -a config_files
901 +
902 + local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf"
903 + if [[ -f "${config_file}" ]] ; then
904 + config_files+=( "${config_file}" )
905 + else
906 + ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..."
907 + fi
908 +
909 + config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf"
910 + if [[ -f "${config_file}" ]] ; then
911 + config_files+=( "${config_file}" )
912 + else
913 + ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..."
914 + fi
915 +
916 + if [[ ${#config_files[@]} -gt 0 ]] ; then
917 + if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then
918 + local user_answer
919 +
920 + echo
921 + einfo "Please select default authentication plugin (enter number or plugin name):"
922 + einfo "1) caching_sha2_password [MySQL 8.0 default]"
923 + einfo "2) mysql_native_password [MySQL 5.7 default]"
924 + einfo
925 + einfo "For details see:"
926 + einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password"
927 + read -p " >" user_answer
928 + echo
929 +
930 + case "${user_answer}" in
931 + 1|caching_sha2_password)
932 + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password
933 + ;;
934 + 2|mysql_native_password)
935 + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password
936 + ;;
937 + '')
938 + die "No authentication plugin selected!"
939 + ;;
940 + *)
941 + die "Authentication plugin '${user_answer}' is unknown/unsupported!"
942 + ;;
943 + esac
944 +
945 + unset user_answer
946 + fi
947 +
948 + local cfg_option cfg_option_tabs cfg_section
949 + for config_file in "${config_files[@]}" ; do
950 + cfg_option="default-authentication-plugin"
951 + cfg_section="mysqld"
952 + cfg_option_tabs="\t\t"
953 + if [[ "${config_file}" == *client.cnf ]] ; then
954 + cfg_option="default-auth"
955 + cfg_section="client"
956 + cfg_option_tabs="\t\t\t\t"
957 + fi
958 +
959 + if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then
960 + einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
961 + sed -i \
962 + -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \
963 + "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!"
964 + else
965 + einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
966 + sed -i \
967 + -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \
968 + "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!"
969 + fi
970 + done
971 + unset cfg_option cfg_option_tabs cfg_section
972 + fi
973 + unset config_files config_file
974 +
975 + echo
976 +
977 + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
978 + local tmp_mysqld_password_source=
979 +
980 + for tmp_mysqld_password_source in mysql client ; do
981 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
982 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
983 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
984 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
985 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
986 + MYSQL_ROOT_PASSWORD=
987 + continue
988 + fi
989 +
990 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
991 + break
992 + fi
993 + done
994 +
995 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
996 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
997 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
998 + fi
999 +
1000 + unset tmp_mysqld_password_source
1001 + fi
1002 +
1003 + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
1004 + local pwd1="a"
1005 + local pwd2="b"
1006 +
1007 + echo
1008 + einfo "No password for mysql 'root' user was specified via environment"
1009 + einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config"
1010 + einfo "file like '${HOME}/.my.cnf'."
1011 + einfo "To continue please provide a password for the mysql 'root' user"
1012 + einfo "now on console:"
1013 + ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!"
1014 + read -rsp " >" pwd1 ; echo
1015 +
1016 + einfo "Retype the password"
1017 + read -rsp " >" pwd2 ; echo
1018 +
1019 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
1020 + die "Passwords are not the same!"
1021 + fi
1022 +
1023 + MYSQL_ROOT_PASSWORD="${pwd1}"
1024 + unset pwd1 pwd2
1025 +
1026 + echo
1027 + fi
1028 +
1029 + local -a mysqld_options
1030 +
1031 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
1032 + # see http://bugs.mysql.com/bug.php?id=31312
1033 + use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" )
1034 +
1035 + # Figure out which options we need to disable to do the setup
1036 + local helpfile="${TMPDIR}/mysqld-help"
1037 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
1038 +
1039 + local opt optexp optfull
1040 + for opt in host-cache name-resolve networking slave-start \
1041 + federated ssl log-bin relay-log slow-query-log external-locking \
1042 + log-slave-updates \
1043 + ; do
1044 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1045 + egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" )
1046 + done
1047 +
1048 + # Prepare timezones, see
1049 + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
1050 + local tz_sql="${TMPDIR}/tz.sql"
1051 + echo "USE mysql;" >"${tz_sql}"
1052 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null
1053 + if [[ $? -ne 0 ]] ; then
1054 + die "mysql_tzinfo_to_sql failed!"
1055 + fi
1056 +
1057 + chown ${MYSQL_USER} "${tz_sql}" || die
1058 +
1059 + local mysql_install_log="${TMPDIR}/mysql_install_db.log"
1060 + touch "${mysql_install_log}" || die
1061 + chown ${MYSQL_USER} "${mysql_install_log}" || die
1062 +
1063 + # --initialize-insecure will not set root password
1064 + # --initialize would set a random one in the log which we don't need as we set it ourselves
1065 + local cmd=(
1066 + "${mysqld_binary}"
1067 + "${mysqld_options[@]}"
1068 + "--initialize-insecure"
1069 + "--init-file='${tz_sql}'"
1070 + "--basedir='${EROOT}/usr'"
1071 + "--datadir='${MY_DATADIR}'"
1072 + "--tmpdir='${MYSQL_TMPDIR}'"
1073 + "--log-error='${mysql_install_log}'"
1074 + "--user=${MYSQL_USER}"
1075 + )
1076 +
1077 + einfo "Initializing ${PN} data directory: ${cmd[@]}"
1078 + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1
1079 +
1080 + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then
1081 + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2
1082 + die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!"
1083 + fi
1084 +
1085 + local x=${RANDOM}
1086 + local socket="${EROOT}/run/mysqld/mysqld${x}.sock"
1087 + local pidfile="${EROOT}/run/mysqld/mysqld${x}.pid"
1088 + unset x
1089 +
1090 + local mysqld_logfile="${TMPDIR}/mysqld.log"
1091 + touch "${mysqld_logfile}" || die
1092 + chown ${MYSQL_USER} "${mysqld_logfile}" || die
1093 +
1094 + cmd=(
1095 + "${mysqld_binary}"
1096 + "${mysqld_options[@]}"
1097 + "--basedir='${EROOT}/usr'"
1098 + "--datadir='${MY_DATADIR}'"
1099 + "--tmpdir='${MYSQL_TMPDIR}'"
1100 + --max_allowed_packet=8M
1101 + --net_buffer_length=16K
1102 + "--socket='${socket}'"
1103 + "--pid-file='${pidfile}'"
1104 + "--log-error='${mysqld_logfile}'"
1105 + "--user=${MYSQL_USER}"
1106 + )
1107 +
1108 + einfo "Starting mysqld to finalize initialization: ${cmd[@]}"
1109 + eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 &
1110 +
1111 + echo -n "Waiting for mysqld to accept connections "
1112 + local maxtry=15
1113 + while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
1114 + maxtry=$((${maxtry}-1))
1115 + echo -n "."
1116 + sleep 1
1117 + done
1118 +
1119 + if [[ -S "${socket}" ]] ; then
1120 + # Even with a socket we don't know if mysqld will abort
1121 + # start due to an error so just wait a little bit more...
1122 + maxtry=5
1123 + while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
1124 + maxtry=$((${maxtry}-1))
1125 + echo -n "."
1126 + sleep 1
1127 + done
1128 + fi
1129 +
1130 + echo
1131 +
1132 + if [[ ! -S "${socket}" ]] ; then
1133 + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2
1134 + die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!"
1135 + fi
1136 +
1137 + local mysql_logfile="${TMPDIR}/set_root_pw.log"
1138 + touch "${mysql_logfile}" || die
1139 +
1140 + ebegin "Setting root password"
1141 + # Do this from memory, as we don't want clear text passwords in temp files
1142 + local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'"
1143 + cmd=(
1144 + "${mysql_binary}"
1145 + --no-defaults
1146 + "--socket='${socket}'"
1147 + -hlocalhost
1148 + "-e \"${sql}\""
1149 + )
1150 + eval "${cmd[@]}" >"${mysql_logfile}" 2>&1
1151 + local rc=$?
1152 + eend ${rc}
1153 +
1154 + if [[ ${rc} -ne 0 ]] ; then
1155 + # Poor man's solution which tries to avoid having password
1156 + # in log. NOTE: sed can fail if user didn't follow advice
1157 + # and included character which will require escaping...
1158 + sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null
1159 +
1160 + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}"
1161 + die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!"
1162 + fi
1163 +
1164 + # Stop the server
1165 + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
1166 + echo -n "Stopping the server "
1167 + pkill -F "${pidfile}" &>/dev/null
1168 +
1169 + maxtry=10
1170 + while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do
1171 + maxtry=$((${maxtry}-1))
1172 + echo -n "."
1173 + sleep 1
1174 + done
1175 +
1176 + echo
1177 +
1178 + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
1179 + # We somehow failed to stop server.
1180 + # However, not a fatal error. Just warn the user.
1181 + ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!"
1182 + fi
1183 + fi
1184 +
1185 + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!"
1186 +}