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/mariadb/
Date: Sat, 23 May 2020 12:25:39
Message-Id: 1590236720.7dbb0f8932ff4e964a72344eacb78733dfb02009.whissi@gentoo
1 commit: 7dbb0f8932ff4e964a72344eacb78733dfb02009
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Sat May 23 10:31:25 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Sat May 23 12:25:20 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7dbb0f89
7
8 dev-db/mariadb: bump to v10.3.23
9
10 Package-Manager: Portage-2.3.99, Repoman-2.3.22
11 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
12
13 dev-db/mariadb/Manifest | 2 +
14 dev-db/mariadb/mariadb-10.3.23.ebuild | 1008 +++++++++++++++++++++++++++++++++
15 2 files changed, 1010 insertions(+)
16
17 diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest
18 index ab8322b064d..aea160bf74e 100644
19 --- a/dev-db/mariadb/Manifest
20 +++ b/dev-db/mariadb/Manifest
21 @@ -6,6 +6,8 @@ DIST mariadb-10.2.29.tar.gz 73087972 BLAKE2B aa3fe880f00b02846b26f16fcd37d18ebe2
22 DIST mariadb-10.2.31.tar.gz 73134720 BLAKE2B a410f71cffd7ff904cb16d9d00bbb4b1d6d17a4931de1635a14dce7c7c66d8dfd097b0c261959809cf2f327d196b11f3196129c2894efb5bab0141aca10ea3c7 SHA512 2cf28e4e049618f633470e7a4cd4f3bc8c2a74bf9796bfd026da7c75812e6d4962323785fdbca7a5b505c2e4fe95e3b47cd2e24e4dec2dcd230ac8a25f49b9b9
23 DIST mariadb-10.3.20.tar.gz 71990355 BLAKE2B f950f0eb836751d0eebb9ae561fe3b5aefade04a0d389465918aa2a887e4f717ab4e6bd835dea8f9a88aacfe10c0b091fc2a59882a1781a3f2903ef07a759f5d SHA512 8080cb6db85c587f39f128e98b00c3e6428bf3e828271a227bb2c61c97683c965802baa6e5f825317f7e2963683c0f81699642853deeca6977faa2b6932044a3
24 DIST mariadb-10.3.22.tar.gz 72050820 BLAKE2B 9e08f1360f8db2c5f466d4f6f967145286412a5598c7de8828eb8f8f3dd113b38f039c38335f9251f3bba19c67c5f62d57808eabc57480338b64dae0c5588774 SHA512 57a6551b8939f54742963202d50a537e69e8ab9b2dca42ce3d2a09c0f7af368fded71f36af26f6cbd956d54fe43853981ba8fe28b7a3ba97c7d52ea4a0d233f6
25 +DIST mariadb-10.3.23-patches-01.tar.xz 5148 BLAKE2B 162c62a4c5a25e4c6fa059352d11ec1bebf5c2166373a455f54bce2e4e157578c29fd7e149a6e78c2884ac5ac25148c9108dd6f77f92730efa88cd823b49c7aa SHA512 bfdf042ba066afb7ddaa612864dcbc1921c72c26e1df718477c899dd9430ee7a26e19987248c74979a1d19f07fe863bd4671f655767cee62a725464e972a111a
26 +DIST mariadb-10.3.23.tar.gz 72582611 BLAKE2B 493605519f714cbe87b938f6ca3243d29189adbfcbb33c4e10a4a3f01b08d875f18b96b647dc92566b785c2cef9862ebacfd55954d13ab0a7a745606e40fb6e9 SHA512 535cd2ce80a95b6c0a1aa559cc3275dfcd559c3a4f958fab3382923190a16e6bc5b4ad79acaa518244512ff618568c239c0edef8a701d958362ede19a29c2986
27 DIST mariadb-10.4.10.tar.gz 78352896 BLAKE2B c0e448fba455feb9385b7d57e1a727e84eaf4cfa52ce0dbd6ff062aa0b5abc42005680fb185416d04fbd7bb62d9bbd6c93e4cb77b145418cf6be92747f8b1c2a SHA512 4a9b9a37bc3a273de4bd781dac3636256364dae6efbba45765d6b28995da3d64e180422cd10418d1c7acd7fd8843fe2a2638c07e0f56b0c09170c58812cc6b71
28 DIST mariadb-10.4.12.tar.gz 79120835 BLAKE2B 1c511e788f8ddc9b9d2e580b29c380ada85d7cc46febe6a6bec626fd6239e4f50480b7a31dcd7e1a9474c6ed9626a910e996257ac8366646a22decc0226c45f0 SHA512 518dae18c04a1f7fcc6fd4d2dfbfbfbdf5e83e72ca41e66e1074328df8d92ab41b458e6a9973771419ac09a7348f264f158916cd198c335085d6e823e707bbc6
29 DIST mariadb-10.4.13-patches-01.tar.xz 5140 BLAKE2B 76bec85715d03cf17d54994205f0a5e452c5bad0353c2a14d6bdad92f0771b54b54753856709b8379fe91efbff48a610414b54b891dd17eabda043a5059e60e7 SHA512 923c54850b1e55ed60988133d615b80aecce3e73c7914b8b02aeea1c61c154ba5ff2ae3575f24d7341b6bf6de9aae2f5751fb951a5a88eafbea7db254da2d4fe
30
31 diff --git a/dev-db/mariadb/mariadb-10.3.23.ebuild b/dev-db/mariadb/mariadb-10.3.23.ebuild
32 new file mode 100644
33 index 00000000000..df2fca71d2c
34 --- /dev/null
35 +++ b/dev-db/mariadb/mariadb-10.3.23.ebuild
36 @@ -0,0 +1,1008 @@
37 +# Copyright 1999-2020 Gentoo Authors
38 +# Distributed under the terms of the GNU General Public License v2
39 +
40 +EAPI="6"
41 +SUBSLOT="18"
42 +
43 +JAVA_PKG_OPT_USE="jdbc"
44 +
45 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
46 +
47 +inherit eutils systemd flag-o-matic prefix toolchain-funcs \
48 + multiprocessing java-pkg-opt-2 cmake-utils
49 +
50 +# Patch version
51 +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.3.23-patches-01.tar.xz"
52 +
53 +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz
54 + ${PATCH_SET}"
55 +
56 +HOMEPAGE="https://mariadb.org/"
57 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
58 +LICENSE="GPL-2 LGPL-2.1+"
59 +SLOT="0/${SUBSLOT:-0}"
60 +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4
61 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 libressl mroonga
62 + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx
63 + sst-rsync sst-mariabackup static systemd systemtap tcmalloc
64 + test tokudb xml yassl"
65 +
66 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
67 +RESTRICT="!bindist? ( bindist ) libressl? ( test ) !test? ( test )"
68 +
69 +REQUIRED_USE="jdbc? ( extraengine server !static )
70 + server? ( tokudb? ( jemalloc !tcmalloc ) )
71 + ?? ( tcmalloc jemalloc )
72 + static? ( yassl !pam )"
73 +
74 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~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 +# Be warned, *DEPEND are version-dependant
81 +# These are used for both runtime and compiletime
82 +COMMON_DEPEND="
83 + kernel_linux? (
84 + sys-process/procps:0=
85 + dev-libs/libaio:0=
86 + )
87 + >=sys-apps/sed-4
88 + >=sys-apps/texinfo-4.7-r1
89 + jemalloc? ( dev-libs/jemalloc:0= )
90 + tcmalloc? ( dev-util/google-perftools:0= )
91 + systemtap? ( >=dev-util/systemtap-1.3:0= )
92 + >=sys-libs/zlib-1.2.3:0=
93 + kerberos? ( virtual/krb5 )
94 + yassl? ( net-libs/gnutls:0= )
95 + !yassl? (
96 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
97 + libressl? ( dev-libs/libressl:0= )
98 + )
99 + sys-libs/ncurses:0=
100 + !bindist? (
101 + sys-libs/binutils-libs:0=
102 + >=sys-libs/readline-4.1:0=
103 + )
104 + server? (
105 + backup? ( app-arch/libarchive:0= )
106 + cracklib? ( sys-libs/cracklib:0= )
107 + extraengine? (
108 + odbc? ( dev-db/unixODBC:0= )
109 + xml? ( dev-libs/libxml2:2= )
110 + )
111 + innodb-lz4? ( app-arch/lz4 )
112 + innodb-lzo? ( dev-libs/lzo )
113 + innodb-snappy? ( app-arch/snappy )
114 + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 )
115 + numa? ( sys-process/numactl )
116 + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= )
117 + pam? ( sys-libs/pam:0= )
118 + systemd? ( sys-apps/systemd:= )
119 + tokudb? ( app-arch/snappy )
120 + )
121 + >=dev-libs/libpcre-8.41-r1:3=
122 +"
123 +DEPEND="virtual/yacc
124 + static? ( sys-libs/ncurses[static-libs] )
125 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
126 + server? (
127 + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) )
128 + test? ( acct-group/mysql acct-user/mysql )
129 + )
130 + ${COMMON_DEPEND}"
131 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
132 + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
133 + !<virtual/mysql-5.6-r11
134 + ${COMMON_DEPEND}
135 + server? (
136 + galera? (
137 + sys-apps/iproute2
138 + =sys-cluster/galera-25*
139 + sst-rsync? ( sys-process/lsof )
140 + sst-mariabackup? ( net-misc/socat[ssl] )
141 + )
142 + !prefix? ( dev-db/mysql-init-scripts acct-group/mysql acct-user/mysql )
143 + extraengine? ( jdbc? ( >=virtual/jre-1.6 ) )
144 + )
145 + perl? (
146 + !dev-db/mytop
147 + virtual/perl-Getopt-Long
148 + dev-perl/TermReadKey
149 + virtual/perl-Term-ANSIColor
150 + virtual/perl-Time-HiRes
151 + )
152 +"
153 +# For other stuff to bring us in
154 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
155 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
156 + server? ( ~virtual/mysql-5.6[static=] )"
157 +
158 +mysql_init_vars() {
159 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"}
160 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
161 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
162 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
163 +
164 + if [[ -z "${MY_DATADIR}" ]] ; then
165 + MY_DATADIR=""
166 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
167 + MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \
168 + | sed -ne '/datadir/s|^--datadir=||p' \
169 + | tail -n1)
170 + if [[ -z "${MY_DATADIR}" ]] ; then
171 + MY_DATADIR=$(grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
172 + | sed -e 's/.*=\s*//' \
173 + | tail -n1)
174 + fi
175 + fi
176 + if [[ -z "${MY_DATADIR}" ]] ; then
177 + MY_DATADIR="${MY_LOCALSTATEDIR}"
178 + einfo "Using default MY_DATADIR"
179 + fi
180 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
181 +
182 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
183 + if [[ -e "${MY_DATADIR}" ]] ; then
184 + # If you get this and you're wondering about it, see bug #207636
185 + elog "MySQL datadir found in ${MY_DATADIR}"
186 + elog "A new one will not be created."
187 + PREVIOUS_DATADIR="yes"
188 + else
189 + PREVIOUS_DATADIR="no"
190 + fi
191 + export PREVIOUS_DATADIR
192 + fi
193 + else
194 + if [[ ${EBUILD_PHASE} == "config" ]]; then
195 + local new_MY_DATADIR
196 + new_MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \
197 + | sed -ne '/datadir/s|^--datadir=||p' \
198 + | tail -n1)
199 +
200 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
201 + ewarn "MySQL MY_DATADIR has changed"
202 + ewarn "from ${MY_DATADIR}"
203 + ewarn "to ${new_MY_DATADIR}"
204 + MY_DATADIR="${new_MY_DATADIR}"
205 + fi
206 + fi
207 + fi
208 +
209 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
210 + export MY_LOCALSTATEDIR MY_LOGDIR
211 + export MY_DATADIR
212 +}
213 +
214 +pkg_setup() {
215 + if [[ ${MERGE_TYPE} != binary ]] ; then
216 + local GCC_MAJOR_SET=$(gcc-major-version)
217 + local GCC_MINOR_SET=$(gcc-minor-version)
218 +
219 + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
220 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
221 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
222 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
223 + die
224 + fi
225 +
226 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
227 + # non x86{,_64} arches
228 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
229 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
230 + eerror "${PN} needs to be built with gcc-4.7 or later."
231 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
232 + die
233 + fi
234 +
235 + if has test ${FEATURES} ; then
236 + # Bug #213475 - MySQL _will_ object strenuously if your machine is named
237 + # localhost. Also causes weird failures.
238 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
239 +
240 + if ! has userpriv ${FEATURES} ; then
241 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
242 + fi
243 + fi
244 + fi
245 +
246 + java-pkg-opt-2_pkg_setup
247 +}
248 +
249 +pkg_preinst() {
250 + java-pkg-opt-2_pkg_preinst
251 +
252 + # Here we need to see if the implementation switched client libraries
253 + # We check if this is a new instance of the package and a client library already exists
254 + local SHOW_ABI_MESSAGE libpath
255 + if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
256 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
257 + elog "Due to ABI changes when switching between different client libraries,"
258 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
259 + elog "Please run: revdep-rebuild --library ${libpath}"
260 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
261 + fi
262 +}
263 +
264 +src_unpack() {
265 + unpack ${A}
266 +
267 + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die
268 +}
269 +
270 +src_prepare() {
271 + eapply "${WORKDIR}"/mariadb-patches
272 +
273 + eapply_user
274 +
275 + _disable_plugin() {
276 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
277 + }
278 + _disable_engine() {
279 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
280 + }
281 +
282 + if use jemalloc; then
283 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt"
284 + elif use tcmalloc; then
285 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
286 + fi
287 +
288 + # Don't build bundled xz-utils for tokudb
289 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
290 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
291 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
292 +
293 + local plugin
294 + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info
295 + locale_info qc_info server_audit sql_errlog auth_ed25519 )
296 + local test_plugins=( audit_null auth_examples daemon_example fulltext
297 + debug_key_management example_key_management versioning )
298 + if ! use server; then # These plugins are for the server
299 + for plugin in "${server_plugins[@]}" ; do
300 + _disable_plugin "${plugin}"
301 + done
302 + fi
303 +
304 + if ! use test; then # These plugins are only used during testing
305 + for plugin in "${test_plugins[@]}" ; do
306 + _disable_plugin "${plugin}"
307 + done
308 + _disable_engine test_sql_discovery
309 + fi
310 +
311 + _disable_engine example
312 +
313 + if ! use oqgraph ; then # avoids extra library checks
314 + _disable_engine oqgraph
315 + fi
316 +
317 + if use mroonga ; then
318 + # Remove the bundled groonga
319 + # There is no CMake flag, it simply checks for existance
320 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
321 + else
322 + _disable_engine mroonga
323 + fi
324 +
325 + # Don't clash with dev-db/mysql-connector-c
326 + sed -i -e 's/ my_print_defaults.1//' \
327 + -e 's/ perror.1//' \
328 + "${S}"/man/CMakeLists.txt || die
329 +
330 + # Fix galera_recovery.sh script
331 + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \
332 + scripts/galera_recovery.sh || die
333 +
334 + cmake-utils_src_prepare
335 + java-pkg-opt-2_src_prepare
336 +}
337 +
338 +src_configure() {
339 + # bug 508724 mariadb cannot use ld.gold
340 + tc-ld-disable-gold
341 + # Bug #114895, bug #110149
342 + filter-flags "-O" "-O[01]"
343 +
344 + append-cxxflags -felide-constructors
345 +
346 + # bug #283926, with GCC4.4, this is required to get correct behavior.
347 + append-flags -fno-strict-aliasing
348 +
349 + CMAKE_BUILD_TYPE="RelWithDebInfo"
350 +
351 + # debug hack wrt #497532
352 + mycmakeargs=(
353 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
354 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
355 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
356 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
357 + -DINSTALL_BINDIR=bin
358 + -DINSTALL_DOCDIR=share/doc/${PF}
359 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
360 + -DINSTALL_INCLUDEDIR=include/mysql
361 + -DINSTALL_INFODIR=share/info
362 + -DINSTALL_LIBDIR=$(get_libdir)
363 + -DINSTALL_MANDIR=share/man
364 + -DINSTALL_MYSQLSHAREDIR=share/mariadb
365 + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin
366 + -DINSTALL_SCRIPTDIR=share/mariadb/scripts
367 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
368 + -DINSTALL_SBINDIR=sbin
369 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb"
370 + -DWITH_COMMENT="Gentoo Linux ${PF}"
371 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
372 + -DWITH_LIBEDIT=0
373 + -DWITH_ZLIB=system
374 + -DWITHOUT_LIBWRAP=1
375 + -DENABLED_LOCAL_INFILE=1
376 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
377 + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock"
378 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
379 + -DWITH_DEFAULT_FEATURE_SET=0
380 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
381 + # The build forces this to be defined when cross-compiling. We pass it
382 + # all the time for simplicity and to make sure it is actually correct.
383 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
384 + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
385 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
386 + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF)
387 + -DCONC_WITH_EXTERNAL_ZLIB=YES
388 + -DWITH_EXTERNAL_ZLIB=YES
389 + -DSUFFIX_INSTALL_DIR=""
390 + -DWITH_UNITTEST=OFF
391 + -DWITHOUT_CLIENTLIBS=YES
392 + -DCLIENT_PLUGIN_DIALOG=OFF
393 + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF
394 + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF
395 + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC
396 + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF
397 + )
398 + if use test ; then
399 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test )
400 + else
401 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
402 + fi
403 +
404 + if ! use yassl ; then
405 + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC )
406 + else
407 + mycmakeargs+=( -DWITH_SSL=bundled )
408 + fi
409 +
410 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
411 + mycmakeargs+=(
412 + -DWITH_READLINE=$(usex bindist 1 0)
413 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
414 + -DENABLE_DTRACE=$(usex systemtap)
415 + )
416 +
417 + if use server ; then
418 +
419 + # Federated{,X} must be treated special otherwise they will not be built as plugins
420 + if ! use extraengine ; then
421 + mycmakeargs+=(
422 + -DPLUGIN_FEDERATED=NO
423 + -DPLUGIN_FEDERATEDX=NO )
424 + fi
425 +
426 + mycmakeargs+=(
427 + -DWITH_PCRE=system
428 + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO)
429 + -DPLUGIN_SPHINX=$(usex sphinx YES NO)
430 + -DPLUGIN_TOKUDB=$(usex tokudb YES NO)
431 + -DPLUGIN_AUTH_PAM=$(usex pam YES NO)
432 + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO)
433 + -DPLUGIN_CASSANDRA=NO
434 + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO)
435 + -DPLUGIN_SPIDER=$(usex extraengine YES NO)
436 + -DPLUGIN_CONNECT=$(usex extraengine YES NO)
437 + -DCONNECT_WITH_MYSQL=1
438 + -DCONNECT_WITH_LIBXML2=$(usex xml)
439 + -DCONNECT_WITH_ODBC=$(usex odbc)
440 + -DCONNECT_WITH_JDBC=$(usex jdbc)
441 + # Build failure and autodep wrt bug 639144
442 + -DCONNECT_WITH_MONGO=OFF
443 + -DWITH_WSREP=$(usex galera)
444 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
445 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
446 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
447 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
448 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
449 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
450 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
451 + -DINSTALL_SQLBENCHDIR=""
452 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
453 + # systemd is only linked to for server notification
454 + -DWITH_SYSTEMD=$(usex systemd yes no)
455 + -DWITH_NUMA=$(usex numa ON OFF)
456 + )
457 +
458 + # Workaround for MDEV-14524
459 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 )
460 +
461 + if use test ; then
462 + # This is needed for the new client lib which tests a real, open server
463 + mycmakeargs+=( -DSKIP_TESTS=ON )
464 + fi
465 +
466 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
467 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
468 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
469 + ewarn "You MUST file bugs without these variables set."
470 +
471 + mycmakeargs+=(
472 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
473 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
474 + )
475 +
476 + elif ! use latin1 ; then
477 + mycmakeargs+=(
478 + -DDEFAULT_CHARSET=utf8
479 + -DDEFAULT_COLLATION=utf8_general_ci
480 + )
481 + else
482 + mycmakeargs+=(
483 + -DDEFAULT_CHARSET=latin1
484 + -DDEFAULT_COLLATION=latin1_swedish_ci
485 + )
486 + fi
487 + mycmakeargs+=(
488 + -DEXTRA_CHARSETS=all
489 + -DMYSQL_USER=mysql
490 + -DDISABLE_SHARED=$(usex static YES NO)
491 + -DWITH_DEBUG=$(usex debug)
492 + -DWITH_EMBEDDED_SERVER=OFF
493 + -DWITH_PROFILING=$(usex profiling)
494 + )
495 +
496 + if use static; then
497 + mycmakeargs+=( -DWITH_PIC=1 )
498 + fi
499 +
500 + if use jemalloc || use tcmalloc ; then
501 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
502 + fi
503 +
504 + # Storage engines
505 + mycmakeargs+=(
506 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
507 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
508 + -DWITH_CSV_STORAGE_ENGINE=1
509 + -DWITH_HEAP_STORAGE_ENGINE=1
510 + -DWITH_INNOBASE_STORAGE_ENGINE=1
511 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
512 + -DWITH_MYISAM_STORAGE_ENGINE=1
513 + -DWITH_PARTITION_STORAGE_ENGINE=1
514 + )
515 +
516 + else
517 + mycmakeargs+=(
518 + -DWITHOUT_SERVER=1
519 + -DWITH_EMBEDDED_SERVER=OFF
520 + -DEXTRA_CHARSETS=none
521 + -DINSTALL_SQLBENCHDIR=
522 + -DWITH_SYSTEMD=no
523 + )
524 + fi
525 +
526 + cmake-utils_src_configure
527 +}
528 +
529 +src_compile() {
530 + cmake-utils_src_compile
531 +}
532 +
533 +# Official test instructions:
534 +# USE='extraengine perl server' \
535 +# FEATURES='test userpriv' \
536 +# ebuild mariadb-X.X.XX.ebuild \
537 +# digest clean package
538 +src_test() {
539 + _disable_test() {
540 + local rawtestname bug reason
541 + rawtestname="${1}" ; shift
542 + bug="${1}" ; shift
543 + reason="${@}"
544 + ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
545 + echo "${rawtestname} : BUG#${bug} ${reason}" >> "${T}/disabled.def"
546 + }
547 +
548 + local TESTDIR="${BUILD_DIR}/mysql-test"
549 + local retstatus_unit
550 + local retstatus_tests
551 +
552 + if ! use server ; then
553 + einfo "Skipping server tests due to minimal build."
554 + return 0
555 + fi
556 +
557 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
558 +
559 + # Run CTest (test-units)
560 + cmake-utils_src_test
561 + retstatus_unit=$?
562 +
563 + # Ensure that parallel runs don't die
564 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
565 +
566 + if [[ -z "${MTR_PARALLEL}" ]] ; then
567 + local -x MTR_PARALLEL=$(makeopts_jobs)
568 +
569 + if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
570 + # Running multiple tests in parallel usually require higher ulimit
571 + # and fs.aio-max-nr setting. In addition, tests like main.multi_update
572 + # are known to hit timeout when system is busy.
573 + # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
574 + # using "auto".
575 + local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
576 + info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
577 + einfo "${info_msg}"
578 + unset info_msg
579 + MTR_PARALLEL=4
580 + fi
581 + else
582 + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
583 + fi
584 +
585 + # Try to increase file limits to increase test coverage
586 + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
587 + # Upper limit comes from parts.partition_* tests
588 + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
589 +
590 + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
591 + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
592 + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
593 +
594 + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
595 + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
596 + else
597 + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
598 + fi
599 + else
600 + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
601 + fi
602 + else
603 + einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
604 + fi
605 +
606 + # create directories because mysqladmin might run out of order
607 + mkdir -p "${T}"/var-tests{,/log} || die
608 +
609 + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die
610 +
611 + local -a disabled_tests
612 + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" )
613 + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" )
614 + disabled_tests+=( "main.func_time;0;Dependent on time test was written" )
615 + disabled_tests+=( "main.grant;0;Sporadically failing test" )
616 + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" )
617 + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" )
618 + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" )
619 + disabled_tests+=( "mariabackup.*;0;Broken test suite" )
620 + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" )
621 + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" )
622 + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" )
623 + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" )
624 +
625 + if ! use latin1 ; then
626 + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" )
627 + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" )
628 + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" )
629 + fi
630 +
631 + local test_infos_str test_infos_arr
632 + for test_infos_str in "${disabled_tests[@]}" ; do
633 + IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
634 +
635 + if [[ ${#test_infos_arr[@]} != 3 ]] ; then
636 + die "Invalid test data set, not matching format: ${test_infos_str}"
637 + fi
638 +
639 + _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
640 + done
641 + unset test_infos_str test_infos_arr
642 +
643 + # run mysql-test tests
644 + pushd "${TESTDIR}" &>/dev/null || die
645 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
646 + retstatus_tests=$?
647 +
648 + popd &>/dev/null || die
649 +
650 + # Cleanup is important for these testcases.
651 + pkill -9 -f "${S}/ndb" 2>/dev/null
652 + pkill -9 -f "${S}/sql" 2>/dev/null
653 +
654 + local failures=""
655 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
656 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
657 +
658 + [[ -z "$failures" ]] || die "Test failures: $failures"
659 + einfo "Tests successfully completed"
660 +}
661 +
662 +src_install() {
663 + cmake-utils_src_install
664 +
665 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
666 + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then
667 + rm "${ED}/usr/include/mysql/server/private/config.h" || die
668 + fi
669 +
670 + # Make sure the vars are correctly initialized
671 + mysql_init_vars
672 +
673 + # Convenience links
674 + einfo "Making Convenience links for mysqlcheck multi-call binary"
675 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
676 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
677 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
678 +
679 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
680 + if [[ -d "${ED}/usr/data" ]] ; then
681 + rm -Rf "${ED}/usr/data" || die
682 + fi
683 +
684 + # Unless they explicitly specific USE=test, then do not install the
685 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
686 + # validation of your database configuration after tuning it.
687 + if ! use test ; then
688 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
689 + fi
690 +
691 + # Configuration stuff
692 + einfo "Building default configuration ..."
693 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
694 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
695 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
696 + eprefixify "${TMPDIR}/my.cnf"
697 + doins "${TMPDIR}/my.cnf"
698 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
699 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
700 + eprefixify "${TMPDIR}/50-distro-client.cnf"
701 + doins "${TMPDIR}/50-distro-client.cnf"
702 +
703 + if use server ; then
704 + mycnf_src="my.cnf.distro-server"
705 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
706 + "${FILESDIR}/${mycnf_src}" \
707 + > "${TMPDIR}/my.cnf.ok" || die
708 + if use prefix ; then
709 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
710 + "${TMPDIR}/my.cnf.ok" || die
711 + fi
712 + if use latin1 ; then
713 + sed -i \
714 + -e "/character-set/s|utf8|latin1|g" \
715 + "${TMPDIR}/my.cnf.ok" || die
716 + fi
717 + eprefixify "${TMPDIR}/my.cnf.ok"
718 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
719 +
720 + einfo "Including support files and sample configurations"
721 + docinto "support-files"
722 + local script
723 + for script in \
724 + "${S}"/support-files/magic
725 + do
726 + [[ -f "$script" ]] && dodoc "${script}"
727 + done
728 +
729 + docinto "scripts"
730 + for script in "${S}"/scripts/mysql* ; do
731 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
732 + done
733 + # Manually install supporting files that conflict with other packages
734 + # but are needed for galera and initial installation
735 + exeinto /usr/libexec/mariadb
736 + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror"
737 + fi
738 +
739 + # Remove mytop if perl is not selected
740 + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then
741 + rm -f "${ED}/usr/bin/mytop" || die
742 + fi
743 +
744 + # Fix a dangling symlink when galera is not built
745 + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then
746 + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die
747 + fi
748 +
749 + # Remove broken SST scripts that are incompatible
750 + local scriptremove
751 + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do
752 + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then
753 + rm "${ED}/usr/bin/${scriptremove}" || die
754 + fi
755 + done
756 +}
757 +
758 +pkg_postinst() {
759 + # Make sure the vars are correctly initialized
760 + mysql_init_vars
761 +
762 + # Create log directory securely if it does not exist
763 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
764 +
765 + if use server ; then
766 + if use pam; then
767 + einfo
768 + elog "This install includes the PAM authentication plugin."
769 + elog "To activate and configure the PAM plugin, please read:"
770 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
771 + einfo
772 + fi
773 +
774 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
775 + einfo
776 + elog "You might want to run:"
777 + elog "\"emerge --config =${CATEGORY}/${PF}\""
778 + elog "if this is a new install."
779 + elog
780 + elog "If you are switching server implentations, you should run the"
781 + elog "mysql_upgrade tool."
782 + einfo
783 + else
784 + einfo
785 + elog "If you are upgrading major versions, you should run the"
786 + elog "mysql_upgrade tool."
787 + einfo
788 + fi
789 +
790 + if use galera ; then
791 + einfo
792 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
793 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
794 + elog "The first time the cluster is activated, you should add"
795 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
796 + elog "This option should then be removed for subsequent starts."
797 + einfo
798 + fi
799 + fi
800 +
801 + # Note about configuration change
802 + einfo
803 + elog "This version of mariadb reorganizes the configuration from a single my.cnf"
804 + elog "to several files in /etc/mysql/${PN}.d."
805 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
806 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
807 + elog "You may have as many files as needed and they are read alphabetically."
808 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
809 + einfo
810 +}
811 +
812 +pkg_config() {
813 + _getoptval() {
814 + local mypd="${EROOT}"usr/libexec/mariadb/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 | tail -n1)"
889 + # These are dir+prefix
890 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)"
891 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
892 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)"
893 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
894 +
895 + if [[ ! -d "${ROOT}/$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 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
900 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
901 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
902 + fi
903 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
904 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
905 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
906 + fi
907 +
908 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
909 + ewarn "You have already a MySQL database in place."
910 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
911 + ewarn "Please rename or delete it if you wish to replace it."
912 + die "MySQL database already exists!"
913 + fi
914 +
915 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
916 + # localhost. Also causes weird failures.
917 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
918 +
919 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
920 +
921 + einfo "Please provide a password for the mysql 'root' user now"
922 + einfo "or through the ${HOME}/.my.cnf file."
923 + ewarn "Avoid [\"'\\_%] characters in the password"
924 + read -rsp " >" pwd1 ; echo
925 +
926 + einfo "Retype the password"
927 + read -rsp " >" pwd2 ; echo
928 +
929 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
930 + die "Passwords are not the same"
931 + fi
932 + MYSQL_ROOT_PASSWORD="${pwd1}"
933 + unset pwd1 pwd2
934 + fi
935 +
936 + local options
937 + local sqltmp="$(emktemp)"
938 +
939 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
940 + # see https://bugs.mysql.com/bug.php?id=31312
941 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
942 +
943 + # Figure out which options we need to disable to do the setup
944 + local helpfile="${TMPDIR}/mysqld-help"
945 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
946 + for opt in grant-tables host-cache name-resolve networking slave-start \
947 + federated ssl log-bin relay-log slow-query-log external-locking \
948 + log-slave-updates \
949 + ; do
950 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
951 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
952 + done
953 +
954 + einfo "Creating the mysql database and setting proper permissions on it ..."
955 +
956 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
957 + PID_DIR="${EROOT}/var/run/mysqld"
958 + if [[ ! -d "${PID_DIR}" ]]; then
959 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
960 + fi
961 +
962 + if [[ ! -d "${MY_DATADIR}" ]]; then
963 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
964 + fi
965 +
966 + pushd "${TMPDIR}" &>/dev/null || die
967 +
968 + # Filling timezones, see
969 + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
970 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
971 +
972 + local cmd=( "${EROOT}usr/share/mariadb/scripts/mysql_install_db" )
973 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
974 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
975 + einfo "Command: ${cmd[*]}"
976 + su -s /bin/sh -c "${cmd[*]}" mysql \
977 + >"${TMPDIR}"/mysql_install_db.log 2>&1
978 + if [ $? -ne 0 ]; then
979 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
980 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
981 + fi
982 + popd &>/dev/null || die
983 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
984 + || die "MySQL databases not installed"
985 +
986 + use prefix || options="${options} --user=mysql"
987 +
988 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
989 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
990 + local mysqld="${EROOT}/usr/sbin/mysqld \
991 + ${options} \
992 + --log-warnings=0 \
993 + --basedir=${EROOT}/usr \
994 + --datadir=${ROOT}/${MY_DATADIR} \
995 + --max_allowed_packet=8M \
996 + --net_buffer_length=16K \
997 + --socket=${socket} \
998 + --pid-file=${pidfile} \
999 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
1000 + #einfo "About to start mysqld: ${mysqld}"
1001 + ebegin "Starting mysqld"
1002 + einfo "Command ${mysqld}"
1003 + ${mysqld} &
1004 + rc=$?
1005 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1006 + maxtry=$((${maxtry}-1))
1007 + echo -n "."
1008 + sleep 1
1009 + done
1010 + eend $rc
1011 +
1012 + if ! [[ -S "${socket}" ]]; then
1013 + die "Completely failed to start up mysqld with: ${mysqld}"
1014 + fi
1015 +
1016 + ebegin "Setting root password"
1017 + # Do this from memory, as we don't want clear text passwords in temp files
1018 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
1019 + "${EROOT}/usr/bin/mysql" \
1020 + "--socket=${socket}" \
1021 + -hlocalhost \
1022 + -e "${sql}"
1023 + eend $?
1024 +
1025 + if [[ -n "${sqltmp}" ]] ; then
1026 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1027 + "${EROOT}/usr/bin/mysql" \
1028 + "--socket=${socket}" \
1029 + -hlocalhost \
1030 + -uroot \
1031 + --password="${MYSQL_ROOT_PASSWORD}" \
1032 + mysql < "${sqltmp}"
1033 + rc=$?
1034 + eend $?
1035 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1036 + fi
1037 +
1038 + # Stop the server and cleanup
1039 + einfo "Stopping the server ..."
1040 + kill $(< "${pidfile}" )
1041 + rm -f "${sqltmp}"
1042 + wait %1
1043 + einfo "Done"
1044 +}