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