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