Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/mariadb/
Date: Wed, 07 Oct 2020 22:30:35
Message-Id: 1602109808.2fec4b7f088c27ec110fd5249287b900a72c5c5e.whissi@gentoo
1 commit: 2fec4b7f088c27ec110fd5249287b900a72c5c5e
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Wed Oct 7 21:28:25 2020 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Wed Oct 7 22:30:08 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2fec4b7f
7
8 dev-db/mariadb: bump to v10.4.15
9
10 Bug: https://bugs.gentoo.org/747166
11 Package-Manager: Portage-3.0.8, Repoman-3.0.1
12 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
13
14 dev-db/mariadb/Manifest | 1 +
15 dev-db/mariadb/mariadb-10.4.15.ebuild | 1038 +++++++++++++++++++++++++++++++++
16 2 files changed, 1039 insertions(+)
17
18 diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest
19 index ec1d43afe5a..1b56301354c 100644
20 --- a/dev-db/mariadb/Manifest
21 +++ b/dev-db/mariadb/Manifest
22 @@ -16,6 +16,7 @@ DIST mariadb-10.4.13-patches-03.tar.xz 5520 BLAKE2B 949b7f6ee5a9a6077424264e53d2
23 DIST mariadb-10.4.13.tar.gz 80608459 BLAKE2B e9ada14da6ec7492311068549a5b6e5a66e1177312013b25472c084a21fbace543ec43b47f2e12190d45432648d508f311198521f42359561f8d75ea60f98205 SHA512 68919ceffb3d4afdd0d94daa77439a954c82ce4e08fbe06044fc397940eeb88a39ec75932cbd08ff26ef3cf7636fdb779947cda5b2764aa1fd888be19c44b566
24 DIST mariadb-10.4.14-patches-01.tar.xz 5512 BLAKE2B f32e1d383ffd99de431bc34c36101c71c5e631344527e96b80ca6bd0a68015b45a4c33d6f0518cb4aa2bcfd493b64b6607671450ca045243404c0d65ebbc66fd SHA512 201fe82cbcca705dba52b32405d463b5569d97a5ffd9fd2967ec7fc3c3ff305011b3d2c3c0e9f7c19aaac57b26661bd361f3b6da6f3812f25934ec18856c7051
25 DIST mariadb-10.4.14.tar.gz 80789865 BLAKE2B fed455e906af9fe105f52cc7180a6b8d8839fdbffac079f2ced265741c2ab8010c78c0e75ff77740d45a2bd02a15c379bdb3a0237152848a0ce1a7aaac4cbf32 SHA512 c09817c1dd7962132bcf2886c97ad17ce43c00ee687724028e5f39f6a6a93877ae8695c2c795abba6a4f3bc40674f93a53d6d43f46788a4a8a42c4a65a22c91c
26 +DIST mariadb-10.4.15.tar.gz 80777094 BLAKE2B 576e06c1d62b399851e13fe0ac55ea94c462889bbd16ec25a2358e174e2822521008ad0dc021d742b1a12c5b22424208b6df92c2c0fb698a083b6a67a771bd64 SHA512 d7090e9e2a2b6fc5611fe498c44b00dbcd02e04456aaff3dc4cef7ef8cd284523776d01511f6f25f717306f6c49fca3f914d298f80e1c920cb6f9f87abebc0ca
27 DIST mariadb-10.5.5-patches-02.tar.xz 6060 BLAKE2B 185a2016836721f76c19228ca39c1c7610c34210e23b42f254e4c4fde34c74d9c77bb0d1a441175c14938ecafea3e9575fa3b7349db826aef63e7d7e7a21901a SHA512 8a26bdbec19d45739ef7accd3cea999bde465714141532d999500df2ebd93bb98a00b8b86b1e855ea4f0cba6984b21ff09beee75372f840282a91f5dc95db432
28 DIST mariadb-10.5.5.tar.gz 86880268 BLAKE2B 58430dd4e7199d674bbd4f7381a56129e067ed1bb30c171545fe9fac3a83f7db2c57cc1b577ef242deb99dd69e17a1d3cbf756031711d27b04c97a7e93e14c60 SHA512 09bed291b39142f8e2f40eabbb443f6f384368b331406a09fd92d3d27ecc75644219066850d89495ed65c6f0d3ac32d51e29e65375331dcc2de4801313178d45
29 DIST mariadb-10.5.6.tar.gz 86884252 BLAKE2B b0230acf43d54e976c4e757139dbaa2bb6ed992b0d056728142fc7fa41bd62539be22eae5aac614ea49acf220646ee57ecc67ff1373c6aa142434e6743a4d174 SHA512 c62bd6278d389baf179962bc6f617693cf3ba748382e96963b1ef5bbee8d1c9f0964025cf00fb7ff5de088a79362b65657ed30a8adbb61fe524bfd0d8d753421
30
31 diff --git a/dev-db/mariadb/mariadb-10.4.15.ebuild b/dev-db/mariadb/mariadb-10.4.15.ebuild
32 new file mode 100644
33 index 00000000000..2f7ec2673f4
34 --- /dev/null
35 +++ b/dev-db/mariadb/mariadb-10.4.15.ebuild
36 @@ -0,0 +1,1038 @@
37 +# Copyright 1999-2020 Gentoo Authors
38 +# Distributed under the terms of the GNU General Public License v2
39 +
40 +EAPI="7"
41 +SUBSLOT="18"
42 +
43 +JAVA_PKG_OPT_USE="jdbc"
44 +
45 +inherit eutils systemd flag-o-matic prefix toolchain-funcs \
46 + multiprocessing java-pkg-opt-2 cmake
47 +
48 +# Patch version
49 +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.14-patches-01.tar.xz"
50 +
51 +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz
52 + ${PATCH_SET}"
53 +
54 +HOMEPAGE="https://mariadb.org/"
55 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
56 +LICENSE="GPL-2 LGPL-2.1+"
57 +SLOT="10.4/${SUBSLOT:-0}"
58 +IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4
59 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 libressl mroonga
60 + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx
61 + sst-rsync sst-mariabackup static systemd systemtap tcmalloc
62 + test tokudb xml yassl"
63 +
64 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
65 +RESTRICT="!bindist? ( bindist ) libressl? ( test ) !test? ( test )"
66 +
67 +REQUIRED_USE="jdbc? ( extraengine server !static )
68 + server? ( tokudb? ( jemalloc !tcmalloc ) )
69 + ?? ( tcmalloc jemalloc )
70 + static? ( yassl !pam )"
71 +
72 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
73 +
74 +# Shorten the path because the socket path length must be shorter than 107 chars
75 +# and we will run a mysql server during test phase
76 +S="${WORKDIR}/mysql"
77 +
78 +# Be warned, *DEPEND are version-dependant
79 +# These are used for both runtime and compiletime
80 +COMMON_DEPEND="
81 + kernel_linux? (
82 + sys-process/procps:0=
83 + dev-libs/libaio:0=
84 + )
85 + >=sys-apps/sed-4
86 + >=sys-apps/texinfo-4.7-r1
87 + jemalloc? ( dev-libs/jemalloc:0= )
88 + tcmalloc? ( dev-util/google-perftools:0= )
89 + systemtap? ( >=dev-util/systemtap-1.3:0= )
90 + >=sys-libs/zlib-1.2.3:0=
91 + kerberos? ( virtual/krb5 )
92 + yassl? ( net-libs/gnutls:0= )
93 + !yassl? (
94 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
95 + libressl? ( dev-libs/libressl:0= )
96 + )
97 + sys-libs/ncurses:0=
98 + !bindist? (
99 + sys-libs/binutils-libs:0=
100 + >=sys-libs/readline-4.1:0=
101 + )
102 + server? (
103 + backup? ( app-arch/libarchive:0= )
104 + cracklib? ( sys-libs/cracklib:0= )
105 + extraengine? (
106 + odbc? ( dev-db/unixODBC:0= )
107 + xml? ( dev-libs/libxml2:2= )
108 + )
109 + innodb-lz4? ( app-arch/lz4 )
110 + innodb-lzo? ( dev-libs/lzo )
111 + innodb-snappy? ( app-arch/snappy )
112 + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 )
113 + numa? ( sys-process/numactl )
114 + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= )
115 + pam? ( sys-libs/pam:0= )
116 + systemd? ( sys-apps/systemd:= )
117 + tokudb? ( app-arch/snappy )
118 + )
119 + >=dev-libs/libpcre-8.41-r1:3=
120 +"
121 +BDEPEND="virtual/yacc
122 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
123 +"
124 +DEPEND="static? ( sys-libs/ncurses[static-libs] )
125 + server? (
126 + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) )
127 + test? ( acct-group/mysql acct-user/mysql )
128 + )
129 + ${COMMON_DEPEND}"
130 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
131 + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
132 + !dev-db/mariadb:0
133 + !dev-db/mariadb:5.5
134 + !dev-db/mariadb:10.1
135 + !dev-db/mariadb:10.2
136 + !dev-db/mariadb:10.3
137 + !dev-db/mariadb:10.5
138 + !<virtual/mysql-5.6-r11
139 + !<virtual/libmysqlclient-18-r1
140 + ${COMMON_DEPEND}
141 + server? (
142 + galera? (
143 + sys-apps/iproute2
144 + =sys-cluster/galera-26*
145 + sst-rsync? ( sys-process/lsof )
146 + sst-mariabackup? ( net-misc/socat[ssl] )
147 + )
148 + !prefix? ( dev-db/mysql-init-scripts acct-group/mysql acct-user/mysql )
149 + extraengine? ( jdbc? ( >=virtual/jre-1.6 ) )
150 + )
151 + perl? (
152 + !dev-db/mytop
153 + virtual/perl-Getopt-Long
154 + dev-perl/TermReadKey
155 + virtual/perl-Term-ANSIColor
156 + virtual/perl-Time-HiRes
157 + )
158 +"
159 +# For other stuff to bring us in
160 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
161 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
162 +
163 +mysql_init_vars() {
164 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"}
165 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
166 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
167 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
168 +
169 + if [[ -z "${MY_DATADIR}" ]] ; then
170 + MY_DATADIR=""
171 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
172 + MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \
173 + | sed -ne '/datadir/s|^--datadir=||p' \
174 + | tail -n1)
175 + if [[ -z "${MY_DATADIR}" ]] ; then
176 + MY_DATADIR=$(grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
177 + | sed -e 's/.*=\s*//' \
178 + | tail -n1)
179 + fi
180 + fi
181 + if [[ -z "${MY_DATADIR}" ]] ; then
182 + MY_DATADIR="${MY_LOCALSTATEDIR}"
183 + einfo "Using default MY_DATADIR"
184 + fi
185 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
186 +
187 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
188 + if [[ -e "${MY_DATADIR}" ]] ; then
189 + # If you get this and you're wondering about it, see bug #207636
190 + elog "MySQL datadir found in ${MY_DATADIR}"
191 + elog "A new one will not be created."
192 + PREVIOUS_DATADIR="yes"
193 + else
194 + PREVIOUS_DATADIR="no"
195 + fi
196 + export PREVIOUS_DATADIR
197 + fi
198 + else
199 + if [[ ${EBUILD_PHASE} == "config" ]]; then
200 + local new_MY_DATADIR
201 + new_MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \
202 + | sed -ne '/datadir/s|^--datadir=||p' \
203 + | tail -n1)
204 +
205 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
206 + ewarn "MySQL MY_DATADIR has changed"
207 + ewarn "from ${MY_DATADIR}"
208 + ewarn "to ${new_MY_DATADIR}"
209 + MY_DATADIR="${new_MY_DATADIR}"
210 + fi
211 + fi
212 + fi
213 +
214 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
215 + export MY_LOCALSTATEDIR MY_LOGDIR
216 + export MY_DATADIR
217 +}
218 +
219 +pkg_setup() {
220 + if [[ ${MERGE_TYPE} != binary ]] ; then
221 + local GCC_MAJOR_SET=$(gcc-major-version)
222 + local GCC_MINOR_SET=$(gcc-minor-version)
223 +
224 + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
225 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
226 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
227 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
228 + die
229 + fi
230 +
231 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
232 + # non x86{,_64} arches
233 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
234 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
235 + eerror "${PN} needs to be built with gcc-4.7 or later."
236 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
237 + die
238 + fi
239 +
240 + if has test ${FEATURES} ; then
241 + # Bug #213475 - MySQL _will_ object strenuously if your machine is named
242 + # localhost. Also causes weird failures.
243 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
244 +
245 + if ! has userpriv ${FEATURES} ; then
246 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
247 + fi
248 + fi
249 + fi
250 +
251 + java-pkg-opt-2_pkg_setup
252 +}
253 +
254 +src_unpack() {
255 + unpack ${A}
256 +
257 + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die
258 +}
259 +
260 +src_prepare() {
261 + eapply "${WORKDIR}"/mariadb-patches
262 +
263 + eapply_user
264 +
265 + _disable_plugin() {
266 + echo > "${S}/plugin/${1}/CMakeLists.txt" || die
267 + }
268 + _disable_engine() {
269 + echo > "${S}/storage/${1}/CMakeLists.txt" || die
270 + }
271 +
272 + if use jemalloc; then
273 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt"
274 + elif use tcmalloc; then
275 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
276 + fi
277 +
278 + # Don't build bundled xz-utils for tokudb
279 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
280 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
281 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
282 +
283 + local plugin
284 + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info
285 + locale_info qc_info server_audit sql_errlog auth_ed25519 )
286 + local test_plugins=( audit_null auth_examples daemon_example fulltext
287 + debug_key_management example_key_management versioning )
288 + if ! use server; then # These plugins are for the server
289 + for plugin in "${server_plugins[@]}" ; do
290 + _disable_plugin "${plugin}"
291 + done
292 + fi
293 +
294 + if ! use test; then # These plugins are only used during testing
295 + for plugin in "${test_plugins[@]}" ; do
296 + _disable_plugin "${plugin}"
297 + done
298 + _disable_engine test_sql_discovery
299 + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die
300 + fi
301 +
302 + _disable_engine example
303 +
304 + if ! use oqgraph ; then # avoids extra library checks
305 + _disable_engine oqgraph
306 + fi
307 +
308 + if use mroonga ; then
309 + # Remove the bundled groonga
310 + # There is no CMake flag, it simply checks for existance
311 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
312 + else
313 + _disable_engine mroonga
314 + fi
315 +
316 + # Fix static bindings in galera replication
317 + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \
318 + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die
319 + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \
320 + "${S}"/wsrep-lib/src/CMakeLists.txt || die
321 +
322 + # Fix galera_recovery.sh script
323 + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \
324 + scripts/galera_recovery.sh || die
325 +
326 + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \
327 + "${S}"/scripts/mysql_install_db.sh || die
328 +
329 + cmake_src_prepare
330 + java-pkg-opt-2_src_prepare
331 +}
332 +
333 +src_configure() {
334 + # bug 508724 mariadb cannot use ld.gold
335 + tc-ld-disable-gold
336 + # Bug #114895, bug #110149
337 + filter-flags "-O" "-O[01]"
338 +
339 + # It fails on alpha without this
340 + use alpha && append-ldflags "-Wl,--no-relax"
341 +
342 + append-cxxflags -felide-constructors
343 +
344 + # bug #283926, with GCC4.4, this is required to get correct behavior.
345 + append-flags -fno-strict-aliasing
346 +
347 + CMAKE_BUILD_TYPE="RelWithDebInfo"
348 +
349 + # debug hack wrt #497532
350 + mycmakeargs=(
351 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
352 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
353 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
354 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
355 + -DINSTALL_BINDIR=bin
356 + -DINSTALL_DOCDIR=share/doc/${PF}
357 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
358 + -DINSTALL_INCLUDEDIR=include/mysql
359 + -DINSTALL_INFODIR=share/info
360 + -DINSTALL_LIBDIR=$(get_libdir)
361 + -DINSTALL_MANDIR=share/man
362 + -DINSTALL_MYSQLSHAREDIR=share/mariadb
363 + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin
364 + -DINSTALL_SCRIPTDIR=share/mariadb/scripts
365 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
366 + -DINSTALL_SBINDIR=sbin
367 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb"
368 + -DWITH_COMMENT="Gentoo Linux ${PF}"
369 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
370 + -DWITH_LIBEDIT=0
371 + -DWITH_ZLIB=system
372 + -DWITHOUT_LIBWRAP=1
373 + -DENABLED_LOCAL_INFILE=1
374 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
375 + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock"
376 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
377 + -DWITH_DEFAULT_FEATURE_SET=0
378 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
379 + # The build forces this to be defined when cross-compiling. We pass it
380 + # all the time for simplicity and to make sure it is actually correct.
381 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
382 + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
383 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
384 + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF)
385 + -DCONC_WITH_EXTERNAL_ZLIB=YES
386 + -DWITH_EXTERNAL_ZLIB=YES
387 + -DSUFFIX_INSTALL_DIR=""
388 + -DWITH_UNITTEST=OFF
389 + -DWITHOUT_CLIENTLIBS=YES
390 + -DCLIENT_PLUGIN_DIALOG=OFF
391 + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF
392 + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF
393 + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC
394 + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF
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_PCRE=system
426 + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO)
427 + -DPLUGIN_SPHINX=$(usex sphinx YES NO)
428 + -DPLUGIN_TOKUDB=$(usex tokudb YES NO)
429 + -DPLUGIN_AUTH_PAM=$(usex pam YES NO)
430 + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO)
431 + -DPLUGIN_CASSANDRA=NO
432 + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO)
433 + -DPLUGIN_SPIDER=$(usex extraengine YES NO)
434 + -DPLUGIN_CONNECT=$(usex extraengine YES NO)
435 + -DCONNECT_WITH_MYSQL=1
436 + -DCONNECT_WITH_LIBXML2=$(usex xml)
437 + -DCONNECT_WITH_ODBC=$(usex odbc)
438 + -DCONNECT_WITH_JDBC=$(usex jdbc)
439 + # Build failure and autodep wrt bug 639144
440 + -DCONNECT_WITH_MONGO=OFF
441 + -DWITH_WSREP=$(usex galera)
442 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
443 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
444 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
445 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
446 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
447 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
448 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
449 + -DINSTALL_SQLBENCHDIR=""
450 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
451 + # systemd is only linked to for server notification
452 + -DWITH_SYSTEMD=$(usex systemd yes no)
453 + -DWITH_NUMA=$(usex numa ON OFF)
454 + )
455 +
456 + # Workaround for MDEV-14524
457 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 )
458 +
459 + if use test ; then
460 + # This is needed for the new client lib which tests a real, open server
461 + mycmakeargs+=( -DSKIP_TESTS=ON )
462 + fi
463 +
464 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
465 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
466 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
467 + ewarn "You MUST file bugs without these variables set."
468 +
469 + mycmakeargs+=(
470 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
471 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
472 + )
473 +
474 + elif ! use latin1 ; then
475 + mycmakeargs+=(
476 + -DDEFAULT_CHARSET=utf8
477 + -DDEFAULT_COLLATION=utf8_general_ci
478 + )
479 + else
480 + mycmakeargs+=(
481 + -DDEFAULT_CHARSET=latin1
482 + -DDEFAULT_COLLATION=latin1_swedish_ci
483 + )
484 + fi
485 + mycmakeargs+=(
486 + -DEXTRA_CHARSETS=all
487 + -DMYSQL_USER=mysql
488 + -DDISABLE_SHARED=$(usex static YES NO)
489 + -DWITH_DEBUG=$(usex debug)
490 + -DWITH_EMBEDDED_SERVER=OFF
491 + -DWITH_PROFILING=$(usex profiling)
492 + )
493 +
494 + if use static; then
495 + mycmakeargs+=( -DWITH_PIC=1 )
496 + fi
497 +
498 + if use jemalloc || use tcmalloc ; then
499 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
500 + fi
501 +
502 + # Storage engines
503 + mycmakeargs+=(
504 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
505 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
506 + -DWITH_CSV_STORAGE_ENGINE=1
507 + -DWITH_HEAP_STORAGE_ENGINE=1
508 + -DWITH_INNOBASE_STORAGE_ENGINE=1
509 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
510 + -DWITH_MYISAM_STORAGE_ENGINE=1
511 + -DWITH_PARTITION_STORAGE_ENGINE=1
512 + )
513 +
514 + else
515 + mycmakeargs+=(
516 + -DWITHOUT_SERVER=1
517 + -DWITH_EMBEDDED_SERVER=OFF
518 + -DEXTRA_CHARSETS=none
519 + -DINSTALL_SQLBENCHDIR=
520 + -DWITH_SYSTEMD=no
521 + )
522 + fi
523 +
524 + cmake_src_configure
525 +}
526 +
527 +src_compile() {
528 + cmake_src_compile
529 +}
530 +
531 +# Official test instructions:
532 +# USE='extraengine perl server' \
533 +# FEATURES='test userpriv' \
534 +# ebuild mariadb-X.X.XX.ebuild \
535 +# digest clean package
536 +src_test() {
537 + _disable_test() {
538 + local rawtestname bug reason
539 + rawtestname="${1}" ; shift
540 + bug="${1}" ; shift
541 + reason="${@}"
542 + ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
543 + echo "${rawtestname} : BUG#${bug} ${reason}" >> "${T}/disabled.def"
544 + }
545 +
546 + local TESTDIR="${BUILD_DIR}/mysql-test"
547 + local retstatus_unit
548 + local retstatus_tests
549 +
550 + if ! use server ; then
551 + einfo "Skipping server tests due to minimal build."
552 + return 0
553 + fi
554 +
555 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
556 +
557 + # Run CTest (test-units)
558 + cmake_src_test
559 + retstatus_unit=$?
560 +
561 + # Ensure that parallel runs don't die
562 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
563 +
564 + if [[ -z "${MTR_PARALLEL}" ]] ; then
565 + local -x MTR_PARALLEL=$(makeopts_jobs)
566 +
567 + if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
568 + # Running multiple tests in parallel usually require higher ulimit
569 + # and fs.aio-max-nr setting. In addition, tests like main.multi_update
570 + # are known to hit timeout when system is busy.
571 + # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
572 + # using "auto".
573 + local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
574 + info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
575 + einfo "${info_msg}"
576 + unset info_msg
577 + MTR_PARALLEL=4
578 + fi
579 + else
580 + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
581 + fi
582 +
583 + # Try to increase file limits to increase test coverage
584 + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
585 + # Upper limit comes from parts.partition_* tests
586 + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
587 +
588 + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
589 + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
590 + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
591 +
592 + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
593 + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
594 + else
595 + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
596 + fi
597 + else
598 + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
599 + fi
600 + else
601 + einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
602 + fi
603 +
604 + # create directories because mysqladmin might run out of order
605 + mkdir -p "${T}"/var-tests{,/log} || die
606 +
607 + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die
608 +
609 + local -a disabled_tests
610 + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" )
611 + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" )
612 + disabled_tests+=( "main.func_time;0;Dependent on time test was written" )
613 + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" )
614 + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" )
615 + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" )
616 + disabled_tests+=( "mariabackup.*;0;Broken test suite" )
617 + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" )
618 + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" )
619 + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" )
620 + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" )
621 + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" )
622 +
623 + if ! use latin1 ; then
624 + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" )
625 + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" )
626 + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" )
627 + fi
628 +
629 + local test_infos_str test_infos_arr
630 + for test_infos_str in "${disabled_tests[@]}" ; do
631 + IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
632 +
633 + if [[ ${#test_infos_arr[@]} != 3 ]] ; then
634 + die "Invalid test data set, not matching format: ${test_infos_str}"
635 + fi
636 +
637 + _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
638 + done
639 + unset test_infos_str test_infos_arr
640 +
641 + # run mysql-test tests
642 + pushd "${TESTDIR}" &>/dev/null || die
643 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
644 + retstatus_tests=$?
645 +
646 + popd &>/dev/null || die
647 +
648 + # Cleanup is important for these testcases.
649 + pkill -9 -f "${S}/ndb" 2>/dev/null
650 + pkill -9 -f "${S}/sql" 2>/dev/null
651 +
652 + local failures=""
653 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
654 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
655 +
656 + [[ -z "$failures" ]] || die "Test failures: $failures"
657 + einfo "Tests successfully completed"
658 +}
659 +
660 +src_install() {
661 + cmake_src_install
662 +
663 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
664 + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then
665 + rm "${ED}/usr/include/mysql/server/private/config.h" || die
666 + fi
667 +
668 + # Make sure the vars are correctly initialized
669 + mysql_init_vars
670 +
671 + # Convenience links
672 + einfo "Making Convenience links for mysqlcheck multi-call binary"
673 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
674 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
675 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
676 +
677 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
678 + if [[ -d "${ED}/usr/data" ]] ; then
679 + rm -Rf "${ED}/usr/data" || die
680 + fi
681 +
682 + # Unless they explicitly specific USE=test, then do not install the
683 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
684 + # validation of your database configuration after tuning it.
685 + if ! use test ; then
686 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
687 + fi
688 +
689 + # Configuration stuff
690 + einfo "Building default configuration ..."
691 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
692 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
693 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
694 + eprefixify "${TMPDIR}/my.cnf"
695 + doins "${TMPDIR}/my.cnf"
696 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
697 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
698 + eprefixify "${TMPDIR}/50-distro-client.cnf"
699 + doins "${TMPDIR}/50-distro-client.cnf"
700 +
701 + if use server ; then
702 + mycnf_src="my.cnf.distro-server"
703 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
704 + "${FILESDIR}/${mycnf_src}" \
705 + > "${TMPDIR}/my.cnf.ok" || die
706 + if use prefix ; then
707 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
708 + "${TMPDIR}/my.cnf.ok" || die
709 + fi
710 + if use latin1 ; then
711 + sed -i \
712 + -e "/character-set/s|utf8|latin1|g" \
713 + "${TMPDIR}/my.cnf.ok" || die
714 + fi
715 + eprefixify "${TMPDIR}/my.cnf.ok"
716 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
717 +
718 + einfo "Including support files and sample configurations"
719 + docinto "support-files"
720 + local script
721 + for script in \
722 + "${S}"/support-files/magic
723 + do
724 + [[ -f "$script" ]] && dodoc "${script}"
725 + done
726 +
727 + docinto "scripts"
728 + for script in "${S}"/scripts/mysql* ; do
729 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
730 + done
731 + # Manually install supporting files that conflict with other packages
732 + # but are needed for galera and initial installation
733 + exeinto /usr/libexec/mariadb
734 + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror"
735 +
736 + if use pam ; then
737 + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir
738 + fi
739 + fi
740 +
741 + # Remove mytop if perl is not selected
742 + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then
743 + rm -f "${ED}/usr/bin/mytop" || die
744 + fi
745 +
746 + # Fix a dangling symlink when galera is not built
747 + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then
748 + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die
749 + fi
750 +
751 + # Remove broken SST scripts that are incompatible
752 + local scriptremove
753 + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do
754 + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then
755 + rm "${ED}/usr/bin/${scriptremove}" || die
756 + fi
757 + done
758 +}
759 +
760 +pkg_preinst() {
761 + java-pkg-opt-2_pkg_preinst
762 +}
763 +
764 +pkg_postinst() {
765 + # Make sure the vars are correctly initialized
766 + mysql_init_vars
767 +
768 + # Create log directory securely if it does not exist
769 + [[ -d "${ROOT}/${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}/${MY_LOGDIR}"
770 +
771 + if use server ; then
772 + if use pam; then
773 + einfo
774 + elog "This install includes the PAM authentication plugin."
775 + elog "To activate and configure the PAM plugin, please read:"
776 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
777 + einfo
778 + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die
779 + fi
780 +
781 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
782 + einfo
783 + elog "You might want to run:"
784 + elog "\"emerge --config =${CATEGORY}/${PF}\""
785 + elog "if this is a new install."
786 + elog
787 + elog "If you are switching server implentations, you should run the"
788 + elog "mysql_upgrade tool."
789 + einfo
790 + else
791 + einfo
792 + elog "If you are upgrading major versions, you should run the"
793 + elog "mysql_upgrade tool."
794 + einfo
795 + fi
796 +
797 + if use galera ; then
798 + einfo
799 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
800 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
801 + elog "The first time the cluster is activated, you should add"
802 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
803 + elog "This option should then be removed for subsequent starts."
804 + einfo
805 + if [[ -n "${REPLACING_VERSIONS}" ]] ; then
806 + local rver
807 + for rver in ${REPLACING_VERSIONS} ; do
808 + if ver_test "${rver}" -lt "10.4.0" ; then
809 + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster."
810 + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4"
811 + ewarn "for more information"
812 + fi
813 + done
814 + fi
815 + fi
816 + fi
817 +
818 + # Note about configuration change
819 + einfo
820 + elog "This version of mariadb reorganizes the configuration from a single my.cnf"
821 + elog "to several files in /etc/mysql/${PN}.d."
822 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
823 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
824 + elog "You may have as many files as needed and they are read alphabetically."
825 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
826 + einfo
827 +}
828 +
829 +pkg_config() {
830 + _getoptval() {
831 + local mypd="${EROOT}"/usr/libexec/mariadb/my_print_defaults
832 + local section="$1"
833 + local flag="--${2}="
834 + local extra_options="${3}"
835 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
836 + }
837 + local old_MY_DATADIR="${MY_DATADIR}"
838 + local old_HOME="${HOME}"
839 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
840 + export HOME=${EPREFIX}/root
841 +
842 + # Make sure the vars are correctly initialized
843 + mysql_init_vars
844 +
845 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
846 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
847 + die "Minimal builds do NOT include the MySQL server"
848 + fi
849 +
850 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
851 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
852 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
853 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
854 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
855 +
856 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
857 + if [[ -d "${MY_DATADIR_s}" ]]; then
858 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
859 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
860 + else
861 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
862 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
863 + || die "Moving MY_DATADIR failed"
864 + fi
865 + else
866 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
867 + if [[ -d "${MY_DATADIR_s}" ]]; then
868 + ewarn "Attempting to use ${MY_DATADIR_s}"
869 + else
870 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
871 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
872 + fi
873 + fi
874 + fi
875 +
876 + local pwd1="a"
877 + local pwd2="b"
878 + local maxtry=15
879 +
880 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
881 + local tmp_mysqld_password_source=
882 +
883 + for tmp_mysqld_password_source in mysql client; do
884 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
885 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
886 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
887 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
888 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
889 + MYSQL_ROOT_PASSWORD=
890 + continue
891 + fi
892 +
893 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
894 + break
895 + fi
896 + done
897 +
898 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
899 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
900 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
901 + fi
902 +
903 + unset tmp_mysqld_password_source
904 + fi
905 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir | tail -n1)"
906 + # These are dir+prefix
907 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)"
908 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
909 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)"
910 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
911 +
912 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
913 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
914 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
915 + fi
916 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
917 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
918 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
919 + fi
920 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
921 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
922 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
923 + fi
924 +
925 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
926 + ewarn "You have already a MySQL database in place."
927 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
928 + ewarn "Please rename or delete it if you wish to replace it."
929 + die "MySQL database already exists!"
930 + fi
931 +
932 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
933 + # localhost. Also causes weird failures.
934 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
935 +
936 + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]]; then
937 +
938 + einfo "Please provide a password for the mysql 'root'@'localhost' user now"
939 + einfo "or through the ${HOME}/.my.cnf file."
940 + ewarn "Avoid [\"'\\_%] characters in the password"
941 + einfo "Not entering a password defaults to UNIX authentication"
942 + read -rsp " >" pwd1 ; echo
943 +
944 + if [[ -n "${pwd1}" ]] ; then
945 + einfo "Retype the password"
946 + read -rsp " >" pwd2 ; echo
947 +
948 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
949 + die "Passwords are not the same"
950 + fi
951 +
952 + MYSQL_ROOT_PASSWORD="${pwd1}"
953 + fi
954 +
955 + unset pwd1 pwd2
956 + fi
957 +
958 + local options
959 + local sqltmp="$(emktemp)"
960 +
961 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
962 + # see https://bugs.mysql.com/bug.php?id=31312
963 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
964 +
965 + # Figure out which options we need to disable to do the setup
966 + local helpfile="${TMPDIR}/mysqld-help"
967 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
968 + for opt in host-cache name-resolve networking slave-start \
969 + federated ssl log-bin relay-log slow-query-log external-locking \
970 + log-slave-updates \
971 + ; do
972 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
973 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
974 + done
975 +
976 + einfo "Creating the mysql database and setting proper permissions on it ..."
977 +
978 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
979 + PID_DIR="${EROOT}/var/run/mysqld"
980 + if [[ ! -d "${PID_DIR}" ]]; then
981 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
982 + fi
983 +
984 + if [[ ! -d "${MY_DATADIR}" ]]; then
985 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
986 + fi
987 +
988 + pushd "${TMPDIR}" &>/dev/null || die
989 +
990 + # Filling timezones, see
991 + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
992 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
993 +
994 + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" )
995 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" )
996 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
997 + einfo "Command: ${cmd[*]}"
998 + su -s /bin/sh -c "${cmd[*]}" mysql \
999 + >"${TMPDIR}"/mysql_install_db.log 2>&1
1000 + if [[ $? -ne 0 ]]; then
1001 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1002 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1003 + fi
1004 + popd &>/dev/null || die
1005 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1006 + || die "MySQL databases not installed"
1007 +
1008 + if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then
1009 + einfo "Done"
1010 + exit 0
1011 + fi
1012 +
1013 + use prefix || options="${options} --user=mysql"
1014 +
1015 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1016 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1017 + local mysqld="${EROOT}/usr/sbin/mysqld \
1018 + ${options} \
1019 + --log-warnings=0 \
1020 + --basedir=${EROOT}/usr \
1021 + --datadir=${ROOT}/${MY_DATADIR} \
1022 + --max_allowed_packet=8M \
1023 + --net_buffer_length=16K \
1024 + --socket=${socket} \
1025 + --pid-file=${pidfile} \
1026 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
1027 + #einfo "About to start mysqld: ${mysqld}"
1028 + ebegin "Starting mysqld"
1029 + einfo "Command ${mysqld}"
1030 + ${mysqld} &
1031 + rc=$?
1032 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1033 + maxtry=$((${maxtry}-1))
1034 + echo -n "."
1035 + sleep 1
1036 + done
1037 + eend $rc
1038 +
1039 + if ! [[ -S "${socket}" ]]; then
1040 + die "Completely failed to start up mysqld with: ${mysqld}"
1041 + fi
1042 +
1043 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
1044 + ebegin "Setting root password"
1045 + # Do this from memory, as we don't want clear text passwords in temp files
1046 + local sql="SET PASSWORD FOR 'root'@'localhost' = PASSWORD('${MYSQL_ROOT_PASSWORD}')"
1047 + "${EROOT}/usr/bin/mysql" \
1048 + "--socket=${socket}" \
1049 + -hlocalhost \
1050 + -e "${sql}"
1051 + unset sql
1052 + eend $?
1053 + fi
1054 +
1055 + if [[ -n "${sqltmp}" ]] ; then
1056 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1057 + "${EROOT}/usr/bin/mysql" \
1058 + "--socket=${socket}" \
1059 + -hlocalhost \
1060 + -uroot \
1061 + --password="${MYSQL_ROOT_PASSWORD}" \
1062 + mysql < "${sqltmp}"
1063 + rc=$?
1064 + eend $?
1065 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1066 + fi
1067 +
1068 + # Stop the server and cleanup
1069 + einfo "Stopping the server ..."
1070 + kill $(< "${pidfile}" )
1071 + rm -f "${sqltmp}"
1072 + wait %1
1073 + einfo "Done"
1074 +}