Gentoo Archives: gentoo-commits

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