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