Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/mariadb/
Date: Tue, 31 May 2022 22:11:05
Message-Id: 1654035015.92e9fbf72178359ea32c18224c39c4f0c072e0c8.sam@gentoo
1 commit: 92e9fbf72178359ea32c18224c39c4f0c072e0c8
2 Author: Tomáš Mózes <hydrapolic <AT> gmail <DOT> com>
3 AuthorDate: Tue May 31 18:39:55 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Tue May 31 22:10:15 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=92e9fbf7
7
8 dev-db/mariadb: bump to 10.3.35
9
10 Bug: https://bugs.gentoo.org/832490
11 Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com>
12 Closes: https://github.com/gentoo/gentoo/pull/25554
13 Signed-off-by: Sam James <sam <AT> gentoo.org>
14
15 dev-db/mariadb/Manifest | 1 +
16 dev-db/mariadb/mariadb-10.3.35.ebuild | 1284 +++++++++++++++++++++++++++++++++
17 2 files changed, 1285 insertions(+)
18
19 diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest
20 index 32c8d3ff8f7f..2ad9594c1305 100644
21 --- a/dev-db/mariadb/Manifest
22 +++ b/dev-db/mariadb/Manifest
23 @@ -7,6 +7,7 @@ DIST mariadb-10.3.32-patches-01.tar.xz 4388 BLAKE2B e84de23ff97e0fcff9867bbba615
24 DIST mariadb-10.3.32.tar.gz 73389214 BLAKE2B 476d293f41804e2124859019c25df1bb93509741e8893939978af9ca6b83dfe238c3079bef0023281a1e2a0b89cb63d9a3de8d8a540ddbb96463f3914490d5ac SHA512 d74c8bdf9cc8126385e1ca69c098e2bd8543de292d36c6c88ffc8228430fd246386f675089e7a1a11c830a947efde755845eda279dfb202c89c641962edf43cd
25 DIST mariadb-10.3.34-patches-01.tar.xz 4696 BLAKE2B 36643b83f773a10180d5f94b4318c19abd441550701ca9e98ff8b7adf037648032023bb93c03efd58e25a650df5650e9b76ee8237cd3b61523f69521e505e643 SHA512 d33c52ad39e249daaae52fde09334f49285212aeb691f3caa7bf8776f95e82eff54bd6a942f24276aa7d945bd030d73e3b1f0ba15f9217236115bd448697d62c
26 DIST mariadb-10.3.34.tar.gz 73455446 BLAKE2B 7737c6f01cb1c9b38d51f9dd390898d835113aca3b17fd0f478f578807e8f65c2cd20a65f96e27b073d4531215b6223a4b5cee307b72d2a9a3ddb45af0ba9680 SHA512 46d4575ec1afb68510652a4bb31ca5ce83a2f5f61048a6e9c1487b0ba58f079465a8b72518d44043cd42c631b19ff50b5498584676ac6473705b138fe3300741
27 +DIST mariadb-10.3.35.tar.gz 73496487 BLAKE2B 3ab05276fc22098be11ce8e2f5c9323c05c28b7617b31655506fe97131cccebe70a525dda0856b05c8196fabf50243865adf91ed6914ca750bbdf27c915767e8 SHA512 9355de944eccef4e0bc01b19ffc3c0c72cf88befae7385c6f0ee1ea47dbd98d23f6bb46af9c140acc48d9d9613552870684bc0b7ca1f3cff1dc09c1a2c801573
28 DIST mariadb-10.4.22-patches-01.tar.xz 4388 BLAKE2B 0e615ddc4db93daa1f4ef1d8755b97502bb19b0ece0fc0d6d8620cb69a7db2df81ef5a06fc0a6b0f7b61fdb5431f919da99afa8068b064d905cdeaa95df807f0 SHA512 7bfff381b7fd19d12f64caaaa7d598ee476e286def9be9acd6f808784ecd47e715f222bd07fd05cd24b3342053f46c22d03041413a6a55b7194d1a5c66b0c03a
29 DIST mariadb-10.4.22.tar.gz 84916052 BLAKE2B f5f7623101cfac6b209a95de20ee737ce0afa574766340471a30ddb81abacaf2acf3809d54ecb62f9377f924b11fac04faa770802c2bdc8dc10e3286b1c8e648 SHA512 e505a56346cfcaf5b8fba80abad6b2ce819dd410f6e6f36e290ad4127aaa9fb580264c28068f9f9e04c3a2fcccd101ef73d2bf5944aedde6b2d4369163fb9248
30 DIST mariadb-10.5.13-patches-01.tar.xz 5012 BLAKE2B 34a5af415737f71750a8fa47de4f2119e31723686f000a7f99f9892a0a12fbd2be3c7bb635197b131691d73ae663e34c1b010b154d62e1ea16535265f96200f1 SHA512 71e7940558fa863835ef86f04c48c4a1ca927dee0d9ae94fcb32facde857dfef1757ae96b5a738653c341fa19a67916b0b3a03ce473020edd5c8b52ccedc0bea
31
32 diff --git a/dev-db/mariadb/mariadb-10.3.35.ebuild b/dev-db/mariadb/mariadb-10.3.35.ebuild
33 new file mode 100644
34 index 000000000000..0a94bc13dd36
35 --- /dev/null
36 +++ b/dev-db/mariadb/mariadb-10.3.35.ebuild
37 @@ -0,0 +1,1284 @@
38 +# Copyright 1999-2022 Gentoo Authors
39 +# Distributed under the terms of the GNU General Public License v2
40 +
41 +EAPI="7"
42 +SUBSLOT="18"
43 +
44 +JAVA_PKG_OPT_USE="jdbc"
45 +
46 +inherit eutils systemd flag-o-matic prefix toolchain-funcs \
47 + multiprocessing java-pkg-opt-2 cmake
48 +
49 +# Patch version
50 +PATCH_SET="https://github.com/hydrapolic/gentoo-dist/raw/master/${PN}/${PN}-10.3.34-patches-01.tar.xz"
51 +
52 +SRC_URI="mirror://mariadb/${PN}-${PV}/source/${P}.tar.gz
53 + ${PATCH_SET}"
54 +
55 +HOMEPAGE="https://mariadb.org/"
56 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
57 +LICENSE="GPL-2 LGPL-2.1+"
58 +SLOT="$(ver_cut 1-2)/${SUBSLOT:-0}"
59 +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4
60 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga
61 + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx
62 + sst-rsync sst-mariabackup static systemd systemtap tcmalloc
63 + test tokudb xml yassl"
64 +
65 +RESTRICT="!bindist? ( bindist ) !test? ( test )"
66 +
67 +REQUIRED_USE="jdbc? ( extraengine server !static )
68 + server? ( tokudb? ( jemalloc !tcmalloc ) )
69 + ?? ( tcmalloc jemalloc )
70 + static? ( yassl !extraengine !pam )"
71 +
72 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-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 + >=dev-libs/openssl-1.0.0:0=
95 + )
96 + sys-libs/ncurses:0=
97 + !bindist? (
98 + sys-libs/binutils-libs:0=
99 + >=sys-libs/readline-4.1:0=
100 + )
101 + server? (
102 + backup? ( app-arch/libarchive:0= )
103 + cracklib? ( sys-libs/cracklib:0= )
104 + extraengine? (
105 + odbc? ( dev-db/unixODBC:0= )
106 + xml? ( dev-libs/libxml2:2= )
107 + )
108 + innodb-lz4? ( app-arch/lz4 )
109 + innodb-lzo? ( dev-libs/lzo )
110 + innodb-snappy? ( app-arch/snappy )
111 + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 )
112 + numa? ( sys-process/numactl )
113 + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= )
114 + pam? ( sys-libs/pam:0= )
115 + systemd? ( sys-apps/systemd:= )
116 + tokudb? ( app-arch/snappy )
117 + )
118 + >=dev-libs/libpcre-8.41-r1:3=
119 + virtual/libcrypt:=
120 +"
121 +BDEPEND="virtual/yacc"
122 +DEPEND="static? ( sys-libs/ncurses[static-libs] )
123 + server? (
124 + extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) )
125 + test? ( acct-group/mysql acct-user/mysql )
126 + )
127 + ${COMMON_DEPEND}"
128 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
129 + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
130 + !dev-db/mariadb:0
131 + !dev-db/mariadb:5.5
132 + !dev-db/mariadb:10.1
133 + !dev-db/mariadb:10.2
134 + !dev-db/mariadb:10.4
135 + !dev-db/mariadb:10.5
136 + !dev-db/mariadb:10.6
137 + !dev-db/mariadb:10.7
138 + !dev-db/mariadb:10.8
139 + !<virtual/mysql-5.6-r11
140 + ${COMMON_DEPEND}
141 + server? (
142 + galera? (
143 + sys-apps/iproute2
144 + =sys-cluster/galera-25*
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.8 ) )
150 + )
151 +"
152 +# For other stuff to bring us in
153 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
154 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
155 +
156 +mysql_init_vars() {
157 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"}
158 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
159 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
160 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
161 +
162 + if [[ -z "${MY_DATADIR}" ]] ; then
163 + MY_DATADIR=""
164 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
165 + MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \
166 + | sed -ne '/datadir/s|^--datadir=||p' \
167 + | tail -n1)
168 + if [[ -z "${MY_DATADIR}" ]] ; then
169 + MY_DATADIR=$(grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
170 + | sed -e 's/.*=\s*//' \
171 + | tail -n1)
172 + fi
173 + fi
174 + if [[ -z "${MY_DATADIR}" ]] ; then
175 + MY_DATADIR="${MY_LOCALSTATEDIR}"
176 + einfo "Using default MY_DATADIR"
177 + fi
178 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
179 +
180 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
181 + if [[ -e "${MY_DATADIR}" ]] ; then
182 + # If you get this and you're wondering about it, see bug #207636
183 + elog "MySQL datadir found in ${MY_DATADIR}"
184 + elog "A new one will not be created."
185 + PREVIOUS_DATADIR="yes"
186 + else
187 + PREVIOUS_DATADIR="no"
188 + fi
189 + export PREVIOUS_DATADIR
190 + fi
191 + else
192 + if [[ ${EBUILD_PHASE} == "config" ]]; then
193 + local new_MY_DATADIR
194 + new_MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \
195 + | sed -ne '/datadir/s|^--datadir=||p' \
196 + | tail -n1)
197 +
198 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
199 + ewarn "MySQL MY_DATADIR has changed"
200 + ewarn "from ${MY_DATADIR}"
201 + ewarn "to ${new_MY_DATADIR}"
202 + MY_DATADIR="${new_MY_DATADIR}"
203 + fi
204 + fi
205 + fi
206 +
207 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
208 + export MY_LOCALSTATEDIR MY_LOGDIR
209 + export MY_DATADIR
210 +}
211 +
212 +pkg_setup() {
213 + if [[ ${MERGE_TYPE} != binary ]] ; then
214 + if has test ${FEATURES} ; then
215 + # Bug #213475 - MySQL _will_ object strenuously if your machine is named
216 + # localhost. Also causes weird failures.
217 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
218 +
219 + if ! has userpriv ${FEATURES} ; then
220 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
221 + fi
222 + fi
223 + fi
224 +
225 + java-pkg-opt-2_pkg_setup
226 +}
227 +
228 +src_unpack() {
229 + unpack ${A}
230 +
231 + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die
232 +}
233 +
234 +src_prepare() {
235 + eapply "${WORKDIR}"/mariadb-patches
236 +
237 + eapply_user
238 +
239 + _disable_plugin() {
240 + echo > "${S}/plugin/${1}/CMakeLists.txt" || die
241 + }
242 + _disable_engine() {
243 + echo > "${S}/storage/${1}/CMakeLists.txt" || die
244 + }
245 +
246 + if use jemalloc; then
247 + echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt"
248 + elif use tcmalloc; then
249 + echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt"
250 + fi
251 +
252 + # Don't build bundled xz-utils for tokudb
253 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
254 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
255 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
256 +
257 + local plugin
258 + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info
259 + locale_info qc_info server_audit sql_errlog auth_ed25519 )
260 + local test_plugins=( audit_null auth_examples daemon_example fulltext
261 + debug_key_management example_key_management versioning )
262 + if ! use server; then # These plugins are for the server
263 + for plugin in "${server_plugins[@]}" ; do
264 + _disable_plugin "${plugin}"
265 + done
266 + fi
267 +
268 + if ! use test; then # These plugins are only used during testing
269 + for plugin in "${test_plugins[@]}" ; do
270 + _disable_plugin "${plugin}"
271 + done
272 + _disable_engine test_sql_discovery
273 + fi
274 +
275 + _disable_engine example
276 +
277 + if ! use oqgraph ; then # avoids extra library checks
278 + _disable_engine oqgraph
279 + fi
280 +
281 + if use mroonga ; then
282 + # Remove the bundled groonga
283 + # There is no CMake flag, it simply checks for existance
284 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
285 + else
286 + _disable_engine mroonga
287 + fi
288 +
289 + # Fix galera_recovery.sh script
290 + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \
291 + scripts/galera_recovery.sh || die
292 +
293 + cmake_src_prepare
294 + java-pkg-opt-2_src_prepare
295 +}
296 +
297 +src_configure() {
298 + # bug 508724 mariadb cannot use ld.gold
299 + tc-ld-disable-gold
300 + # Bug #114895, bug #110149
301 + filter-flags "-O" "-O[01]"
302 +
303 + append-cxxflags -felide-constructors
304 +
305 + # bug #283926, with GCC4.4, this is required to get correct behavior.
306 + append-flags -fno-strict-aliasing
307 +
308 + CMAKE_BUILD_TYPE="RelWithDebInfo"
309 +
310 + # debug hack wrt #497532
311 + mycmakeargs=(
312 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
313 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
314 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
315 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
316 + -DINSTALL_BINDIR=bin
317 + -DINSTALL_DOCDIR=share/doc/${PF}
318 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
319 + -DINSTALL_INCLUDEDIR=include/mysql
320 + -DINSTALL_INFODIR=share/info
321 + -DINSTALL_LIBDIR=$(get_libdir)
322 + -DINSTALL_MANDIR=share/man
323 + -DINSTALL_MYSQLSHAREDIR=share/mariadb
324 + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin
325 + -DINSTALL_SCRIPTDIR=bin
326 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
327 + -DINSTALL_SBINDIR=sbin
328 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb"
329 + -DWITH_COMMENT="Gentoo Linux ${PF}"
330 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
331 + -DWITH_LIBEDIT=0
332 + -DWITH_ZLIB=system
333 + -DWITHOUT_LIBWRAP=1
334 + -DENABLED_LOCAL_INFILE=1
335 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
336 + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock"
337 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
338 + -DWITH_DEFAULT_FEATURE_SET=0
339 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
340 + # The build forces this to be defined when cross-compiling. We pass it
341 + # all the time for simplicity and to make sure it is actually correct.
342 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
343 + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
344 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
345 + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF)
346 + -DCONC_WITH_EXTERNAL_ZLIB=YES
347 + -DWITH_EXTERNAL_ZLIB=YES
348 + -DSUFFIX_INSTALL_DIR=""
349 + -DWITH_UNITTEST=OFF
350 + -DWITHOUT_CLIENTLIBS=YES
351 + -DCLIENT_PLUGIN_DIALOG=OFF
352 + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF
353 + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF
354 + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC
355 + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF
356 + )
357 + if use test ; then
358 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test )
359 + else
360 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
361 + fi
362 +
363 + if ! use yassl ; then
364 + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC )
365 + else
366 + mycmakeargs+=( -DWITH_SSL=bundled )
367 + fi
368 +
369 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
370 + mycmakeargs+=(
371 + -DWITH_READLINE=$(usex bindist 1 0)
372 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
373 + -DENABLE_DTRACE=$(usex systemtap)
374 + )
375 +
376 + if use server ; then
377 + # Connect and Federated{,X} must be treated special
378 + # otherwise they will not be built as plugins
379 + if ! use extraengine ; then
380 + mycmakeargs+=(
381 + -DPLUGIN_CONNECT=NO
382 + -DPLUGIN_FEDERATED=NO
383 + -DPLUGIN_FEDERATEDX=NO
384 + )
385 + fi
386 +
387 + mycmakeargs+=(
388 + -DWITH_PCRE=system
389 + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO)
390 + -DPLUGIN_SPHINX=$(usex sphinx YES NO)
391 + -DPLUGIN_TOKUDB=$(usex tokudb YES NO)
392 + -DPLUGIN_AUTH_PAM=$(usex pam YES NO)
393 + -DPLUGIN_AWS_KEY_MANAGEMENT=NO
394 + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO)
395 + -DPLUGIN_CASSANDRA=NO
396 + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO)
397 + -DPLUGIN_SPIDER=$(usex extraengine YES NO)
398 + -DCONNECT_WITH_MYSQL=1
399 + -DCONNECT_WITH_LIBXML2=$(usex xml)
400 + -DCONNECT_WITH_ODBC=$(usex odbc)
401 + -DCONNECT_WITH_JDBC=$(usex jdbc)
402 + # Build failure and autodep wrt bug 639144
403 + -DCONNECT_WITH_MONGO=OFF
404 + -DWITH_WSREP=$(usex galera)
405 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
406 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
407 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
408 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
409 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
410 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
411 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
412 + -DINSTALL_SQLBENCHDIR=""
413 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
414 + # systemd is only linked to for server notification
415 + -DWITH_SYSTEMD=$(usex systemd yes no)
416 + -DWITH_NUMA=$(usex numa ON OFF)
417 + )
418 +
419 + # Workaround for MDEV-14524
420 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 )
421 +
422 + if use test ; then
423 + # This is needed for the new client lib which tests a real, open server
424 + mycmakeargs+=( -DSKIP_TESTS=ON )
425 + fi
426 +
427 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
428 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
429 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
430 + ewarn "You MUST file bugs without these variables set."
431 +
432 + mycmakeargs+=(
433 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
434 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
435 + )
436 +
437 + elif ! use latin1 ; then
438 + mycmakeargs+=(
439 + -DDEFAULT_CHARSET=utf8
440 + -DDEFAULT_COLLATION=utf8_general_ci
441 + )
442 + else
443 + mycmakeargs+=(
444 + -DDEFAULT_CHARSET=latin1
445 + -DDEFAULT_COLLATION=latin1_swedish_ci
446 + )
447 + fi
448 + mycmakeargs+=(
449 + -DEXTRA_CHARSETS=all
450 + -DMYSQL_USER=mysql
451 + -DDISABLE_SHARED=$(usex static YES NO)
452 + -DWITH_DEBUG=$(usex debug)
453 + -DWITH_EMBEDDED_SERVER=OFF
454 + -DWITH_PROFILING=$(usex profiling)
455 + )
456 +
457 + if use static; then
458 + mycmakeargs+=( -DWITH_PIC=1 )
459 + fi
460 +
461 + if use jemalloc || use tcmalloc ; then
462 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
463 + fi
464 +
465 + # Storage engines
466 + mycmakeargs+=(
467 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
468 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
469 + -DWITH_CSV_STORAGE_ENGINE=1
470 + -DWITH_HEAP_STORAGE_ENGINE=1
471 + -DWITH_INNOBASE_STORAGE_ENGINE=1
472 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
473 + -DWITH_MYISAM_STORAGE_ENGINE=1
474 + -DWITH_PARTITION_STORAGE_ENGINE=1
475 + )
476 + else
477 + mycmakeargs+=(
478 + -DWITHOUT_SERVER=1
479 + -DWITH_EMBEDDED_SERVER=OFF
480 + -DEXTRA_CHARSETS=none
481 + -DINSTALL_SQLBENCHDIR=
482 + -DWITH_SYSTEMD=no
483 + )
484 + fi
485 +
486 + cmake_src_configure
487 +}
488 +
489 +src_compile() {
490 + cmake_src_compile
491 +}
492 +
493 +# Official test instructions:
494 +# USE='extraengine perl server xml' \
495 +# FEATURES='test userpriv' \
496 +# ebuild mariadb-X.X.XX.ebuild \
497 +# digest clean package
498 +src_test() {
499 + _disable_test() {
500 + local rawtestname bug reason
501 + rawtestname="${1}" ; shift
502 + bug="${1}" ; shift
503 + reason="${@}"
504 + ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
505 + echo "${rawtestname} : BUG#${bug} ${reason}" >> "${T}/disabled.def"
506 + }
507 +
508 + local TESTDIR="${BUILD_DIR}/mysql-test"
509 + local retstatus_tests
510 +
511 + if ! use server ; then
512 + einfo "Skipping server tests due to minimal build."
513 + return 0
514 + fi
515 +
516 + # Ensure that parallel runs don't die
517 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
518 +
519 + if [[ -z "${MTR_PARALLEL}" ]] ; then
520 + local -x MTR_PARALLEL=$(makeopts_jobs)
521 +
522 + if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
523 + # Running multiple tests in parallel usually require higher ulimit
524 + # and fs.aio-max-nr setting. In addition, tests like main.multi_update
525 + # are known to hit timeout when system is busy.
526 + # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
527 + # using "auto".
528 + local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
529 + info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
530 + einfo "${info_msg}"
531 + unset info_msg
532 + MTR_PARALLEL=4
533 + fi
534 + else
535 + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
536 + fi
537 +
538 + # Try to increase file limits to increase test coverage
539 + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
540 + # Upper limit comes from parts.partition_* tests
541 + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
542 +
543 + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
544 + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
545 + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
546 +
547 + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
548 + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
549 + else
550 + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
551 + fi
552 + else
553 + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
554 + fi
555 + else
556 + einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
557 + fi
558 +
559 + # create directories because mysqladmin might run out of order
560 + mkdir -p "${T}"/var-tests{,/log} || die
561 +
562 + if [[ ! -f "${S}/mysql-test/unstable-tests" ]] ; then
563 + touch "${S}"/mysql-test/unstable-tests || die
564 + fi
565 +
566 + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die
567 +
568 + local -a disabled_tests
569 + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" )
570 + disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" )
571 + disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" )
572 + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" )
573 + disabled_tests+=( "main.func_time;0;Dependent on time test was written" )
574 + disabled_tests+=( "main.grant;0;Sporadically failing test" )
575 + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" )
576 + disabled_tests+=( "main.selectivity_no_engine;26320;Sporadically failing test" )
577 + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" )
578 + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" )
579 + disabled_tests+=( "mariabackup.*;0;Broken test suite" )
580 + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" )
581 + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" )
582 + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" )
583 + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" )
584 +
585 + if ! use latin1 ; then
586 + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" )
587 + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" )
588 + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" )
589 + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" )
590 + fi
591 +
592 + local test_infos_str test_infos_arr
593 + for test_infos_str in "${disabled_tests[@]}" ; do
594 + IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
595 +
596 + if [[ ${#test_infos_arr[@]} != 3 ]] ; then
597 + die "Invalid test data set, not matching format: ${test_infos_str}"
598 + fi
599 +
600 + _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
601 + done
602 + unset test_infos_str test_infos_arr
603 +
604 + # run mysql-test tests
605 + pushd "${TESTDIR}" &>/dev/null || die
606 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
607 + retstatus_tests=$?
608 +
609 + popd &>/dev/null || die
610 +
611 + # Cleanup is important for these testcases.
612 + pkill -9 -f "${S}/ndb" 2>/dev/null
613 + pkill -9 -f "${S}/sql" 2>/dev/null
614 +
615 + local failures=""
616 + [[ ${retstatus_tests} -eq 0 ]] || failures="${failures} tests"
617 +
618 + [[ -z "${failures}" ]] || die "Test failures: ${failures}"
619 + einfo "Tests successfully completed"
620 +}
621 +
622 +src_install() {
623 + cmake_src_install
624 +
625 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
626 + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then
627 + rm "${ED}/usr/include/mysql/server/private/config.h" || die
628 + fi
629 +
630 + # Make sure the vars are correctly initialized
631 + mysql_init_vars
632 +
633 + # Convenience links
634 + einfo "Making Convenience links for mysqlcheck multi-call binary"
635 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
636 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
637 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
638 +
639 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
640 + if [[ -d "${ED}/usr/data" ]] ; then
641 + rm -Rf "${ED}/usr/data" || die
642 + fi
643 +
644 + # Unless they explicitly specific USE=test, then do not install the
645 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
646 + # validation of your database configuration after tuning it.
647 + if ! use test ; then
648 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
649 + fi
650 +
651 + # Configuration stuff
652 + einfo "Building default configuration ..."
653 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
654 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
655 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
656 + eprefixify "${TMPDIR}/my.cnf"
657 + doins "${TMPDIR}/my.cnf"
658 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
659 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
660 + eprefixify "${TMPDIR}/50-distro-client.cnf"
661 + doins "${TMPDIR}/50-distro-client.cnf"
662 +
663 + if use server ; then
664 + mycnf_src="my.cnf.distro-server"
665 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
666 + "${FILESDIR}/${mycnf_src}" \
667 + > "${TMPDIR}/my.cnf.ok" || die
668 + if use prefix ; then
669 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
670 + "${TMPDIR}/my.cnf.ok" || die
671 + fi
672 + if use latin1 ; then
673 + sed -i \
674 + -e "/character-set/s|utf8|latin1|g" \
675 + "${TMPDIR}/my.cnf.ok" || die
676 + fi
677 + eprefixify "${TMPDIR}/my.cnf.ok"
678 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
679 +
680 + einfo "Including support files and sample configurations"
681 + docinto "support-files"
682 + local script
683 + for script in \
684 + "${S}"/support-files/magic
685 + do
686 + [[ -f "$script" ]] && dodoc "${script}"
687 + done
688 +
689 + docinto "scripts"
690 + for script in "${S}"/scripts/mysql* ; do
691 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
692 + done
693 + # Manually install supporting files that conflict with other packages
694 + # but are needed for galera and initial installation
695 + exeinto /usr/libexec/mariadb
696 + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror"
697 + fi
698 +
699 + # Remove bundled mytop in favor of dev-db/mytop
700 + local mytop_file
701 + for mytop_file in \
702 + "${ED}/usr/bin/mytop" \
703 + "${ED}/usr/share/man/man1/mytop.1" \
704 + ; do
705 + if [[ -e "${mytop_file}" ]] ; then
706 + rm -v "${mytop_file}" || die
707 + fi
708 + done
709 +
710 + # Fix a dangling symlink when galera is not built
711 + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then
712 + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die
713 + fi
714 +
715 + # Remove broken SST scripts that are incompatible
716 + local scriptremove
717 + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do
718 + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then
719 + rm "${ED}/usr/bin/${scriptremove}" || die
720 + fi
721 + done
722 +
723 + # Remove dangling symlink
724 + rm "${ED}/usr/$(get_libdir)/libmariadb.a" || die
725 +}
726 +
727 +pkg_preinst() {
728 + java-pkg-opt-2_pkg_preinst
729 +
730 + # Here we need to see if the implementation switched client libraries
731 + # We check if this is a new instance of the package and a client library already exists
732 + local SHOW_ABI_MESSAGE libpath
733 + if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}/usr/$(get_libdir)/libmysqlclient.so" ]] ; then
734 + libpath=$(readlink "${EROOT}/usr/$(get_libdir)/libmysqlclient.so")
735 + elog "Due to ABI changes when switching between different client libraries,"
736 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
737 + elog "Please run: revdep-rebuild --library ${libpath}"
738 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
739 + fi
740 +}
741 +
742 +pkg_postinst() {
743 + # Make sure the vars are correctly initialized
744 + mysql_init_vars
745 +
746 + # Create log directory securely if it does not exist
747 + [[ -d "${ROOT}/${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}/${MY_LOGDIR}"
748 +
749 + if use server ; then
750 + if use pam; then
751 + einfo
752 + elog "This install includes the PAM authentication plugin."
753 + elog "To activate and configure the PAM plugin, please read:"
754 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
755 + einfo
756 + fi
757 +
758 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
759 + einfo
760 + elog "You might want to run:"
761 + elog "\"emerge --config =${CATEGORY}/${PF}\""
762 + elog "if this is a new install."
763 + elog
764 + elog "If you are switching server implentations, you should run the"
765 + elog "mysql_upgrade tool."
766 + einfo
767 + else
768 + einfo
769 + elog "If you are upgrading major versions, you should run the"
770 + elog "mysql_upgrade tool."
771 + einfo
772 + fi
773 +
774 + if use galera ; then
775 + einfo
776 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
777 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
778 + elog "The first time the cluster is activated, you should add"
779 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
780 + elog "This option should then be removed for subsequent starts."
781 + einfo
782 + fi
783 + fi
784 +
785 + # Note about configuration change
786 + einfo
787 + elog "This version of mariadb reorganizes the configuration from a single my.cnf"
788 + elog "to several files in /etc/mysql/${PN}.d."
789 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
790 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
791 + elog "You may have as many files as needed and they are read alphabetically."
792 + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
793 + einfo
794 +}
795 +
796 +pkg_config() {
797 + _getoptval() {
798 + local section="${1}"
799 + local option="--${2}"
800 + local extra_options="${3}"
801 + local cmd=(
802 + "${my_print_defaults_binary}"
803 + "${extra_options}"
804 + "${section}"
805 + )
806 +
807 + local values=()
808 + local parameters=( $(eval "${cmd[@]}" 2>/dev/null) )
809 + for parameter in "${parameters[@]}"
810 + do
811 + # my_print_defaults guarantees output of options, one per line,
812 + # in the form that they would be specified on the command line.
813 + # So checking for --option=* should be safe.
814 + case ${parameter} in
815 + ${option}=*)
816 + values+=( "${parameter#*=}" )
817 + ;;
818 + esac
819 + done
820 +
821 + if [[ ${#values[@]} -gt 0 ]] ; then
822 + # Option could have been set multiple times
823 + # in which case only the last occurrence
824 + # contains the current value
825 + echo "${values[-1]}"
826 + fi
827 + }
828 +
829 + _mktemp_dry() {
830 + # emktemp has no --dry-run option
831 + local template="${1}"
832 +
833 + if [[ -z "${template}" ]] ; then
834 + if [[ -z "${T}" ]] ; then
835 + template="/tmp/XXXXXXX"
836 + else
837 + template="${T}/XXXXXXX"
838 + fi
839 + fi
840 +
841 + local template_wo_X=${template//X/}
842 + local n_X
843 + let n_X=${#template}-${#template_wo_X}
844 + if [[ ${n_X} -lt 3 ]] ; then
845 + echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2
846 + return
847 + fi
848 +
849 + local attempts=0
850 + local character tmpfile
851 + while [[ true ]] ; do
852 + let attempts=attempts+1
853 +
854 + new_file=
855 + while read -n1 character ; do
856 + if [[ "${character}" == "X" ]] ; then
857 + tmpfile+="${RANDOM:0:1}"
858 + else
859 + tmpfile+="${character}"
860 + fi
861 + done < <(echo -n "${template}")
862 +
863 + if [[ ! -f "${tmpfile}" ]]
864 + then
865 + echo "${tmpfile}"
866 + return
867 + fi
868 +
869 + if [[ ${attempts} -ge 100 ]] ; then
870 + echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2
871 + return
872 + fi
873 + done
874 + }
875 +
876 + local mysql_binary="${EROOT}/usr/bin/mysql"
877 + if [[ ! -x "${mysql_binary}" ]] ; then
878 + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
879 + fi
880 +
881 + local mysqld_binary="${EROOT}/usr/sbin/mysqld"
882 + if [[ ! -x "${mysqld_binary}" ]] ; then
883 + die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
884 + fi
885 +
886 + local mysql_install_db_binary="${EROOT}/usr/bin/mysql_install_db"
887 + if [[ ! -x "${mysql_install_db_binary}" ]] ; then
888 + die "'${mysql_install_db_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
889 + fi
890 +
891 + local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults"
892 + if [[ ! -x "${my_print_defaults_binary}" ]] ; then
893 + die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!"
894 + fi
895 +
896 + if [[ -z "${MYSQL_USER}" ]] ; then
897 + MYSQL_USER=mysql
898 + if use prefix ; then
899 + MYSQL_USER=$(id -u -n 2>/dev/null)
900 + if [[ -z "${MYSQL_USER}" ]] ; then
901 + die "Failed to determine current username!"
902 + fi
903 + fi
904 + fi
905 +
906 + if [[ -z "${MYSQL_GROUP}" ]] ; then
907 + MYSQL_GROUP=mysql
908 + if use prefix ; then
909 + MYSQL_GROUP=$(id -g -n 2>/dev/null)
910 + if [[ -z "${MYSQL_GROUP}" ]] ; then
911 + die "Failed to determine current user groupname!"
912 + fi
913 + fi
914 + fi
915 +
916 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
917 + local -x HOME="${EROOT}/root"
918 +
919 + # Make sure the vars are correctly initialized
920 + mysql_init_vars
921 +
922 + # Read currently set data directory
923 + MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
924 +
925 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
926 + # localhost. Also causes weird failures.
927 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
928 +
929 + if [[ -z "${MY_DATADIR}" ]] ; then
930 + die "Sorry, unable to find MY_DATADIR!"
931 + elif [[ -d "${MY_DATADIR}/mysql" ]] ; then
932 + ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!"
933 + ewarn "Please rename or delete its content if you wish to initialize a new data directory."
934 + die "${PN} data directory at '${MY_DATADIR}' looks already initialized!"
935 + fi
936 +
937 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
938 + MYSQL_TMPDIR=${MYSQL_TMPDIR%/}
939 + # These are dir+prefix
940 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
941 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
942 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
943 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
944 +
945 + # Create missing directories.
946 + # Always check if mysql user can write to directory even if we just
947 + # created directory because a parent directory might be not
948 + # accessible for that user.
949 + PID_DIR="${EROOT}/run/mysqld"
950 + if [[ ! -d "${PID_DIR}" ]] ; then
951 + einfo "Creating ${PN} PID directory '${PID_DIR}' ..."
952 + install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \
953 + || die "Failed to create PID directory '${PID_DIR}'!"
954 + fi
955 +
956 + local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")"
957 + [[ -z "${_pid_dir_testfile}" ]] \
958 + && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
959 +
960 + if use prefix ; then
961 + touch "${_pid_dir_testfile}" &>/dev/null
962 + else
963 + su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null
964 + fi
965 +
966 + if [[ $? -ne 0 ]] ; then
967 + die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!"
968 + else
969 + rm "${_pid_dir_testfile}" || die
970 + unset _pid_dir_testfile
971 + fi
972 +
973 + if [[ ! -d "${MY_DATADIR}" ]] ; then
974 + einfo "Creating ${PN} data directory '${MY_DATADIR}' ..."
975 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \
976 + || die "Failed to create ${PN} data directory '${MY_DATADIR}'!"
977 + fi
978 +
979 + local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")"
980 + [[ -z "${_my_datadir_testfile}" ]] \
981 + && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
982 +
983 + if use prefix ; then
984 + touch "${_my_datadir_testfile}" &>/dev/null
985 + else
986 + su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null
987 + fi
988 +
989 + if [[ $? -ne 0 ]] ; then
990 + die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!"
991 + else
992 + rm "${_my_datadir_testfile}" || die
993 + unset _my_datadir_testfile
994 + fi
995 +
996 + if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then
997 + einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..."
998 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \
999 + || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!"
1000 + fi
1001 +
1002 + if [[ -z "${MYSQL_TMPDIR}" ]] ; then
1003 + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")"
1004 + [[ -z "${MYSQL_TMPDIR}" ]] \
1005 + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!"
1006 +
1007 + mkdir "${MYSQL_TMPDIR}" || die
1008 + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die
1009 + fi
1010 +
1011 + # Now we need to test MYSQL_TMPDIR...
1012 + local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")"
1013 + [[ -z "${_my_tmpdir_testfile}" ]] \
1014 + && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
1015 +
1016 + if use prefix ; then
1017 + touch "${_my_tmpdir_testfile}" &>/dev/null
1018 + else
1019 + su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null
1020 + fi
1021 +
1022 + if [[ $? -ne 0 ]] ; then
1023 + die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!"
1024 + else
1025 + rm "${_my_tmpdir_testfile}" || die
1026 + unset _my_tmpdir_testfile
1027 + fi
1028 +
1029 + if [[ "${MYSQL_LOG_BIN}" == /* && ! -d "${MYSQL_LOG_BIN}" ]] ; then
1030 + # Only create directory when MYSQL_LOG_BIN is an absolute path
1031 + einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..."
1032 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \
1033 + || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'"
1034 + fi
1035 +
1036 + if [[ "${MYSQL_LOG_BIN}" == /* ]] ; then
1037 + # Only test when MYSQL_LOG_BIN is an absolute path
1038 + local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")"
1039 + [[ -z "${_my_logbin_testfile}" ]] \
1040 + && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!"
1041 +
1042 + if use prefix ; then
1043 + touch "${_my_logbin_testfile}" &>/dev/null
1044 + else
1045 + su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null
1046 + fi
1047 +
1048 + if [[ $? -ne 0 ]] ; then
1049 + die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!"
1050 + else
1051 + rm "${_my_logbin_testfile}" || die
1052 + unset _my_logbin_testfile
1053 + fi
1054 + fi
1055 +
1056 + if [[ "${MYSQL_RELAY_LOG}" == /* && ! -d "${MYSQL_RELAY_LOG}" ]] ; then
1057 + # Only create directory when MYSQL_RELAY_LOG is an absolute path
1058 + einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..."
1059 + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \
1060 + || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!"
1061 + fi
1062 +
1063 + if [[ "${MYSQL_RELAY_LOG}" == /* ]] ; then
1064 + # Only test when MYSQL_RELAY_LOG is an absolute path
1065 + local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")"
1066 + [[ -z "${_my_relaylog_testfile}" ]] \
1067 + && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!"
1068 +
1069 + if use prefix ; then
1070 + touch "${_my_relaylog_testfile}" &>/dev/null
1071 + else
1072 + su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null
1073 + fi
1074 +
1075 + if [[ $? -ne 0 ]] ; then
1076 + die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!"
1077 + else
1078 + rm "${_my_relaylog_testfile}" || die
1079 + unset _my_relaylog_testfile
1080 + fi
1081 + fi
1082 +
1083 + local SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null)
1084 + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir"
1085 +
1086 + # Limit access
1087 + chmod 0770 "${SETUP_TMPDIR}" || die
1088 + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die
1089 +
1090 + local mysql_install_log="${SETUP_TMPDIR}/install_db.log"
1091 + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log"
1092 +
1093 + echo ""
1094 + einfo "Detected settings:"
1095 + einfo "=================="
1096 + einfo "MySQL User:\t\t\t\t${MYSQL_USER}"
1097 + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}"
1098 + einfo "MySQL DATA directory:\t\t${MY_DATADIR}"
1099 + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}"
1100 +
1101 + if [[ "${MYSQL_LOG_BIN}" == /* ]] ; then
1102 + # Absolute path for binary log files specified
1103 + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}"
1104 + fi
1105 +
1106 + if [[ "${MYSQL_RELAY_LOG}" == /* ]] ; then
1107 + # Absolute path for relay log files specified
1108 + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}"
1109 + fi
1110 +
1111 + einfo "PID DIR:\t\t\t\t${PID_DIR}"
1112 + einfo "Install db log:\t\t\t${mysql_install_log}"
1113 + einfo "Install server log:\t\t\t${mysqld_logfile}"
1114 +
1115 + echo
1116 +
1117 + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
1118 + local tmp_mysqld_password_source=
1119 +
1120 + for tmp_mysqld_password_source in mysql client ; do
1121 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
1122 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
1123 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
1124 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
1125 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
1126 + MYSQL_ROOT_PASSWORD=
1127 + continue
1128 + fi
1129 +
1130 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
1131 + break
1132 + fi
1133 + done
1134 +
1135 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
1136 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
1137 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
1138 + fi
1139 +
1140 + unset tmp_mysqld_password_source
1141 + fi
1142 +
1143 + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
1144 + local pwd1="a"
1145 + local pwd2="b"
1146 +
1147 + echo
1148 + einfo "No password for mysql 'root' user was specified via environment"
1149 + einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config"
1150 + einfo "file like '${HOME}/.my.cnf'."
1151 + einfo "To continue please provide a password for the mysql 'root' user"
1152 + einfo "now on console:"
1153 + ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!"
1154 + read -rsp " >" pwd1 ; echo
1155 +
1156 + einfo "Retype the password"
1157 + read -rsp " >" pwd2 ; echo
1158 +
1159 + if [[ "x${pwd1}" != "x${pwd2}" ]] ; then
1160 + die "Passwords are not the same!"
1161 + fi
1162 +
1163 + MYSQL_ROOT_PASSWORD="${pwd1}"
1164 + unset pwd1 pwd2
1165 +
1166 + echo
1167 + fi
1168 +
1169 + local -a mysqld_options
1170 +
1171 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
1172 + # see http://bugs.mysql.com/bug.php?id=31312
1173 + use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" )
1174 +
1175 + # Figure out which options we need to disable to do the setup
1176 + local helpfile="${TMPDIR}/mysqld-help"
1177 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
1178 +
1179 + local opt optexp optfull
1180 + for opt in host-cache name-resolve networking slave-start \
1181 + federated ssl log-bin relay-log slow-query-log external-locking \
1182 + log-slave-updates \
1183 + ; do
1184 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1185 + grep -E -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" )
1186 + done
1187 +
1188 + # Prepare timezones, see
1189 + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
1190 + local tz_sql="${SETUP_TMPDIR}/tz.sql"
1191 +
1192 + echo "USE mysql;" >"${tz_sql}"
1193 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null
1194 + if [[ $? -ne 0 ]] ; then
1195 + die "mysql_tzinfo_to_sql failed!"
1196 + fi
1197 +
1198 + local cmd=(
1199 + "${mysql_install_db_binary}"
1200 + "${mysqld_options[@]}"
1201 + "--init-file='${tz_sql}'"
1202 + "--basedir='${EROOT}/usr'"
1203 + "--datadir='${MY_DATADIR}'"
1204 + "--tmpdir='${MYSQL_TMPDIR}'"
1205 + "--log-error='${mysql_install_log}'"
1206 + "--rpm"
1207 + "--cross-bootstrap"
1208 + "--skip-test-db"
1209 + "--user=${MYSQL_USER}"
1210 + )
1211 +
1212 + einfo "Initializing ${PN} data directory: ${cmd[@]}"
1213 + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1
1214 +
1215 + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; then
1216 + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2
1217 + die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!"
1218 + fi
1219 +
1220 + local x=${RANDOM}
1221 + local socket="${PID_DIR}/mysqld.${x}.sock"
1222 + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!"
1223 + local pidfile="${PID_DIR}/mysqld.${x}.pid"
1224 + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!"
1225 + unset x
1226 +
1227 + cmd=(
1228 + "${mysqld_binary}"
1229 + "${mysqld_options[@]}"
1230 + "--basedir='${EROOT}/usr'"
1231 + "--datadir='${MY_DATADIR}'"
1232 + "--tmpdir='${MYSQL_TMPDIR}'"
1233 + --max_allowed_packet=8M
1234 + --net_buffer_length=16K
1235 + "--socket='${socket}'"
1236 + "--pid-file='${pidfile}'"
1237 + "--log-error='${mysqld_logfile}'"
1238 + "--user=${MYSQL_USER}"
1239 + )
1240 +
1241 + einfo "Starting mysqld to finalize initialization: ${cmd[@]}"
1242 + eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 &
1243 +
1244 + echo -n "Waiting for mysqld to accept connections "
1245 + local maxtry=15
1246 + while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
1247 + maxtry=$((${maxtry}-1))
1248 + echo -n "."
1249 + sleep 1
1250 + done
1251 +
1252 + if [[ -S "${socket}" ]] ; then
1253 + # Even with a socket we don't know if mysqld will abort
1254 + # start due to an error so just wait a little bit more...
1255 + maxtry=5
1256 + while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
1257 + maxtry=$((${maxtry}-1))
1258 + echo -n "."
1259 + sleep 1
1260 + done
1261 + fi
1262 +
1263 + echo
1264 +
1265 + if [[ ! -S "${socket}" ]] ; then
1266 + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2
1267 + die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!"
1268 + fi
1269 +
1270 + local mysql_logfile="${SETUP_TMPDIR}/set_root_pw.log"
1271 + touch "${mysql_logfile}" || die
1272 +
1273 + ebegin "Setting root password"
1274 + # Do this from memory, as we don't want clear text passwords in temp files
1275 + local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'"
1276 + cmd=(
1277 + "${mysql_binary}"
1278 + --no-defaults
1279 + "--socket='${socket}'"
1280 + -hlocalhost
1281 + "-e \"${sql}\""
1282 + )
1283 + eval "${cmd[@]}" >"${mysql_logfile}" 2>&1
1284 + local rc=$?
1285 + eend ${rc}
1286 +
1287 + if [[ ${rc} -ne 0 ]] ; then
1288 + # Poor man's solution which tries to avoid having password
1289 + # in log. NOTE: sed can fail if user didn't follow advice
1290 + # and included character which will require escaping...
1291 + sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null
1292 +
1293 + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}"
1294 + die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!"
1295 + fi
1296 +
1297 + # Stop the server
1298 + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
1299 + echo -n "Stopping the server "
1300 + pkill -F "${pidfile}" &>/dev/null
1301 +
1302 + maxtry=10
1303 + while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do
1304 + maxtry=$((${maxtry}-1))
1305 + echo -n "."
1306 + sleep 1
1307 + done
1308 +
1309 + echo
1310 +
1311 + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
1312 + # We somehow failed to stop server.
1313 + # However, not a fatal error. Just warn the user.
1314 + ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!"
1315 + fi
1316 + fi
1317 +
1318 + rm -r "${SETUP_TMPDIR}" || die
1319 +
1320 + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!"
1321 +}