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