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