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