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: Wed, 29 Jan 2020 21:28:26
Message-Id: 1580333279.36934aef878bee12006b506faf2037b7563a1280.grknight@gentoo
1 commit: 36934aef878bee12006b506faf2037b7563a1280
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jan 29 21:27:59 2020 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Wed Jan 29 21:27:59 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=36934aef
7
8 dev-db/mariadb: Version bump for 10.2.31
9
10 Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
11
12 dev-db/mariadb/Manifest | 1 +
13 dev-db/mariadb/mariadb-10.2.31.ebuild | 986 ++++++++++++++++++++++++++++++++++
14 2 files changed, 987 insertions(+)
15
16 diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest
17 index 5fee34d8ec2..54d301febbd 100644
18 --- a/dev-db/mariadb/Manifest
19 +++ b/dev-db/mariadb/Manifest
20 @@ -2,6 +2,7 @@ DIST mariadb-10.1.38.tar.gz 63535685 BLAKE2B c179ea2f60287c2bc1c0d1c47ae989ac265
21 DIST mariadb-10.1.43.tar.gz 63635313 BLAKE2B 60617d3021bb478633a995b93a3659a287ecab49bb1997efc430e2f453a8145307f0db02799b43560a51c92ef528060f93fb82fd0362ea34052f68590144bff0 SHA512 47e9693c6c1d25d2c3541efe001569c17e70721edcbfc3d0ccc96f3638820123436c18d2cbc3c2ad252adf1eda446feff0370eb97f9e57b6711757ac899b47e8
22 DIST mariadb-10.2.22.tar.gz 71907765 BLAKE2B e7781a9e1bb0becca543ebb0b9e03912fbafa9de45bbd5c7232f92d29b934148dd124ad462bf8aa5aec2e4ee0bf75a03fae5e5fe97a77e1d93095052a577c14b SHA512 cd61d0c2d528b23b975e6ea142560d9b9ebff7ecda6fa9b3659b25b3406e8cc925918f4c3bb0e200ddb8d0520bcaa4d4f70d245b4731896f9ba2f1bdf0a817b2
23 DIST mariadb-10.2.29.tar.gz 73087972 BLAKE2B aa3fe880f00b02846b26f16fcd37d18ebe217a2c9680c8c535042d2759852c929cd649d662c6a2bc603d934a6ba770ef945752c99d150f539e1fdd0d9be0ad51 SHA512 cee4e0d1a2b203cadaaa5678c5ce17302f18ffa55d07c8329392b1ea84740340c006eb9ab5920beef80835c2a399d5fffca409b8288e10ae62d290af62ec4ab8
24 +DIST mariadb-10.2.31.tar.gz 73134720 BLAKE2B a410f71cffd7ff904cb16d9d00bbb4b1d6d17a4931de1635a14dce7c7c66d8dfd097b0c261959809cf2f327d196b11f3196129c2894efb5bab0141aca10ea3c7 SHA512 2cf28e4e049618f633470e7a4cd4f3bc8c2a74bf9796bfd026da7c75812e6d4962323785fdbca7a5b505c2e4fe95e3b47cd2e24e4dec2dcd230ac8a25f49b9b9
25 DIST mariadb-10.3.20.tar.gz 71990355 BLAKE2B f950f0eb836751d0eebb9ae561fe3b5aefade04a0d389465918aa2a887e4f717ab4e6bd835dea8f9a88aacfe10c0b091fc2a59882a1781a3f2903ef07a759f5d SHA512 8080cb6db85c587f39f128e98b00c3e6428bf3e828271a227bb2c61c97683c965802baa6e5f825317f7e2963683c0f81699642853deeca6977faa2b6932044a3
26 DIST mariadb-10.4.10.tar.gz 78352896 BLAKE2B c0e448fba455feb9385b7d57e1a727e84eaf4cfa52ce0dbd6ff062aa0b5abc42005680fb185416d04fbd7bb62d9bbd6c93e4cb77b145418cf6be92747f8b1c2a SHA512 4a9b9a37bc3a273de4bd781dac3636256364dae6efbba45765d6b28995da3d64e180422cd10418d1c7acd7fd8843fe2a2638c07e0f56b0c09170c58812cc6b71
27 DIST mariadb-5.5.66.tar.gz 45962591 BLAKE2B 41befba24abec2af876168a11fc205d328c137baa49e5e521787898e4b973d1dc548ef459228811caa99fa3c2b7a9fe96f3eb7a04bf62f0bb20966e4ffd2ea9b SHA512 403f3bc67018e01eb2277a88d3a7ac673d50df8f7a67607f9d14e3167d1bdd4ca202983df69c97688ff51edbd6d6b43af3541c75e968d1d01713a7b6495e4c8c
28
29 diff --git a/dev-db/mariadb/mariadb-10.2.31.ebuild b/dev-db/mariadb/mariadb-10.2.31.ebuild
30 new file mode 100644
31 index 00000000000..e779a0f1775
32 --- /dev/null
33 +++ b/dev-db/mariadb/mariadb-10.2.31.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 sst-xtrabackup 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.2.16-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.2-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 + sst-xtrabackup? ( net-misc/socat[ssl] )
162 + ) )
163 + perl? ( !dev-db/mytop
164 + virtual/perl-Getopt-Long
165 + dev-perl/TermReadKey
166 + virtual/perl-Term-ANSIColor
167 + virtual/perl-Time-HiRes )
168 + server? ( extraengine? ( jdbc? ( >=virtual/jre-1.6 ) ) )
169 +"
170 +# For other stuff to bring us in
171 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
172 +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed
173 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
174 + server? ( ~virtual/mysql-5.6[static=]
175 + galera? ( sst-xtrabackup? ( || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) ) ) )"
176 +
177 +pkg_setup() {
178 + if [[ ${MERGE_TYPE} != binary ]] ; then
179 + local GCC_MAJOR_SET=$(gcc-major-version)
180 + local GCC_MINOR_SET=$(gcc-minor-version)
181 + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
182 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
183 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
184 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
185 + die
186 + fi
187 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
188 + # non x86{,_64} arches
189 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
190 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
191 + eerror "${PN} needs to be built with gcc-4.7 or later."
192 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
193 + die
194 + fi
195 + fi
196 + java-pkg-opt-2_pkg_setup
197 + if has test ${FEATURES} && \
198 + use server && ! has userpriv ${FEATURES} ; then
199 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
200 + fi
201 +
202 + # This should come after all of the die statements
203 + enewgroup mysql 60 || die "problem adding 'mysql' group"
204 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
205 +}
206 +
207 +pkg_preinst() {
208 + java-pkg-opt-2_pkg_preinst
209 +
210 + # Here we need to see if the implementation switched client libraries
211 + # We check if this is a new instance of the package and a client library already exists
212 + local SHOW_ABI_MESSAGE libpath
213 + if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
214 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
215 + elog "Due to ABI changes when switching between different client libraries,"
216 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
217 + elog "Please run: revdep-rebuild --library ${libpath}"
218 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
219 + fi
220 +}
221 +
222 +pkg_postinst() {
223 + # Make sure the vars are correctly initialized
224 + mysql_init_vars
225 +
226 + # Create log directory securely if it does not exist
227 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
228 +
229 + if use server ; then
230 + if use pam; then
231 + einfo
232 + elog "This install includes the PAM authentication plugin."
233 + elog "To activate and configure the PAM plugin, please read:"
234 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
235 + einfo
236 + fi
237 +
238 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
239 + einfo
240 + elog "You might want to run:"
241 + elog "\"emerge --config =${CATEGORY}/${PF}\""
242 + elog "if this is a new install."
243 + elog
244 + elog "If you are switching server implentations, you should run the"
245 + elog "mysql_upgrade tool."
246 + einfo
247 + else
248 + einfo
249 + elog "If you are upgrading major versions, you should run the"
250 + elog "mysql_upgrade tool."
251 + einfo
252 + fi
253 +
254 + if use galera ; then
255 + einfo
256 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
257 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
258 + elog "The first time the cluster is activated, you should add"
259 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
260 + elog "This option should then be removed for subsequent starts."
261 + einfo
262 + if use sst-xtrabackup ; then
263 + ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup"
264 + ewarn "as an SST is broken by default beginning with 10.2.19 with the setting"
265 + ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead."
266 + ewarn "sst-xtrabackup is being removed in 10.3 and higher."
267 + fi
268 + fi
269 + fi
270 +
271 + # Note about configuration change
272 + einfo
273 + elog "This version of mariadb reorganizes the configuration from a single my.cnf"
274 + elog "to several files in /etc/mysql/${PN}.d."
275 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
276 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
277 + elog "You may have as many files as needed and they are read alphabetically."
278 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
279 + einfo
280 +}
281 +
282 +src_unpack() {
283 + unpack ${A}
284 + # Grab the patches
285 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR%/}/mysql-extras" git-r3_src_unpack
286 +
287 + mv -f "${WORKDIR%/}/${P}" "${S}" || die
288 +}
289 +
290 +src_prepare() {
291 + _disable_plugin() {
292 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
293 + }
294 + _disable_engine() {
295 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
296 + }
297 +
298 + local malloc
299 + for malloc in jemalloc tcmalloc ; do
300 + if use ${malloc}; then
301 + echo "TARGET_LINK_LIBRARIES(mysqld ${malloc})" >> "${S}/sql/CMakeLists.txt"
302 + fi
303 + done
304 +
305 + # Don't build bundled xz-utils for tokudb
306 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
307 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
308 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
309 +
310 + local plugin
311 + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info
312 + locale_info qc_info server_audit sql_errlog auth_ed25519 )
313 + local test_plugins=( audit_null auth_examples daemon_example fulltext
314 + debug_key_management example_key_management )
315 + if ! use server; then # These plugins are for the server
316 + for plugin in "${server_plugins[@]}" ; do
317 + _disable_plugin "${plugin}"
318 + done
319 + fi
320 +
321 + if ! use test; then # These plugins are only used during testing
322 + for plugin in "${test_plugins[@]}" ; do
323 + _disable_plugin "${plugin}"
324 + done
325 + _disable_engine test_sql_discovery
326 + fi
327 +
328 + _disable_engine example
329 +
330 + if ! use oqgraph ; then # avoids extra library checks
331 + _disable_engine oqgraph
332 + fi
333 +
334 + if use mroonga ; then
335 + # Remove the bundled groonga
336 + # There is no CMake flag, it simply checks for existance
337 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
338 + else
339 + _disable_engine mroonga
340 + fi
341 +
342 + # Don't clash with dev-db/mysql-connector-c
343 + sed -i -e 's/ my_print_defaults.1//' \
344 + -e 's/ perror.1//' \
345 + "${S}"/man/CMakeLists.txt || die
346 +
347 + # Fix galera_recovery.sh script
348 + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \
349 + scripts/galera_recovery.sh || die
350 +
351 + cmake-utils_src_prepare
352 + java-pkg-opt-2_src_prepare
353 +}
354 +
355 +src_configure(){
356 + # bug 508724 mariadb cannot use ld.gold
357 + tc-ld-disable-gold
358 + # Bug #114895, bug #110149
359 + filter-flags "-O" "-O[01]"
360 +
361 + append-cxxflags -felide-constructors
362 +
363 + # bug #283926, with GCC4.4, this is required to get correct behavior.
364 + append-flags -fno-strict-aliasing
365 +
366 + CMAKE_BUILD_TYPE="RelWithDebInfo"
367 +
368 + # debug hack wrt #497532
369 + mycmakeargs=(
370 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
371 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
372 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
373 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
374 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
375 + -DINSTALL_BINDIR=bin
376 + -DINSTALL_DOCDIR=share/doc/${PF}
377 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
378 + -DINSTALL_INCLUDEDIR=include/mysql
379 + -DINSTALL_INFODIR=share/info
380 + -DINSTALL_LIBDIR=$(get_libdir)
381 + -DINSTALL_MANDIR=share/man
382 + -DINSTALL_MYSQLSHAREDIR=share/mariadb
383 + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin
384 + -DINSTALL_SCRIPTDIR=share/mariadb/scripts
385 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
386 + -DINSTALL_SBINDIR=sbin
387 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb"
388 + -DWITH_COMMENT="Gentoo Linux ${PF}"
389 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
390 + -DWITH_LIBEDIT=0
391 + -DWITH_ZLIB=system
392 + -DWITHOUT_LIBWRAP=1
393 + -DENABLED_LOCAL_INFILE=1
394 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
395 + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock"
396 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
397 + -DWITH_DEFAULT_FEATURE_SET=0
398 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
399 + # The build forces this to be defined when cross-compiling. We pass it
400 + # all the time for simplicity and to make sure it is actually correct.
401 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
402 + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
403 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
404 + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF)
405 + -DCONC_WITH_EXTERNAL_ZLIB=YES
406 + -DWITH_EXTERNAL_ZLIB=YES
407 + -DSUFFIX_INSTALL_DIR=""
408 + -DWITH_UNITTEST=OFF
409 + -DWITHOUT_CLIENTLIBS=YES
410 + -DCLIENT_PLUGIN_DIALOG=OFF
411 + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF
412 + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF
413 + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC
414 + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF
415 + )
416 + if use test ; then
417 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test )
418 + else
419 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
420 + fi
421 +
422 + if ! use yassl ; then
423 + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC )
424 + else
425 + mycmakeargs+=( -DWITH_SSL=bundled )
426 + fi
427 +
428 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
429 + mycmakeargs+=(
430 + -DWITH_READLINE=$(usex bindist 1 0)
431 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
432 + -DENABLE_DTRACE=$(usex systemtap)
433 + )
434 +
435 + if use server ; then
436 +
437 + # Federated{,X} must be treated special otherwise they will not be built as plugins
438 + if ! use extraengine ; then
439 + mycmakeargs+=(
440 + -DPLUGIN_FEDERATED=NO
441 + -DPLUGIN_FEDERATEDX=NO )
442 + fi
443 +
444 + mycmakeargs+=(
445 + -DWITH_JEMALLOC=$(usex jemalloc system)
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=share/mariadb
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-utils_src_configure
546 +}
547 +
548 +src_compile() {
549 + cmake-utils_src_compile
550 +}
551 +
552 +src_install() {
553 + cmake-utils_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 + fi
628 +
629 + #Remove mytop if perl is not selected
630 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
631 +}
632 +
633 +# Official test instructions:
634 +# USE='extraengine perl server' \
635 +# FEATURES='test userpriv -usersandbox' \
636 +# ebuild mariadb-X.X.XX.ebuild \
637 +# digest clean package
638 +src_test() {
639 +
640 + _disable_test() {
641 + local rawtestname reason
642 + rawtestname="${1}" ; shift
643 + reason="${@}"
644 + ewarn "test '${rawtestname}' disabled: '${reason}'"
645 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
646 + }
647 +
648 + local TESTDIR="${BUILD_DIR}/mysql-test"
649 + local retstatus_unit
650 + local retstatus_tests
651 +
652 + if ! use server ; then
653 + einfo "Skipping server tests due to minimal build."
654 + return 0
655 + fi
656 +
657 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
658 + # localhost. Also causes weird failures.
659 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
660 +
661 + if [[ $UID -eq 0 ]]; then
662 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
663 + fi
664 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
665 +
666 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
667 +
668 + # Run CTest (test-units)
669 + cmake-utils_src_test
670 + retstatus_unit=$?
671 +
672 + # Ensure that parallel runs don't die
673 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
674 + # Enable parallel testing, auto will try to detect number of cores
675 + # You may set this by hand.
676 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
677 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
678 +
679 + # create directories because mysqladmin might run out of order
680 + mkdir -p "${T}"/var-tests{,/log} || die
681 +
682 + # Run mysql tests
683 + pushd "${TESTDIR}" > /dev/null || die
684 +
685 + touch "${T}/disabled.def"
686 + # These are failing in MariaDB 10.0 for now and are believed to be
687 + # false positives:
688 + #
689 + # main.mysql_client_test, main.mysql_client_test_nonblock
690 + # main.mysql_client_test_comp:
691 + # segfaults at random under Portage only, suspect resource limits.
692 +
693 + local t
694 + for t in plugins.cracklib_password_check plugins.two_password_validations ; do
695 + _disable_test "$t" "False positive due to varying policies"
696 + done
697 +
698 + for t in main.mysql_client_test main.mysql_client_test_nonblock main.mysql \
699 + main.mysql_client_test_comp rpl.rpl_extra_col_master_myisam ; do
700 + _disable_test "$t" "False positives in Gentoo"
701 + done
702 +
703 + _disable_test main.gis_notembedded "Needs latin1 USE set"
704 + _disable_test main.plugin_auth "Needs client libraries built"
705 + _disable_test plugins.auth_ed25519 "Needs client libraries built"
706 + _disable_test main.mysqldump "Test fails past 2018-12-31 due to event expiration"
707 +
708 + # Likely environment issues as only number of clients connected fails
709 + _disable_test rpl.rpl_semi_sync_uninstall_plugin \
710 + "Fails intermittently on parallel testing"
711 +
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 +}