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