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