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, 27 Dec 2018 20:14:37
Message-Id: 1545941420.1b4af3efa5a587c9151689be8a557c80e7e509be.grknight@gentoo
1 commit: 1b4af3efa5a587c9151689be8a557c80e7e509be
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 27 20:10:20 2018 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 27 20:10:20 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1b4af3ef
7
8 dev-db/mariadb: Version bump for 10.2.20
9
10 Package-Manager: Portage-2.3.52, 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.20.ebuild | 964 ++++++++++++++++++++++++++++++++++
15 2 files changed, 965 insertions(+)
16
17 diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest
18 index fea9c282420..8e0d18691bd 100644
19 --- a/dev-db/mariadb/Manifest
20 +++ b/dev-db/mariadb/Manifest
21 @@ -3,6 +3,7 @@ DIST mariadb-10.0.37.tar.gz 64728382 BLAKE2B 3d794633cc400013be05c326681f11f8b27
22 DIST mariadb-10.1.34.tar.gz 65298561 BLAKE2B 3f3af7b8bad68a08f69befd3f3e7bd88b8cf058feb20309dc2cdbd16bf5d015c2cb0d1d9d2fdf831f6183c0b9bb25405124c24b2940467489e05d42c57f7b0a6 SHA512 3c18359006b340dcf724d1fce36dcc19916c42492269a7545e0726172b8f7b84860e10725c74e4458dae34572395f1650bf17838e9058544e0a6cfcbffd54f6d
23 DIST mariadb-10.1.37.tar.gz 63492946 BLAKE2B 0f19b402c597443ef970cbe2a2d85d51743cc2d05ab741897efb150f007d7be8b645706a2d0dc5a9f91c7a380d2313840f77d6e9b15f3335495f275b415e5a33 SHA512 b7c35cd67ad265ce2e3a4db20a2ae2b78745db96dc70a211f027a39b6dbb3dc900991c2ee1021ee6a97d12489c3e2a70252e2adf348a458af38b99c3de5a4f25
24 DIST mariadb-10.2.19.tar.gz 71856357 BLAKE2B 7e55760b85d7b8b19f9d1afe22e7cf5c3001ab03d64062bd702442cb771b2c76f62cf8794b027098b6fb4ade5bf3de39d68dbede65c72fc9e1482083fb19a9c9 SHA512 7bfd65687c923d50b04d598fccea60a23a3fafc3e57b803b2a06c2f25ae68bd25206e18bd71af4797492792d821f4be05cef19e8075080b82b539afdd8af9f46
25 +DIST mariadb-10.2.20.tar.gz 71876032 BLAKE2B cb170dc8e341dd4406112ec66aa3d9754662f2a5fa986e3ebc7ebfc96f475cd993189bb2b9b60b2258299e363376c2c50bfdd1abbcf09525b951c2cac9c5ed0b SHA512 24f5ec7381aa3c9dc8862260e5ed2296034c41286fe81aa2e2547b3d02e1a3b6146cbde7396c6ef803e7aebb98a59c24c815dd0cc4fae462789f2362690c6ba6
26 DIST mariadb-10.3.10.tar.gz 70493771 BLAKE2B 03540ed111405febb46c27422f957fb6c533ffe7502c56d6eb4fe8a3bc45bfd18fb2b12a16a01780c0bc291ff139132666741df00d4be068fb99e2a63c543cc2 SHA512 dee7789dff359a6352ceacb2db6bcb4730940e9458adda4e23894f9bfa0a7ff8c238060bffca58a60b662275e52a31ea1784d51fae114312b003c024e9412b31
27 DIST mariadb-10.3.11.tar.gz 70669435 BLAKE2B e16346519b60aa11a0ffd2c19254ef888c44c054d55b7f98a8d696e3df2c0801c6141adddfb9169098ad5efa5d881c83681c3c5741f68b10c9ce4d15def34254 SHA512 1adc1f9bbabf848726c669a7a0ab01257ba31882758b53fbf3b1316f2295670dba1c3d1f3292d7c1a749c701504588694a55d020839e690595897b0e20435298
28 DIST mariadb-5.5.62.tar.gz 45938380 BLAKE2B aa17d0e5740805d74f7f74f54605e04c4e29c4208a2efa6da2dde5855dfdc13e3225fe349e2146b11a6cbf5a0ac82a9e6c3e4f31e62afa71fc7ab1381040c68f SHA512 136668a54b404a303ee8f87e736bd14463b2323f0a517e7161c8729f4534bc1d653241d6b79f8cb7ad66ea09cf4190f9b95eceaa209b18a46822a68d9580ba5a
29
30 diff --git a/dev-db/mariadb/mariadb-10.2.20.ebuild b/dev-db/mariadb/mariadb-10.2.20.ebuild
31 new file mode 100644
32 index 00000000000..6a7484aab06
33 --- /dev/null
34 +++ b/dev-db/mariadb/mariadb-10.2.20.ebuild
35 @@ -0,0 +1,964 @@
36 +# Copyright 1999-2018 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 + )
400 + if use test ; then
401 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test )
402 + else
403 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
404 + fi
405 +
406 + if ! use yassl ; then
407 + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC )
408 + else
409 + mycmakeargs+=( -DWITH_SSL=bundled )
410 + fi
411 +
412 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
413 + mycmakeargs+=(
414 + -DWITH_READLINE=$(usex bindist 1 0)
415 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
416 + -DENABLE_DTRACE=$(usex systemtap)
417 + )
418 +
419 + if use server ; then
420 +
421 + # Federated{,X} must be treated special otherwise they will not be built as plugins
422 + if ! use extraengine ; then
423 + mycmakeargs+=(
424 + -DPLUGIN_FEDERATED=NO
425 + -DPLUGIN_FEDERATEDX=NO )
426 + fi
427 +
428 + mycmakeargs+=(
429 + -DWITH_JEMALLOC=$(usex jemalloc system)
430 + -DWITH_PCRE=system
431 + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO)
432 + -DPLUGIN_SPHINX=$(usex sphinx YES NO)
433 + -DPLUGIN_TOKUDB=$(usex tokudb YES NO)
434 + -DPLUGIN_AUTH_PAM=$(usex pam YES NO)
435 + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO)
436 + -DPLUGIN_CASSANDRA=NO
437 + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO)
438 + -DPLUGIN_SPIDER=$(usex extraengine YES NO)
439 + -DPLUGIN_CONNECT=$(usex extraengine YES NO)
440 + -DCONNECT_WITH_MYSQL=1
441 + -DCONNECT_WITH_LIBXML2=$(usex xml)
442 + -DCONNECT_WITH_ODBC=$(usex odbc)
443 + -DCONNECT_WITH_JDBC=$(usex jdbc)
444 + # Build failure and autodep wrt bug 639144
445 + -DCONNECT_WITH_MONGO=OFF
446 + -DWITH_WSREP=$(usex galera)
447 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
448 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
449 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
450 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
451 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
452 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
453 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
454 + -DINSTALL_SQLBENCHDIR=share/mariadb
455 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
456 + # systemd is only linked to for server notification
457 + -DWITH_SYSTEMD=$(usex systemd yes no)
458 + -DWITH_NUMA=$(usex numa ON OFF)
459 + )
460 +
461 + # Workaround for MDEV-14524
462 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 )
463 +
464 + if use test ; then
465 + # This is needed for the new client lib which tests a real, open server
466 + mycmakeargs+=( -DSKIP_TESTS=ON )
467 + fi
468 +
469 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
470 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
471 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
472 + ewarn "You MUST file bugs without these variables set."
473 +
474 + mycmakeargs+=(
475 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
476 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
477 + )
478 +
479 + elif ! use latin1 ; then
480 + mycmakeargs+=(
481 + -DDEFAULT_CHARSET=utf8
482 + -DDEFAULT_COLLATION=utf8_general_ci
483 + )
484 + else
485 + mycmakeargs+=(
486 + -DDEFAULT_CHARSET=latin1
487 + -DDEFAULT_COLLATION=latin1_swedish_ci
488 + )
489 + fi
490 + mycmakeargs+=(
491 + -DEXTRA_CHARSETS=all
492 + -DMYSQL_USER=mysql
493 + -DDISABLE_SHARED=$(usex static YES NO)
494 + -DWITH_DEBUG=$(usex debug)
495 + -DWITH_EMBEDDED_SERVER=OFF
496 + -DWITH_PROFILING=$(usex profiling)
497 + )
498 +
499 + if use static; then
500 + mycmakeargs+=( -DWITH_PIC=1 )
501 + fi
502 +
503 + if use jemalloc || use tcmalloc ; then
504 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
505 + fi
506 +
507 + # Storage engines
508 + mycmakeargs+=(
509 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
510 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
511 + -DWITH_CSV_STORAGE_ENGINE=1
512 + -DWITH_HEAP_STORAGE_ENGINE=1
513 + -DWITH_INNOBASE_STORAGE_ENGINE=1
514 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
515 + -DWITH_MYISAM_STORAGE_ENGINE=1
516 + -DWITH_PARTITION_STORAGE_ENGINE=1
517 + )
518 +
519 + else
520 + mycmakeargs+=(
521 + -DWITHOUT_SERVER=1
522 + -DWITH_EMBEDDED_SERVER=OFF
523 + -DEXTRA_CHARSETS=none
524 + -DINSTALL_SQLBENCHDIR=
525 + -DWITH_SYSTEMD=no
526 + )
527 + fi
528 +
529 + cmake-utils_src_configure
530 +}
531 +
532 +src_compile() {
533 + cmake-utils_src_compile
534 +}
535 +
536 +src_install() {
537 + cmake-utils_src_install
538 +
539 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
540 + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then
541 + rm "${ED}/usr/include/mysql/server/private/config.h" || die
542 + fi
543 +
544 + # Make sure the vars are correctly initialized
545 + mysql_init_vars
546 +
547 + # Convenience links
548 + einfo "Making Convenience links for mysqlcheck multi-call binary"
549 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
550 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
551 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
552 +
553 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
554 + if [[ -d "${ED}/usr/data" ]] ; then
555 + rm -Rf "${ED}/usr/data" || die
556 + fi
557 +
558 + # Unless they explicitly specific USE=test, then do not install the
559 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
560 + # validation of your database configuration after tuning it.
561 + if ! use test ; then
562 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
563 + fi
564 +
565 + # Configuration stuff
566 + einfo "Building default configuration ..."
567 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
568 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
569 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
570 + eprefixify "${TMPDIR}/my.cnf"
571 + doins "${TMPDIR}/my.cnf"
572 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
573 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
574 + eprefixify "${TMPDIR}/50-distro-client.cnf"
575 + doins "${TMPDIR}/50-distro-client.cnf"
576 +
577 + if use server ; then
578 + mycnf_src="my.cnf.distro-server"
579 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
580 + "${FILESDIR}/${mycnf_src}" \
581 + > "${TMPDIR}/my.cnf.ok" || die
582 + if use prefix ; then
583 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
584 + "${TMPDIR}/my.cnf.ok" || die
585 + fi
586 + if use latin1 ; then
587 + sed -i \
588 + -e "/character-set/s|utf8|latin1|g" \
589 + "${TMPDIR}/my.cnf.ok" || die
590 + fi
591 + eprefixify "${TMPDIR}/my.cnf.ok"
592 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
593 +
594 + einfo "Including support files and sample configurations"
595 + docinto "support-files"
596 + local script
597 + for script in \
598 + "${S}"/support-files/magic
599 + do
600 + [[ -f "$script" ]] && dodoc "${script}"
601 + done
602 +
603 + docinto "scripts"
604 + for script in "${S}"/scripts/mysql* ; do
605 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
606 + done
607 + # Manually install supporting files that conflict with other packages
608 + # but are needed for galera and initial installation
609 + exeinto /usr/libexec/mariadb
610 + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror"
611 + fi
612 +
613 + #Remove mytop if perl is not selected
614 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
615 +}
616 +
617 +# Official test instructions:
618 +# USE='extraengine perl server' \
619 +# FEATURES='test userpriv -usersandbox' \
620 +# ebuild mariadb-X.X.XX.ebuild \
621 +# digest clean package
622 +src_test() {
623 +
624 + _disable_test() {
625 + local rawtestname reason
626 + rawtestname="${1}" ; shift
627 + reason="${@}"
628 + ewarn "test '${rawtestname}' disabled: '${reason}'"
629 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
630 + }
631 +
632 + local TESTDIR="${BUILD_DIR}/mysql-test"
633 + local retstatus_unit
634 + local retstatus_tests
635 +
636 + if ! use server ; then
637 + einfo "Skipping server tests due to minimal build."
638 + return 0
639 + fi
640 +
641 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
642 + # localhost. Also causes weird failures.
643 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
644 +
645 + if [[ $UID -eq 0 ]]; then
646 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
647 + fi
648 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
649 +
650 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
651 +
652 + # Run CTest (test-units)
653 + cmake-utils_src_test
654 + retstatus_unit=$?
655 +
656 + # Ensure that parallel runs don't die
657 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
658 + # Enable parallel testing, auto will try to detect number of cores
659 + # You may set this by hand.
660 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
661 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
662 +
663 + # create directories because mysqladmin might run out of order
664 + mkdir -p "${T}"/var-tests{,/log} || die
665 +
666 + # Run mysql tests
667 + pushd "${TESTDIR}" > /dev/null || die
668 +
669 + touch "${T}/disabled.def"
670 + # These are failing in MariaDB 10.0 for now and are believed to be
671 + # false positives:
672 + #
673 + # main.mysql_client_test, main.mysql_client_test_nonblock
674 + # main.mysql_client_test_comp:
675 + # segfaults at random under Portage only, suspect resource limits.
676 +
677 + local t
678 + for t in plugins.cracklib_password_check plugins.two_password_validations ; do
679 + _disable_test "$t" "False positive due to varying policies"
680 + done
681 +
682 + for t in main.mysql_client_test main.mysql_client_test_nonblock \
683 + main.mysql_client_test_comp rpl.rpl_extra_col_master_myisam ; do
684 + _disable_test "$t" "False positives in Gentoo"
685 + done
686 +
687 + _disable_test main.plugin_auth "Needs client libraries built"
688 +
689 + # Likely environment issues as only number of clients connected fails
690 + _disable_test rpl.rpl_semi_sync_uninstall_plugin \
691 + "Fails intermittently on parallel testing"
692 +
693 + # run mysql-test tests
694 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
695 + retstatus_tests=$?
696 +
697 + popd > /dev/null || die
698 +
699 + # Cleanup is important for these testcases.
700 + pkill -9 -f "${S}/ndb" 2>/dev/null
701 + pkill -9 -f "${S}/sql" 2>/dev/null
702 +
703 + local failures=""
704 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
705 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
706 +
707 + [[ -z "$failures" ]] || die "Test failures: $failures"
708 + einfo "Tests successfully completed"
709 +}
710 +
711 +mysql_init_vars() {
712 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"}
713 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
714 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
715 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
716 +
717 + if [[ -z "${MY_DATADIR}" ]] ; then
718 + MY_DATADIR=""
719 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
720 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
721 + | sed -ne '/datadir/s|^--datadir=||p' \
722 + | tail -n1`
723 + if [[ -z "${MY_DATADIR}" ]] ; then
724 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
725 + | sed -e 's/.*=\s*//' \
726 + | tail -n1`
727 + fi
728 + fi
729 + if [[ -z "${MY_DATADIR}" ]] ; then
730 + MY_DATADIR="${MY_LOCALSTATEDIR}"
731 + einfo "Using default MY_DATADIR"
732 + fi
733 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
734 +
735 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
736 + if [[ -e "${MY_DATADIR}" ]] ; then
737 + # If you get this and you're wondering about it, see bug #207636
738 + elog "MySQL datadir found in ${MY_DATADIR}"
739 + elog "A new one will not be created."
740 + PREVIOUS_DATADIR="yes"
741 + else
742 + PREVIOUS_DATADIR="no"
743 + fi
744 + export PREVIOUS_DATADIR
745 + fi
746 + else
747 + if [[ ${EBUILD_PHASE} == "config" ]]; then
748 + local new_MY_DATADIR
749 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
750 + | sed -ne '/datadir/s|^--datadir=||p' \
751 + | tail -n1`
752 +
753 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
754 + ewarn "MySQL MY_DATADIR has changed"
755 + ewarn "from ${MY_DATADIR}"
756 + ewarn "to ${new_MY_DATADIR}"
757 + MY_DATADIR="${new_MY_DATADIR}"
758 + fi
759 + fi
760 + fi
761 +
762 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
763 + export MY_LOCALSTATEDIR MY_LOGDIR
764 + export MY_DATADIR
765 +}
766 +
767 +pkg_config() {
768 + _getoptval() {
769 + local mypd="${EROOT}"/usr/bin/my_print_defaults
770 + local section="$1"
771 + local flag="--${2}="
772 + local extra_options="${3}"
773 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
774 + }
775 + local old_MY_DATADIR="${MY_DATADIR}"
776 + local old_HOME="${HOME}"
777 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
778 + export HOME=${EPREFIX}/root
779 +
780 + # Make sure the vars are correctly initialized
781 + mysql_init_vars
782 +
783 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
784 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
785 + die "Minimal builds do NOT include the MySQL server"
786 + fi
787 +
788 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
789 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
790 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
791 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
792 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
793 +
794 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
795 + if [[ -d "${MY_DATADIR_s}" ]]; then
796 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
797 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
798 + else
799 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
800 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
801 + || die "Moving MY_DATADIR failed"
802 + fi
803 + else
804 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
805 + if [[ -d "${MY_DATADIR_s}" ]]; then
806 + ewarn "Attempting to use ${MY_DATADIR_s}"
807 + else
808 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
809 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
810 + fi
811 + fi
812 + fi
813 +
814 + local pwd1="a"
815 + local pwd2="b"
816 + local maxtry=15
817 +
818 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
819 + local tmp_mysqld_password_source=
820 +
821 + for tmp_mysqld_password_source in mysql client; do
822 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
823 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
824 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
825 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
826 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
827 + MYSQL_ROOT_PASSWORD=
828 + continue
829 + fi
830 +
831 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
832 + break
833 + fi
834 + done
835 +
836 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
837 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
838 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
839 + fi
840 +
841 + unset tmp_mysqld_password_source
842 + fi
843 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
844 + # These are dir+prefix
845 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
846 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
847 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
848 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
849 +
850 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
851 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
852 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
853 + fi
854 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
855 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
856 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
857 + fi
858 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
859 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
860 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
861 + fi
862 +
863 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
864 + ewarn "You have already a MySQL database in place."
865 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
866 + ewarn "Please rename or delete it if you wish to replace it."
867 + die "MySQL database already exists!"
868 + fi
869 +
870 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
871 + # localhost. Also causes weird failures.
872 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
873 +
874 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
875 +
876 + einfo "Please provide a password for the mysql 'root' user now"
877 + einfo "or through the ${HOME}/.my.cnf file."
878 + ewarn "Avoid [\"'\\_%] characters in the password"
879 + read -rsp " >" pwd1 ; echo
880 +
881 + einfo "Retype the password"
882 + read -rsp " >" pwd2 ; echo
883 +
884 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
885 + die "Passwords are not the same"
886 + fi
887 + MYSQL_ROOT_PASSWORD="${pwd1}"
888 + unset pwd1 pwd2
889 + fi
890 +
891 + local options
892 + local sqltmp="$(emktemp)"
893 +
894 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
895 + # see https://bugs.mysql.com/bug.php?id=31312
896 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
897 +
898 + # Figure out which options we need to disable to do the setup
899 + local helpfile="${TMPDIR}/mysqld-help"
900 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
901 + for opt in grant-tables host-cache name-resolve networking slave-start \
902 + federated ssl log-bin relay-log slow-query-log external-locking \
903 + log-slave-updates \
904 + ; do
905 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
906 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
907 + done
908 +
909 + einfo "Creating the mysql database and setting proper permissions on it ..."
910 +
911 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
912 + PID_DIR="${EROOT}/var/run/mysqld"
913 + if [[ ! -d "${PID_DIR}" ]]; then
914 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
915 + fi
916 +
917 + if [[ ! -d "${MY_DATADIR}" ]]; then
918 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
919 + fi
920 +
921 + pushd "${TMPDIR}" &>/dev/null || die
922 +
923 + # Filling timezones, see
924 + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
925 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
926 +
927 + local cmd=( "${EROOT}usr/share/mariadb/scripts/mysql_install_db" )
928 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
929 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
930 + einfo "Command: ${cmd[*]}"
931 + su -s /bin/sh -c "${cmd[*]}" mysql \
932 + >"${TMPDIR}"/mysql_install_db.log 2>&1
933 + if [ $? -ne 0 ]; then
934 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
935 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
936 + fi
937 + popd &>/dev/null || die
938 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
939 + || die "MySQL databases not installed"
940 +
941 + use prefix || options="${options} --user=mysql"
942 +
943 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
944 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
945 + local mysqld="${EROOT}/usr/sbin/mysqld \
946 + ${options} \
947 + --log-warnings=0 \
948 + --basedir=${EROOT}/usr \
949 + --datadir=${ROOT}/${MY_DATADIR} \
950 + --max_allowed_packet=8M \
951 + --net_buffer_length=16K \
952 + --socket=${socket} \
953 + --pid-file=${pidfile} \
954 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
955 + #einfo "About to start mysqld: ${mysqld}"
956 + ebegin "Starting mysqld"
957 + einfo "Command ${mysqld}"
958 + ${mysqld} &
959 + rc=$?
960 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
961 + maxtry=$((${maxtry}-1))
962 + echo -n "."
963 + sleep 1
964 + done
965 + eend $rc
966 +
967 + if ! [[ -S "${socket}" ]]; then
968 + die "Completely failed to start up mysqld with: ${mysqld}"
969 + fi
970 +
971 + ebegin "Setting root password"
972 + # Do this from memory, as we don't want clear text passwords in temp files
973 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
974 + "${EROOT}/usr/bin/mysql" \
975 + "--socket=${socket}" \
976 + -hlocalhost \
977 + -e "${sql}"
978 + eend $?
979 +
980 + if [[ -n "${sqltmp}" ]] ; then
981 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
982 + "${EROOT}/usr/bin/mysql" \
983 + "--socket=${socket}" \
984 + -hlocalhost \
985 + -uroot \
986 + --password="${MYSQL_ROOT_PASSWORD}" \
987 + mysql < "${sqltmp}"
988 + rc=$?
989 + eend $?
990 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
991 + fi
992 +
993 + # Stop the server and cleanup
994 + einfo "Stopping the server ..."
995 + kill $(< "${pidfile}" )
996 + rm -f "${sqltmp}"
997 + wait %1
998 + einfo "Done"
999 +}