1 |
commit: 354298f979e834d7a95caf530cf61eb580e4b0e6 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Apr 30 19:07:18 2020 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 30 20:44:55 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=354298f9 |
7 |
|
8 |
dev-db/mysql: bump to v8.0.20 |
9 |
|
10 |
Bug: https://bugs.gentoo.org/717628 |
11 |
Package-Manager: Portage-2.3.99, Repoman-2.3.22 |
12 |
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> |
13 |
|
14 |
dev-db/mysql/Manifest | 2 + |
15 |
dev-db/mysql/mysql-8.0.20.ebuild | 1108 ++++++++++++++++++++++++++++++++++++++ |
16 |
2 files changed, 1110 insertions(+) |
17 |
|
18 |
diff --git a/dev-db/mysql/Manifest b/dev-db/mysql/Manifest |
19 |
index 1ecef78e7c6..6f0e03d7d84 100644 |
20 |
--- a/dev-db/mysql/Manifest |
21 |
+++ b/dev-db/mysql/Manifest |
22 |
@@ -1,9 +1,11 @@ |
23 |
DIST mysql-5.6.44.tar.gz 32531507 BLAKE2B 28fbf49f699eb9f43223ffa186671b119d16016274cc7192db232b85c58123a61154e37193b9b7145c6a650b80b5f6cf838529bc2bc5ea9c78c0dbc39de834d3 SHA512 65ace1c803773ca6c8759d171c09bc93c7d61b8e3208ac9905f82e99087622c9dcca602d2da217741dc62fc6eabe9108ebc7f31facd26705072eae65fcc37077 |
24 |
DIST mysql-5.6.45.tar.gz 32525559 BLAKE2B 3c629aed1de808acdea6654c7413e6851507c9c5be939ca4b4f5e2796da317e9b518a749bfc03d2b0ef05bd604b39f72e24b751076b9f206b462d21fa5db4f50 SHA512 f9d8bb72e96cc83f1064fe7df2e5fe8317ca9d44c4e776cf7827a61292fbcfccec716806c80d565958383d78fef93a19d61c726687b57680d5f93299291ff168 |
25 |
+DIST mysql-8.0.20-patches-01.tar.xz 7176 BLAKE2B 2fc51986c0a4da60521d0e64b9f8705caf8ec3869af930c9729359c3710059fc78aae176523fdf17d10173b404431f31f9bb23ee5c82fba7cbbb4cb39881c005 SHA512 bf8211cf3873f8672b9d3d1dc42b68a1c635690ffdc2d3393eafa83f060ada9f2eaa63f859bf8eecc24976a733d8c7c3b9632ac70f28b5facf48eae921c7ceeb |
26 |
DIST mysql-boost-5.7.26.tar.gz 51098338 BLAKE2B 1263cd75814a7293b26b0f44fd2b7d20d983f3c6a62725df9515ecac2ef252f6644810cb4bf0d6f36b98e55317f1c67ea7541228cb38d896dfedc476a5755f26 SHA512 a5f9871dc5a8e5fffc1467c3dd542533a63fe553c029120475f8fd5530d884c76ab0c33ad260daf317faf318ccef01464f6ac2dc3468efceb6bf2b6c06c54cfd |
27 |
DIST mysql-boost-5.7.27.tar.gz 51436383 BLAKE2B 6db64ab5fa659aae9baa3725a0de9465e48c37618ffd69f34809880c06a00ce55dce77f507810c6fa52d86901facfa42d3d1bd8db1914a779fbc88a69be82497 SHA512 573f4555f3d62bcd3dc2228bcfba023518d462bb6689114a3505ccf7c7c3061d2775a8e7a37ec3c8b9dea6e8fbc56ba599610f237abc38cedff58e75799bdc52 |
28 |
DIST mysql-boost-5.7.29.tar.gz 51417554 BLAKE2B 652ce9f99419387e9bcc37afeb1b46438784752e963c3aa1877f17650c31d8b058b4052da97c3a7e9454e758c259d6c311e0518f9a75909fce9741150b82164c SHA512 38acf7c2a10b20c59230ad05cd2cd6996c4c582233c1be573ead08e5c6684275790da07a036570363f89b4d61547b306589b0b98ed5fca70723a3f2cbc21fe11 |
29 |
DIST mysql-boost-8.0.19.tar.gz 264147972 BLAKE2B 61a5ccbef1a7a675c85e4e6bda8e5285bdb931e6ee14d4710bf13dfd9157d1095200db2886dc93ea7251d3d59245f35c0bef5ba88ba6aac209b1e080f3b07dc4 SHA512 5ffc03f005ab2585694902e926b6cb2b10059b2b030549eccd3949f9c3b2f02626d02529f940dec003f2d69683856fd1c720ff12f89dfbdc48befaf24a9c4d01 |
30 |
+DIST mysql-boost-8.0.20.tar.gz 266282970 BLAKE2B 2aeb9d6c575ed9dc2d00d3e51e6391c59ffa39156491d9ed2c07e19bb2efb88a14d5a9d4b537c137d71854e39fa3a7fc2b93618118d4fd062e92ba2d83783c6f SHA512 7a962e9ddec7069008c5ab6ac2801515e2661ca2875afc6141541c03e2f941f4255b3c0d806a4df2fd2f2f1d12323aeb1e456c1d364777a18ccebefad7b22a99 |
31 |
DIST mysql-extras-20190817-0024Z.tar.bz2 337793 BLAKE2B dfd51a708654aff5bdbbaf2acad7ef966869a8e3adcba544ee15f217d2ba942827445841e73981bccc6c1f145b6225bfa7245114219f0cf52f0dfb85494a6830 SHA512 c2ff81be1c55636f0a2700033af030149f312f0383217054a4b8c65aef174626299fcb4539eaae967ea7d096a5bb09f5b5122dce344b44b0a135d886ba0fdf28 |
32 |
DIST mysql-extras-20190822-1908Z.tar.bz2 338830 BLAKE2B bc197f8e541206548d8982814e82e028d699ba9c41aec8d5191bcc46581f7880ed2741dbe2206fde44a5e8d8d54bbcf40efbd0709b357636c4c8fdb2ccc3a7bb SHA512 be469e55f7e9966638600d6836a44258c74e5600240fafe2d79eaeebe7d1695b043678184b5d18ee9946f28154bc2529586a7f860b510180a30c82454ed575c8 |
33 |
DIST mysql-extras-20200125-1945Z.tar.bz2 344906 BLAKE2B 0e87875efbc221ded43d6f080dc7dce4277b676b538950120c94b962e51d054093286486e5d83ea3e38e1b2d0b12cf81873df50e1cebbe4cff33b54297e6a17a SHA512 5fcc5d372998db2b8aef32661ff71290791c20c1195a6210ca79c0fda12008906e665f9dc878d3df5a38a95e23ff05b910daa861002c17a1b6de71ef0520bee1 |
34 |
|
35 |
diff --git a/dev-db/mysql/mysql-8.0.20.ebuild b/dev-db/mysql/mysql-8.0.20.ebuild |
36 |
new file mode 100644 |
37 |
index 00000000000..e6d1693f2a1 |
38 |
--- /dev/null |
39 |
+++ b/dev-db/mysql/mysql-8.0.20.ebuild |
40 |
@@ -0,0 +1,1108 @@ |
41 |
+# Copyright 1999-2020 Gentoo Authors |
42 |
+# Distributed under the terms of the GNU General Public License v2 |
43 |
+ |
44 |
+EAPI="7" |
45 |
+ |
46 |
+CMAKE_MAKEFILE_GENERATOR=emake |
47 |
+ |
48 |
+inherit cmake-utils flag-o-matic linux-info \ |
49 |
+ multiprocessing prefix toolchain-funcs check-reqs |
50 |
+ |
51 |
+MY_PV="${PV//_pre*}" |
52 |
+MY_P="${PN}-${MY_PV}" |
53 |
+ |
54 |
+# Patch version |
55 |
+PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-8.0.20-patches-01.tar.xz" |
56 |
+ |
57 |
+SRC_URI="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${MY_PV}.tar.gz |
58 |
+ https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${MY_PV}.tar.gz |
59 |
+ http://downloads.mysql.com/archives/MySQL-8.0/${PN}-boost-${MY_PV}.tar.gz |
60 |
+ ${PATCH_SET}" |
61 |
+ |
62 |
+HOMEPAGE="https://www.mysql.com/" |
63 |
+DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" |
64 |
+LICENSE="GPL-2" |
65 |
+SLOT="0" |
66 |
+IUSE="cjk cracklib debug jemalloc latin1 libressl numa +perl profiling |
67 |
+ router selinux +server tcmalloc test" |
68 |
+ |
69 |
+# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests |
70 |
+RESTRICT="!test? ( test ) libressl? ( test )" |
71 |
+ |
72 |
+REQUIRED_USE="?? ( tcmalloc jemalloc ) |
73 |
+ cjk? ( server ) |
74 |
+ jemalloc? ( server ) |
75 |
+ numa? ( server ) |
76 |
+ profiling? ( server ) |
77 |
+ router? ( server ) |
78 |
+ tcmalloc? ( server )" |
79 |
+ |
80 |
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" |
81 |
+ |
82 |
+# Shorten the path because the socket path length must be shorter than 107 chars |
83 |
+# and we will run a mysql server during test phase |
84 |
+S="${WORKDIR}/mysql" |
85 |
+ |
86 |
+# Be warned, *DEPEND are version-dependant |
87 |
+# These are used for both runtime and compiletime |
88 |
+COMMON_DEPEND=" |
89 |
+ >=app-arch/lz4-0_p131:= |
90 |
+ sys-libs/ncurses:0= |
91 |
+ >=sys-libs/zlib-1.2.3:0= |
92 |
+ libressl? ( dev-libs/libressl:0= ) |
93 |
+ !libressl? ( >=dev-libs/openssl-1.0.0:0= ) |
94 |
+ server? ( |
95 |
+ dev-libs/icu:= |
96 |
+ dev-libs/libevent:= |
97 |
+ >=dev-libs/protobuf-3.8:= |
98 |
+ net-libs/libtirpc:= |
99 |
+ cjk? ( app-text/mecab:= ) |
100 |
+ jemalloc? ( dev-libs/jemalloc:0= ) |
101 |
+ kernel_linux? ( |
102 |
+ dev-libs/libaio:0= |
103 |
+ sys-process/procps:0= |
104 |
+ ) |
105 |
+ numa? ( sys-process/numactl ) |
106 |
+ tcmalloc? ( dev-util/google-perftools:0= ) |
107 |
+ ) |
108 |
+" |
109 |
+DEPEND="${COMMON_DEPEND} |
110 |
+ || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) |
111 |
+ virtual/yacc |
112 |
+ server? ( net-libs/rpcsvc-proto ) |
113 |
+ test? ( |
114 |
+ acct-group/mysql acct-user/mysql |
115 |
+ dev-perl/JSON |
116 |
+ ) |
117 |
+" |
118 |
+RDEPEND="${COMMON_DEPEND} |
119 |
+ !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster |
120 |
+ selinux? ( sec-policy/selinux-mysql ) |
121 |
+ !prefix? ( |
122 |
+ acct-group/mysql acct-user/mysql |
123 |
+ dev-db/mysql-init-scripts |
124 |
+ ) |
125 |
+" |
126 |
+# For other stuff to bring us in |
127 |
+# dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
128 |
+PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
129 |
+ |
130 |
+CHECKREQS_DISK_BUILD="8G" |
131 |
+ |
132 |
+mysql_init_vars() { |
133 |
+ : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"} |
134 |
+ : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"} |
135 |
+ : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"} |
136 |
+ : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"} |
137 |
+ MY_DATADIR="${MY_LOCALSTATEDIR}" |
138 |
+ |
139 |
+ export MY_SHAREDSTATEDIR MY_SYSCONFDIR |
140 |
+ export MY_LOCALSTATEDIR MY_LOGDIR |
141 |
+ export MY_DATADIR |
142 |
+} |
143 |
+ |
144 |
+pkg_pretend() { |
145 |
+ [[ ${MERGE_TYPE} == binary ]] && return |
146 |
+ use server && check-reqs_pkg_pretend |
147 |
+} |
148 |
+ |
149 |
+pkg_setup() { |
150 |
+ [[ ${MERGE_TYPE} == binary ]] && return |
151 |
+ |
152 |
+ if has test ${FEATURES} ; then |
153 |
+ # Bug #213475 - MySQL _will_ object strenuously if your machine is named |
154 |
+ # localhost. Also causes weird failures. |
155 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
156 |
+ |
157 |
+ if ! has userpriv ${FEATURES} ; then |
158 |
+ die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
159 |
+ fi |
160 |
+ |
161 |
+ local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null) |
162 |
+ [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \ |
163 |
+ && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!" |
164 |
+ |
165 |
+ if use latin1 ; then |
166 |
+ # Upstream only supports tests with default charset |
167 |
+ die "Testing with USE=latin1 is not supported." |
168 |
+ fi |
169 |
+ fi |
170 |
+ |
171 |
+ if use kernel_linux ; then |
172 |
+ if use numa ; then |
173 |
+ linux-info_get_any_version |
174 |
+ |
175 |
+ local CONFIG_CHECK="~NUMA" |
176 |
+ |
177 |
+ local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" |
178 |
+ WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" |
179 |
+ |
180 |
+ check_extra_config |
181 |
+ fi |
182 |
+ fi |
183 |
+ |
184 |
+ use server && check-reqs_pkg_setup |
185 |
+} |
186 |
+ |
187 |
+src_unpack() { |
188 |
+ unpack ${A} |
189 |
+ |
190 |
+ mv -f "${WORKDIR}/${MY_P}" "${S}" || die |
191 |
+} |
192 |
+ |
193 |
+src_prepare() { |
194 |
+ eapply "${WORKDIR}"/mysql-patches |
195 |
+ |
196 |
+ eapply_user |
197 |
+ |
198 |
+ # Avoid rpm call which would trigger sandbox, #692368 |
199 |
+ sed -i \ |
200 |
+ -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \ |
201 |
+ CMakeLists.txt || die |
202 |
+ |
203 |
+ if use jemalloc ; then |
204 |
+ echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die |
205 |
+ fi |
206 |
+ |
207 |
+ if use tcmalloc ; then |
208 |
+ echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die |
209 |
+ fi |
210 |
+ |
211 |
+ # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux |
212 |
+ if [[ -d "${S}/support-files/SELinux" ]] ; then |
213 |
+ echo > "${S}/support-files/SELinux/CMakeLists.txt" || die |
214 |
+ fi |
215 |
+ |
216 |
+ # Remove man pages for client-lib tools we don't install |
217 |
+ rm \ |
218 |
+ man/my_print_defaults.1 \ |
219 |
+ man/perror.1 \ |
220 |
+ man/zlib_decompress.1 \ |
221 |
+ || die |
222 |
+ |
223 |
+ cmake-utils_src_prepare |
224 |
+} |
225 |
+ |
226 |
+src_configure() { |
227 |
+ # Bug #114895, bug #110149 |
228 |
+ filter-flags "-O" "-O[01]" |
229 |
+ |
230 |
+ append-cxxflags -felide-constructors |
231 |
+ |
232 |
+ # bug #283926, with GCC4.4, this is required to get correct behavior. |
233 |
+ append-flags -fno-strict-aliasing |
234 |
+ |
235 |
+ CMAKE_BUILD_TYPE="RelWithDebInfo" |
236 |
+ |
237 |
+ # debug hack wrt #497532 |
238 |
+ mycmakeargs=( |
239 |
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
240 |
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
241 |
+ -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" |
242 |
+ -DSYSCONFDIR="${EPREFIX}/etc/mysql" |
243 |
+ -DINSTALL_BINDIR=bin |
244 |
+ -DINSTALL_DOCDIR=share/doc/${PF} |
245 |
+ -DINSTALL_DOCREADMEDIR=share/doc/${PF} |
246 |
+ -DINSTALL_INCLUDEDIR=include/mysql |
247 |
+ -DINSTALL_INFODIR=share/info |
248 |
+ -DINSTALL_LIBDIR=$(get_libdir) |
249 |
+ -DINSTALL_MANDIR=share/man |
250 |
+ -DINSTALL_MYSQLSHAREDIR=share/mysql |
251 |
+ -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin |
252 |
+ -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" |
253 |
+ -DINSTALL_SBINDIR=sbin |
254 |
+ -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" |
255 |
+ -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" |
256 |
+ -DWITH_UNIT_TESTS=$(usex test ON OFF) |
257 |
+ # Using bundled editline to get CTRL+C working |
258 |
+ -DWITH_EDITLINE=bundled |
259 |
+ -DWITH_ZLIB=system |
260 |
+ -DWITH_SSL=system |
261 |
+ -DWITH_LIBWRAP=0 |
262 |
+ -DENABLED_LOCAL_INFILE=1 |
263 |
+ -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" |
264 |
+ -DWITH_DEFAULT_COMPILER_OPTIONS=0 |
265 |
+ -DWITH_DEFAULT_FEATURE_SET=0 |
266 |
+ # The build forces this to be defined when cross-compiling. We pass it |
267 |
+ # all the time for simplicity and to make sure it is actually correct. |
268 |
+ -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) |
269 |
+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON |
270 |
+ -DWITH_CURL=system |
271 |
+ -DWITH_BOOST="${S}/boost" |
272 |
+ -DWITH_ROUTER=$(usex router ON OFF) |
273 |
+ ) |
274 |
+ |
275 |
+ if is-flagq -fno-lto ; then |
276 |
+ einfo "LTO disabled via {C,CXX,F,FC}FLAGS" |
277 |
+ mycmakeargs+=( -DWITH_LTO=OFF ) |
278 |
+ elif is-flagq -flto ; then |
279 |
+ einfo "LTO forced via {C,CXX,F,FC}FLAGS" |
280 |
+ myconf+=( -DWITH_LTO=ON ) |
281 |
+ else |
282 |
+ # Disable automagic |
283 |
+ myconf+=( -DWITH_LTO=OFF ) |
284 |
+ fi |
285 |
+ |
286 |
+ if use test ; then |
287 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) |
288 |
+ else |
289 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) |
290 |
+ fi |
291 |
+ |
292 |
+ mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) |
293 |
+ |
294 |
+ mycmakeargs+=( |
295 |
+ -DWITH_ICU=system |
296 |
+ -DWITH_LZ4=system |
297 |
+ # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex |
298 |
+ -DWITH_RAPIDJSON=bundled |
299 |
+ ) |
300 |
+ |
301 |
+ if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then |
302 |
+ ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" |
303 |
+ ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." |
304 |
+ ewarn "You MUST file bugs without these variables set." |
305 |
+ ewarn "Tests will probably fail!" |
306 |
+ |
307 |
+ mycmakeargs+=( |
308 |
+ -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} |
309 |
+ -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} |
310 |
+ ) |
311 |
+ elif use latin1 ; then |
312 |
+ mycmakeargs+=( |
313 |
+ -DDEFAULT_CHARSET=latin1 |
314 |
+ -DDEFAULT_COLLATION=latin1_swedish_ci |
315 |
+ ) |
316 |
+ else |
317 |
+ mycmakeargs+=( |
318 |
+ -DDEFAULT_CHARSET=utf8mb4 |
319 |
+ -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci |
320 |
+ ) |
321 |
+ fi |
322 |
+ |
323 |
+ if use server ; then |
324 |
+ mycmakeargs+=( |
325 |
+ -DWITH_EXTRA_CHARSETS=all |
326 |
+ -DWITH_DEBUG=$(usex debug) |
327 |
+ -DWITH_MECAB=$(usex cjk system OFF) |
328 |
+ -DWITH_LIBEVENT=system |
329 |
+ -DWITH_PROTOBUF=system |
330 |
+ -DWITH_NUMA=$(usex numa ON OFF) |
331 |
+ ) |
332 |
+ |
333 |
+ if use profiling ; then |
334 |
+ # Setting to OFF doesn't work: Once set, profiling options will be added |
335 |
+ # to `mysqld --help` output via sql/sys_vars.cc causing |
336 |
+ # "main.mysqld--help-notwin" test to fail |
337 |
+ mycmakeargs+=( -DENABLED_PROFILING=ON ) |
338 |
+ fi |
339 |
+ |
340 |
+ # Storage engines |
341 |
+ mycmakeargs+=( |
342 |
+ -DWITH_EXAMPLE_STORAGE_ENGINE=0 |
343 |
+ -DWITH_ARCHIVE_STORAGE_ENGINE=1 |
344 |
+ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 |
345 |
+ -DWITH_CSV_STORAGE_ENGINE=1 |
346 |
+ -DWITH_FEDERATED_STORAGE_ENGINE=1 |
347 |
+ -DWITH_HEAP_STORAGE_ENGINE=1 |
348 |
+ -DWITH_INNOBASE_STORAGE_ENGINE=1 |
349 |
+ -DWITH_INNODB_MEMCACHED=0 |
350 |
+ -DWITH_MYISAMMRG_STORAGE_ENGINE=1 |
351 |
+ -DWITH_MYISAM_STORAGE_ENGINE=1 |
352 |
+ ) |
353 |
+ else |
354 |
+ mycmakeargs+=( |
355 |
+ -DWITHOUT_SERVER=1 |
356 |
+ -DWITH_SYSTEMD=no |
357 |
+ ) |
358 |
+ fi |
359 |
+ |
360 |
+ cmake-utils_src_configure |
361 |
+} |
362 |
+ |
363 |
+# Official test instructions: |
364 |
+# ulimit -n 16500 && \ |
365 |
+# USE='perl server' \ |
366 |
+# FEATURES='test userpriv' \ |
367 |
+# ebuild mysql-X.X.XX.ebuild \ |
368 |
+# digest clean package |
369 |
+src_test() { |
370 |
+ _disable_test() { |
371 |
+ local rawtestname bug reason |
372 |
+ rawtestname="${1}" ; shift |
373 |
+ bug="${1}" ; shift |
374 |
+ reason="${@}" |
375 |
+ ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" |
376 |
+ echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def" |
377 |
+ } |
378 |
+ |
379 |
+ local TESTDIR="${BUILD_DIR}/mysql-test" |
380 |
+ local retstatus_unit |
381 |
+ local retstatus_tests |
382 |
+ |
383 |
+ # Run CTest (test-units) |
384 |
+ cmake-utils_src_test |
385 |
+ retstatus_unit=$? |
386 |
+ |
387 |
+ # Ensure that parallel runs don't die |
388 |
+ export MTR_BUILD_THREAD="$((${RANDOM} % 100))" |
389 |
+ |
390 |
+ if [[ -z "${MTR_PARALLEL}" ]] ; then |
391 |
+ local -x MTR_PARALLEL=$(makeopts_jobs) |
392 |
+ |
393 |
+ if [[ ${MTR_PARALLEL} -gt 4 ]] ; then |
394 |
+ # Running multiple tests in parallel usually require higher ulimit |
395 |
+ # and fs.aio-max-nr setting. In addition, tests like main.multi_update |
396 |
+ # are known to hit timeout when system is busy. |
397 |
+ # To avoid test failure we will limit MTR_PARALLEL to 4 instead of |
398 |
+ # using "auto". |
399 |
+ local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" |
400 |
+ info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" |
401 |
+ einfo "${info_msg}" |
402 |
+ unset info_msg |
403 |
+ MTR_PARALLEL=4 |
404 |
+ fi |
405 |
+ else |
406 |
+ einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" |
407 |
+ fi |
408 |
+ |
409 |
+ # create directories because mysqladmin might run out of order |
410 |
+ mkdir -p "${T}"/var-tests{,/log} || die |
411 |
+ |
412 |
+ # Run mysql tests |
413 |
+ pushd "${TESTDIR}" &>/dev/null || die |
414 |
+ |
415 |
+ touch "${T}/disabled.def" |
416 |
+ |
417 |
+ local -a disabled_tests |
418 |
+ disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" ) |
419 |
+ disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" ) |
420 |
+ disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" ) |
421 |
+ disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" ) |
422 |
+ disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" ) |
423 |
+ disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" ) |
424 |
+ disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" ) |
425 |
+ disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" ) |
426 |
+ disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" ) |
427 |
+ disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" ) |
428 |
+ disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" ) |
429 |
+ disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) |
430 |
+ disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" ) |
431 |
+ disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" ) |
432 |
+ disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Known failure - no upstream bug yet" ) |
433 |
+ disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware") |
434 |
+ disabled_tests+=( "x.connection;0;Known failure - no upstream bug yet" ) |
435 |
+ disabled_tests+=( "main.mysqlpump_basic_lz4;0;Extra tool output causes false positive" ) |
436 |
+ disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" ) |
437 |
+ disabled_tests+=( "x.message_protobuf_nested;0;False positive caused by protobuff-3.11+" ) |
438 |
+ |
439 |
+ local test_infos_str test_infos_arr |
440 |
+ for test_infos_str in "${disabled_tests[@]}" ; do |
441 |
+ IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" |
442 |
+ |
443 |
+ if [[ ${#test_infos_arr[@]} != 3 ]] ; then |
444 |
+ die "Invalid test data set, not matching format: ${test_infos_str}" |
445 |
+ fi |
446 |
+ |
447 |
+ _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" |
448 |
+ done |
449 |
+ unset test_infos_str test_infos_arr |
450 |
+ |
451 |
+ # Try to increase file limits to increase test coverage |
452 |
+ if ! ulimit -n 16500 1>/dev/null 2>&1 ; then |
453 |
+ # Upper limit comes from parts.partition_* tests |
454 |
+ ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." |
455 |
+ |
456 |
+ if ! ulimit -n 4162 1>/dev/null 2>&1 ; then |
457 |
+ # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' |
458 |
+ ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." |
459 |
+ |
460 |
+ if ! ulimit -n 3000 1>/dev/null 2>&1 ; then |
461 |
+ ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." |
462 |
+ else |
463 |
+ einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." |
464 |
+ fi |
465 |
+ else |
466 |
+ einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." |
467 |
+ fi |
468 |
+ else |
469 |
+ einfo "Will run test suite with open file limit set to 16500 (best test coverage)." |
470 |
+ fi |
471 |
+ |
472 |
+ # run mysql-test tests |
473 |
+ perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" |
474 |
+ retstatus_tests=$? |
475 |
+ |
476 |
+ popd &>/dev/null || die |
477 |
+ |
478 |
+ # Cleanup is important for these testcases. |
479 |
+ pkill -9 -f "${S}/ndb" 2>/dev/null |
480 |
+ pkill -9 -f "${S}/sql" 2>/dev/null |
481 |
+ |
482 |
+ local failures="" |
483 |
+ [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" |
484 |
+ [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" |
485 |
+ |
486 |
+ [[ -z "$failures" ]] || die "Test failures: $failures" |
487 |
+ einfo "Tests successfully completed" |
488 |
+} |
489 |
+ |
490 |
+src_install() { |
491 |
+ cmake-utils_src_install |
492 |
+ |
493 |
+ # Make sure the vars are correctly initialized |
494 |
+ mysql_init_vars |
495 |
+ |
496 |
+ # Convenience links |
497 |
+ einfo "Making Convenience links for mysqlcheck multi-call binary" |
498 |
+ dosym "mysqlcheck" "/usr/bin/mysqlanalyze" |
499 |
+ dosym "mysqlcheck" "/usr/bin/mysqlrepair" |
500 |
+ dosym "mysqlcheck" "/usr/bin/mysqloptimize" |
501 |
+ |
502 |
+ # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir |
503 |
+ if [[ -d "${ED}/usr/data" ]] ; then |
504 |
+ rm -Rf "${ED}/usr/data" || die |
505 |
+ fi |
506 |
+ |
507 |
+ # Unless they explicitly specific USE=test, then do not install the |
508 |
+ # testsuite. It DOES have a use to be installed, esp. when you want to do a |
509 |
+ # validation of your database configuration after tuning it. |
510 |
+ if ! use test ; then |
511 |
+ rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test" |
512 |
+ fi |
513 |
+ |
514 |
+ # Configuration stuff |
515 |
+ einfo "Building default configuration ..." |
516 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}" |
517 |
+ [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf |
518 |
+ cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die |
519 |
+ eprefixify "${TMPDIR}/my.cnf" |
520 |
+ doins "${TMPDIR}/my.cnf" |
521 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" |
522 |
+ cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die |
523 |
+ eprefixify "${TMPDIR}/50-distro-client.cnf" |
524 |
+ doins "${TMPDIR}/50-distro-client.cnf" |
525 |
+ |
526 |
+ mycnf_src="my.cnf-8.0.distro-server" |
527 |
+ sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ |
528 |
+ "${FILESDIR}/${mycnf_src}" \ |
529 |
+ > "${TMPDIR}/my.cnf.ok" || die |
530 |
+ |
531 |
+ if use prefix ; then |
532 |
+ sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ |
533 |
+ "${TMPDIR}/my.cnf.ok" || die |
534 |
+ fi |
535 |
+ |
536 |
+ if use latin1 ; then |
537 |
+ sed -i \ |
538 |
+ -e "/character-set/s|utf8mb4|latin1|g" \ |
539 |
+ "${TMPDIR}/my.cnf.ok" || die |
540 |
+ fi |
541 |
+ |
542 |
+ eprefixify "${TMPDIR}/my.cnf.ok" |
543 |
+ |
544 |
+ newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf |
545 |
+ |
546 |
+ #Remove mytop if perl is not selected |
547 |
+ [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" |
548 |
+ |
549 |
+ if use router ; then |
550 |
+ rm -rf \ |
551 |
+ "${ED}/usr/LICENSE.router" \ |
552 |
+ "${ED}/usr/README.router" \ |
553 |
+ "${ED}/usr/run" \ |
554 |
+ "${ED}/usr/var" \ |
555 |
+ || die |
556 |
+ fi |
557 |
+ |
558 |
+ # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. |
559 |
+ find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die |
560 |
+} |
561 |
+ |
562 |
+pkg_postinst() { |
563 |
+ # Make sure the vars are correctly initialized |
564 |
+ mysql_init_vars |
565 |
+ |
566 |
+ # Create log directory securely if it does not exist |
567 |
+ # NOTE: $MY_LOGDIR contains $EPREFIX by default |
568 |
+ [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}" |
569 |
+ |
570 |
+ # Note about configuration change |
571 |
+ einfo |
572 |
+ elog "This version of ${PN} reorganizes the configuration from a single my.cnf" |
573 |
+ elog "to several files in /etc/mysql/mysql.d." |
574 |
+ elog "Please backup any changes you made to /etc/mysql/my.cnf" |
575 |
+ elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." |
576 |
+ elog "You may have as many files as needed and they are read alphabetically." |
577 |
+ elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." |
578 |
+ einfo |
579 |
+ |
580 |
+ if [[ -z "${REPLACING_VERSIONS}" ]] ; then |
581 |
+ einfo |
582 |
+ elog "You might want to run:" |
583 |
+ elog " \"emerge --config =${CATEGORY}/${PF}\"" |
584 |
+ elog "if this is a new install." |
585 |
+ einfo |
586 |
+ else |
587 |
+ einfo |
588 |
+ elog "Upgrade process for ${PN}-8.x has changed. Please read" |
589 |
+ elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html" |
590 |
+ einfo |
591 |
+ fi |
592 |
+} |
593 |
+ |
594 |
+pkg_config() { |
595 |
+ local mysqld_binary="${EROOT}/usr/sbin/mysqld" |
596 |
+ if [[ ! -x "${mysqld_binary}" ]] ; then |
597 |
+ die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" |
598 |
+ fi |
599 |
+ |
600 |
+ local mysql_binary="${EROOT}/usr/bin/mysql" |
601 |
+ if [[ ! -x "${mysql_binary}" ]] ; then |
602 |
+ die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" |
603 |
+ fi |
604 |
+ |
605 |
+ local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" |
606 |
+ if [[ ! -x "${my_print_defaults_binary}" ]] ; then |
607 |
+ die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" |
608 |
+ fi |
609 |
+ |
610 |
+ if [[ -z "${MYSQL_USER}" ]] ; then |
611 |
+ MYSQL_USER=mysql |
612 |
+ if use prefix ; then |
613 |
+ MYSQL_USER=$(id -u -n 2>/dev/null) |
614 |
+ if [[ -z "${MYSQL_USER}" ]] ; then |
615 |
+ die "Failed to determine current username!" |
616 |
+ fi |
617 |
+ fi |
618 |
+ fi |
619 |
+ |
620 |
+ if [[ -z "${MYSQL_GROUP}" ]] ; then |
621 |
+ MYSQL_GROUP=mysql |
622 |
+ if use prefix ; then |
623 |
+ MYSQL_GROUP=$(id -g -n 2>/dev/null) |
624 |
+ if [[ -z "${MYSQL_GROUP}" ]] ; then |
625 |
+ die "Failed to determine current user groupname!" |
626 |
+ fi |
627 |
+ fi |
628 |
+ fi |
629 |
+ |
630 |
+ einfo "Will use username '${MYSQL_USER}' and group '${MYSQL_GROUP}' ..." |
631 |
+ |
632 |
+ _getoptval() { |
633 |
+ local section="$1" |
634 |
+ local flag="--${2}=" |
635 |
+ local extra_options="${3}" |
636 |
+ local cmd=( |
637 |
+ "${my_print_defaults_binary}" |
638 |
+ "${extra_options}" |
639 |
+ "${section}" |
640 |
+ ) |
641 |
+ local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) |
642 |
+ |
643 |
+ if [[ ${#results[@]} -gt 0 ]] ; then |
644 |
+ # When option is set multiple times only return last value |
645 |
+ echo "${results[-1]}" |
646 |
+ fi |
647 |
+ } |
648 |
+ |
649 |
+ _mktemp_dry() { |
650 |
+ # emktemp has no --dry-run option |
651 |
+ local template="${1}" |
652 |
+ |
653 |
+ if [[ -z "${template}" ]] ; then |
654 |
+ if [[ -z "${T}" ]] ; then |
655 |
+ template="/tmp/XXXXXXX" |
656 |
+ else |
657 |
+ template="${T}/XXXXXXX" |
658 |
+ fi |
659 |
+ fi |
660 |
+ |
661 |
+ local template_wo_X=${template//X/} |
662 |
+ local n_X |
663 |
+ let n_X=${#template}-${#template_wo_X} |
664 |
+ if [[ ${n_X} -lt 3 ]] ; then |
665 |
+ echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 |
666 |
+ return |
667 |
+ fi |
668 |
+ |
669 |
+ local attempts=0 |
670 |
+ local character tmpfile |
671 |
+ while [[ true ]] ; do |
672 |
+ let attempts=attempts+1 |
673 |
+ |
674 |
+ new_file= |
675 |
+ while read -n1 character ; do |
676 |
+ if [[ "${character}" == "X" ]] ; then |
677 |
+ tmpfile+="${RANDOM:0:1}" |
678 |
+ else |
679 |
+ tmpfile+="${character}" |
680 |
+ fi |
681 |
+ done < <(echo -n "${template}") |
682 |
+ |
683 |
+ if [[ ! -f "${tmpfile}" ]] |
684 |
+ then |
685 |
+ echo "${tmpfile}" |
686 |
+ return |
687 |
+ fi |
688 |
+ |
689 |
+ if [[ ${attempts} -ge 100 ]] ; then |
690 |
+ echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 |
691 |
+ return |
692 |
+ fi |
693 |
+ done |
694 |
+ } |
695 |
+ |
696 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
697 |
+ local -x HOME="${EROOT}/root" |
698 |
+ |
699 |
+ # Make sure the vars are correctly initialized |
700 |
+ mysql_init_vars |
701 |
+ |
702 |
+ # Read currently set data directory |
703 |
+ MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
704 |
+ |
705 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
706 |
+ # localhost. Also causes weird failures. |
707 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
708 |
+ |
709 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
710 |
+ die "Sorry, unable to find MY_DATADIR!" |
711 |
+ elif [[ -d "${MY_DATADIR}/mysql" ]] ; then |
712 |
+ ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" |
713 |
+ ewarn "Please rename or delete its content if you wish to initialize a new data directory." |
714 |
+ die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" |
715 |
+ else |
716 |
+ einfo "${PN} data directory detected as '${MY_DATADIR}' ..." |
717 |
+ fi |
718 |
+ |
719 |
+ MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
720 |
+ # These are dir+prefix |
721 |
+ MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
722 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
723 |
+ MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
724 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
725 |
+ |
726 |
+ # Create missing directories. |
727 |
+ # Always check if mysql user can write to directory even if we just |
728 |
+ # created directory because a parent directory might be not |
729 |
+ # accessible for that user. |
730 |
+ PID_DIR="${EROOT}/run/mysqld" |
731 |
+ if [[ ! -d "${PID_DIR}" ]] ; then |
732 |
+ einfo "Creating ${PN} PID directory '${PID_DIR}' ..." |
733 |
+ install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ |
734 |
+ || die "Failed to create PID directory '${PID_DIR}'!" |
735 |
+ fi |
736 |
+ |
737 |
+ local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" |
738 |
+ [[ -z "${_pid_dir_testfile}" ]] \ |
739 |
+ && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
740 |
+ |
741 |
+ if use prefix ; then |
742 |
+ touch "${_pid_dir_testfile}" &>/dev/null |
743 |
+ else |
744 |
+ su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null |
745 |
+ fi |
746 |
+ |
747 |
+ if [[ $? -ne 0 ]] ; then |
748 |
+ die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" |
749 |
+ else |
750 |
+ rm "${_pid_dir_testfile}" || die |
751 |
+ unset _pid_dir_testfile |
752 |
+ fi |
753 |
+ |
754 |
+ if [[ ! -d "${MY_DATADIR}" ]] ; then |
755 |
+ einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." |
756 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ |
757 |
+ || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" |
758 |
+ fi |
759 |
+ |
760 |
+ local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" |
761 |
+ [[ -z "${_my_datadir_testfile}" ]] \ |
762 |
+ && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
763 |
+ |
764 |
+ if use prefix ; then |
765 |
+ touch "${_my_datadir_testfile}" &>/dev/null |
766 |
+ else |
767 |
+ su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null |
768 |
+ fi |
769 |
+ |
770 |
+ if [[ $? -ne 0 ]]; then |
771 |
+ die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" |
772 |
+ else |
773 |
+ rm "${_my_datadir_testfile}" || die |
774 |
+ unset _my_datadir_testfile |
775 |
+ fi |
776 |
+ |
777 |
+ if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then |
778 |
+ einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." |
779 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ |
780 |
+ || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" |
781 |
+ fi |
782 |
+ |
783 |
+ if [[ -n "${MYSQL_TMPDIR}" ]] ; then |
784 |
+ local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" |
785 |
+ [[ -z "${_my_tmpdir_testfile}" ]] \ |
786 |
+ && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
787 |
+ |
788 |
+ if use prefix ; then |
789 |
+ touch "${_my_tmpdir_testfile}" &>/dev/null |
790 |
+ else |
791 |
+ su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null |
792 |
+ fi |
793 |
+ |
794 |
+ if [[ $? -ne 0 ]]; then |
795 |
+ die "${MYSQL_USER} user cannot write into data directory '${MYSQL_TMPDIR}'!" |
796 |
+ else |
797 |
+ rm "${_my_tmpdir_testfile}" || die |
798 |
+ unset _my_tmpdir_testfile |
799 |
+ fi |
800 |
+ else |
801 |
+ # If no tmpdir is set, mysqld will use default system tmpdir. |
802 |
+ # However, we are using tmpdir from package manager at the |
803 |
+ # moment which maybe isn't writeable for $MYSQL_USER... |
804 |
+ MYSQL_TMPDIR="$(_mktemp_dry "${T}/mysqld-tmp.XXXXXXXXX")" |
805 |
+ [[ -z "${MYSQL_TMPDIR}" ]] \ |
806 |
+ && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" |
807 |
+ |
808 |
+ mkdir "${MYSQL_TMPDIR}" || die |
809 |
+ chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die |
810 |
+ fi |
811 |
+ |
812 |
+ if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then |
813 |
+ einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." |
814 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ |
815 |
+ || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" |
816 |
+ fi |
817 |
+ |
818 |
+ if [[ -n "${MYSQL_LOG_BIN}" ]] ; then |
819 |
+ local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" |
820 |
+ [[ -z "${_my_logbin_testfile}" ]] \ |
821 |
+ && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" |
822 |
+ |
823 |
+ if use prefix ; then |
824 |
+ touch "${_my_logbin_testfile}" &>/dev/null |
825 |
+ else |
826 |
+ su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null |
827 |
+ fi |
828 |
+ |
829 |
+ if [[ $? -ne 0 ]]; then |
830 |
+ die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" |
831 |
+ else |
832 |
+ rm "${_my_logbin_testfile}" || die |
833 |
+ unset _my_logbin_testfile |
834 |
+ fi |
835 |
+ fi |
836 |
+ |
837 |
+ if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then |
838 |
+ einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." |
839 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ |
840 |
+ || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" |
841 |
+ fi |
842 |
+ |
843 |
+ if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then |
844 |
+ local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" |
845 |
+ [[ -z "${_my_relaylog_testfile}" ]] \ |
846 |
+ && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" |
847 |
+ |
848 |
+ if use prefix ; then |
849 |
+ touch "${_my_relaylog_testfile}" &>/dev/null |
850 |
+ else |
851 |
+ su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null |
852 |
+ fi |
853 |
+ |
854 |
+ if [[ $? -ne 0 ]]; then |
855 |
+ die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" |
856 |
+ else |
857 |
+ rm "${_my_relaylog_testfile}" || die |
858 |
+ unset _my_relaylog_testfile |
859 |
+ fi |
860 |
+ fi |
861 |
+ |
862 |
+ local -a config_files |
863 |
+ |
864 |
+ local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf" |
865 |
+ if [[ -f "${config_file}" ]] ; then |
866 |
+ config_files+=( "${config_file}" ) |
867 |
+ else |
868 |
+ ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..." |
869 |
+ fi |
870 |
+ |
871 |
+ config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf" |
872 |
+ if [[ -f "${config_file}" ]] ; then |
873 |
+ config_files+=( "${config_file}" ) |
874 |
+ else |
875 |
+ ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..." |
876 |
+ fi |
877 |
+ |
878 |
+ if [[ ${#config_files[@]} -gt 0 ]] ; then |
879 |
+ if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then |
880 |
+ local user_answer |
881 |
+ |
882 |
+ echo |
883 |
+ einfo "Please select default authentication plugin (enter number or plugin name):" |
884 |
+ einfo "1) caching_sha2_password [MySQL 8.0 default]" |
885 |
+ einfo "2) mysql_native_password [MySQL 5.7 default]" |
886 |
+ einfo |
887 |
+ einfo "For details see:" |
888 |
+ einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password" |
889 |
+ read -p " >" user_answer |
890 |
+ echo |
891 |
+ |
892 |
+ case "${user_answer}" in |
893 |
+ 1|caching_sha2_password) |
894 |
+ MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password |
895 |
+ ;; |
896 |
+ 2|mysql_native_password) |
897 |
+ MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password |
898 |
+ ;; |
899 |
+ '') |
900 |
+ die "No authentication plugin selected!" |
901 |
+ ;; |
902 |
+ *) |
903 |
+ die "Authentication plugin '${user_answer}' is unknown/unsupported!" |
904 |
+ ;; |
905 |
+ esac |
906 |
+ |
907 |
+ unset user_answer |
908 |
+ fi |
909 |
+ |
910 |
+ local cfg_option cfg_option_tabs cfg_section |
911 |
+ for config_file in "${config_files[@]}" ; do |
912 |
+ cfg_option="default-authentication-plugin" |
913 |
+ cfg_section="mysqld" |
914 |
+ cfg_option_tabs="\t\t" |
915 |
+ if [[ "${config_file}" == *client.cnf ]] ; then |
916 |
+ cfg_option="default-auth" |
917 |
+ cfg_section="client" |
918 |
+ cfg_option_tabs="\t\t\t\t" |
919 |
+ fi |
920 |
+ |
921 |
+ if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then |
922 |
+ einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." |
923 |
+ sed -i \ |
924 |
+ -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \ |
925 |
+ "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!" |
926 |
+ else |
927 |
+ einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." |
928 |
+ sed -i \ |
929 |
+ -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \ |
930 |
+ "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!" |
931 |
+ fi |
932 |
+ done |
933 |
+ unset cfg_option cfg_option_tabs cfg_section |
934 |
+ fi |
935 |
+ unset config_files config_file |
936 |
+ |
937 |
+ echo |
938 |
+ |
939 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
940 |
+ local tmp_mysqld_password_source= |
941 |
+ |
942 |
+ for tmp_mysqld_password_source in mysql client ; do |
943 |
+ einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." |
944 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" |
945 |
+ if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then |
946 |
+ if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then |
947 |
+ ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" |
948 |
+ MYSQL_ROOT_PASSWORD= |
949 |
+ continue |
950 |
+ fi |
951 |
+ |
952 |
+ einfo "Found password in '${tmp_mysqld_password_source}' section!" |
953 |
+ break |
954 |
+ fi |
955 |
+ done |
956 |
+ |
957 |
+ # Sometimes --show is required to display passwords in some implementations of my_print_defaults |
958 |
+ if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then |
959 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" |
960 |
+ fi |
961 |
+ |
962 |
+ unset tmp_mysqld_password_source |
963 |
+ fi |
964 |
+ |
965 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
966 |
+ local pwd1="a" |
967 |
+ local pwd2="b" |
968 |
+ |
969 |
+ echo |
970 |
+ einfo "No password for mysql 'root' user was specified via environment" |
971 |
+ einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" |
972 |
+ einfo "file like '${HOME}/.my.cnf'." |
973 |
+ einfo "To continue please provide a password for the mysql 'root' user" |
974 |
+ einfo "now on console:" |
975 |
+ ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" |
976 |
+ read -rsp " >" pwd1 ; echo |
977 |
+ |
978 |
+ einfo "Retype the password" |
979 |
+ read -rsp " >" pwd2 ; echo |
980 |
+ |
981 |
+ if [[ "x$pwd1" != "x$pwd2" ]] ; then |
982 |
+ die "Passwords are not the same!" |
983 |
+ fi |
984 |
+ |
985 |
+ MYSQL_ROOT_PASSWORD="${pwd1}" |
986 |
+ unset pwd1 pwd2 |
987 |
+ |
988 |
+ echo |
989 |
+ fi |
990 |
+ |
991 |
+ local -a mysqld_options |
992 |
+ |
993 |
+ # Fix bug 446200. Don't reference host my.cnf, needs to come first, |
994 |
+ # see http://bugs.mysql.com/bug.php?id=31312 |
995 |
+ use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) |
996 |
+ |
997 |
+ # Figure out which options we need to disable to do the setup |
998 |
+ local helpfile="${TMPDIR}/mysqld-help" |
999 |
+ "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null |
1000 |
+ |
1001 |
+ local opt optexp optfull |
1002 |
+ for opt in host-cache name-resolve networking slave-start \ |
1003 |
+ federated ssl log-bin relay-log slow-query-log external-locking \ |
1004 |
+ log-slave-updates \ |
1005 |
+ ; do |
1006 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
1007 |
+ egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) |
1008 |
+ done |
1009 |
+ |
1010 |
+ # Prepare timezones, see |
1011 |
+ # https://dev.mysql.com/doc/mysql/en/time-zone-support.html |
1012 |
+ local tz_sql="${TMPDIR}/tz.sql" |
1013 |
+ echo "USE mysql;" >"${tz_sql}" |
1014 |
+ "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null |
1015 |
+ if [[ $? -ne 0 ]] ; then |
1016 |
+ die "mysql_tzinfo_to_sql failed!" |
1017 |
+ fi |
1018 |
+ |
1019 |
+ chown ${MYSQL_USER} "${tz_sql}" || die |
1020 |
+ |
1021 |
+ local mysql_install_log="${TMPDIR}/mysql_install_db.log" |
1022 |
+ touch "${mysql_install_log}" || die |
1023 |
+ chown ${MYSQL_USER} "${mysql_install_log}" || die |
1024 |
+ |
1025 |
+ # --initialize-insecure will not set root password |
1026 |
+ # --initialize would set a random one in the log which we don't need as we set it ourselves |
1027 |
+ local cmd=( |
1028 |
+ "${mysqld_binary}" |
1029 |
+ "${mysqld_options[@]}" |
1030 |
+ "--initialize-insecure" |
1031 |
+ "--init-file='${tz_sql}'" |
1032 |
+ "--basedir='${EROOT}/usr'" |
1033 |
+ "--datadir='${MY_DATADIR}'" |
1034 |
+ "--tmpdir='${MYSQL_TMPDIR}'" |
1035 |
+ "--log-error='${mysql_install_log}'" |
1036 |
+ "--user=${MYSQL_USER}" |
1037 |
+ ) |
1038 |
+ |
1039 |
+ einfo "Initializing ${PN} data directory: ${cmd[@]}" |
1040 |
+ eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 |
1041 |
+ |
1042 |
+ if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then |
1043 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 |
1044 |
+ die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" |
1045 |
+ fi |
1046 |
+ |
1047 |
+ local x=${RANDOM} |
1048 |
+ local socket="${EROOT}/run/mysqld/mysqld${x}.sock" |
1049 |
+ local pidfile="${EROOT}/run/mysqld/mysqld${x}.pid" |
1050 |
+ unset x |
1051 |
+ |
1052 |
+ local mysqld_logfile="${TMPDIR}/mysqld.log" |
1053 |
+ touch "${mysqld_logfile}" || die |
1054 |
+ chown ${MYSQL_USER} "${mysqld_logfile}" || die |
1055 |
+ |
1056 |
+ cmd=( |
1057 |
+ "${mysqld_binary}" |
1058 |
+ "${mysqld_options[@]}" |
1059 |
+ "--basedir='${EROOT}/usr'" |
1060 |
+ "--datadir='${MY_DATADIR}'" |
1061 |
+ "--tmpdir='${MYSQL_TMPDIR}'" |
1062 |
+ --max_allowed_packet=8M |
1063 |
+ --net_buffer_length=16K |
1064 |
+ "--socket='${socket}'" |
1065 |
+ "--pid-file='${pidfile}'" |
1066 |
+ "--log-error='${mysqld_logfile}'" |
1067 |
+ "--user=${MYSQL_USER}" |
1068 |
+ ) |
1069 |
+ |
1070 |
+ einfo "Starting mysqld to finalize initialization: ${cmd[@]}" |
1071 |
+ eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & |
1072 |
+ |
1073 |
+ echo -n "Waiting for mysqld to accept connections " |
1074 |
+ local maxtry=15 |
1075 |
+ while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do |
1076 |
+ maxtry=$((${maxtry}-1)) |
1077 |
+ echo -n "." |
1078 |
+ sleep 1 |
1079 |
+ done |
1080 |
+ |
1081 |
+ if [[ -S "${socket}" ]] ; then |
1082 |
+ # Even with a socket we don't know if mysqld will abort |
1083 |
+ # start due to an error so just wait a little bit more... |
1084 |
+ maxtry=5 |
1085 |
+ while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do |
1086 |
+ maxtry=$((${maxtry}-1)) |
1087 |
+ echo -n "." |
1088 |
+ sleep 1 |
1089 |
+ done |
1090 |
+ fi |
1091 |
+ |
1092 |
+ echo |
1093 |
+ |
1094 |
+ if [[ ! -S "${socket}" ]] ; then |
1095 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 |
1096 |
+ die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" |
1097 |
+ fi |
1098 |
+ |
1099 |
+ local mysql_logfile="${TMPDIR}/set_root_pw.log" |
1100 |
+ touch "${mysql_logfile}" || die |
1101 |
+ |
1102 |
+ ebegin "Setting root password" |
1103 |
+ # Do this from memory, as we don't want clear text passwords in temp files |
1104 |
+ local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" |
1105 |
+ cmd=( |
1106 |
+ "${mysql_binary}" |
1107 |
+ --no-defaults |
1108 |
+ "--socket='${socket}'" |
1109 |
+ -hlocalhost |
1110 |
+ "-e \"${sql}\"" |
1111 |
+ ) |
1112 |
+ eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 |
1113 |
+ local rc=$? |
1114 |
+ eend ${rc} |
1115 |
+ |
1116 |
+ if [[ ${rc} -ne 0 ]] ; then |
1117 |
+ # Poor man's solution which tries to avoid having password |
1118 |
+ # in log. NOTE: sed can fail if user didn't follow advice |
1119 |
+ # and included character which will require escaping... |
1120 |
+ sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null |
1121 |
+ |
1122 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" |
1123 |
+ die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" |
1124 |
+ fi |
1125 |
+ |
1126 |
+ # Stop the server |
1127 |
+ if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then |
1128 |
+ echo -n "Stopping the server " |
1129 |
+ pkill -F "${pidfile}" &>/dev/null |
1130 |
+ |
1131 |
+ maxtry=10 |
1132 |
+ while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do |
1133 |
+ maxtry=$((${maxtry}-1)) |
1134 |
+ echo -n "." |
1135 |
+ sleep 1 |
1136 |
+ done |
1137 |
+ |
1138 |
+ echo |
1139 |
+ |
1140 |
+ if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then |
1141 |
+ # We somehow failed to stop server. |
1142 |
+ # However, not a fatal error. Just warn the user. |
1143 |
+ ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" |
1144 |
+ fi |
1145 |
+ fi |
1146 |
+ |
1147 |
+ einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" |
1148 |
+} |