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