Gentoo Archives: gentoo-commits

From: Brian Evans <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/mariadb/
Date: Tue, 11 Dec 2018 18:43:59
Message-Id: 1544553812.fa8dc6c76d185bed9f37d5965bb23bc9f99ace09.grknight@gentoo
1 commit: fa8dc6c76d185bed9f37d5965bb23bc9f99ace09
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 11 18:43:32 2018 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 11 18:43:32 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fa8dc6c7
7
8 dev-db/mariadb: Restore jemalloc support in the server
9
10 Package-Manager: Portage-2.3.52, Repoman-2.3.12
11 Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
12
13 dev-db/mariadb/Manifest | 1 +
14 dev-db/mariadb/mariadb-10.2.19-r1.ebuild | 958 ++++++++++++++++++++++++++++++
15 dev-db/mariadb/mariadb-10.3.10-r1.ebuild | 960 +++++++++++++++++++++++++++++++
16 3 files changed, 1919 insertions(+)
17
18 diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest
19 index bba587ace33..d0c6ab87360 100644
20 --- a/dev-db/mariadb/Manifest
21 +++ b/dev-db/mariadb/Manifest
22 @@ -7,3 +7,4 @@ DIST mariadb-10.3.10.tar.gz 70493771 BLAKE2B 03540ed111405febb46c27422f957fb6c53
23 DIST mariadb-5.5.62.tar.gz 45938380 BLAKE2B aa17d0e5740805d74f7f74f54605e04c4e29c4208a2efa6da2dde5855dfdc13e3225fe349e2146b11a6cbf5a0ac82a9e6c3e4f31e62afa71fc7ab1381040c68f SHA512 136668a54b404a303ee8f87e736bd14463b2323f0a517e7161c8729f4534bc1d653241d6b79f8cb7ad66ea09cf4190f9b95eceaa209b18a46822a68d9580ba5a
24 DIST mysql-extras-20180809-1700Z.tar.bz2 322999 BLAKE2B 8b5feb32085dc35b2f68dae985b2d266c4eaa0e956b490050a2df04bbff99bf8623b67e75af9326d84e3ad625c4d86b0d21d23c9a96df5a0c9cd5ed730958970 SHA512 fbd7af9284bbf09d55f128361e7cc52d94f24ac491aac800cd6d61f2e444aeca66a4d5e6ae94c2fb4044e00cec9b232bae9a76a229f87f19d90b7aecf70792ec
25 DIST mysql-extras-20181104-2252Z.tar.bz2 328613 BLAKE2B c869dbdd8eb8ab6706b52815fae88e0789b955b9d3e89eac305e6de6e1bc9e78ea10ac58efeac0d6478c7f83587910834e9b4c44e3621224f006daae44dc2bf3 SHA512 e0dff23aa6420a9cfcf2f60464381d4b08194759dcd96910cdf94075fa71e90b74fa3dae700f279f421fee68315af37e47054c9422adeb6cc757fa968a1b65bf
26 +DIST mysql-extras-20181211-1735Z.tar.bz2 330779 BLAKE2B 4a41b9067a8b8bc5b595ff8dfeaa20d6577083ad1f6a0d1b56d29663cd436abc611a2ff394fafb8d466771c8676e2019a415554b830f20828ace31eb5b7e082a SHA512 03db4b1b483395eeba57d049c10a07ef50b26ba97f3fad74aa6a19f8835aea60106bbc86dea2a168ec613d9b2caa016240d8d888e42823d383fa3466f8b262d4
27
28 diff --git a/dev-db/mariadb/mariadb-10.2.19-r1.ebuild b/dev-db/mariadb/mariadb-10.2.19-r1.ebuild
29 new file mode 100644
30 index 00000000000..7ed2c00ee4a
31 --- /dev/null
32 +++ b/dev-db/mariadb/mariadb-10.2.19-r1.ebuild
33 @@ -0,0 +1,958 @@
34 +# Copyright 1999-2018 Gentoo Authors
35 +# Distributed under the terms of the GNU General Public License v2
36 +
37 +EAPI="6"
38 +MY_EXTRAS_VER="20181211-1735Z"
39 +SUBSLOT="18"
40 +
41 +JAVA_PKG_OPT_USE="jdbc"
42 +
43 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
44 +
45 +inherit eutils systemd flag-o-matic prefix toolchain-funcs \
46 + java-pkg-opt-2 user cmake-utils
47 +
48 +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz "
49 +
50 +# Gentoo patches to MySQL
51 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then
52 + SRC_URI="${SRC_URI}
53 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
54 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
55 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
56 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
57 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
58 +fi
59 +
60 +HOMEPAGE="https://mariadb.org/"
61 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
62 +LICENSE="GPL-2 LGPL-2.1+"
63 +SLOT="0/${SUBSLOT:-0}"
64 +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4
65 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 libressl mroonga
66 + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx
67 + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc
68 + test tokudb xml yassl"
69 +
70 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
71 +RESTRICT="!bindist? ( bindist ) libressl? ( test )"
72 +
73 +REQUIRED_USE="jdbc? ( extraengine server !static )
74 + server? ( tokudb? ( jemalloc !tcmalloc ) )
75 + ?? ( tcmalloc jemalloc )
76 + static? ( yassl !pam )"
77 +
78 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
79 +
80 +# Shorten the path because the socket path length must be shorter than 107 chars
81 +# and we will run a mysql server during test phase
82 +S="${WORKDIR}/mysql"
83 +
84 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
85 + inherit git-r3
86 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git"
87 + EGIT_CHECKOUT_DIR="${WORKDIR%/}/mysql-extras"
88 + EGIT_CLONE_TYPE=shallow
89 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras"
90 +else
91 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras-${MY_EXTRAS_VER}"
92 +fi
93 +
94 +PATCHES=(
95 + "${MY_PATCH_DIR}"/20015_all_mariadb-pkgconfig-location.patch
96 + "${MY_PATCH_DIR}"/20018_all_mariadb-10.2.16-without-clientlibs-tools.patch
97 + "${MY_PATCH_DIR}"/20024_all_mariadb-10.2.6-mysql_st-regression.patch
98 + "${MY_PATCH_DIR}"/20025_all_mariadb-10.2.6-gssapi-detect.patch
99 + "${MY_PATCH_DIR}"/20035_all_mariadb-10.2-atomic-detection.patch
100 + "${MY_PATCH_DIR}"/20037_all_mariadb-10.2-restore-jemalloc.patch
101 +)
102 +
103 +# Be warned, *DEPEND are version-dependant
104 +# These are used for both runtime and compiletime
105 +COMMON_DEPEND="
106 + kernel_linux? (
107 + sys-process/procps:0=
108 + dev-libs/libaio:0=
109 + )
110 + >=sys-apps/sed-4
111 + >=sys-apps/texinfo-4.7-r1
112 + jemalloc? ( dev-libs/jemalloc:0= )
113 + tcmalloc? ( dev-util/google-perftools:0= )
114 + systemtap? ( >=dev-util/systemtap-1.3:0= )
115 + >=sys-libs/zlib-1.2.3:0=
116 + kerberos? ( virtual/krb5 )
117 + yassl? ( net-libs/gnutls:0= )
118 + !yassl? (
119 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
120 + libressl? ( dev-libs/libressl:0= )
121 + )
122 + sys-libs/ncurses:0=
123 + !bindist? (
124 + sys-libs/binutils-libs:0=
125 + >=sys-libs/readline-4.1:0=
126 + )
127 + server? (
128 + backup? ( app-arch/libarchive:0= )
129 + cracklib? ( sys-libs/cracklib:0= )
130 + extraengine? (
131 + odbc? ( dev-db/unixODBC:0= )
132 + xml? ( dev-libs/libxml2:2= )
133 + )
134 + innodb-lz4? ( app-arch/lz4 )
135 + innodb-lzo? ( dev-libs/lzo )
136 + innodb-snappy? ( app-arch/snappy )
137 + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 )
138 + numa? ( sys-process/numactl )
139 + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= )
140 + pam? ( virtual/pam:0= )
141 + systemd? ( sys-apps/systemd:= )
142 + tokudb? ( app-arch/snappy )
143 + )
144 + >=dev-libs/libpcre-8.41-r1:3=
145 +"
146 +DEPEND="virtual/yacc
147 + static? ( sys-libs/ncurses[static-libs] )
148 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
149 + server? ( extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) )
150 + ${COMMON_DEPEND}"
151 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
152 + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
153 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
154 + !<virtual/mysql-5.6-r11
155 + ${COMMON_DEPEND}
156 + server? ( galera? (
157 + sys-apps/iproute2
158 + =sys-cluster/galera-25*
159 + sst-rsync? ( sys-process/lsof )
160 + sst-mariabackup? ( net-misc/socat[ssl] )
161 + sst-xtrabackup? ( net-misc/socat[ssl] )
162 + ) )
163 + perl? ( !dev-db/mytop
164 + virtual/perl-Getopt-Long
165 + dev-perl/TermReadKey
166 + virtual/perl-Term-ANSIColor
167 + virtual/perl-Time-HiRes )
168 + server? ( extraengine? ( jdbc? ( >=virtual/jre-1.6 ) ) )
169 +"
170 +# For other stuff to bring us in
171 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
172 +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed
173 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
174 + server? ( ~virtual/mysql-5.6[static=]
175 + galera? ( sst-xtrabackup? ( || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) ) ) )"
176 +
177 +pkg_setup() {
178 + if [[ ${MERGE_TYPE} != binary ]] ; then
179 + local GCC_MAJOR_SET=$(gcc-major-version)
180 + local GCC_MINOR_SET=$(gcc-minor-version)
181 + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
182 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
183 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
184 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
185 + die
186 + fi
187 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
188 + # non x86{,_64} arches
189 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
190 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
191 + eerror "${PN} needs to be built with gcc-4.7 or later."
192 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
193 + die
194 + fi
195 + fi
196 + java-pkg-opt-2_pkg_setup
197 + if has test ${FEATURES} && \
198 + use server && ! has userpriv ${FEATURES} ; then
199 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
200 + fi
201 +
202 + # This should come after all of the die statements
203 + enewgroup mysql 60 || die "problem adding 'mysql' group"
204 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
205 +}
206 +
207 +pkg_preinst() {
208 + java-pkg-opt-2_pkg_preinst
209 +
210 + # Here we need to see if the implementation switched client libraries
211 + # We check if this is a new instance of the package and a client library already exists
212 + local SHOW_ABI_MESSAGE libpath
213 + if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
214 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
215 + elog "Due to ABI changes when switching between different client libraries,"
216 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
217 + elog "Please run: revdep-rebuild --library ${libpath}"
218 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
219 + fi
220 +}
221 +
222 +pkg_postinst() {
223 + # Make sure the vars are correctly initialized
224 + mysql_init_vars
225 +
226 + # Create log directory securely if it does not exist
227 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
228 +
229 + if use server ; then
230 + if use pam; then
231 + einfo
232 + elog "This install includes the PAM authentication plugin."
233 + elog "To activate and configure the PAM plugin, please read:"
234 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
235 + einfo
236 + fi
237 +
238 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
239 + einfo
240 + elog "You might want to run:"
241 + elog "\"emerge --config =${CATEGORY}/${PF}\""
242 + elog "if this is a new install."
243 + elog
244 + elog "If you are switching server implentations, you should run the"
245 + elog "mysql_upgrade tool."
246 + einfo
247 + else
248 + einfo
249 + elog "If you are upgrading major versions, you should run the"
250 + elog "mysql_upgrade tool."
251 + einfo
252 + fi
253 +
254 + if use galera ; then
255 + einfo
256 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
257 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
258 + elog "The first time the cluster is activated, you should add"
259 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
260 + elog "This option should then be removed for subsequent starts."
261 + einfo
262 + fi
263 + fi
264 +
265 + # Note about configuration change
266 + einfo
267 + elog "This version of mariadb reorganizes the configuration from a single my.cnf"
268 + elog "to several files in /etc/mysql/${PN}.d."
269 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
270 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
271 + elog "You may have as many files as needed and they are read alphabetically."
272 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
273 + einfo
274 +}
275 +
276 +src_unpack() {
277 + unpack ${A}
278 + # Grab the patches
279 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR%/}/mysql-extras" git-r3_src_unpack
280 +
281 + mv -f "${WORKDIR%/}/${P}" "${S}" || die
282 +}
283 +
284 +src_prepare() {
285 + _disable_plugin() {
286 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
287 + }
288 + _disable_engine() {
289 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
290 + }
291 +
292 + if use tcmalloc; then
293 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
294 + fi
295 +
296 + # Don't build bundled xz-utils for tokudb
297 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
298 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
299 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
300 +
301 + local plugin
302 + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info
303 + locale_info qc_info server_audit sql_errlog )
304 + local test_plugins=( audit_null auth_examples daemon_example fulltext
305 + debug_key_management example_key_management )
306 + if ! use server; then # These plugins are for the server
307 + for plugin in "${server_plugins[@]}" ; do
308 + _disable_plugin "${plugin}"
309 + done
310 + fi
311 +
312 + if ! use test; then # These plugins are only used during testing
313 + for plugin in "${test_plugins[@]}" ; do
314 + _disable_plugin "${plugin}"
315 + done
316 + _disable_engine test_sql_discovery
317 + fi
318 +
319 + _disable_engine example
320 +
321 + if ! use oqgraph ; then # avoids extra library checks
322 + _disable_engine oqgraph
323 + fi
324 +
325 + if use mroonga ; then
326 + # Remove the bundled groonga
327 + # There is no CMake flag, it simply checks for existance
328 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
329 + else
330 + _disable_engine mroonga
331 + fi
332 +
333 + cmake-utils_src_prepare
334 + java-pkg-opt-2_src_prepare
335 +}
336 +
337 +src_configure(){
338 + # bug 508724 mariadb cannot use ld.gold
339 + tc-ld-disable-gold
340 + # Bug #114895, bug #110149
341 + filter-flags "-O" "-O[01]"
342 +
343 + append-cxxflags -felide-constructors
344 +
345 + # bug #283926, with GCC4.4, this is required to get correct behavior.
346 + append-flags -fno-strict-aliasing
347 +
348 + CMAKE_BUILD_TYPE="RelWithDebInfo"
349 +
350 + # debug hack wrt #497532
351 + mycmakeargs=(
352 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
353 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
354 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
355 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
356 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
357 + -DINSTALL_BINDIR=bin
358 + -DINSTALL_DOCDIR=share/doc/${PF}
359 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
360 + -DINSTALL_INCLUDEDIR=include/mysql
361 + -DINSTALL_INFODIR=share/info
362 + -DINSTALL_LIBDIR=$(get_libdir)
363 + -DINSTALL_MANDIR=share/man
364 + -DINSTALL_MYSQLSHAREDIR=share/mariadb
365 + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin
366 + -DINSTALL_SCRIPTDIR=share/mariadb/scripts
367 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
368 + -DINSTALL_SBINDIR=sbin
369 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb"
370 + -DWITH_COMMENT="Gentoo Linux ${PF}"
371 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
372 + -DWITH_LIBEDIT=0
373 + -DWITH_ZLIB=system
374 + -DWITHOUT_LIBWRAP=1
375 + -DENABLED_LOCAL_INFILE=1
376 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
377 + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock"
378 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
379 + -DWITH_DEFAULT_FEATURE_SET=0
380 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
381 + # The build forces this to be defined when cross-compiling. We pass it
382 + # all the time for simplicity and to make sure it is actually correct.
383 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
384 + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
385 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
386 + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF)
387 + -DCONC_WITH_EXTERNAL_ZLIB=YES
388 + -DWITH_EXTERNAL_ZLIB=YES
389 + -DSUFFIX_INSTALL_DIR=""
390 + -DWITH_UNITTEST=OFF
391 + -DWITHOUT_CLIENTLIBS=YES
392 + -DCLIENT_PLUGIN_DIALOG=OFF
393 + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF
394 + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC
395 + )
396 + if use test ; then
397 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test )
398 + else
399 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
400 + fi
401 +
402 + if ! use yassl ; then
403 + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC )
404 + else
405 + mycmakeargs+=( -DWITH_SSL=bundled )
406 + fi
407 +
408 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
409 + mycmakeargs+=(
410 + -DWITH_READLINE=$(usex bindist 1 0)
411 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
412 + -DENABLE_DTRACE=$(usex systemtap)
413 + )
414 +
415 + if use server ; then
416 +
417 + # Federated{,X} must be treated special otherwise they will not be built as plugins
418 + if ! use extraengine ; then
419 + mycmakeargs+=(
420 + -DPLUGIN_FEDERATED=NO
421 + -DPLUGIN_FEDERATEDX=NO )
422 + fi
423 +
424 + mycmakeargs+=(
425 + -DWITH_JEMALLOC=$(usex jemalloc system)
426 + -DWITH_PCRE=system
427 + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO)
428 + -DPLUGIN_SPHINX=$(usex sphinx YES NO)
429 + -DPLUGIN_TOKUDB=$(usex tokudb YES NO)
430 + -DPLUGIN_AUTH_PAM=$(usex pam YES NO)
431 + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO)
432 + -DPLUGIN_CASSANDRA=NO
433 + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO)
434 + -DPLUGIN_SPIDER=$(usex extraengine YES NO)
435 + -DPLUGIN_CONNECT=$(usex extraengine YES NO)
436 + -DCONNECT_WITH_MYSQL=1
437 + -DCONNECT_WITH_LIBXML2=$(usex xml)
438 + -DCONNECT_WITH_ODBC=$(usex odbc)
439 + -DCONNECT_WITH_JDBC=$(usex jdbc)
440 + # Build failure and autodep wrt bug 639144
441 + -DCONNECT_WITH_MONGO=OFF
442 + -DWITH_WSREP=$(usex galera)
443 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
444 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
445 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
446 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
447 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
448 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
449 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
450 + -DINSTALL_SQLBENCHDIR=share/mariadb
451 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
452 + # systemd is only linked to for server notification
453 + -DWITH_SYSTEMD=$(usex systemd yes no)
454 + -DWITH_NUMA=$(usex numa ON OFF)
455 + )
456 +
457 + # Workaround for MDEV-14524
458 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 )
459 +
460 + if use test ; then
461 + # This is needed for the new client lib which tests a real, open server
462 + mycmakeargs+=( -DSKIP_TESTS=ON )
463 + fi
464 +
465 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
466 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
467 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
468 + ewarn "You MUST file bugs without these variables set."
469 +
470 + mycmakeargs+=(
471 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
472 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
473 + )
474 +
475 + elif ! use latin1 ; then
476 + mycmakeargs+=(
477 + -DDEFAULT_CHARSET=utf8
478 + -DDEFAULT_COLLATION=utf8_general_ci
479 + )
480 + else
481 + mycmakeargs+=(
482 + -DDEFAULT_CHARSET=latin1
483 + -DDEFAULT_COLLATION=latin1_swedish_ci
484 + )
485 + fi
486 + mycmakeargs+=(
487 + -DEXTRA_CHARSETS=all
488 + -DMYSQL_USER=mysql
489 + -DDISABLE_SHARED=$(usex static YES NO)
490 + -DWITH_DEBUG=$(usex debug)
491 + -DWITH_EMBEDDED_SERVER=OFF
492 + -DWITH_PROFILING=$(usex profiling)
493 + )
494 +
495 + if use static; then
496 + mycmakeargs+=( -DWITH_PIC=1 )
497 + fi
498 +
499 + if use jemalloc || use tcmalloc ; then
500 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
501 + fi
502 +
503 + # Storage engines
504 + mycmakeargs+=(
505 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
506 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
507 + -DWITH_CSV_STORAGE_ENGINE=1
508 + -DWITH_HEAP_STORAGE_ENGINE=1
509 + -DWITH_INNOBASE_STORAGE_ENGINE=1
510 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
511 + -DWITH_MYISAM_STORAGE_ENGINE=1
512 + -DWITH_PARTITION_STORAGE_ENGINE=1
513 + )
514 +
515 + else
516 + mycmakeargs+=(
517 + -DWITHOUT_SERVER=1
518 + -DWITH_EMBEDDED_SERVER=OFF
519 + -DEXTRA_CHARSETS=none
520 + -DINSTALL_SQLBENCHDIR=
521 + -DWITH_SYSTEMD=no
522 + )
523 + fi
524 +
525 + cmake-utils_src_configure
526 +}
527 +
528 +src_compile() {
529 + cmake-utils_src_compile
530 +}
531 +
532 +src_install() {
533 + cmake-utils_src_install
534 +
535 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
536 + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then
537 + rm "${ED}/usr/include/mysql/server/private/config.h" || die
538 + fi
539 +
540 + # Make sure the vars are correctly initialized
541 + mysql_init_vars
542 +
543 + # Convenience links
544 + einfo "Making Convenience links for mysqlcheck multi-call binary"
545 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
546 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
547 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
548 +
549 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
550 + if [[ -d "${ED}/usr/data" ]] ; then
551 + rm -Rf "${ED}/usr/data" || die
552 + fi
553 +
554 + # Unless they explicitly specific USE=test, then do not install the
555 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
556 + # validation of your database configuration after tuning it.
557 + if ! use test ; then
558 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
559 + fi
560 +
561 + # Configuration stuff
562 + einfo "Building default configuration ..."
563 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
564 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
565 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
566 + eprefixify "${TMPDIR}/my.cnf"
567 + doins "${TMPDIR}/my.cnf"
568 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
569 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
570 + eprefixify "${TMPDIR}/50-distro-client.cnf"
571 + doins "${TMPDIR}/50-distro-client.cnf"
572 +
573 + if use server ; then
574 + mycnf_src="my.cnf.distro-server"
575 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
576 + "${FILESDIR}/${mycnf_src}" \
577 + > "${TMPDIR}/my.cnf.ok" || die
578 + if use prefix ; then
579 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
580 + "${TMPDIR}/my.cnf.ok" || die
581 + fi
582 + if use latin1 ; then
583 + sed -i \
584 + -e "/character-set/s|utf8|latin1|g" \
585 + "${TMPDIR}/my.cnf.ok" || die
586 + fi
587 + eprefixify "${TMPDIR}/my.cnf.ok"
588 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
589 +
590 + einfo "Including support files and sample configurations"
591 + docinto "support-files"
592 + local script
593 + for script in \
594 + "${S}"/support-files/magic
595 + do
596 + [[ -f "$script" ]] && dodoc "${script}"
597 + done
598 +
599 + docinto "scripts"
600 + for script in "${S}"/scripts/mysql* ; do
601 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
602 + done
603 + # Manually install supporting files that conflict with other packages
604 + # but are needed for galera and initial installation
605 + exeinto /usr/libexec/mariadb
606 + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror"
607 + fi
608 +
609 + #Remove mytop if perl is not selected
610 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
611 +}
612 +
613 +# Official test instructions:
614 +# USE='extraengine perl server' \
615 +# FEATURES='test userpriv -usersandbox' \
616 +# ebuild mariadb-X.X.XX.ebuild \
617 +# digest clean package
618 +src_test() {
619 +
620 + _disable_test() {
621 + local rawtestname reason
622 + rawtestname="${1}" ; shift
623 + reason="${@}"
624 + ewarn "test '${rawtestname}' disabled: '${reason}'"
625 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
626 + }
627 +
628 + local TESTDIR="${BUILD_DIR}/mysql-test"
629 + local retstatus_unit
630 + local retstatus_tests
631 +
632 + if ! use server ; then
633 + einfo "Skipping server tests due to minimal build."
634 + return 0
635 + fi
636 +
637 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
638 + # localhost. Also causes weird failures.
639 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
640 +
641 + if [[ $UID -eq 0 ]]; then
642 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
643 + fi
644 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
645 +
646 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
647 +
648 + # Run CTest (test-units)
649 + cmake-utils_src_test
650 + retstatus_unit=$?
651 +
652 + # Ensure that parallel runs don't die
653 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
654 + # Enable parallel testing, auto will try to detect number of cores
655 + # You may set this by hand.
656 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
657 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
658 +
659 + # create directories because mysqladmin might run out of order
660 + mkdir -p "${T}"/var-tests{,/log} || die
661 +
662 + # Run mysql tests
663 + pushd "${TESTDIR}" > /dev/null || die
664 +
665 + touch "${T}/disabled.def"
666 + # These are failing in MariaDB 10.0 for now and are believed to be
667 + # false positives:
668 + #
669 + # main.mysql_client_test, main.mysql_client_test_nonblock
670 + # main.mysql_client_test_comp:
671 + # segfaults at random under Portage only, suspect resource limits.
672 +
673 + local t
674 + for t in plugins.cracklib_password_check plugins.two_password_validations ; do
675 + _disable_test "$t" "False positive due to varying policies"
676 + done
677 +
678 + for t in main.mysql_client_test main.mysql_client_test_nonblock \
679 + main.mysql_client_test_comp rpl.rpl_extra_col_master_myisam ; do
680 + _disable_test "$t" "False positives in Gentoo"
681 + done
682 +
683 + _disable_test main.plugin_auth "Needs client libraries built"
684 +
685 + # run mysql-test tests
686 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
687 + retstatus_tests=$?
688 +
689 + popd > /dev/null || die
690 +
691 + # Cleanup is important for these testcases.
692 + pkill -9 -f "${S}/ndb" 2>/dev/null
693 + pkill -9 -f "${S}/sql" 2>/dev/null
694 +
695 + local failures=""
696 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
697 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
698 +
699 + [[ -z "$failures" ]] || die "Test failures: $failures"
700 + einfo "Tests successfully completed"
701 +}
702 +
703 +mysql_init_vars() {
704 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"}
705 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
706 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
707 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
708 +
709 + if [[ -z "${MY_DATADIR}" ]] ; then
710 + MY_DATADIR=""
711 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
712 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
713 + | sed -ne '/datadir/s|^--datadir=||p' \
714 + | tail -n1`
715 + if [[ -z "${MY_DATADIR}" ]] ; then
716 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
717 + | sed -e 's/.*=\s*//' \
718 + | tail -n1`
719 + fi
720 + fi
721 + if [[ -z "${MY_DATADIR}" ]] ; then
722 + MY_DATADIR="${MY_LOCALSTATEDIR}"
723 + einfo "Using default MY_DATADIR"
724 + fi
725 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
726 +
727 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
728 + if [[ -e "${MY_DATADIR}" ]] ; then
729 + # If you get this and you're wondering about it, see bug #207636
730 + elog "MySQL datadir found in ${MY_DATADIR}"
731 + elog "A new one will not be created."
732 + PREVIOUS_DATADIR="yes"
733 + else
734 + PREVIOUS_DATADIR="no"
735 + fi
736 + export PREVIOUS_DATADIR
737 + fi
738 + else
739 + if [[ ${EBUILD_PHASE} == "config" ]]; then
740 + local new_MY_DATADIR
741 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
742 + | sed -ne '/datadir/s|^--datadir=||p' \
743 + | tail -n1`
744 +
745 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
746 + ewarn "MySQL MY_DATADIR has changed"
747 + ewarn "from ${MY_DATADIR}"
748 + ewarn "to ${new_MY_DATADIR}"
749 + MY_DATADIR="${new_MY_DATADIR}"
750 + fi
751 + fi
752 + fi
753 +
754 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
755 + export MY_LOCALSTATEDIR MY_LOGDIR
756 + export MY_DATADIR
757 +}
758 +
759 +pkg_config() {
760 + _getoptval() {
761 + local mypd="${EROOT}"/usr/bin/my_print_defaults
762 + local section="$1"
763 + local flag="--${2}="
764 + local extra_options="${3}"
765 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
766 + }
767 + local old_MY_DATADIR="${MY_DATADIR}"
768 + local old_HOME="${HOME}"
769 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
770 + export HOME=${EPREFIX}/root
771 +
772 + # Make sure the vars are correctly initialized
773 + mysql_init_vars
774 +
775 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
776 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
777 + die "Minimal builds do NOT include the MySQL server"
778 + fi
779 +
780 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
781 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
782 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
783 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
784 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
785 +
786 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
787 + if [[ -d "${MY_DATADIR_s}" ]]; then
788 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
789 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
790 + else
791 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
792 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
793 + || die "Moving MY_DATADIR failed"
794 + fi
795 + else
796 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
797 + if [[ -d "${MY_DATADIR_s}" ]]; then
798 + ewarn "Attempting to use ${MY_DATADIR_s}"
799 + else
800 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
801 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
802 + fi
803 + fi
804 + fi
805 +
806 + local pwd1="a"
807 + local pwd2="b"
808 + local maxtry=15
809 +
810 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
811 + local tmp_mysqld_password_source=
812 +
813 + for tmp_mysqld_password_source in mysql client; do
814 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
815 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
816 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
817 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
818 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
819 + MYSQL_ROOT_PASSWORD=
820 + continue
821 + fi
822 +
823 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
824 + break
825 + fi
826 + done
827 +
828 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
829 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
830 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
831 + fi
832 +
833 + unset tmp_mysqld_password_source
834 + fi
835 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
836 + # These are dir+prefix
837 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
838 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
839 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
840 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
841 +
842 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
843 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
844 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
845 + fi
846 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
847 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
848 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
849 + fi
850 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
851 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
852 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
853 + fi
854 +
855 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
856 + ewarn "You have already a MySQL database in place."
857 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
858 + ewarn "Please rename or delete it if you wish to replace it."
859 + die "MySQL database already exists!"
860 + fi
861 +
862 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
863 + # localhost. Also causes weird failures.
864 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
865 +
866 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
867 +
868 + einfo "Please provide a password for the mysql 'root' user now"
869 + einfo "or through the ${HOME}/.my.cnf file."
870 + ewarn "Avoid [\"'\\_%] characters in the password"
871 + read -rsp " >" pwd1 ; echo
872 +
873 + einfo "Retype the password"
874 + read -rsp " >" pwd2 ; echo
875 +
876 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
877 + die "Passwords are not the same"
878 + fi
879 + MYSQL_ROOT_PASSWORD="${pwd1}"
880 + unset pwd1 pwd2
881 + fi
882 +
883 + local options
884 + local sqltmp="$(emktemp)"
885 +
886 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
887 + # see https://bugs.mysql.com/bug.php?id=31312
888 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
889 +
890 + # Figure out which options we need to disable to do the setup
891 + local helpfile="${TMPDIR}/mysqld-help"
892 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
893 + for opt in grant-tables host-cache name-resolve networking slave-start \
894 + federated ssl log-bin relay-log slow-query-log external-locking \
895 + log-slave-updates \
896 + ; do
897 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
898 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
899 + done
900 +
901 + einfo "Creating the mysql database and setting proper permissions on it ..."
902 +
903 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
904 + PID_DIR="${EROOT}/var/run/mysqld"
905 + if [[ ! -d "${PID_DIR}" ]]; then
906 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
907 + fi
908 +
909 + if [[ ! -d "${MY_DATADIR}" ]]; then
910 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
911 + fi
912 +
913 + pushd "${TMPDIR}" &>/dev/null || die
914 +
915 + # Filling timezones, see
916 + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
917 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
918 +
919 + local cmd=( "${EROOT}usr/share/mariadb/scripts/mysql_install_db" )
920 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
921 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
922 + einfo "Command: ${cmd[*]}"
923 + su -s /bin/sh -c "${cmd[*]}" mysql \
924 + >"${TMPDIR}"/mysql_install_db.log 2>&1
925 + if [ $? -ne 0 ]; then
926 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
927 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
928 + fi
929 + popd &>/dev/null || die
930 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
931 + || die "MySQL databases not installed"
932 +
933 + use prefix || options="${options} --user=mysql"
934 +
935 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
936 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
937 + local mysqld="${EROOT}/usr/sbin/mysqld \
938 + ${options} \
939 + --log-warnings=0 \
940 + --basedir=${EROOT}/usr \
941 + --datadir=${ROOT}/${MY_DATADIR} \
942 + --max_allowed_packet=8M \
943 + --net_buffer_length=16K \
944 + --socket=${socket} \
945 + --pid-file=${pidfile} \
946 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
947 + #einfo "About to start mysqld: ${mysqld}"
948 + ebegin "Starting mysqld"
949 + einfo "Command ${mysqld}"
950 + ${mysqld} &
951 + rc=$?
952 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
953 + maxtry=$((${maxtry}-1))
954 + echo -n "."
955 + sleep 1
956 + done
957 + eend $rc
958 +
959 + if ! [[ -S "${socket}" ]]; then
960 + die "Completely failed to start up mysqld with: ${mysqld}"
961 + fi
962 +
963 + ebegin "Setting root password"
964 + # Do this from memory, as we don't want clear text passwords in temp files
965 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
966 + "${EROOT}/usr/bin/mysql" \
967 + "--socket=${socket}" \
968 + -hlocalhost \
969 + -e "${sql}"
970 + eend $?
971 +
972 + if [[ -n "${sqltmp}" ]] ; then
973 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
974 + "${EROOT}/usr/bin/mysql" \
975 + "--socket=${socket}" \
976 + -hlocalhost \
977 + -uroot \
978 + --password="${MYSQL_ROOT_PASSWORD}" \
979 + mysql < "${sqltmp}"
980 + rc=$?
981 + eend $?
982 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
983 + fi
984 +
985 + # Stop the server and cleanup
986 + einfo "Stopping the server ..."
987 + kill $(< "${pidfile}" )
988 + rm -f "${sqltmp}"
989 + wait %1
990 + einfo "Done"
991 +}
992
993 diff --git a/dev-db/mariadb/mariadb-10.3.10-r1.ebuild b/dev-db/mariadb/mariadb-10.3.10-r1.ebuild
994 new file mode 100644
995 index 00000000000..aef8625f9e5
996 --- /dev/null
997 +++ b/dev-db/mariadb/mariadb-10.3.10-r1.ebuild
998 @@ -0,0 +1,960 @@
999 +# Copyright 1999-2018 Gentoo Authors
1000 +# Distributed under the terms of the GNU General Public License v2
1001 +
1002 +EAPI="6"
1003 +MY_EXTRAS_VER="20181211-1735Z"
1004 +SUBSLOT="18"
1005 +
1006 +JAVA_PKG_OPT_USE="jdbc"
1007 +
1008 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
1009 +
1010 +inherit eutils systemd flag-o-matic prefix toolchain-funcs \
1011 + java-pkg-opt-2 user cmake-utils
1012 +
1013 +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz "
1014 +
1015 +# Gentoo patches to MySQL
1016 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then
1017 + SRC_URI="${SRC_URI}
1018 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
1019 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
1020 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
1021 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
1022 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
1023 +fi
1024 +
1025 +HOMEPAGE="https://mariadb.org/"
1026 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
1027 +LICENSE="GPL-2 LGPL-2.1+"
1028 +SLOT="0/${SUBSLOT:-0}"
1029 +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4
1030 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 libressl mroonga
1031 + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx
1032 + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc
1033 + test tokudb xml yassl"
1034 +
1035 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
1036 +RESTRICT="!bindist? ( bindist ) libressl? ( test )"
1037 +
1038 +REQUIRED_USE="jdbc? ( extraengine server !static )
1039 + server? ( tokudb? ( jemalloc !tcmalloc ) )
1040 + ?? ( tcmalloc jemalloc )
1041 + static? ( yassl !pam )"
1042 +
1043 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
1044 +
1045 +# Shorten the path because the socket path length must be shorter than 107 chars
1046 +# and we will run a mysql server during test phase
1047 +S="${WORKDIR}/mysql"
1048 +
1049 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
1050 + inherit git-r3
1051 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git"
1052 + EGIT_CHECKOUT_DIR="${WORKDIR%/}/mysql-extras"
1053 + EGIT_CLONE_TYPE=shallow
1054 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras"
1055 +else
1056 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras-${MY_EXTRAS_VER}"
1057 +fi
1058 +
1059 +PATCHES=(
1060 + "${MY_PATCH_DIR}"/20015_all_mariadb-pkgconfig-location.patch
1061 + "${MY_PATCH_DIR}"/20018_all_mariadb-10.2.16-without-clientlibs-tools.patch
1062 + "${MY_PATCH_DIR}"/20024_all_mariadb-10.2.6-mysql_st-regression.patch
1063 + "${MY_PATCH_DIR}"/20025_all_mariadb-10.2.6-gssapi-detect.patch
1064 + "${MY_PATCH_DIR}"/20035_all_mariadb-10.3-atomic-detection.patch
1065 + "${MY_PATCH_DIR}"/20037_all_mariadb-10.3-restore-jemalloc.patch
1066 +)
1067 +
1068 +# Be warned, *DEPEND are version-dependant
1069 +# These are used for both runtime and compiletime
1070 +COMMON_DEPEND="
1071 + kernel_linux? (
1072 + sys-process/procps:0=
1073 + dev-libs/libaio:0=
1074 + )
1075 + >=sys-apps/sed-4
1076 + >=sys-apps/texinfo-4.7-r1
1077 + jemalloc? ( dev-libs/jemalloc:0= )
1078 + tcmalloc? ( dev-util/google-perftools:0= )
1079 + systemtap? ( >=dev-util/systemtap-1.3:0= )
1080 + >=sys-libs/zlib-1.2.3:0=
1081 + kerberos? ( virtual/krb5 )
1082 + yassl? ( net-libs/gnutls:0= )
1083 + !yassl? (
1084 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
1085 + libressl? ( dev-libs/libressl:0= )
1086 + )
1087 + sys-libs/ncurses:0=
1088 + !bindist? (
1089 + sys-libs/binutils-libs:0=
1090 + >=sys-libs/readline-4.1:0=
1091 + )
1092 + server? (
1093 + backup? ( app-arch/libarchive:0= )
1094 + cracklib? ( sys-libs/cracklib:0= )
1095 + extraengine? (
1096 + odbc? ( dev-db/unixODBC:0= )
1097 + xml? ( dev-libs/libxml2:2= )
1098 + )
1099 + innodb-lz4? ( app-arch/lz4 )
1100 + innodb-lzo? ( dev-libs/lzo )
1101 + innodb-snappy? ( app-arch/snappy )
1102 + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 )
1103 + numa? ( sys-process/numactl )
1104 + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= )
1105 + pam? ( virtual/pam:0= )
1106 + systemd? ( sys-apps/systemd:= )
1107 + tokudb? ( app-arch/snappy )
1108 + )
1109 + >=dev-libs/libpcre-8.41-r1:3=
1110 +"
1111 +DEPEND="virtual/yacc
1112 + static? ( sys-libs/ncurses[static-libs] )
1113 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
1114 + server? ( extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) )
1115 + ${COMMON_DEPEND}"
1116 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
1117 + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
1118 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
1119 + !<virtual/mysql-5.6-r11
1120 + ${COMMON_DEPEND}
1121 + server? ( galera? (
1122 + sys-apps/iproute2
1123 + =sys-cluster/galera-25*
1124 + sst-rsync? ( sys-process/lsof )
1125 + sst-mariabackup? ( net-misc/socat[ssl] )
1126 + sst-xtrabackup? ( net-misc/socat[ssl] )
1127 + ) )
1128 + perl? ( !dev-db/mytop
1129 + virtual/perl-Getopt-Long
1130 + dev-perl/TermReadKey
1131 + virtual/perl-Term-ANSIColor
1132 + virtual/perl-Time-HiRes )
1133 + server? ( extraengine? ( jdbc? ( >=virtual/jre-1.6 ) ) )
1134 +"
1135 +# For other stuff to bring us in
1136 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
1137 +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed
1138 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
1139 + server? ( ~virtual/mysql-5.6[static=]
1140 + galera? ( sst-xtrabackup? ( || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) ) ) )"
1141 +
1142 +pkg_setup() {
1143 + if [[ ${MERGE_TYPE} != binary ]] ; then
1144 + local GCC_MAJOR_SET=$(gcc-major-version)
1145 + local GCC_MINOR_SET=$(gcc-minor-version)
1146 + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
1147 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
1148 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
1149 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
1150 + die
1151 + fi
1152 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
1153 + # non x86{,_64} arches
1154 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
1155 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
1156 + eerror "${PN} needs to be built with gcc-4.7 or later."
1157 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
1158 + die
1159 + fi
1160 + fi
1161 + java-pkg-opt-2_pkg_setup
1162 + if has test ${FEATURES} && \
1163 + use server && ! has userpriv ${FEATURES} ; then
1164 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
1165 + fi
1166 +
1167 + # This should come after all of the die statements
1168 + enewgroup mysql 60 || die "problem adding 'mysql' group"
1169 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
1170 +}
1171 +
1172 +pkg_preinst() {
1173 + java-pkg-opt-2_pkg_preinst
1174 +
1175 + # Here we need to see if the implementation switched client libraries
1176 + # We check if this is a new instance of the package and a client library already exists
1177 + local SHOW_ABI_MESSAGE libpath
1178 + if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
1179 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
1180 + elog "Due to ABI changes when switching between different client libraries,"
1181 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
1182 + elog "Please run: revdep-rebuild --library ${libpath}"
1183 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
1184 + fi
1185 +}
1186 +
1187 +pkg_postinst() {
1188 + # Make sure the vars are correctly initialized
1189 + mysql_init_vars
1190 +
1191 + # Create log directory securely if it does not exist
1192 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
1193 +
1194 + if use server ; then
1195 + if use pam; then
1196 + einfo
1197 + elog "This install includes the PAM authentication plugin."
1198 + elog "To activate and configure the PAM plugin, please read:"
1199 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
1200 + einfo
1201 + fi
1202 +
1203 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
1204 + einfo
1205 + elog "You might want to run:"
1206 + elog "\"emerge --config =${CATEGORY}/${PF}\""
1207 + elog "if this is a new install."
1208 + elog
1209 + elog "If you are switching server implentations, you should run the"
1210 + elog "mysql_upgrade tool."
1211 + einfo
1212 + else
1213 + einfo
1214 + elog "If you are upgrading major versions, you should run the"
1215 + elog "mysql_upgrade tool."
1216 + einfo
1217 + fi
1218 +
1219 + if use galera ; then
1220 + einfo
1221 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
1222 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
1223 + elog "The first time the cluster is activated, you should add"
1224 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
1225 + elog "This option should then be removed for subsequent starts."
1226 + einfo
1227 + fi
1228 + fi
1229 +
1230 + # Note about configuration change
1231 + einfo
1232 + elog "This version of mariadb reorganizes the configuration from a single my.cnf"
1233 + elog "to several files in /etc/mysql/${PN}.d."
1234 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
1235 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
1236 + elog "You may have as many files as needed and they are read alphabetically."
1237 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
1238 + einfo
1239 +}
1240 +
1241 +src_unpack() {
1242 + unpack ${A}
1243 + # Grab the patches
1244 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
1245 +
1246 + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die
1247 +}
1248 +
1249 +src_prepare() {
1250 + _disable_plugin() {
1251 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
1252 + }
1253 + _disable_engine() {
1254 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
1255 + }
1256 +
1257 + if use tcmalloc; then
1258 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
1259 + fi
1260 +
1261 + # Don't build bundled xz-utils for tokudb
1262 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
1263 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
1264 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
1265 +
1266 + local plugin
1267 + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info
1268 + locale_info qc_info server_audit sql_errlog )
1269 + local test_plugins=( audit_null auth_examples daemon_example fulltext
1270 + debug_key_management example_key_management versioning )
1271 + if ! use server; then # These plugins are for the server
1272 + for plugin in "${server_plugins[@]}" ; do
1273 + _disable_plugin "${plugin}"
1274 + done
1275 + fi
1276 +
1277 + if ! use test; then # These plugins are only used during testing
1278 + for plugin in "${test_plugins[@]}" ; do
1279 + _disable_plugin "${plugin}"
1280 + done
1281 + _disable_engine test_sql_discovery
1282 + fi
1283 +
1284 + _disable_engine example
1285 +
1286 + if ! use oqgraph ; then # avoids extra library checks
1287 + _disable_engine oqgraph
1288 + fi
1289 +
1290 + if use mroonga ; then
1291 + # Remove the bundled groonga
1292 + # There is no CMake flag, it simply checks for existance
1293 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
1294 + else
1295 + _disable_engine mroonga
1296 + fi
1297 +
1298 + cmake-utils_src_prepare
1299 + java-pkg-opt-2_src_prepare
1300 +}
1301 +
1302 +src_configure(){
1303 + # bug 508724 mariadb cannot use ld.gold
1304 + tc-ld-disable-gold
1305 + # Bug #114895, bug #110149
1306 + filter-flags "-O" "-O[01]"
1307 +
1308 + append-cxxflags -felide-constructors
1309 +
1310 + # bug #283926, with GCC4.4, this is required to get correct behavior.
1311 + append-flags -fno-strict-aliasing
1312 +
1313 + CMAKE_BUILD_TYPE="RelWithDebInfo"
1314 +
1315 + # debug hack wrt #497532
1316 + mycmakeargs=(
1317 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1318 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1319 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
1320 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
1321 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
1322 + -DINSTALL_BINDIR=bin
1323 + -DINSTALL_DOCDIR=share/doc/${PF}
1324 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
1325 + -DINSTALL_INCLUDEDIR=include/mysql
1326 + -DINSTALL_INFODIR=share/info
1327 + -DINSTALL_LIBDIR=$(get_libdir)
1328 + -DINSTALL_MANDIR=share/man
1329 + -DINSTALL_MYSQLSHAREDIR=share/mariadb
1330 + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin
1331 + -DINSTALL_SCRIPTDIR=share/mariadb/scripts
1332 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
1333 + -DINSTALL_SBINDIR=sbin
1334 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb"
1335 + -DWITH_COMMENT="Gentoo Linux ${PF}"
1336 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
1337 + -DWITH_LIBEDIT=0
1338 + -DWITH_ZLIB=system
1339 + -DWITHOUT_LIBWRAP=1
1340 + -DENABLED_LOCAL_INFILE=1
1341 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
1342 + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock"
1343 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
1344 + -DWITH_DEFAULT_FEATURE_SET=0
1345 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
1346 + # The build forces this to be defined when cross-compiling. We pass it
1347 + # all the time for simplicity and to make sure it is actually correct.
1348 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
1349 + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
1350 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
1351 + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF)
1352 + -DCONC_WITH_EXTERNAL_ZLIB=YES
1353 + -DWITH_EXTERNAL_ZLIB=YES
1354 + -DSUFFIX_INSTALL_DIR=""
1355 + -DWITH_UNITTEST=OFF
1356 + -DWITHOUT_CLIENTLIBS=YES
1357 + -DCLIENT_PLUGIN_DIALOG=OFF
1358 + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF
1359 + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC
1360 + )
1361 + if use test ; then
1362 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test )
1363 + else
1364 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
1365 + fi
1366 +
1367 + if ! use yassl ; then
1368 + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC )
1369 + else
1370 + mycmakeargs+=( -DWITH_SSL=bundled )
1371 + fi
1372 +
1373 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
1374 + mycmakeargs+=(
1375 + -DWITH_READLINE=$(usex bindist 1 0)
1376 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
1377 + -DENABLE_DTRACE=$(usex systemtap)
1378 + )
1379 +
1380 + if use server ; then
1381 +
1382 + # Federated{,X} must be treated special otherwise they will not be built as plugins
1383 + if ! use extraengine ; then
1384 + mycmakeargs+=(
1385 + -DPLUGIN_FEDERATED=NO
1386 + -DPLUGIN_FEDERATEDX=NO )
1387 + fi
1388 +
1389 + mycmakeargs+=(
1390 + -DWITH_JEMALLOC=$(usex jemalloc system)
1391 + -DWITH_PCRE=system
1392 + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO)
1393 + -DPLUGIN_SPHINX=$(usex sphinx YES NO)
1394 + -DPLUGIN_TOKUDB=$(usex tokudb YES NO)
1395 + -DPLUGIN_AUTH_PAM=$(usex pam YES NO)
1396 + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO)
1397 + -DPLUGIN_CASSANDRA=NO
1398 + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO)
1399 + -DPLUGIN_SPIDER=$(usex extraengine YES NO)
1400 + -DPLUGIN_CONNECT=$(usex extraengine YES NO)
1401 + -DCONNECT_WITH_MYSQL=1
1402 + -DCONNECT_WITH_LIBXML2=$(usex xml)
1403 + -DCONNECT_WITH_ODBC=$(usex odbc)
1404 + -DCONNECT_WITH_JDBC=$(usex jdbc)
1405 + # Build failure and autodep wrt bug 639144
1406 + -DCONNECT_WITH_MONGO=OFF
1407 + -DWITH_WSREP=$(usex galera)
1408 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
1409 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
1410 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
1411 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
1412 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
1413 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
1414 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
1415 + -DINSTALL_SQLBENCHDIR=""
1416 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
1417 + # systemd is only linked to for server notification
1418 + -DWITH_SYSTEMD=$(usex systemd yes no)
1419 + -DWITH_NUMA=$(usex numa ON OFF)
1420 + )
1421 +
1422 + # Workaround for MDEV-14524
1423 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 )
1424 +
1425 + if use test ; then
1426 + # This is needed for the new client lib which tests a real, open server
1427 + mycmakeargs+=( -DSKIP_TESTS=ON )
1428 + fi
1429 +
1430 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
1431 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
1432 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
1433 + ewarn "You MUST file bugs without these variables set."
1434 +
1435 + mycmakeargs+=(
1436 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
1437 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
1438 + )
1439 +
1440 + elif ! use latin1 ; then
1441 + mycmakeargs+=(
1442 + -DDEFAULT_CHARSET=utf8
1443 + -DDEFAULT_COLLATION=utf8_general_ci
1444 + )
1445 + else
1446 + mycmakeargs+=(
1447 + -DDEFAULT_CHARSET=latin1
1448 + -DDEFAULT_COLLATION=latin1_swedish_ci
1449 + )
1450 + fi
1451 + mycmakeargs+=(
1452 + -DEXTRA_CHARSETS=all
1453 + -DMYSQL_USER=mysql
1454 + -DDISABLE_SHARED=$(usex static YES NO)
1455 + -DWITH_DEBUG=$(usex debug)
1456 + -DWITH_EMBEDDED_SERVER=OFF
1457 + -DWITH_PROFILING=$(usex profiling)
1458 + )
1459 +
1460 + if use static; then
1461 + mycmakeargs+=( -DWITH_PIC=1 )
1462 + fi
1463 +
1464 + if use jemalloc || use tcmalloc ; then
1465 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
1466 + fi
1467 +
1468 + # Storage engines
1469 + mycmakeargs+=(
1470 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
1471 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
1472 + -DWITH_CSV_STORAGE_ENGINE=1
1473 + -DWITH_HEAP_STORAGE_ENGINE=1
1474 + -DWITH_INNOBASE_STORAGE_ENGINE=1
1475 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
1476 + -DWITH_MYISAM_STORAGE_ENGINE=1
1477 + -DWITH_PARTITION_STORAGE_ENGINE=1
1478 + )
1479 +
1480 + else
1481 + mycmakeargs+=(
1482 + -DWITHOUT_SERVER=1
1483 + -DWITH_EMBEDDED_SERVER=OFF
1484 + -DEXTRA_CHARSETS=none
1485 + -DINSTALL_SQLBENCHDIR=
1486 + -DWITH_SYSTEMD=no
1487 + )
1488 + fi
1489 +
1490 + cmake-utils_src_configure
1491 +}
1492 +
1493 +src_compile() {
1494 + cmake-utils_src_compile
1495 +}
1496 +
1497 +src_install() {
1498 + cmake-utils_src_install
1499 +
1500 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
1501 + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then
1502 + rm "${ED}/usr/include/mysql/server/private/config.h" || die
1503 + fi
1504 +
1505 + # Make sure the vars are correctly initialized
1506 + mysql_init_vars
1507 +
1508 + # Convenience links
1509 + einfo "Making Convenience links for mysqlcheck multi-call binary"
1510 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
1511 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
1512 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
1513 +
1514 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
1515 + if [[ -d "${ED}/usr/data" ]] ; then
1516 + rm -Rf "${ED}/usr/data" || die
1517 + fi
1518 +
1519 + # Unless they explicitly specific USE=test, then do not install the
1520 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
1521 + # validation of your database configuration after tuning it.
1522 + if ! use test ; then
1523 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
1524 + fi
1525 +
1526 + # Configuration stuff
1527 + einfo "Building default configuration ..."
1528 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
1529 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
1530 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
1531 + eprefixify "${TMPDIR}/my.cnf"
1532 + doins "${TMPDIR}/my.cnf"
1533 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
1534 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
1535 + eprefixify "${TMPDIR}/50-distro-client.cnf"
1536 + doins "${TMPDIR}/50-distro-client.cnf"
1537 +
1538 + if use server ; then
1539 + mycnf_src="my.cnf.distro-server"
1540 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
1541 + "${FILESDIR}/${mycnf_src}" \
1542 + > "${TMPDIR}/my.cnf.ok" || die
1543 + if use prefix ; then
1544 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
1545 + "${TMPDIR}/my.cnf.ok" || die
1546 + fi
1547 + if use latin1 ; then
1548 + sed -i \
1549 + -e "/character-set/s|utf8|latin1|g" \
1550 + "${TMPDIR}/my.cnf.ok" || die
1551 + fi
1552 + eprefixify "${TMPDIR}/my.cnf.ok"
1553 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
1554 +
1555 + einfo "Including support files and sample configurations"
1556 + docinto "support-files"
1557 + local script
1558 + for script in \
1559 + "${S}"/support-files/magic
1560 + do
1561 + [[ -f "$script" ]] && dodoc "${script}"
1562 + done
1563 +
1564 + docinto "scripts"
1565 + for script in "${S}"/scripts/mysql* ; do
1566 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
1567 + done
1568 + # Manually install supporting files that conflict with other packages
1569 + # but are needed for galera and initial installation
1570 + exeinto /usr/libexec/mariadb
1571 + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror"
1572 + fi
1573 +
1574 + #Remove mytop if perl is not selected
1575 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
1576 +}
1577 +
1578 +# Official test instructions:
1579 +# USE='extraengine perl server' \
1580 +# FEATURES='test userpriv -usersandbox' \
1581 +# ebuild mariadb-X.X.XX.ebuild \
1582 +# digest clean package
1583 +src_test() {
1584 +
1585 + _disable_test() {
1586 + local rawtestname reason
1587 + rawtestname="${1}" ; shift
1588 + reason="${@}"
1589 + ewarn "test '${rawtestname}' disabled: '${reason}'"
1590 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
1591 + }
1592 +
1593 + local TESTDIR="${BUILD_DIR}/mysql-test"
1594 + local retstatus_unit
1595 + local retstatus_tests
1596 +
1597 + if ! use server ; then
1598 + einfo "Skipping server tests due to minimal build."
1599 + return 0
1600 + fi
1601 +
1602 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
1603 + # localhost. Also causes weird failures.
1604 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1605 +
1606 + if [[ $UID -eq 0 ]]; then
1607 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
1608 + fi
1609 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
1610 +
1611 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
1612 +
1613 + # Run CTest (test-units)
1614 + cmake-utils_src_test
1615 + retstatus_unit=$?
1616 +
1617 + # Ensure that parallel runs don't die
1618 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
1619 + # Enable parallel testing, auto will try to detect number of cores
1620 + # You may set this by hand.
1621 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
1622 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
1623 +
1624 + # create directories because mysqladmin might run out of order
1625 + mkdir -p "${T}"/var-tests{,/log} || die
1626 +
1627 + # Run mysql tests
1628 + pushd "${TESTDIR}" > /dev/null || die
1629 +
1630 + touch "${T}/disabled.def"
1631 + # These are failing in MariaDB 10.0 for now and are believed to be
1632 + # false positives:
1633 + #
1634 + # main.mysql_client_test, main.mysql_client_test_nonblock
1635 + # main.mysql_client_test_comp:
1636 + # segfaults at random under Portage only, suspect resource limits.
1637 +
1638 + local t
1639 + for t in plugins.cracklib_password_check plugins.two_password_validations ; do
1640 + _disable_test "$t" "False positive due to varying policies"
1641 + done
1642 +
1643 + for t in main.mysql_client_test main.mysql_client_test_nonblock \
1644 + main.mysql_client_test_comp rpl.rpl_extra_col_master_myisam ; do
1645 + _disable_test "$t" "False positives in Gentoo"
1646 + done
1647 +
1648 + _disable_test main.plugin_auth "Needs client libraries built"
1649 +
1650 + _disable_test main.func_time "Dependent on time test was written"
1651 +
1652 + # run mysql-test tests
1653 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
1654 + retstatus_tests=$?
1655 +
1656 + popd > /dev/null || die
1657 +
1658 + # Cleanup is important for these testcases.
1659 + pkill -9 -f "${S}/ndb" 2>/dev/null
1660 + pkill -9 -f "${S}/sql" 2>/dev/null
1661 +
1662 + local failures=""
1663 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
1664 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
1665 +
1666 + [[ -z "$failures" ]] || die "Test failures: $failures"
1667 + einfo "Tests successfully completed"
1668 +}
1669 +
1670 +mysql_init_vars() {
1671 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"}
1672 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
1673 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
1674 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
1675 +
1676 + if [[ -z "${MY_DATADIR}" ]] ; then
1677 + MY_DATADIR=""
1678 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
1679 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
1680 + | sed -ne '/datadir/s|^--datadir=||p' \
1681 + | tail -n1`
1682 + if [[ -z "${MY_DATADIR}" ]] ; then
1683 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
1684 + | sed -e 's/.*=\s*//' \
1685 + | tail -n1`
1686 + fi
1687 + fi
1688 + if [[ -z "${MY_DATADIR}" ]] ; then
1689 + MY_DATADIR="${MY_LOCALSTATEDIR}"
1690 + einfo "Using default MY_DATADIR"
1691 + fi
1692 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
1693 +
1694 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
1695 + if [[ -e "${MY_DATADIR}" ]] ; then
1696 + # If you get this and you're wondering about it, see bug #207636
1697 + elog "MySQL datadir found in ${MY_DATADIR}"
1698 + elog "A new one will not be created."
1699 + PREVIOUS_DATADIR="yes"
1700 + else
1701 + PREVIOUS_DATADIR="no"
1702 + fi
1703 + export PREVIOUS_DATADIR
1704 + fi
1705 + else
1706 + if [[ ${EBUILD_PHASE} == "config" ]]; then
1707 + local new_MY_DATADIR
1708 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
1709 + | sed -ne '/datadir/s|^--datadir=||p' \
1710 + | tail -n1`
1711 +
1712 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
1713 + ewarn "MySQL MY_DATADIR has changed"
1714 + ewarn "from ${MY_DATADIR}"
1715 + ewarn "to ${new_MY_DATADIR}"
1716 + MY_DATADIR="${new_MY_DATADIR}"
1717 + fi
1718 + fi
1719 + fi
1720 +
1721 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
1722 + export MY_LOCALSTATEDIR MY_LOGDIR
1723 + export MY_DATADIR
1724 +}
1725 +
1726 +pkg_config() {
1727 + _getoptval() {
1728 + local mypd="${EROOT}"/usr/bin/my_print_defaults
1729 + local section="$1"
1730 + local flag="--${2}="
1731 + local extra_options="${3}"
1732 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
1733 + }
1734 + local old_MY_DATADIR="${MY_DATADIR}"
1735 + local old_HOME="${HOME}"
1736 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
1737 + export HOME=${EPREFIX}/root
1738 +
1739 + # Make sure the vars are correctly initialized
1740 + mysql_init_vars
1741 +
1742 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
1743 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
1744 + die "Minimal builds do NOT include the MySQL server"
1745 + fi
1746 +
1747 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
1748 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
1749 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
1750 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
1751 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
1752 +
1753 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
1754 + if [[ -d "${MY_DATADIR_s}" ]]; then
1755 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
1756 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
1757 + else
1758 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
1759 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
1760 + || die "Moving MY_DATADIR failed"
1761 + fi
1762 + else
1763 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
1764 + if [[ -d "${MY_DATADIR_s}" ]]; then
1765 + ewarn "Attempting to use ${MY_DATADIR_s}"
1766 + else
1767 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
1768 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
1769 + fi
1770 + fi
1771 + fi
1772 +
1773 + local pwd1="a"
1774 + local pwd2="b"
1775 + local maxtry=15
1776 +
1777 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1778 + local tmp_mysqld_password_source=
1779 +
1780 + for tmp_mysqld_password_source in mysql client; do
1781 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
1782 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
1783 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
1784 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
1785 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
1786 + MYSQL_ROOT_PASSWORD=
1787 + continue
1788 + fi
1789 +
1790 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
1791 + break
1792 + fi
1793 + done
1794 +
1795 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
1796 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
1797 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
1798 + fi
1799 +
1800 + unset tmp_mysqld_password_source
1801 + fi
1802 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
1803 + # These are dir+prefix
1804 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
1805 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
1806 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
1807 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
1808 +
1809 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
1810 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
1811 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
1812 + fi
1813 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
1814 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
1815 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
1816 + fi
1817 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
1818 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
1819 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
1820 + fi
1821 +
1822 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
1823 + ewarn "You have already a MySQL database in place."
1824 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
1825 + ewarn "Please rename or delete it if you wish to replace it."
1826 + die "MySQL database already exists!"
1827 + fi
1828 +
1829 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
1830 + # localhost. Also causes weird failures.
1831 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1832 +
1833 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1834 +
1835 + einfo "Please provide a password for the mysql 'root' user now"
1836 + einfo "or through the ${HOME}/.my.cnf file."
1837 + ewarn "Avoid [\"'\\_%] characters in the password"
1838 + read -rsp " >" pwd1 ; echo
1839 +
1840 + einfo "Retype the password"
1841 + read -rsp " >" pwd2 ; echo
1842 +
1843 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
1844 + die "Passwords are not the same"
1845 + fi
1846 + MYSQL_ROOT_PASSWORD="${pwd1}"
1847 + unset pwd1 pwd2
1848 + fi
1849 +
1850 + local options
1851 + local sqltmp="$(emktemp)"
1852 +
1853 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
1854 + # see https://bugs.mysql.com/bug.php?id=31312
1855 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
1856 +
1857 + # Figure out which options we need to disable to do the setup
1858 + local helpfile="${TMPDIR}/mysqld-help"
1859 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
1860 + for opt in grant-tables host-cache name-resolve networking slave-start \
1861 + federated ssl log-bin relay-log slow-query-log external-locking \
1862 + log-slave-updates \
1863 + ; do
1864 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1865 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
1866 + done
1867 +
1868 + einfo "Creating the mysql database and setting proper permissions on it ..."
1869 +
1870 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
1871 + PID_DIR="${EROOT}/var/run/mysqld"
1872 + if [[ ! -d "${PID_DIR}" ]]; then
1873 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
1874 + fi
1875 +
1876 + if [[ ! -d "${MY_DATADIR}" ]]; then
1877 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
1878 + fi
1879 +
1880 + pushd "${TMPDIR}" &>/dev/null || die
1881 +
1882 + # Filling timezones, see
1883 + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
1884 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
1885 +
1886 + local cmd=( "${EROOT}usr/share/mariadb/scripts/mysql_install_db" )
1887 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
1888 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
1889 + einfo "Command: ${cmd[*]}"
1890 + su -s /bin/sh -c "${cmd[*]}" mysql \
1891 + >"${TMPDIR}"/mysql_install_db.log 2>&1
1892 + if [ $? -ne 0 ]; then
1893 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1894 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1895 + fi
1896 + popd &>/dev/null || die
1897 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1898 + || die "MySQL databases not installed"
1899 +
1900 + use prefix || options="${options} --user=mysql"
1901 +
1902 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1903 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1904 + local mysqld="${EROOT}/usr/sbin/mysqld \
1905 + ${options} \
1906 + --log-warnings=0 \
1907 + --basedir=${EROOT}/usr \
1908 + --datadir=${ROOT}/${MY_DATADIR} \
1909 + --max_allowed_packet=8M \
1910 + --net_buffer_length=16K \
1911 + --socket=${socket} \
1912 + --pid-file=${pidfile} \
1913 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
1914 + #einfo "About to start mysqld: ${mysqld}"
1915 + ebegin "Starting mysqld"
1916 + einfo "Command ${mysqld}"
1917 + ${mysqld} &
1918 + rc=$?
1919 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1920 + maxtry=$((${maxtry}-1))
1921 + echo -n "."
1922 + sleep 1
1923 + done
1924 + eend $rc
1925 +
1926 + if ! [[ -S "${socket}" ]]; then
1927 + die "Completely failed to start up mysqld with: ${mysqld}"
1928 + fi
1929 +
1930 + ebegin "Setting root password"
1931 + # Do this from memory, as we don't want clear text passwords in temp files
1932 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
1933 + "${EROOT}/usr/bin/mysql" \
1934 + "--socket=${socket}" \
1935 + -hlocalhost \
1936 + -e "${sql}"
1937 + eend $?
1938 +
1939 + if [[ -n "${sqltmp}" ]] ; then
1940 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1941 + "${EROOT}/usr/bin/mysql" \
1942 + "--socket=${socket}" \
1943 + -hlocalhost \
1944 + -uroot \
1945 + --password="${MYSQL_ROOT_PASSWORD}" \
1946 + mysql < "${sqltmp}"
1947 + rc=$?
1948 + eend $?
1949 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1950 + fi
1951 +
1952 + # Stop the server and cleanup
1953 + einfo "Stopping the server ..."
1954 + kill $(< "${pidfile}" )
1955 + rm -f "${sqltmp}"
1956 + wait %1
1957 + einfo "Done"
1958 +}