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