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