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