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