Gentoo Archives: gentoo-commits

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