1 |
commit: aa0f272d5a3612f52f2e918d92f18eff718890d0 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Oct 31 15:45:07 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Oct 31 15:45:07 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aa0f272d |
7 |
|
8 |
dev-db/mysql: add 5.7.40 |
9 |
|
10 |
Bug: https://bugs.gentoo.org/859388 |
11 |
Bug: https://bugs.gentoo.org/877593 |
12 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
13 |
|
14 |
dev-db/mysql/Manifest | 1 + |
15 |
dev-db/mysql/mysql-5.7.40.ebuild | 1285 ++++++++++++++++++++++++++++++++++++++ |
16 |
2 files changed, 1286 insertions(+) |
17 |
|
18 |
diff --git a/dev-db/mysql/Manifest b/dev-db/mysql/Manifest |
19 |
index 17d7fae4b8e1..bb390ff9eeb7 100644 |
20 |
--- a/dev-db/mysql/Manifest |
21 |
+++ b/dev-db/mysql/Manifest |
22 |
@@ -1,4 +1,5 @@ |
23 |
DIST mysql-5.7.36-patches-01.tar.xz 6396 BLAKE2B ed9783f207d40fc220992c4193bdd8e96523f69414daa756f1f30306c1aedff9e96216ba2294a4c41eefbaf39c8bb37784bf1e7cce656c93f829c9cf0682fa6d SHA512 b0fbd41ebb2d32067e6c81707dffa91fece2d368f4b2fa47951492936509972d425b64d7613748c42b31cf9ba9dab697efeff70debe7268855a90d322d3f3158 |
24 |
DIST mysql-8.0.27-patches-03.tar.xz 9864 BLAKE2B 03136477a97a5bff0c5f1cbc7921a77d9b36e148e94f80463f00f0efd1a6859af4595f9cf15aa492bce043fdc9d6c6328bd64102f8b0127eacbc7795b1785ecb SHA512 8c00c8fef2b01389f59138eaa29399d8a9ce7930b6bdfb7689d1d7bf14a32fbb10a2b8dbe91933b805899ef3af0cf0bda704d4be14249991b381054bcc496058 |
25 |
DIST mysql-boost-5.7.36.tar.gz 52968383 BLAKE2B 4d5e4fcf8d56f4a1d1d54ee889d432ee3265f55ff9c0ecf6fe216e67790a49ed052b94457680daef4cb42df29f14db7b0e678e0f0443c20b7e2324c772c24313 SHA512 a95580efd5b87776ee7f1aae9b50d50d88c70a48c16e7a2d8c6ada0b1cadc5ec6074a859291a65caa1b50a00e08a9e350df342bb0c6ef74edaf21055331c081b |
26 |
+DIST mysql-boost-5.7.40.tar.gz 53255386 BLAKE2B 1c367dd4d65a42713fb09943c4518c9be375210fee4e8e6b7b889dc32f0b429a98f132498ba8e6423d288f2936a97ec6c5098411d5f28adc608d04deeb068b24 SHA512 5c49ef65c00658786117cc489d80a6ed7517759b010fb4530508649ab6b4079bb8f1dbc70cefe5d179e1a003960d296b85210b161be4f8f18756a578a1a11365 |
27 |
DIST mysql-boost-8.0.27.tar.gz 292184025 BLAKE2B 177209f3c62b0326ca9d021c751a701dec84c1b15c946ab0a68b1b4cf0620468eb3a1df77a918284007a0fde1aaa6a9767d0baed57936612813ef583df51c35e SHA512 6ef2426c0bee46bdf8e2fa5cb159d5ae19f0bed4f7c9bea9b33e0dd922b568c3c68ca063dcbcd7ea6904aaea31877c10064ea10b4bc63fb40d9f31778e3a7891 |
28 |
|
29 |
diff --git a/dev-db/mysql/mysql-5.7.40.ebuild b/dev-db/mysql/mysql-5.7.40.ebuild |
30 |
new file mode 100644 |
31 |
index 000000000000..8daf02105f3c |
32 |
--- /dev/null |
33 |
+++ b/dev-db/mysql/mysql-5.7.40.ebuild |
34 |
@@ -0,0 +1,1285 @@ |
35 |
+# Copyright 1999-2022 Gentoo Authors |
36 |
+# Distributed under the terms of the GNU General Public License v2 |
37 |
+ |
38 |
+EAPI="7" |
39 |
+ |
40 |
+CMAKE_MAKEFILE_GENERATOR=emake |
41 |
+ |
42 |
+inherit check-reqs cmake flag-o-matic linux-info \ |
43 |
+ multiprocessing prefix toolchain-funcs multilib-minimal |
44 |
+ |
45 |
+# Patch version |
46 |
+PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-5.7.36-patches-01.tar.xz" |
47 |
+ |
48 |
+SRC_URI="https://cdn.mysql.com/Downloads/MySQL-$(ver_cut 1-2)/${PN}-boost-${PV}.tar.gz |
49 |
+ https://cdn.mysql.com/archives/mysql-$(ver_cut 1-2)/mysql-boost-${PV}.tar.gz |
50 |
+ http://downloads.mysql.com/archives/MySQL-$(ver_cut 1-2)/${PN}-boost-${PV}.tar.gz |
51 |
+ ${PATCH_SET}" |
52 |
+ |
53 |
+HOMEPAGE="https://www.mysql.com/" |
54 |
+DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" |
55 |
+LICENSE="GPL-2" |
56 |
+SLOT="5.7/18" |
57 |
+IUSE="cjk client-libs cracklib debug experimental jemalloc latin1 numa +perl profiling |
58 |
+ selinux +server static static-libs systemtap tcmalloc test" |
59 |
+ |
60 |
+RESTRICT="!test? ( test )" |
61 |
+ |
62 |
+REQUIRED_USE="?? ( tcmalloc jemalloc )" |
63 |
+ |
64 |
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris" |
65 |
+ |
66 |
+# Shorten the path because the socket path length must be shorter than 107 chars |
67 |
+# and we will run a mysql server during test phase |
68 |
+S="${WORKDIR}/mysql" |
69 |
+ |
70 |
+# Be warned, *DEPEND are version-dependant |
71 |
+# These are used for both runtime and compiletime |
72 |
+# MULTILIB_USEDEP only set for libraries used by the client library |
73 |
+COMMON_DEPEND=" |
74 |
+ sys-libs/ncurses:0= |
75 |
+ client-libs? ( |
76 |
+ >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?] |
77 |
+ >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] |
78 |
+ ) |
79 |
+ !client-libs? ( |
80 |
+ dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] |
81 |
+ >=sys-libs/zlib-1.2.3:0= |
82 |
+ >=dev-libs/openssl-1.0.0:0= |
83 |
+ ) |
84 |
+ server? ( |
85 |
+ >=app-arch/lz4-0_p131:= |
86 |
+ virtual/libcrypt:= |
87 |
+ cjk? ( app-text/mecab:= ) |
88 |
+ experimental? ( |
89 |
+ dev-libs/libevent:=[ssl] |
90 |
+ dev-libs/protobuf:= |
91 |
+ net-libs/libtirpc:= |
92 |
+ ) |
93 |
+ jemalloc? ( dev-libs/jemalloc:0= ) |
94 |
+ kernel_linux? ( |
95 |
+ dev-libs/libaio:0= |
96 |
+ sys-process/procps:0= |
97 |
+ ) |
98 |
+ numa? ( sys-process/numactl ) |
99 |
+ ) |
100 |
+ systemtap? ( >=dev-util/systemtap-1.3:0= ) |
101 |
+ tcmalloc? ( dev-util/google-perftools:0= ) |
102 |
+" |
103 |
+ |
104 |
+DEPEND=" |
105 |
+ ${COMMON_DEPEND} |
106 |
+ || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) |
107 |
+ dev-libs/protobuf |
108 |
+ virtual/yacc |
109 |
+ server? ( |
110 |
+ dev-libs/libevent:=[ssl] |
111 |
+ experimental? ( net-libs/rpcsvc-proto ) |
112 |
+ ) |
113 |
+ static? ( sys-libs/ncurses[static-libs] ) |
114 |
+ test? ( |
115 |
+ acct-group/mysql acct-user/mysql |
116 |
+ dev-perl/JSON |
117 |
+ ) |
118 |
+" |
119 |
+ |
120 |
+RDEPEND=" |
121 |
+ ${COMMON_DEPEND} |
122 |
+ !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster |
123 |
+ !dev-db/mysql:0 |
124 |
+ !dev-db/mysql:8.0 |
125 |
+ client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c dev-libs/protobuf:= ) |
126 |
+ selinux? ( sec-policy/selinux-mysql ) |
127 |
+ server? ( |
128 |
+ !prefix? ( |
129 |
+ acct-group/mysql acct-user/mysql |
130 |
+ dev-db/mysql-init-scripts |
131 |
+ ) |
132 |
+ ) |
133 |
+" |
134 |
+ |
135 |
+# For other stuff to bring us in |
136 |
+# dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
137 |
+PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
138 |
+ |
139 |
+mysql_init_vars() { |
140 |
+ : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"} |
141 |
+ : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"} |
142 |
+ : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"} |
143 |
+ : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"} |
144 |
+ MY_DATADIR="${MY_LOCALSTATEDIR}" |
145 |
+ |
146 |
+ export MY_SHAREDSTATEDIR MY_SYSCONFDIR |
147 |
+ export MY_LOCALSTATEDIR MY_LOGDIR |
148 |
+ export MY_DATADIR |
149 |
+} |
150 |
+ |
151 |
+pkg_pretend() { |
152 |
+ if [[ ${MERGE_TYPE} != binary ]] ; then |
153 |
+ if use server ; then |
154 |
+ CHECKREQS_DISK_BUILD="3G" |
155 |
+ |
156 |
+ if has test $FEATURES ; then |
157 |
+ CHECKREQS_DISK_BUILD="9G" |
158 |
+ fi |
159 |
+ |
160 |
+ check-reqs_pkg_pretend |
161 |
+ fi |
162 |
+ fi |
163 |
+} |
164 |
+ |
165 |
+pkg_setup() { |
166 |
+ if [[ ${MERGE_TYPE} != binary ]] ; then |
167 |
+ CHECKREQS_DISK_BUILD="3G" |
168 |
+ |
169 |
+ if has test ${FEATURES} ; then |
170 |
+ CHECKREQS_DISK_BUILD="9G" |
171 |
+ |
172 |
+ # Bug #213475 - MySQL _will_ object strenuously if your machine is named |
173 |
+ # localhost. Also causes weird failures. |
174 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
175 |
+ |
176 |
+ if ! has userpriv ${FEATURES} ; then |
177 |
+ die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
178 |
+ fi |
179 |
+ |
180 |
+ local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null) |
181 |
+ [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \ |
182 |
+ && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!" |
183 |
+ |
184 |
+ if use latin1 ; then |
185 |
+ # Upstream only supports tests with default charset |
186 |
+ die "Testing with USE=latin1 is not supported." |
187 |
+ fi |
188 |
+ fi |
189 |
+ |
190 |
+ if use kernel_linux ; then |
191 |
+ if use numa ; then |
192 |
+ linux-info_get_any_version |
193 |
+ |
194 |
+ local CONFIG_CHECK="~NUMA" |
195 |
+ |
196 |
+ local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" |
197 |
+ WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" |
198 |
+ |
199 |
+ check_extra_config |
200 |
+ fi |
201 |
+ fi |
202 |
+ |
203 |
+ use server && check-reqs_pkg_setup |
204 |
+ fi |
205 |
+} |
206 |
+ |
207 |
+pkg_preinst() { |
208 |
+ # Here we need to see if the implementation switched client libraries |
209 |
+ # We check if this is a new instance of the package and a client library already exists |
210 |
+ local SHOW_ABI_MESSAGE libpath |
211 |
+ if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}/usr/$(get_libdir)/libmysqlclient.so" ]] ; then |
212 |
+ libpath=$(readlink "${EROOT}/usr/$(get_libdir)/libmysqlclient.so") |
213 |
+ elog "Due to ABI changes when switching between different client libraries," |
214 |
+ elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." |
215 |
+ elog "Please run: revdep-rebuild --library ${libpath}" |
216 |
+ ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" |
217 |
+ fi |
218 |
+} |
219 |
+ |
220 |
+pkg_postinst() { |
221 |
+ # Make sure the vars are correctly initialized |
222 |
+ mysql_init_vars |
223 |
+ |
224 |
+ # Create log directory securely if it does not exist |
225 |
+ [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
226 |
+ |
227 |
+ if use server ; then |
228 |
+ if [[ -z "${REPLACING_VERSIONS}" ]] ; then |
229 |
+ einfo |
230 |
+ elog "You might want to run:" |
231 |
+ elog "\"emerge --config =${CATEGORY}/${PF}\"" |
232 |
+ elog "if this is a new install." |
233 |
+ elog |
234 |
+ elog "If you are switching server implentations, you should run the" |
235 |
+ elog "mysql_upgrade tool." |
236 |
+ einfo |
237 |
+ else |
238 |
+ einfo |
239 |
+ elog "If you are upgrading major versions, you should run the" |
240 |
+ elog "mysql_upgrade tool." |
241 |
+ einfo |
242 |
+ fi |
243 |
+ fi |
244 |
+ |
245 |
+ # Note about configuration change |
246 |
+ einfo |
247 |
+ elog "This version of ${PN} reorganizes the configuration from a single my.cnf" |
248 |
+ elog "to several files in /etc/mysql/mysql.d." |
249 |
+ elog "Please backup any changes you made to /etc/mysql/my.cnf" |
250 |
+ elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." |
251 |
+ elog "You may have as many files as needed and they are read alphabetically." |
252 |
+ elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." |
253 |
+ einfo |
254 |
+} |
255 |
+ |
256 |
+src_unpack() { |
257 |
+ unpack ${A} |
258 |
+ |
259 |
+ mv -f "${WORKDIR}/${P}" "${S}" || die |
260 |
+} |
261 |
+ |
262 |
+src_prepare() { |
263 |
+ eapply "${WORKDIR}"/mysql-patches |
264 |
+ |
265 |
+ if use jemalloc ; then |
266 |
+ echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die |
267 |
+ fi |
268 |
+ |
269 |
+ if use tcmalloc ; then |
270 |
+ echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die |
271 |
+ fi |
272 |
+ |
273 |
+ # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux |
274 |
+ if [[ -d "${S}/support-files/SELinux" ]] ; then |
275 |
+ echo > "${S}/support-files/SELinux/CMakeLists.txt" || die |
276 |
+ fi |
277 |
+ |
278 |
+ # Remove bundled libs so we cannot accidentally use them |
279 |
+ # We keep extra/lz4 directory because we use extra/lz4/xxhash.c via sql/CMakeLists.txt:394 |
280 |
+ rm -rv \ |
281 |
+ "${S}"/extra/protobuf \ |
282 |
+ "${S}"/extra/libevent \ |
283 |
+ || die |
284 |
+ |
285 |
+ # Don't clash with dev-db/mysql-connector-c |
286 |
+ rm \ |
287 |
+ man/my_print_defaults.1 \ |
288 |
+ man/perror.1 \ |
289 |
+ man/zlib_decompress.1 \ |
290 |
+ || die |
291 |
+ |
292 |
+ sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die |
293 |
+ |
294 |
+ cmake_src_prepare |
295 |
+} |
296 |
+ |
297 |
+src_configure() { |
298 |
+ # Bug #114895, bug #110149 |
299 |
+ filter-flags "-O" "-O[01]" |
300 |
+ |
301 |
+ append-cxxflags -felide-constructors |
302 |
+ |
303 |
+ # code is not C++17 ready, bug #786402 |
304 |
+ append-cxxflags -std=c++14 |
305 |
+ |
306 |
+ # bug #283926, with GCC4.4, this is required to get correct behavior. |
307 |
+ append-flags -fno-strict-aliasing |
308 |
+ |
309 |
+ if use client-libs ; then |
310 |
+ multilib-minimal_src_configure |
311 |
+ else |
312 |
+ multilib_src_configure |
313 |
+ fi |
314 |
+} |
315 |
+ |
316 |
+multilib_src_configure() { |
317 |
+ debug-print-function ${FUNCNAME} "$@" |
318 |
+ |
319 |
+ if ! multilib_is_native_abi && ! use client-libs ; then |
320 |
+ return |
321 |
+ fi |
322 |
+ |
323 |
+ CMAKE_BUILD_TYPE="RelWithDebInfo" |
324 |
+ |
325 |
+ # debug hack wrt #497532 |
326 |
+ mycmakeargs=( |
327 |
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
328 |
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
329 |
+ -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" |
330 |
+ -DSYSCONFDIR="${EPREFIX}/etc/mysql" |
331 |
+ -DINSTALL_BINDIR=bin |
332 |
+ -DINSTALL_DOCDIR=share/doc/${PF} |
333 |
+ -DINSTALL_DOCREADMEDIR=share/doc/${PF} |
334 |
+ -DINSTALL_INCLUDEDIR=include/mysql |
335 |
+ -DINSTALL_INFODIR=share/info |
336 |
+ -DINSTALL_LIBDIR=$(get_libdir) |
337 |
+ -DINSTALL_MANDIR=share/man |
338 |
+ -DINSTALL_MYSQLSHAREDIR=share/mysql |
339 |
+ -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin |
340 |
+ -DINSTALL_SCRIPTDIR=share/mysql/scripts |
341 |
+ -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" |
342 |
+ -DINSTALL_SBINDIR=sbin |
343 |
+ -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" |
344 |
+ -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" |
345 |
+ -DWITH_UNIT_TESTS=$(usex test ON OFF) |
346 |
+ ### TODO: make this system but issues with UTF-8 prevent it |
347 |
+ -DWITH_EDITLINE=bundled |
348 |
+ -DWITH_ZLIB=system |
349 |
+ -DWITH_SSL=system |
350 |
+ -DWITH_LIBWRAP=0 |
351 |
+ -DENABLED_LOCAL_INFILE=1 |
352 |
+ -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" |
353 |
+ -DWITH_DEFAULT_COMPILER_OPTIONS=0 |
354 |
+ -DWITH_DEFAULT_FEATURE_SET=0 |
355 |
+ # The build forces this to be defined when cross-compiling. We pass it |
356 |
+ # all the time for simplicity and to make sure it is actually correct. |
357 |
+ -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) |
358 |
+ -DWITH_CURL=system |
359 |
+ -DWITH_BOOST="${S}/boost" |
360 |
+ ) |
361 |
+ if use test ; then |
362 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) |
363 |
+ else |
364 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) |
365 |
+ fi |
366 |
+ |
367 |
+ if ! use client-libs ; then |
368 |
+ mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) |
369 |
+ fi |
370 |
+ |
371 |
+ # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION |
372 |
+ # systemtap only works on native ABI, bug 530132 |
373 |
+ if multilib_is_native_abi ; then |
374 |
+ mycmakeargs+=( |
375 |
+ -DENABLE_DTRACE=$(usex systemtap) |
376 |
+ ) |
377 |
+ else |
378 |
+ mycmakeargs+=( |
379 |
+ -DWITHOUT_TOOLS=1 |
380 |
+ -DWITH_READLINE=1 |
381 |
+ -DENABLE_DTRACE=0 |
382 |
+ ) |
383 |
+ fi |
384 |
+ |
385 |
+ if multilib_is_native_abi && use server ; then |
386 |
+ mycmakeargs+=( |
387 |
+ -DWITH_LIBEVENT=system |
388 |
+ -DWITH_LZ4=system |
389 |
+ -DWITH_PROTOBUF=system |
390 |
+ -DWITH_MECAB=$(usex cjk system OFF) |
391 |
+ -DWITH_NUMA=$(usex numa ON OFF) |
392 |
+ -DWITH_RAPID=$(usex experimental ON OFF) |
393 |
+ ) |
394 |
+ |
395 |
+ if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]] ; then |
396 |
+ ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" |
397 |
+ ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." |
398 |
+ ewarn "You MUST file bugs without these variables set." |
399 |
+ |
400 |
+ mycmakeargs+=( |
401 |
+ -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} |
402 |
+ -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} |
403 |
+ ) |
404 |
+ elif ! use latin1 ; then |
405 |
+ mycmakeargs+=( |
406 |
+ -DDEFAULT_CHARSET=utf8 |
407 |
+ -DDEFAULT_COLLATION=utf8_general_ci |
408 |
+ ) |
409 |
+ else |
410 |
+ mycmakeargs+=( |
411 |
+ -DDEFAULT_CHARSET=latin1 |
412 |
+ -DDEFAULT_COLLATION=latin1_swedish_ci |
413 |
+ ) |
414 |
+ fi |
415 |
+ |
416 |
+ mycmakeargs+=( |
417 |
+ -DEXTRA_CHARSETS=all |
418 |
+ -DDISABLE_SHARED=$(usex static YES NO) |
419 |
+ -DWITH_DEBUG=$(usex debug) |
420 |
+ -DWITH_EMBEDDED_SERVER=OFF |
421 |
+ ) |
422 |
+ |
423 |
+ if use profiling ; then |
424 |
+ # Setting to OFF doesn't work: Once set, profiling options will be added |
425 |
+ # to `mysqld --help` output via sql/sys_vars.cc causing |
426 |
+ # "main.mysqld--help-notwin" test to fail |
427 |
+ mycmakeargs+=( -DENABLED_PROFILING=ON ) |
428 |
+ fi |
429 |
+ |
430 |
+ if use static ; then |
431 |
+ mycmakeargs+=( -DWITH_PIC=1 ) |
432 |
+ fi |
433 |
+ |
434 |
+ # Storage engines |
435 |
+ mycmakeargs+=( |
436 |
+ -DWITH_EXAMPLE_STORAGE_ENGINE=0 |
437 |
+ -DWITH_ARCHIVE_STORAGE_ENGINE=1 |
438 |
+ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 |
439 |
+ -DWITH_CSV_STORAGE_ENGINE=1 |
440 |
+ -DWITH_FEDERATED_STORAGE_ENGINE=1 |
441 |
+ -DWITH_HEAP_STORAGE_ENGINE=1 |
442 |
+ -DWITH_INNOBASE_STORAGE_ENGINE=1 |
443 |
+ -DWITH_INNODB_MEMCACHED=0 |
444 |
+ -DWITH_MYISAMMRG_STORAGE_ENGINE=1 |
445 |
+ -DWITH_MYISAM_STORAGE_ENGINE=1 |
446 |
+ -DWITH_PARTITION_STORAGE_ENGINE=1 |
447 |
+ ) |
448 |
+ |
449 |
+ else |
450 |
+ mycmakeargs+=( |
451 |
+ -DWITHOUT_SERVER=1 |
452 |
+ -DWITH_EMBEDDED_SERVER=OFF |
453 |
+ -DEXTRA_CHARSETS=none |
454 |
+ ) |
455 |
+ fi |
456 |
+ |
457 |
+ cmake_src_configure |
458 |
+} |
459 |
+ |
460 |
+src_compile() { |
461 |
+ if use client-libs ; then |
462 |
+ multilib-minimal_src_compile |
463 |
+ else |
464 |
+ multilib_src_compile |
465 |
+ fi |
466 |
+} |
467 |
+ |
468 |
+multilib_src_compile() { |
469 |
+ cmake_src_compile |
470 |
+} |
471 |
+ |
472 |
+# Official test instructions: |
473 |
+# ulimit -n 16500 && \ |
474 |
+# USE='latin1 perl server' \ |
475 |
+# FEATURES='test userpriv -usersandbox' \ |
476 |
+# ebuild mysql-X.X.XX.ebuild \ |
477 |
+# digest clean package |
478 |
+src_test() { |
479 |
+ _disable_test() { |
480 |
+ local rawtestname reason |
481 |
+ rawtestname="${1}" ; shift |
482 |
+ reason="${@}" |
483 |
+ ewarn "test '${rawtestname}' disabled: '${reason}'" |
484 |
+ echo ${rawtestname} : ${reason} >> "${T}/disabled.def" |
485 |
+ } |
486 |
+ |
487 |
+ local TESTDIR="${BUILD_DIR}/mysql-test" |
488 |
+ local retstatus_tests |
489 |
+ |
490 |
+ if ! use server ; then |
491 |
+ einfo "Skipping server tests due to minimal build." |
492 |
+ return 0 |
493 |
+ fi |
494 |
+ |
495 |
+ # Ensure that parallel runs don't die |
496 |
+ export MTR_BUILD_THREAD="$((${RANDOM} % 100))" |
497 |
+ |
498 |
+ if [[ -z "${MTR_PARALLEL}" ]] ; then |
499 |
+ local -x MTR_PARALLEL=$(makeopts_jobs) |
500 |
+ |
501 |
+ if [[ ${MTR_PARALLEL} -gt 4 ]] ; then |
502 |
+ # Running multiple tests in parallel usually require higher ulimit |
503 |
+ # and fs.aio-max-nr setting. In addition, tests like main.multi_update |
504 |
+ # are known to hit timeout when system is busy. |
505 |
+ # To avoid test failure we will limit MTR_PARALLEL to 4 instead of |
506 |
+ # using "auto". |
507 |
+ local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" |
508 |
+ info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" |
509 |
+ einfo "${info_msg}" |
510 |
+ unset info_msg |
511 |
+ MTR_PARALLEL=4 |
512 |
+ fi |
513 |
+ else |
514 |
+ einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" |
515 |
+ fi |
516 |
+ |
517 |
+ # create directories because mysqladmin might run out of order |
518 |
+ mkdir -p "${T}"/var-tests{,/log} || die |
519 |
+ |
520 |
+ # Run mysql tests |
521 |
+ pushd "${TESTDIR}" &>/dev/null || die |
522 |
+ |
523 |
+ touch "${T}/disabled.def" |
524 |
+ # These are failing in MySQL 5.7 for now and are believed to be |
525 |
+ # false positives: |
526 |
+ # |
527 |
+ local t |
528 |
+ |
529 |
+ for t in \ |
530 |
+ auth_sec.keyring_udf \ |
531 |
+ innodb.alter_kill \ |
532 |
+ innodb.innodb-multiple-tablespaces \ |
533 |
+ innodb.import_compress_encrypt \ |
534 |
+ perfschema.privilege_table_io \ |
535 |
+ ; do |
536 |
+ _disable_test "$t" "False positives in Gentoo" |
537 |
+ done |
538 |
+ |
539 |
+ # Unstable tests |
540 |
+ # - main.xa_prepared_binlog_off: https://bugs.mysql.com/bug.php?id=83340 |
541 |
+ # - rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch: https://bugs.mysql.com/bug.php?id=89223 |
542 |
+ # - rpl.rpl_non_direct_stm_mixing_engines: MDEV-14489 |
543 |
+ for t in \ |
544 |
+ main.xa_prepared_binlog_off \ |
545 |
+ rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch \ |
546 |
+ rpl.rpl_non_direct_stm_mixing_engines \ |
547 |
+ ; do |
548 |
+ _disable_test "$t" "Unstable test" |
549 |
+ done |
550 |
+ |
551 |
+ for t in \ |
552 |
+ gis.geometry_class_attri_prop \ |
553 |
+ gis.geometry_property_function_issimple \ |
554 |
+ gis.gis_bugs_crashes \ |
555 |
+ gis.spatial_op_testingfunc_mix \ |
556 |
+ gis.spatial_analysis_functions_buffer \ |
557 |
+ gis.spatial_analysis_functions_distance \ |
558 |
+ gis.spatial_utility_function_distance_sphere \ |
559 |
+ gis.spatial_utility_function_simplify \ |
560 |
+ gis.spatial_analysis_functions_centroid \ |
561 |
+ main.with_recursive \ |
562 |
+ ; do |
563 |
+ _disable_test "$t" "Known rounding error with latest AMD processors" |
564 |
+ done |
565 |
+ |
566 |
+ if ! hash zip 1>/dev/null 2>&1 ; then |
567 |
+ # no need to force dep app-arch/zip for one test |
568 |
+ _disable_test "innodb.partition_upgrade_create" "Requires app-arch/zip" |
569 |
+ fi |
570 |
+ |
571 |
+ if use numa && use kernel_linux ; then |
572 |
+ # bug 584880 |
573 |
+ if ! linux_config_exists || ! linux_chkconfig_present NUMA ; then |
574 |
+ for t in sys_vars.innodb_numa_interleave_basic ; do |
575 |
+ _disable_test "$t" "Test $t requires system with NUMA support" |
576 |
+ done |
577 |
+ fi |
578 |
+ fi |
579 |
+ |
580 |
+ if ! use latin1 ; then |
581 |
+ # The following tests will fail if DEFAULT_CHARSET |
582 |
+ # isn't set to latin1: |
583 |
+ for t in \ |
584 |
+ binlog.binlog_mysqlbinlog_filter \ |
585 |
+ binlog.binlog_xa_prepared_disconnect \ |
586 |
+ funcs_1.is_columns_mysql \ |
587 |
+ funcs_1.is_tables_mysql \ |
588 |
+ funcs_1.is_triggers \ |
589 |
+ innodb.innodb_pagesize_max_recordsize \ |
590 |
+ innodb.innodb-system-table-view \ |
591 |
+ innodb.mysqldump_max_recordsize \ |
592 |
+ main.mysql_client_test \ |
593 |
+ main.mysqld--help-notwin \ |
594 |
+ main.mysqldump_bugs \ |
595 |
+ main.type_string \ |
596 |
+ main.information_schema \ |
597 |
+ perfschema.binlog_edge_mix \ |
598 |
+ perfschema.binlog_edge_stmt \ |
599 |
+ rpl.rpl_xa_survive_disconnect \ |
600 |
+ rpl.rpl_xa_survive_disconnect_lsu_off \ |
601 |
+ rpl.rpl_xa_survive_disconnect_table \ |
602 |
+ ; do |
603 |
+ _disable_test "$t" "Requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" |
604 |
+ done |
605 |
+ fi |
606 |
+ |
607 |
+ if has_version ">=dev-libs/openssl-3" ; then |
608 |
+ # >=dev-libs/openssl-3 defaults to security level 1 which disallow |
609 |
+ # TLSv1/1.1 but tests will require TLSv1/1.1. |
610 |
+ einfo "Set OpenSSL configuration for test suite ..." |
611 |
+ cat > "${T}/openssl_tlsv1.cnf" <<- EOF || die |
612 |
+ openssl_conf = default_conf |
613 |
+ |
614 |
+ [ req ] |
615 |
+ default_bits = 2048 |
616 |
+ default_keyfile = privkey.pem |
617 |
+ distinguished_name = req_distinguished_name |
618 |
+ |
619 |
+ [ req_distinguished_name ] |
620 |
+ countryName = Country Name (2 letter code) |
621 |
+ countryName_default = AU |
622 |
+ countryName_min = 2 |
623 |
+ countryName_max = 2 |
624 |
+ |
625 |
+ stateOrProvinceName = State or Province Name (full name) |
626 |
+ stateOrProvinceName_default = Some-State |
627 |
+ |
628 |
+ localityName = Locality Name (eg, city) |
629 |
+ |
630 |
+ 0.organizationName = Organization Name (eg, company) |
631 |
+ 0.organizationName_default = Internet Widgits Pty Ltd |
632 |
+ |
633 |
+ organizationalUnitName = Organizational Unit Name (eg, section) |
634 |
+ |
635 |
+ commonName = Common Name (e.g. server FQDN or YOUR name) |
636 |
+ commonName_max = 64 |
637 |
+ |
638 |
+ emailAddress = Email Address |
639 |
+ emailAddress_max = 64 |
640 |
+ |
641 |
+ [default_conf] |
642 |
+ ssl_conf = ssl_sect |
643 |
+ |
644 |
+ [ssl_sect] |
645 |
+ system_default = system_default_sect |
646 |
+ |
647 |
+ [system_default_sect] |
648 |
+ CipherString = DEFAULT@SECLEVEL=0 |
649 |
+ EOF |
650 |
+ |
651 |
+ local -x OPENSSL_CONF="${T}/openssl_tlsv1.cnf" |
652 |
+ fi |
653 |
+ |
654 |
+ if has_version '>=dev-libs/openssl-1.1.1' ; then |
655 |
+ # Tests are expecting <openssl-1.1.1 default cipher |
656 |
+ for t in \ |
657 |
+ auth_sec.cert_verify \ |
658 |
+ auth_sec.mysql_ssl_connection \ |
659 |
+ auth_sec.openssl_cert_generation \ |
660 |
+ auth_sec.ssl_auto_detect \ |
661 |
+ auth_sec.ssl_mode \ |
662 |
+ auth_sec.tls \ |
663 |
+ binlog.binlog_grant_alter_user \ |
664 |
+ encryption.innodb_onlinealter_encryption \ |
665 |
+ main.grant_alter_user_qa \ |
666 |
+ main.grant_user_lock_qa \ |
667 |
+ main.mysql_ssl_default \ |
668 |
+ main.openssl_1 \ |
669 |
+ main.plugin_auth_sha256 \ |
670 |
+ main.plugin_auth_sha256_2 \ |
671 |
+ main.plugin_auth_sha256_server_default \ |
672 |
+ main.plugin_auth_sha256_server_default_tls \ |
673 |
+ main.plugin_auth_sha256_tls \ |
674 |
+ main.ssl \ |
675 |
+ main.ssl_8k_key \ |
676 |
+ main.ssl_bug75311 \ |
677 |
+ main.ssl_ca \ |
678 |
+ main.ssl_cipher \ |
679 |
+ main.ssl_compress \ |
680 |
+ main.ssl_crl \ |
681 |
+ main.ssl_ecdh \ |
682 |
+ main.ssl_verify_identity \ |
683 |
+ x.connection_tls_version \ |
684 |
+ x.connection_openssl \ |
685 |
+ ; do |
686 |
+ _disable_test "$t" "Requires <dev-libs/openssl-1.1.1" |
687 |
+ done |
688 |
+ fi |
689 |
+ |
690 |
+ # Try to increase file limits to increase test coverage |
691 |
+ if ! ulimit -n 16500 1>/dev/null 2>&1 ; then |
692 |
+ # Upper limit comes from parts.partition_* tests |
693 |
+ ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." |
694 |
+ |
695 |
+ if ! ulimit -n 4162 1>/dev/null 2>&1 ; then |
696 |
+ # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' |
697 |
+ ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." |
698 |
+ |
699 |
+ if ! ulimit -n 3000 1>/dev/null 2>&1 ; then |
700 |
+ ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." |
701 |
+ else |
702 |
+ einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." |
703 |
+ fi |
704 |
+ else |
705 |
+ einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." |
706 |
+ fi |
707 |
+ else |
708 |
+ einfo "Will run test suite with open file limit set to 16500 (best test coverage)." |
709 |
+ fi |
710 |
+ |
711 |
+ # run mysql-test tests |
712 |
+ perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" |
713 |
+ retstatus_tests=$? |
714 |
+ |
715 |
+ popd &>/dev/null || die |
716 |
+ |
717 |
+ # Cleanup is important for these testcases. |
718 |
+ pkill -9 -f "${S}/ndb" 2>/dev/null |
719 |
+ pkill -9 -f "${S}/sql" 2>/dev/null |
720 |
+ |
721 |
+ local failures="" |
722 |
+ [[ ${retstatus_tests} -eq 0 ]] || failures="${failures} tests" |
723 |
+ |
724 |
+ [[ -z "${failures}" ]] || die "Test failures: ${failures}" |
725 |
+ einfo "Tests successfully completed" |
726 |
+} |
727 |
+ |
728 |
+src_install() { |
729 |
+ local MULTILIB_WRAPPED_HEADERS |
730 |
+ local MULTILIB_CHOST_TOOLS |
731 |
+ if use client-libs ; then |
732 |
+ # headers with ABI specific data |
733 |
+ MULTILIB_WRAPPED_HEADERS=( |
734 |
+ /usr/include/mysql/server/my_config.h |
735 |
+ /usr/include/mysql/server/mysql_version.h ) |
736 |
+ |
737 |
+ # wrap the config scripts |
738 |
+ MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config ) |
739 |
+ multilib-minimal_src_install |
740 |
+ else |
741 |
+ multilib_src_install |
742 |
+ multilib_src_install_all |
743 |
+ fi |
744 |
+} |
745 |
+ |
746 |
+# Intentionally override eclass function |
747 |
+multilib_src_install() { |
748 |
+ cmake_src_install |
749 |
+ |
750 |
+ # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. |
751 |
+ find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die |
752 |
+} |
753 |
+ |
754 |
+multilib_src_install_all() { |
755 |
+ # Make sure the vars are correctly initialized |
756 |
+ mysql_init_vars |
757 |
+ |
758 |
+ # Convenience links |
759 |
+ einfo "Making Convenience links for mysqlcheck multi-call binary" |
760 |
+ dosym "mysqlcheck" "/usr/bin/mysqlanalyze" |
761 |
+ dosym "mysqlcheck" "/usr/bin/mysqlrepair" |
762 |
+ dosym "mysqlcheck" "/usr/bin/mysqloptimize" |
763 |
+ |
764 |
+ # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir |
765 |
+ if [[ -d "${ED}/usr/data" ]] ; then |
766 |
+ rm -Rf "${ED}/usr/data" || die |
767 |
+ fi |
768 |
+ |
769 |
+ # Unless they explicitly specific USE=test, then do not install the |
770 |
+ # testsuite. It DOES have a use to be installed, esp. when you want to do a |
771 |
+ # validation of your database configuration after tuning it. |
772 |
+ if ! use test ; then |
773 |
+ rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" |
774 |
+ fi |
775 |
+ |
776 |
+ # Configuration stuff |
777 |
+ einfo "Building default configuration ..." |
778 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}" |
779 |
+ [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf |
780 |
+ cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die |
781 |
+ eprefixify "${TMPDIR}/my.cnf" |
782 |
+ doins "${TMPDIR}/my.cnf" |
783 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" |
784 |
+ cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die |
785 |
+ eprefixify "${TMPDIR}/50-distro-client.cnf" |
786 |
+ doins "${TMPDIR}/50-distro-client.cnf" |
787 |
+ |
788 |
+ if use server ; then |
789 |
+ mycnf_src="my.cnf.distro-server" |
790 |
+ sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ |
791 |
+ "${FILESDIR}/${mycnf_src}" \ |
792 |
+ > "${TMPDIR}/my.cnf.ok" || die |
793 |
+ |
794 |
+ if use prefix ; then |
795 |
+ sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ |
796 |
+ "${TMPDIR}/my.cnf.ok" || die |
797 |
+ fi |
798 |
+ |
799 |
+ if use latin1 ; then |
800 |
+ sed -i \ |
801 |
+ -e "/character-set/s|utf8|latin1|g" \ |
802 |
+ "${TMPDIR}/my.cnf.ok" || die |
803 |
+ fi |
804 |
+ |
805 |
+ eprefixify "${TMPDIR}/my.cnf.ok" |
806 |
+ |
807 |
+ newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf |
808 |
+ fi |
809 |
+ |
810 |
+ #Remove mytop if perl is not selected |
811 |
+ [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" |
812 |
+} |
813 |
+ |
814 |
+pkg_config() { |
815 |
+ _getoptval() { |
816 |
+ local section="$1" |
817 |
+ local flag="--${2}=" |
818 |
+ local extra_options="${3}" |
819 |
+ local cmd=( |
820 |
+ "${my_print_defaults_binary}" |
821 |
+ "${extra_options}" |
822 |
+ "${section}" |
823 |
+ ) |
824 |
+ local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) |
825 |
+ |
826 |
+ if [[ ${#results[@]} -gt 0 ]] ; then |
827 |
+ # When option is set multiple times only return last value |
828 |
+ echo "${results[-1]}" |
829 |
+ fi |
830 |
+ } |
831 |
+ |
832 |
+ _mktemp_dry() { |
833 |
+ # emktemp has no --dry-run option |
834 |
+ local template="${1}" |
835 |
+ |
836 |
+ if [[ -z "${template}" ]] ; then |
837 |
+ if [[ -z "${T}" ]] ; then |
838 |
+ template="/tmp/XXXXXXX" |
839 |
+ else |
840 |
+ template="${T}/XXXXXXX" |
841 |
+ fi |
842 |
+ fi |
843 |
+ |
844 |
+ local template_wo_X=${template//X/} |
845 |
+ local n_X |
846 |
+ let n_X=${#template}-${#template_wo_X} |
847 |
+ if [[ ${n_X} -lt 3 ]] ; then |
848 |
+ echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 |
849 |
+ return |
850 |
+ fi |
851 |
+ |
852 |
+ local attempts=0 |
853 |
+ local character tmpfile |
854 |
+ while [[ true ]] ; do |
855 |
+ let attempts=attempts+1 |
856 |
+ |
857 |
+ new_file= |
858 |
+ while read -n1 character ; do |
859 |
+ if [[ "${character}" == "X" ]] ; then |
860 |
+ tmpfile+="${RANDOM:0:1}" |
861 |
+ else |
862 |
+ tmpfile+="${character}" |
863 |
+ fi |
864 |
+ done < <(echo -n "${template}") |
865 |
+ |
866 |
+ if [[ ! -f "${tmpfile}" ]] |
867 |
+ then |
868 |
+ echo "${tmpfile}" |
869 |
+ return |
870 |
+ fi |
871 |
+ |
872 |
+ if [[ ${attempts} -ge 100 ]] ; then |
873 |
+ echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 |
874 |
+ return |
875 |
+ fi |
876 |
+ done |
877 |
+ } |
878 |
+ |
879 |
+ local mysqld_binary="${EROOT}/usr/sbin/mysqld" |
880 |
+ if [[ ! -x "${mysqld_binary}" ]] ; then |
881 |
+ die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" |
882 |
+ fi |
883 |
+ |
884 |
+ local mysql_binary="${EROOT}/usr/bin/mysql" |
885 |
+ if [[ ! -x "${mysql_binary}" ]] ; then |
886 |
+ die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" |
887 |
+ fi |
888 |
+ |
889 |
+ local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" |
890 |
+ if [[ ! -x "${my_print_defaults_binary}" ]] ; then |
891 |
+ die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" |
892 |
+ fi |
893 |
+ |
894 |
+ if [[ -z "${MYSQL_USER}" ]] ; then |
895 |
+ MYSQL_USER=mysql |
896 |
+ if use prefix ; then |
897 |
+ MYSQL_USER=$(id -u -n 2>/dev/null) |
898 |
+ if [[ -z "${MYSQL_USER}" ]] ; then |
899 |
+ die "Failed to determine current username!" |
900 |
+ fi |
901 |
+ fi |
902 |
+ fi |
903 |
+ |
904 |
+ if [[ -z "${MYSQL_GROUP}" ]] ; then |
905 |
+ MYSQL_GROUP=mysql |
906 |
+ if use prefix ; then |
907 |
+ MYSQL_GROUP=$(id -g -n 2>/dev/null) |
908 |
+ if [[ -z "${MYSQL_GROUP}" ]] ; then |
909 |
+ die "Failed to determine current user groupname!" |
910 |
+ fi |
911 |
+ fi |
912 |
+ fi |
913 |
+ |
914 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
915 |
+ local -x HOME="${EROOT}/root" |
916 |
+ |
917 |
+ # Make sure the vars are correctly initialized |
918 |
+ mysql_init_vars |
919 |
+ |
920 |
+ # Read currently set data directory |
921 |
+ MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
922 |
+ |
923 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
924 |
+ # localhost. Also causes weird failures. |
925 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
926 |
+ |
927 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
928 |
+ die "Sorry, unable to find MY_DATADIR!" |
929 |
+ elif [[ -d "${MY_DATADIR}/mysql" ]] ; then |
930 |
+ ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" |
931 |
+ ewarn "Please rename or delete its content if you wish to initialize a new data directory." |
932 |
+ die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" |
933 |
+ fi |
934 |
+ |
935 |
+ MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
936 |
+ MYSQL_TMPDIR=${MYSQL_TMPDIR%/} |
937 |
+ # These are dir+prefix |
938 |
+ MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
939 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
940 |
+ MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
941 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
942 |
+ |
943 |
+ # Create missing directories. |
944 |
+ # Always check if mysql user can write to directory even if we just |
945 |
+ # created directory because a parent directory might be not |
946 |
+ # accessible for that user. |
947 |
+ PID_DIR="${EROOT}/run/mysqld" |
948 |
+ if [[ ! -d "${PID_DIR}" ]] ; then |
949 |
+ einfo "Creating ${PN} PID directory '${PID_DIR}' ..." |
950 |
+ install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ |
951 |
+ || die "Failed to create PID directory '${PID_DIR}'!" |
952 |
+ fi |
953 |
+ |
954 |
+ local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" |
955 |
+ [[ -z "${_pid_dir_testfile}" ]] \ |
956 |
+ && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
957 |
+ |
958 |
+ if use prefix ; then |
959 |
+ touch "${_pid_dir_testfile}" &>/dev/null |
960 |
+ else |
961 |
+ su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null |
962 |
+ fi |
963 |
+ |
964 |
+ if [[ $? -ne 0 ]] ; then |
965 |
+ die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" |
966 |
+ else |
967 |
+ rm "${_pid_dir_testfile}" || die |
968 |
+ unset _pid_dir_testfile |
969 |
+ fi |
970 |
+ |
971 |
+ if [[ ! -d "${MY_DATADIR}" ]] ; then |
972 |
+ einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." |
973 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ |
974 |
+ || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" |
975 |
+ fi |
976 |
+ |
977 |
+ local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" |
978 |
+ [[ -z "${_my_datadir_testfile}" ]] \ |
979 |
+ && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
980 |
+ |
981 |
+ if use prefix ; then |
982 |
+ touch "${_my_datadir_testfile}" &>/dev/null |
983 |
+ else |
984 |
+ su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null |
985 |
+ fi |
986 |
+ |
987 |
+ if [[ $? -ne 0 ]] ; then |
988 |
+ die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" |
989 |
+ else |
990 |
+ rm "${_my_datadir_testfile}" || die |
991 |
+ unset _my_datadir_testfile |
992 |
+ fi |
993 |
+ |
994 |
+ if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then |
995 |
+ einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." |
996 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ |
997 |
+ || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" |
998 |
+ fi |
999 |
+ |
1000 |
+ if [[ -z "${MYSQL_TMPDIR}" ]] ; then |
1001 |
+ MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" |
1002 |
+ [[ -z "${MYSQL_TMPDIR}" ]] \ |
1003 |
+ && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" |
1004 |
+ |
1005 |
+ mkdir "${MYSQL_TMPDIR}" || die |
1006 |
+ chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die |
1007 |
+ fi |
1008 |
+ |
1009 |
+ # Now we need to test MYSQL_TMPDIR... |
1010 |
+ local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" |
1011 |
+ [[ -z "${_my_tmpdir_testfile}" ]] \ |
1012 |
+ && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
1013 |
+ |
1014 |
+ if use prefix ; then |
1015 |
+ touch "${_my_tmpdir_testfile}" &>/dev/null |
1016 |
+ else |
1017 |
+ su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null |
1018 |
+ fi |
1019 |
+ |
1020 |
+ if [[ $? -ne 0 ]] ; then |
1021 |
+ die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!" |
1022 |
+ else |
1023 |
+ rm "${_my_tmpdir_testfile}" || die |
1024 |
+ unset _my_tmpdir_testfile |
1025 |
+ fi |
1026 |
+ |
1027 |
+ if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then |
1028 |
+ einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." |
1029 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ |
1030 |
+ || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" |
1031 |
+ fi |
1032 |
+ |
1033 |
+ if [[ -n "${MYSQL_LOG_BIN}" ]] ; then |
1034 |
+ local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" |
1035 |
+ [[ -z "${_my_logbin_testfile}" ]] \ |
1036 |
+ && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" |
1037 |
+ |
1038 |
+ if use prefix ; then |
1039 |
+ touch "${_my_logbin_testfile}" &>/dev/null |
1040 |
+ else |
1041 |
+ su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null |
1042 |
+ fi |
1043 |
+ |
1044 |
+ if [[ $? -ne 0 ]] ; then |
1045 |
+ die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" |
1046 |
+ else |
1047 |
+ rm "${_my_logbin_testfile}" || die |
1048 |
+ unset _my_logbin_testfile |
1049 |
+ fi |
1050 |
+ fi |
1051 |
+ |
1052 |
+ if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then |
1053 |
+ einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." |
1054 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ |
1055 |
+ || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" |
1056 |
+ fi |
1057 |
+ |
1058 |
+ if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then |
1059 |
+ local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" |
1060 |
+ [[ -z "${_my_relaylog_testfile}" ]] \ |
1061 |
+ && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" |
1062 |
+ |
1063 |
+ if use prefix ; then |
1064 |
+ touch "${_my_relaylog_testfile}" &>/dev/null |
1065 |
+ else |
1066 |
+ su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null |
1067 |
+ fi |
1068 |
+ |
1069 |
+ if [[ $? -ne 0 ]] ; then |
1070 |
+ die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" |
1071 |
+ else |
1072 |
+ rm "${_my_relaylog_testfile}" || die |
1073 |
+ unset _my_relaylog_testfile |
1074 |
+ fi |
1075 |
+ fi |
1076 |
+ |
1077 |
+ local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")" |
1078 |
+ if [[ -z "${mysql_install_log}" ]] ; then |
1079 |
+ die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!" |
1080 |
+ else |
1081 |
+ # make sure file is writable for MYSQL_USER... |
1082 |
+ touch "${mysql_install_log}" || die |
1083 |
+ chown ${MYSQL_USER} "${mysql_install_log}" || die |
1084 |
+ fi |
1085 |
+ |
1086 |
+ local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")" |
1087 |
+ if [[ -z "${mysqld_logfile}" ]] ; then |
1088 |
+ die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!" |
1089 |
+ else |
1090 |
+ # make sure file is writable for MYSQL_USER... |
1091 |
+ touch "${mysqld_logfile}" || die |
1092 |
+ chown ${MYSQL_USER} "${mysqld_logfile}" || die |
1093 |
+ fi |
1094 |
+ |
1095 |
+ echo "" |
1096 |
+ einfo "Detected settings:" |
1097 |
+ einfo "==================" |
1098 |
+ einfo "MySQL User:\t\t\t\t${MYSQL_USER}" |
1099 |
+ einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" |
1100 |
+ einfo "MySQL DATA directory:\t\t${MY_DATADIR}" |
1101 |
+ einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" |
1102 |
+ |
1103 |
+ if [[ -n "${MYSQL_LOG_BIN}" ]] ; then |
1104 |
+ einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" |
1105 |
+ fi |
1106 |
+ |
1107 |
+ if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then |
1108 |
+ einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" |
1109 |
+ fi |
1110 |
+ |
1111 |
+ einfo "PID DIR:\t\t\t\t${PID_DIR}" |
1112 |
+ einfo "Install db log:\t\t\t${mysql_install_log}" |
1113 |
+ einfo "Install server log:\t\t\t${mysqld_logfile}" |
1114 |
+ |
1115 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
1116 |
+ local tmp_mysqld_password_source= |
1117 |
+ |
1118 |
+ for tmp_mysqld_password_source in mysql client ; do |
1119 |
+ einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." |
1120 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" |
1121 |
+ if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then |
1122 |
+ if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then |
1123 |
+ ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" |
1124 |
+ MYSQL_ROOT_PASSWORD= |
1125 |
+ continue |
1126 |
+ fi |
1127 |
+ |
1128 |
+ einfo "Found password in '${tmp_mysqld_password_source}' section!" |
1129 |
+ break |
1130 |
+ fi |
1131 |
+ done |
1132 |
+ |
1133 |
+ # Sometimes --show is required to display passwords in some implementations of my_print_defaults |
1134 |
+ if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then |
1135 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" |
1136 |
+ fi |
1137 |
+ |
1138 |
+ unset tmp_mysqld_password_source |
1139 |
+ fi |
1140 |
+ |
1141 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
1142 |
+ local pwd1="a" |
1143 |
+ local pwd2="b" |
1144 |
+ |
1145 |
+ echo |
1146 |
+ einfo "No password for mysql 'root' user was specified via environment" |
1147 |
+ einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" |
1148 |
+ einfo "file like '${HOME}/.my.cnf'." |
1149 |
+ einfo "To continue please provide a password for the mysql 'root' user" |
1150 |
+ einfo "now on console:" |
1151 |
+ ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" |
1152 |
+ read -rsp " >" pwd1 ; echo |
1153 |
+ |
1154 |
+ einfo "Retype the password" |
1155 |
+ read -rsp " >" pwd2 ; echo |
1156 |
+ |
1157 |
+ if [[ "x$pwd1" != "x$pwd2" ]] ; then |
1158 |
+ die "Passwords are not the same!" |
1159 |
+ fi |
1160 |
+ |
1161 |
+ MYSQL_ROOT_PASSWORD="${pwd1}" |
1162 |
+ unset pwd1 pwd2 |
1163 |
+ |
1164 |
+ echo |
1165 |
+ fi |
1166 |
+ |
1167 |
+ local -a mysqld_options |
1168 |
+ |
1169 |
+ # Fix bug 446200. Don't reference host my.cnf, needs to come first, |
1170 |
+ # see http://bugs.mysql.com/bug.php?id=31312 |
1171 |
+ use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) |
1172 |
+ |
1173 |
+ # Figure out which options we need to disable to do the setup |
1174 |
+ local helpfile="${TMPDIR}/mysqld-help" |
1175 |
+ "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null |
1176 |
+ |
1177 |
+ local opt optexp optfull |
1178 |
+ for opt in host-cache name-resolve networking slave-start \ |
1179 |
+ federated ssl log-bin relay-log slow-query-log external-locking \ |
1180 |
+ log-slave-updates \ |
1181 |
+ ; do |
1182 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
1183 |
+ grep -E -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) |
1184 |
+ done |
1185 |
+ |
1186 |
+ # Prepare timezones, see |
1187 |
+ # https://dev.mysql.com/doc/mysql/en/time-zone-support.html |
1188 |
+ local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")" |
1189 |
+ [[ -z "${tz_sql}" ]] \ |
1190 |
+ && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!" |
1191 |
+ |
1192 |
+ echo "USE mysql;" >"${tz_sql}" |
1193 |
+ "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null |
1194 |
+ if [[ $? -ne 0 ]] ; then |
1195 |
+ die "mysql_tzinfo_to_sql failed!" |
1196 |
+ fi |
1197 |
+ |
1198 |
+ # --initialize-insecure will not set root password |
1199 |
+ # --initialize would set a random one in the log which we don't need as we set it ourselves |
1200 |
+ local cmd=( |
1201 |
+ "${mysqld_binary}" |
1202 |
+ "${mysqld_options[@]}" |
1203 |
+ "--initialize-insecure" |
1204 |
+ "--init-file='${tz_sql}'" |
1205 |
+ "--basedir='${EROOT}/usr'" |
1206 |
+ "--datadir='${MY_DATADIR}'" |
1207 |
+ "--tmpdir='${MYSQL_TMPDIR}'" |
1208 |
+ "--log-error='${mysql_install_log}'" |
1209 |
+ "--user=${MYSQL_USER}" |
1210 |
+ ) |
1211 |
+ |
1212 |
+ einfo "Initializing ${PN} data directory: ${cmd[@]}" |
1213 |
+ eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 |
1214 |
+ |
1215 |
+ if [[ $? -ne 0 ]] ; then |
1216 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 |
1217 |
+ die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" |
1218 |
+ fi |
1219 |
+ |
1220 |
+ rm "${tz_sql}" || die |
1221 |
+ |
1222 |
+ local x=${RANDOM} |
1223 |
+ local socket="${EROOT}${PID_DIR}/mysqld${x}.sock" |
1224 |
+ local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid" |
1225 |
+ unset x |
1226 |
+ |
1227 |
+ cmd=( |
1228 |
+ "${mysqld_binary}" |
1229 |
+ "${mysqld_options[@]}" |
1230 |
+ "--basedir='${EROOT}/usr'" |
1231 |
+ "--datadir='${MY_DATADIR}'" |
1232 |
+ "--tmpdir='${MYSQL_TMPDIR}'" |
1233 |
+ --max_allowed_packet=8M |
1234 |
+ --net_buffer_length=16K |
1235 |
+ "--socket='${socket}'" |
1236 |
+ "--pid-file='${pidfile}'" |
1237 |
+ "--log-error='${mysqld_logfile}'" |
1238 |
+ "--user=${MYSQL_USER}" |
1239 |
+ ) |
1240 |
+ |
1241 |
+ einfo "Starting mysqld to finalize initialization: ${cmd[@]}" |
1242 |
+ eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & |
1243 |
+ |
1244 |
+ echo -n "Waiting for mysqld to accept connections " |
1245 |
+ local maxtry=15 |
1246 |
+ while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do |
1247 |
+ maxtry=$((${maxtry}-1)) |
1248 |
+ echo -n "." |
1249 |
+ sleep 1 |
1250 |
+ done |
1251 |
+ |
1252 |
+ if [[ -S "${socket}" ]] ; then |
1253 |
+ # Even with a socket we don't know if mysqld will abort |
1254 |
+ # start due to an error so just wait a little bit more... |
1255 |
+ maxtry=5 |
1256 |
+ while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do |
1257 |
+ maxtry=$((${maxtry}-1)) |
1258 |
+ echo -n "." |
1259 |
+ sleep 1 |
1260 |
+ done |
1261 |
+ fi |
1262 |
+ |
1263 |
+ echo |
1264 |
+ |
1265 |
+ if [[ ! -S "${socket}" ]] ; then |
1266 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 |
1267 |
+ die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" |
1268 |
+ fi |
1269 |
+ |
1270 |
+ local mysql_logfile="${TMPDIR}/set_root_pw.log" |
1271 |
+ touch "${mysql_logfile}" || die |
1272 |
+ |
1273 |
+ ebegin "Setting root password" |
1274 |
+ # Do this from memory, as we don't want clear text passwords in temp files |
1275 |
+ local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" |
1276 |
+ cmd=( |
1277 |
+ "${mysql_binary}" |
1278 |
+ --no-defaults |
1279 |
+ "--socket='${socket}'" |
1280 |
+ -hlocalhost |
1281 |
+ "-e \"${sql}\"" |
1282 |
+ ) |
1283 |
+ eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 |
1284 |
+ local rc=$? |
1285 |
+ eend ${rc} |
1286 |
+ |
1287 |
+ if [[ ${rc} -ne 0 ]] ; then |
1288 |
+ # Poor man's solution which tries to avoid having password |
1289 |
+ # in log. NOTE: sed can fail if user didn't follow advice |
1290 |
+ # and included character which will require escaping... |
1291 |
+ sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null |
1292 |
+ |
1293 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" |
1294 |
+ die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" |
1295 |
+ fi |
1296 |
+ |
1297 |
+ # Stop the server |
1298 |
+ if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then |
1299 |
+ echo -n "Stopping the server " |
1300 |
+ pkill -F "${pidfile}" &>/dev/null |
1301 |
+ |
1302 |
+ maxtry=10 |
1303 |
+ while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do |
1304 |
+ maxtry=$((${maxtry}-1)) |
1305 |
+ echo -n "." |
1306 |
+ sleep 1 |
1307 |
+ done |
1308 |
+ |
1309 |
+ echo |
1310 |
+ |
1311 |
+ if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then |
1312 |
+ # We somehow failed to stop server. |
1313 |
+ # However, not a fatal error. Just warn the user. |
1314 |
+ ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" |
1315 |
+ fi |
1316 |
+ fi |
1317 |
+ |
1318 |
+ einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" |
1319 |
+} |