Gentoo Archives: gentoo-commits

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