1 |
commit: 1d17c28118c0eb467d78c2d7a7432e675cadcbd4 |
2 |
Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Apr 30 21:25:21 2020 +0000 |
4 |
Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 30 21:42:16 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1d17c281 |
7 |
|
8 |
dev-db/mysql: bump to v5.7.30 |
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-5.7.30.ebuild | 975 +++++++++++++++++++++++++++++++++++++++ |
16 |
2 files changed, 977 insertions(+) |
17 |
|
18 |
diff --git a/dev-db/mysql/Manifest b/dev-db/mysql/Manifest |
19 |
index 6f0e03d7d84..9cf53ff8307 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-5.7.30-patches-01.tar.xz 6684 BLAKE2B 9350280094619fda0d91eacae573396198954fceb5dc039669d236b1dad98eef306702550b517ef30ee3d0e6721667b6f5549df91e3c15cef68888079c00d9ba SHA512 74e8e8794fe54b73776b38296aa42c65547311b80bfe65c88b2f961bd44083e9628eb47da4ebcf4c20e2d7c694f514223bcbf29cce27853cca500710ae97778d |
26 |
DIST mysql-8.0.20-patches-01.tar.xz 7176 BLAKE2B 2fc51986c0a4da60521d0e64b9f8705caf8ec3869af930c9729359c3710059fc78aae176523fdf17d10173b404431f31f9bb23ee5c82fba7cbbb4cb39881c005 SHA512 bf8211cf3873f8672b9d3d1dc42b68a1c635690ffdc2d3393eafa83f060ada9f2eaa63f859bf8eecc24976a733d8c7c3b9632ac70f28b5facf48eae921c7ceeb |
27 |
DIST mysql-boost-5.7.26.tar.gz 51098338 BLAKE2B 1263cd75814a7293b26b0f44fd2b7d20d983f3c6a62725df9515ecac2ef252f6644810cb4bf0d6f36b98e55317f1c67ea7541228cb38d896dfedc476a5755f26 SHA512 a5f9871dc5a8e5fffc1467c3dd542533a63fe553c029120475f8fd5530d884c76ab0c33ad260daf317faf318ccef01464f6ac2dc3468efceb6bf2b6c06c54cfd |
28 |
DIST mysql-boost-5.7.27.tar.gz 51436383 BLAKE2B 6db64ab5fa659aae9baa3725a0de9465e48c37618ffd69f34809880c06a00ce55dce77f507810c6fa52d86901facfa42d3d1bd8db1914a779fbc88a69be82497 SHA512 573f4555f3d62bcd3dc2228bcfba023518d462bb6689114a3505ccf7c7c3061d2775a8e7a37ec3c8b9dea6e8fbc56ba599610f237abc38cedff58e75799bdc52 |
29 |
DIST mysql-boost-5.7.29.tar.gz 51417554 BLAKE2B 652ce9f99419387e9bcc37afeb1b46438784752e963c3aa1877f17650c31d8b058b4052da97c3a7e9454e758c259d6c311e0518f9a75909fce9741150b82164c SHA512 38acf7c2a10b20c59230ad05cd2cd6996c4c582233c1be573ead08e5c6684275790da07a036570363f89b4d61547b306589b0b98ed5fca70723a3f2cbc21fe11 |
30 |
+DIST mysql-boost-5.7.30.tar.gz 51363998 BLAKE2B 7897ad74b685c3b30e7ecdf132fdfa72f3416c05e8d0086cb8f7674b6c4f377fff9abc51ed258cc4dfeab50a2cb393af9076d9c1f9a83a26521facbaf223afa1 SHA512 b75d41d0c72d16c6f8d5393dab6e476b7993d296eb5683c12417ce2da3db2052fdab2a152f6e7c545315d21bfa35f26a247cb6cdab83d3418b5d34ed7f5f9560 |
31 |
DIST mysql-boost-8.0.19.tar.gz 264147972 BLAKE2B 61a5ccbef1a7a675c85e4e6bda8e5285bdb931e6ee14d4710bf13dfd9157d1095200db2886dc93ea7251d3d59245f35c0bef5ba88ba6aac209b1e080f3b07dc4 SHA512 5ffc03f005ab2585694902e926b6cb2b10059b2b030549eccd3949f9c3b2f02626d02529f940dec003f2d69683856fd1c720ff12f89dfbdc48befaf24a9c4d01 |
32 |
DIST mysql-boost-8.0.20.tar.gz 266282970 BLAKE2B 2aeb9d6c575ed9dc2d00d3e51e6391c59ffa39156491d9ed2c07e19bb2efb88a14d5a9d4b537c137d71854e39fa3a7fc2b93618118d4fd062e92ba2d83783c6f SHA512 7a962e9ddec7069008c5ab6ac2801515e2661ca2875afc6141541c03e2f941f4255b3c0d806a4df2fd2f2f1d12323aeb1e456c1d364777a18ccebefad7b22a99 |
33 |
DIST mysql-extras-20190817-0024Z.tar.bz2 337793 BLAKE2B dfd51a708654aff5bdbbaf2acad7ef966869a8e3adcba544ee15f217d2ba942827445841e73981bccc6c1f145b6225bfa7245114219f0cf52f0dfb85494a6830 SHA512 c2ff81be1c55636f0a2700033af030149f312f0383217054a4b8c65aef174626299fcb4539eaae967ea7d096a5bb09f5b5122dce344b44b0a135d886ba0fdf28 |
34 |
|
35 |
diff --git a/dev-db/mysql/mysql-5.7.30.ebuild b/dev-db/mysql/mysql-5.7.30.ebuild |
36 |
new file mode 100644 |
37 |
index 00000000000..ddb4b28d3e1 |
38 |
--- /dev/null |
39 |
+++ b/dev-db/mysql/mysql-5.7.30.ebuild |
40 |
@@ -0,0 +1,975 @@ |
41 |
+# Copyright 1999-2020 Gentoo Authors |
42 |
+# Distributed under the terms of the GNU General Public License v2 |
43 |
+ |
44 |
+EAPI="6" |
45 |
+ |
46 |
+CMAKE_MAKEFILE_GENERATOR=emake |
47 |
+ |
48 |
+# Keeping eutils in EAPI=6 for emktemp in pkg_config |
49 |
+ |
50 |
+inherit cmake-utils eutils flag-o-matic linux-info \ |
51 |
+ prefix toolchain-funcs multilib-minimal |
52 |
+ |
53 |
+# Patch version |
54 |
+PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-5.7.30-patches-01.tar.xz" |
55 |
+ |
56 |
+SRC_URI="https://cdn.mysql.com/Downloads/MySQL-5.7/${PN}-boost-${PV}.tar.gz |
57 |
+ https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${PV}.tar.gz |
58 |
+ http://downloads.mysql.com/archives/MySQL-5.7/${PN}-boost-${PV}.tar.gz |
59 |
+ ${PATCH_SET}" |
60 |
+ |
61 |
+HOMEPAGE="https://www.mysql.com/" |
62 |
+DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" |
63 |
+LICENSE="GPL-2" |
64 |
+SLOT="0/18" |
65 |
+IUSE="cjk client-libs cracklib debug experimental jemalloc latin1 libressl numa +perl profiling |
66 |
+ selinux +server static static-libs systemtap tcmalloc test yassl" |
67 |
+ |
68 |
+# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests |
69 |
+RESTRICT="!test? ( test ) libressl? ( test )" |
70 |
+ |
71 |
+REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )" |
72 |
+ |
73 |
+KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" |
74 |
+ |
75 |
+# Shorten the path because the socket path length must be shorter than 107 chars |
76 |
+# and we will run a mysql server during test phase |
77 |
+S="${WORKDIR}/mysql" |
78 |
+ |
79 |
+# Be warned, *DEPEND are version-dependant |
80 |
+# These are used for both runtime and compiletime |
81 |
+# MULTILIB_USEDEP only set for libraries used by the client library |
82 |
+COMMON_DEPEND="net-misc/curl:= |
83 |
+ >=sys-apps/sed-4 |
84 |
+ >=sys-apps/texinfo-4.7-r1 |
85 |
+ sys-libs/ncurses:0= |
86 |
+ client-libs? ( >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?] ) |
87 |
+ !client-libs? ( |
88 |
+ dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] |
89 |
+ >=sys-libs/zlib-1.2.3:0= |
90 |
+ ) |
91 |
+ jemalloc? ( dev-libs/jemalloc:0= ) |
92 |
+ kernel_linux? ( |
93 |
+ dev-libs/libaio:0= |
94 |
+ sys-process/procps:0= |
95 |
+ ) |
96 |
+ server? ( |
97 |
+ >=app-arch/lz4-0_p131:= |
98 |
+ cjk? ( app-text/mecab:= ) |
99 |
+ experimental? ( |
100 |
+ dev-libs/libevent:= |
101 |
+ dev-libs/protobuf:= |
102 |
+ net-libs/libtirpc:= |
103 |
+ ) |
104 |
+ numa? ( sys-process/numactl ) |
105 |
+ ) |
106 |
+ systemtap? ( >=dev-util/systemtap-1.3:0= ) |
107 |
+ tcmalloc? ( dev-util/google-perftools:0= ) |
108 |
+ !yassl? ( |
109 |
+ client-libs? ( |
110 |
+ !libressl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] ) |
111 |
+ libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] ) |
112 |
+ ) |
113 |
+ !client-libs? ( |
114 |
+ !libressl? ( >=dev-libs/openssl-1.0.0:0= ) |
115 |
+ libressl? ( dev-libs/libressl:0= ) |
116 |
+ ) |
117 |
+ ) |
118 |
+" |
119 |
+DEPEND="${COMMON_DEPEND} |
120 |
+ || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) |
121 |
+ dev-libs/protobuf |
122 |
+ virtual/yacc |
123 |
+ server? ( |
124 |
+ dev-libs/libevent |
125 |
+ experimental? ( net-libs/rpcsvc-proto ) |
126 |
+ ) |
127 |
+ static? ( sys-libs/ncurses[static-libs] ) |
128 |
+ test? ( |
129 |
+ acct-group/mysql acct-user/mysql |
130 |
+ dev-perl/JSON |
131 |
+ ) |
132 |
+" |
133 |
+RDEPEND="${COMMON_DEPEND} |
134 |
+ !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster |
135 |
+ client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c dev-libs/protobuf:= ) |
136 |
+ selinux? ( sec-policy/selinux-mysql ) |
137 |
+ server? ( |
138 |
+ !prefix? ( |
139 |
+ acct-group/mysql acct-user/mysql |
140 |
+ dev-db/mysql-init-scripts |
141 |
+ ) |
142 |
+ ) |
143 |
+" |
144 |
+# For other stuff to bring us in |
145 |
+# dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
146 |
+PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
147 |
+ |
148 |
+mysql_init_vars() { |
149 |
+ MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"} |
150 |
+ MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"} |
151 |
+ MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"} |
152 |
+ MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"} |
153 |
+ |
154 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
155 |
+ MY_DATADIR="" |
156 |
+ if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then |
157 |
+ MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ |
158 |
+ | sed -ne '/datadir/s|^--datadir=||p' \ |
159 |
+ | tail -n1` |
160 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
161 |
+ MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ |
162 |
+ | sed -e 's/.*=\s*//' \ |
163 |
+ | tail -n1` |
164 |
+ fi |
165 |
+ fi |
166 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
167 |
+ MY_DATADIR="${MY_LOCALSTATEDIR}" |
168 |
+ einfo "Using default MY_DATADIR" |
169 |
+ fi |
170 |
+ elog "MySQL MY_DATADIR is ${MY_DATADIR}" |
171 |
+ |
172 |
+ if [[ -z "${PREVIOUS_DATADIR}" ]] ; then |
173 |
+ if [[ -e "${MY_DATADIR}" ]] ; then |
174 |
+ # If you get this and you're wondering about it, see bug #207636 |
175 |
+ elog "MySQL datadir found in ${MY_DATADIR}" |
176 |
+ elog "A new one will not be created." |
177 |
+ PREVIOUS_DATADIR="yes" |
178 |
+ else |
179 |
+ PREVIOUS_DATADIR="no" |
180 |
+ fi |
181 |
+ export PREVIOUS_DATADIR |
182 |
+ fi |
183 |
+ else |
184 |
+ if [[ ${EBUILD_PHASE} == "config" ]] ; then |
185 |
+ local new_MY_DATADIR |
186 |
+ new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ |
187 |
+ | sed -ne '/datadir/s|^--datadir=||p' \ |
188 |
+ | tail -n1` |
189 |
+ |
190 |
+ if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]] ; then |
191 |
+ ewarn "MySQL MY_DATADIR has changed" |
192 |
+ ewarn "from ${MY_DATADIR}" |
193 |
+ ewarn "to ${new_MY_DATADIR}" |
194 |
+ MY_DATADIR="${new_MY_DATADIR}" |
195 |
+ fi |
196 |
+ fi |
197 |
+ fi |
198 |
+ |
199 |
+ export MY_SHAREDSTATEDIR MY_SYSCONFDIR |
200 |
+ export MY_LOCALSTATEDIR MY_LOGDIR |
201 |
+ export MY_DATADIR |
202 |
+} |
203 |
+ |
204 |
+pkg_pretend() { |
205 |
+ if use numa ; then |
206 |
+ local CONFIG_CHECK="~NUMA" |
207 |
+ |
208 |
+ local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" |
209 |
+ WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" |
210 |
+ |
211 |
+ check_extra_config |
212 |
+ fi |
213 |
+} |
214 |
+ |
215 |
+pkg_setup() { |
216 |
+ if [[ ${MERGE_TYPE} != binary ]] ; then |
217 |
+ local GCC_MAJOR_SET=$(gcc-major-version) |
218 |
+ local GCC_MINOR_SET=$(gcc-minor-version) |
219 |
+ # Bug 565584: InnoDB now requires atomic functions introduced with gcc-4.7 on |
220 |
+ # non x86{,_64} arches |
221 |
+ if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \ |
222 |
+ ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then |
223 |
+ eerror "${PN} needs to be built with gcc-4.7 or later." |
224 |
+ eerror "Please use gcc-config to switch to gcc-4.7 or later version." |
225 |
+ die |
226 |
+ fi |
227 |
+ fi |
228 |
+ |
229 |
+ if has test ${FEATURES} && \ |
230 |
+ use server && ! has userpriv ${FEATURES} ; then |
231 |
+ eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
232 |
+ fi |
233 |
+} |
234 |
+ |
235 |
+pkg_preinst() { |
236 |
+ # Here we need to see if the implementation switched client libraries |
237 |
+ # We check if this is a new instance of the package and a client library already exists |
238 |
+ local SHOW_ABI_MESSAGE libpath |
239 |
+ if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then |
240 |
+ libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so") |
241 |
+ elog "Due to ABI changes when switching between different client libraries," |
242 |
+ elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." |
243 |
+ elog "Please run: revdep-rebuild --library ${libpath}" |
244 |
+ ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" |
245 |
+ fi |
246 |
+} |
247 |
+ |
248 |
+pkg_postinst() { |
249 |
+ # Make sure the vars are correctly initialized |
250 |
+ mysql_init_vars |
251 |
+ |
252 |
+ # Create log directory securely if it does not exist |
253 |
+ [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
254 |
+ |
255 |
+ if use server ; then |
256 |
+ if [[ -z "${REPLACING_VERSIONS}" ]] ; then |
257 |
+ einfo |
258 |
+ elog "You might want to run:" |
259 |
+ elog "\"emerge --config =${CATEGORY}/${PF}\"" |
260 |
+ elog "if this is a new install." |
261 |
+ elog |
262 |
+ elog "If you are switching server implentations, you should run the" |
263 |
+ elog "mysql_upgrade tool." |
264 |
+ einfo |
265 |
+ else |
266 |
+ einfo |
267 |
+ elog "If you are upgrading major versions, you should run the" |
268 |
+ elog "mysql_upgrade tool." |
269 |
+ einfo |
270 |
+ fi |
271 |
+ fi |
272 |
+ |
273 |
+ # Note about configuration change |
274 |
+ einfo |
275 |
+ elog "This version of ${PN} reorganizes the configuration from a single my.cnf" |
276 |
+ elog "to several files in /etc/mysql/mysql.d." |
277 |
+ elog "Please backup any changes you made to /etc/mysql/my.cnf" |
278 |
+ elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." |
279 |
+ elog "You may have as many files as needed and they are read alphabetically." |
280 |
+ elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." |
281 |
+ einfo |
282 |
+} |
283 |
+ |
284 |
+src_unpack() { |
285 |
+ unpack ${A} |
286 |
+ |
287 |
+ mv -f "${WORKDIR}/${P}" "${S}" || die |
288 |
+} |
289 |
+ |
290 |
+src_prepare() { |
291 |
+ eapply "${WORKDIR}"/mysql-patches |
292 |
+ |
293 |
+ cmake-utils_src_prepare |
294 |
+ |
295 |
+ if use jemalloc ; then |
296 |
+ echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die |
297 |
+ fi |
298 |
+ |
299 |
+ if use tcmalloc ; then |
300 |
+ echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die |
301 |
+ fi |
302 |
+ |
303 |
+ # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux |
304 |
+ if [[ -d "${S}/support-files/SELinux" ]] ; then |
305 |
+ echo > "${S}/support-files/SELinux/CMakeLists.txt" || die |
306 |
+ fi |
307 |
+ |
308 |
+ # Remove bundled libs so we cannot accidentally use them |
309 |
+ # We keep extra/lz4 directory because we use extra/lz4/xxhash.c via sql/CMakeLists.txt:394 |
310 |
+ rm -rv \ |
311 |
+ "${S}"/extra/protobuf \ |
312 |
+ "${S}"/extra/libevent \ |
313 |
+ "${S}"/zlib \ |
314 |
+ || die |
315 |
+ |
316 |
+ # Don't clash with dev-db/mysql-connector-c |
317 |
+ rm \ |
318 |
+ man/my_print_defaults.1 \ |
319 |
+ man/perror.1 \ |
320 |
+ man/zlib_decompress.1 \ |
321 |
+ || die |
322 |
+ |
323 |
+ if use libressl ; then |
324 |
+ sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \ |
325 |
+ "${S}/cmake/ssl.cmake" || die |
326 |
+ fi |
327 |
+ |
328 |
+ sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die |
329 |
+} |
330 |
+ |
331 |
+src_configure() { |
332 |
+ # Bug #114895, bug #110149 |
333 |
+ filter-flags "-O" "-O[01]" |
334 |
+ |
335 |
+ append-cxxflags -felide-constructors |
336 |
+ |
337 |
+ # bug #283926, with GCC4.4, this is required to get correct behavior. |
338 |
+ append-flags -fno-strict-aliasing |
339 |
+ |
340 |
+ if use client-libs ; then |
341 |
+ multilib-minimal_src_configure |
342 |
+ else |
343 |
+ multilib_src_configure |
344 |
+ fi |
345 |
+} |
346 |
+ |
347 |
+multilib_src_configure() { |
348 |
+ debug-print-function ${FUNCNAME} "$@" |
349 |
+ |
350 |
+ if ! multilib_is_native_abi && ! use client-libs ; then |
351 |
+ return |
352 |
+ fi |
353 |
+ |
354 |
+ CMAKE_BUILD_TYPE="RelWithDebInfo" |
355 |
+ |
356 |
+ # debug hack wrt #497532 |
357 |
+ mycmakeargs=( |
358 |
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
359 |
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
360 |
+ -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" |
361 |
+ -DSYSCONFDIR="${EPREFIX}/etc/mysql" |
362 |
+ -DINSTALL_BINDIR=bin |
363 |
+ -DINSTALL_DOCDIR=share/doc/${PF} |
364 |
+ -DINSTALL_DOCREADMEDIR=share/doc/${PF} |
365 |
+ -DINSTALL_INCLUDEDIR=include/mysql |
366 |
+ -DINSTALL_INFODIR=share/info |
367 |
+ -DINSTALL_LIBDIR=$(get_libdir) |
368 |
+ -DINSTALL_MANDIR=share/man |
369 |
+ -DINSTALL_MYSQLSHAREDIR=share/mysql |
370 |
+ -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin |
371 |
+ -DINSTALL_SCRIPTDIR=share/mysql/scripts |
372 |
+ -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" |
373 |
+ -DINSTALL_SBINDIR=sbin |
374 |
+ -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" |
375 |
+ -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" |
376 |
+ -DWITH_UNIT_TESTS=$(usex test ON OFF) |
377 |
+ ### TODO: make this system but issues with UTF-8 prevent it |
378 |
+ -DWITH_EDITLINE=bundled |
379 |
+ -DWITH_ZLIB=system |
380 |
+ -DWITH_LIBWRAP=0 |
381 |
+ -DENABLED_LOCAL_INFILE=1 |
382 |
+ -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" |
383 |
+ -DWITH_DEFAULT_COMPILER_OPTIONS=0 |
384 |
+ -DWITH_DEFAULT_FEATURE_SET=0 |
385 |
+ # The build forces this to be defined when cross-compiling. We pass it |
386 |
+ # all the time for simplicity and to make sure it is actually correct. |
387 |
+ -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) |
388 |
+ -DWITH_CURL=system |
389 |
+ -DWITH_BOOST="${S}/boost" |
390 |
+ ) |
391 |
+ if use test ; then |
392 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) |
393 |
+ else |
394 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) |
395 |
+ fi |
396 |
+ |
397 |
+ if ! use yassl ; then |
398 |
+ mycmakeargs+=( -DWITH_SSL=system ) |
399 |
+ else |
400 |
+ mycmakeargs+=( -DWITH_SSL=bundled ) |
401 |
+ fi |
402 |
+ |
403 |
+ if ! use client-libs ; then |
404 |
+ mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) |
405 |
+ fi |
406 |
+ |
407 |
+ # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION |
408 |
+ # systemtap only works on native ABI, bug 530132 |
409 |
+ if multilib_is_native_abi ; then |
410 |
+ mycmakeargs+=( |
411 |
+ -DENABLE_DTRACE=$(usex systemtap) |
412 |
+ ) |
413 |
+ else |
414 |
+ mycmakeargs+=( |
415 |
+ -DWITHOUT_TOOLS=1 |
416 |
+ -DWITH_READLINE=1 |
417 |
+ -DENABLE_DTRACE=0 |
418 |
+ ) |
419 |
+ fi |
420 |
+ |
421 |
+ if multilib_is_native_abi && use server ; then |
422 |
+ mycmakeargs+=( |
423 |
+ -DWITH_LIBEVENT=system |
424 |
+ -DWITH_LZ4=system |
425 |
+ -DWITH_PROTOBUF=system |
426 |
+ -DWITH_MECAB=$(usex cjk system OFF) |
427 |
+ -DWITH_NUMA=$(usex numa ON OFF) |
428 |
+ -DWITH_RAPID=$(usex experimental ON OFF) |
429 |
+ ) |
430 |
+ |
431 |
+ if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]] ; then |
432 |
+ ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" |
433 |
+ ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." |
434 |
+ ewarn "You MUST file bugs without these variables set." |
435 |
+ |
436 |
+ mycmakeargs+=( |
437 |
+ -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} |
438 |
+ -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} |
439 |
+ ) |
440 |
+ elif ! use latin1 ; then |
441 |
+ mycmakeargs+=( |
442 |
+ -DDEFAULT_CHARSET=utf8 |
443 |
+ -DDEFAULT_COLLATION=utf8_general_ci |
444 |
+ ) |
445 |
+ else |
446 |
+ mycmakeargs+=( |
447 |
+ -DDEFAULT_CHARSET=latin1 |
448 |
+ -DDEFAULT_COLLATION=latin1_swedish_ci |
449 |
+ ) |
450 |
+ fi |
451 |
+ |
452 |
+ mycmakeargs+=( |
453 |
+ -DEXTRA_CHARSETS=all |
454 |
+ -DDISABLE_SHARED=$(usex static YES NO) |
455 |
+ -DWITH_DEBUG=$(usex debug) |
456 |
+ -DWITH_EMBEDDED_SERVER=OFF |
457 |
+ ) |
458 |
+ |
459 |
+ if use profiling ; then |
460 |
+ # Setting to OFF doesn't work: Once set, profiling options will be added |
461 |
+ # to `mysqld --help` output via sql/sys_vars.cc causing |
462 |
+ # "main.mysqld--help-notwin" test to fail |
463 |
+ mycmakeargs+=( -DENABLED_PROFILING=ON ) |
464 |
+ fi |
465 |
+ |
466 |
+ if use static ; then |
467 |
+ mycmakeargs+=( -DWITH_PIC=1 ) |
468 |
+ fi |
469 |
+ |
470 |
+ # Storage engines |
471 |
+ mycmakeargs+=( |
472 |
+ -DWITH_EXAMPLE_STORAGE_ENGINE=0 |
473 |
+ -DWITH_ARCHIVE_STORAGE_ENGINE=1 |
474 |
+ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 |
475 |
+ -DWITH_CSV_STORAGE_ENGINE=1 |
476 |
+ -DWITH_FEDERATED_STORAGE_ENGINE=1 |
477 |
+ -DWITH_HEAP_STORAGE_ENGINE=1 |
478 |
+ -DWITH_INNOBASE_STORAGE_ENGINE=1 |
479 |
+ -DWITH_INNODB_MEMCACHED=0 |
480 |
+ -DWITH_MYISAMMRG_STORAGE_ENGINE=1 |
481 |
+ -DWITH_MYISAM_STORAGE_ENGINE=1 |
482 |
+ -DWITH_PARTITION_STORAGE_ENGINE=1 |
483 |
+ ) |
484 |
+ |
485 |
+ else |
486 |
+ mycmakeargs+=( |
487 |
+ -DWITHOUT_SERVER=1 |
488 |
+ -DWITH_EMBEDDED_SERVER=OFF |
489 |
+ -DEXTRA_CHARSETS=none |
490 |
+ ) |
491 |
+ fi |
492 |
+ |
493 |
+ cmake-utils_src_configure |
494 |
+} |
495 |
+ |
496 |
+src_compile() { |
497 |
+ if use client-libs ; then |
498 |
+ multilib-minimal_src_compile |
499 |
+ else |
500 |
+ multilib_src_compile |
501 |
+ fi |
502 |
+} |
503 |
+ |
504 |
+multilib_src_compile() { |
505 |
+ cmake-utils_src_compile |
506 |
+} |
507 |
+ |
508 |
+# Official test instructions: |
509 |
+# ulimit -n 16500 && \ |
510 |
+# USE='latin1 perl server' \ |
511 |
+# FEATURES='test userpriv -usersandbox' \ |
512 |
+# ebuild mysql-X.X.XX.ebuild \ |
513 |
+# digest clean package |
514 |
+src_test() { |
515 |
+ _disable_test() { |
516 |
+ local rawtestname reason |
517 |
+ rawtestname="${1}" ; shift |
518 |
+ reason="${@}" |
519 |
+ ewarn "test '${rawtestname}' disabled: '${reason}'" |
520 |
+ echo ${rawtestname} : ${reason} >> "${T}/disabled.def" |
521 |
+ } |
522 |
+ |
523 |
+ local TESTDIR="${BUILD_DIR}/mysql-test" |
524 |
+ local retstatus_unit |
525 |
+ local retstatus_tests |
526 |
+ |
527 |
+ if ! use server ; then |
528 |
+ einfo "Skipping server tests due to minimal build." |
529 |
+ return 0 |
530 |
+ fi |
531 |
+ |
532 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
533 |
+ # localhost. Also causes weird failures. |
534 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
535 |
+ |
536 |
+ if [[ $UID -eq 0 ]] ; then |
537 |
+ die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
538 |
+ fi |
539 |
+ has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox" |
540 |
+ |
541 |
+ einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" |
542 |
+ |
543 |
+ # Run CTest (test-units) |
544 |
+ cmake-utils_src_test |
545 |
+ retstatus_unit=$? |
546 |
+ |
547 |
+ # Ensure that parallel runs don't die |
548 |
+ export MTR_BUILD_THREAD="$((${RANDOM} % 100))" |
549 |
+ # Enable parallel testing, auto will try to detect number of cores |
550 |
+ # You may set this by hand. |
551 |
+ # The default maximum is 8 unless MTR_MAX_PARALLEL is increased |
552 |
+ export MTR_PARALLEL="${MTR_PARALLEL:-auto}" |
553 |
+ |
554 |
+ # create directories because mysqladmin might run out of order |
555 |
+ mkdir -p "${T}"/var-tests{,/log} || die |
556 |
+ |
557 |
+ # Run mysql tests |
558 |
+ pushd "${TESTDIR}" &>/dev/null || die |
559 |
+ |
560 |
+ touch "${T}/disabled.def" |
561 |
+ # These are failing in MySQL 5.7 for now and are believed to be |
562 |
+ # false positives: |
563 |
+ # |
564 |
+ local t |
565 |
+ |
566 |
+ for t in auth_sec.keyring_udf ; do |
567 |
+ _disable_test "$t" "False positives in Gentoo" |
568 |
+ done |
569 |
+ |
570 |
+ # Unstable tests |
571 |
+ # - main.xa_prepared_binlog_off: https://bugs.mysql.com/bug.php?id=83340 |
572 |
+ # - rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch: https://bugs.mysql.com/bug.php?id=89223 |
573 |
+ # - rpl.rpl_non_direct_stm_mixing_engines: MDEV-14489 |
574 |
+ for t in \ |
575 |
+ main.xa_prepared_binlog_off \ |
576 |
+ rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch \ |
577 |
+ rpl.rpl_non_direct_stm_mixing_engines \ |
578 |
+ ; do |
579 |
+ _disable_test "$t" "Unstable test" |
580 |
+ done |
581 |
+ |
582 |
+ for t in \ |
583 |
+ gis.geometry_class_attri_prop \ |
584 |
+ gis.geometry_property_function_issimple \ |
585 |
+ gis.gis_bugs_crashes \ |
586 |
+ gis.spatial_op_testingfunc_mix \ |
587 |
+ gis.spatial_analysis_functions_buffer \ |
588 |
+ gis.spatial_analysis_functions_distance \ |
589 |
+ gis.spatial_utility_function_distance_sphere \ |
590 |
+ gis.spatial_utility_function_simplify \ |
591 |
+ gis.spatial_analysis_functions_centroid \ |
592 |
+ ; do |
593 |
+ _disable_test "$t" "Known rounding error with latest AMD processors" |
594 |
+ done |
595 |
+ |
596 |
+ if use numa && use kernel_linux ; then |
597 |
+ # bug 584880 |
598 |
+ if ! linux_config_exists || ! linux_chkconfig_present NUMA ; then |
599 |
+ for t in sys_vars.innodb_numa_interleave_basic ; do |
600 |
+ _disable_test "$t" "Test $t requires system with NUMA support" |
601 |
+ done |
602 |
+ fi |
603 |
+ fi |
604 |
+ |
605 |
+ if ! use latin1 ; then |
606 |
+ # The following tests will fail if DEFAULT_CHARSET |
607 |
+ # isn't set to latin1: |
608 |
+ for t in \ |
609 |
+ binlog.binlog_mysqlbinlog_filter \ |
610 |
+ binlog.binlog_xa_prepared_disconnect \ |
611 |
+ funcs_1.is_columns_mysql \ |
612 |
+ funcs_1.is_tables_mysql \ |
613 |
+ funcs_1.is_triggers \ |
614 |
+ innodb.innodb_pagesize_max_recordsize \ |
615 |
+ innodb.innodb-system-table-view \ |
616 |
+ innodb.mysqldump_max_recordsize \ |
617 |
+ main.mysql_client_test \ |
618 |
+ main.mysqld--help-notwin \ |
619 |
+ main.type_string \ |
620 |
+ main.information_schema \ |
621 |
+ perfschema.binlog_edge_mix \ |
622 |
+ perfschema.binlog_edge_stmt \ |
623 |
+ rpl.rpl_xa_survive_disconnect \ |
624 |
+ rpl.rpl_xa_survive_disconnect_lsu_off \ |
625 |
+ rpl.rpl_xa_survive_disconnect_table \ |
626 |
+ ; do |
627 |
+ _disable_test "$t" "Requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" |
628 |
+ done |
629 |
+ fi |
630 |
+ |
631 |
+ if has_version '>=dev-libs/openssl-1.1.1' ; then |
632 |
+ # Tests are expecting <openssl-1.1.1 default cipher |
633 |
+ for t in \ |
634 |
+ auth_sec.cert_verify \ |
635 |
+ auth_sec.mysql_ssl_connection \ |
636 |
+ auth_sec.openssl_cert_generation \ |
637 |
+ auth_sec.ssl_auto_detect \ |
638 |
+ auth_sec.ssl_mode \ |
639 |
+ auth_sec.tls \ |
640 |
+ binlog.binlog_grant_alter_user \ |
641 |
+ encryption.innodb_onlinealter_encryption \ |
642 |
+ main.grant_alter_user_qa \ |
643 |
+ main.grant_user_lock_qa \ |
644 |
+ main.mysql_ssl_default \ |
645 |
+ main.openssl_1 \ |
646 |
+ main.plugin_auth_sha256_tls \ |
647 |
+ main.ssl \ |
648 |
+ main.ssl_8k_key \ |
649 |
+ main.ssl_bug75311 \ |
650 |
+ main.ssl_ca \ |
651 |
+ main.ssl_cipher \ |
652 |
+ main.ssl_compress \ |
653 |
+ main.ssl_crl \ |
654 |
+ main.ssl_ecdh \ |
655 |
+ main.ssl_verify_identity \ |
656 |
+ x.connection_tls_version \ |
657 |
+ x.connection_openssl \ |
658 |
+ ; do |
659 |
+ _disable_test "$t" "Requires <dev-libs/openssl-1.1.1" |
660 |
+ done |
661 |
+ fi |
662 |
+ |
663 |
+ # Try to increase file limits to increase test coverage |
664 |
+ if ! ulimit -n 16500 1>/dev/null 2>&1 ; then |
665 |
+ # Upper limit comes from parts.partition_* tests |
666 |
+ ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." |
667 |
+ |
668 |
+ if ! ulimit -n 4162 1>/dev/null 2>&1 ; then |
669 |
+ # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' |
670 |
+ ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." |
671 |
+ |
672 |
+ if ! ulimit -n 3000 1>/dev/null 2>&1 ; then |
673 |
+ ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." |
674 |
+ else |
675 |
+ einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." |
676 |
+ fi |
677 |
+ else |
678 |
+ einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." |
679 |
+ fi |
680 |
+ else |
681 |
+ einfo "Will run test suite with open file limit set to 16500 (best test coverage)." |
682 |
+ fi |
683 |
+ |
684 |
+ # run mysql-test tests |
685 |
+ perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" |
686 |
+ retstatus_tests=$? |
687 |
+ |
688 |
+ popd &>/dev/null || die |
689 |
+ |
690 |
+ # Cleanup is important for these testcases. |
691 |
+ pkill -9 -f "${S}/ndb" 2>/dev/null |
692 |
+ pkill -9 -f "${S}/sql" 2>/dev/null |
693 |
+ |
694 |
+ local failures="" |
695 |
+ [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" |
696 |
+ [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" |
697 |
+ |
698 |
+ [[ -z "$failures" ]] || die "Test failures: $failures" |
699 |
+ einfo "Tests successfully completed" |
700 |
+} |
701 |
+ |
702 |
+src_install() { |
703 |
+ local MULTILIB_WRAPPED_HEADERS |
704 |
+ local MULTILIB_CHOST_TOOLS |
705 |
+ if use client-libs ; then |
706 |
+ # headers with ABI specific data |
707 |
+ MULTILIB_WRAPPED_HEADERS=( |
708 |
+ /usr/include/mysql/server/my_config.h |
709 |
+ /usr/include/mysql/server/mysql_version.h ) |
710 |
+ |
711 |
+ # wrap the config scripts |
712 |
+ MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config ) |
713 |
+ multilib-minimal_src_install |
714 |
+ else |
715 |
+ multilib_src_install |
716 |
+ multilib_src_install_all |
717 |
+ fi |
718 |
+} |
719 |
+ |
720 |
+# Intentionally override eclass function |
721 |
+multilib_src_install() { |
722 |
+ |
723 |
+ cmake-utils_src_install |
724 |
+ |
725 |
+ # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. |
726 |
+ find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die |
727 |
+} |
728 |
+ |
729 |
+multilib_src_install_all() { |
730 |
+ # Make sure the vars are correctly initialized |
731 |
+ mysql_init_vars |
732 |
+ |
733 |
+ # Convenience links |
734 |
+ einfo "Making Convenience links for mysqlcheck multi-call binary" |
735 |
+ dosym "mysqlcheck" "/usr/bin/mysqlanalyze" |
736 |
+ dosym "mysqlcheck" "/usr/bin/mysqlrepair" |
737 |
+ dosym "mysqlcheck" "/usr/bin/mysqloptimize" |
738 |
+ |
739 |
+ # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir |
740 |
+ if [[ -d "${ED}/usr/data" ]] ; then |
741 |
+ rm -Rf "${ED}/usr/data" || die |
742 |
+ fi |
743 |
+ |
744 |
+ # Unless they explicitly specific USE=test, then do not install the |
745 |
+ # testsuite. It DOES have a use to be installed, esp. when you want to do a |
746 |
+ # validation of your database configuration after tuning it. |
747 |
+ if ! use test ; then |
748 |
+ rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" |
749 |
+ fi |
750 |
+ |
751 |
+ # Configuration stuff |
752 |
+ einfo "Building default configuration ..." |
753 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}" |
754 |
+ [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf |
755 |
+ cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die |
756 |
+ eprefixify "${TMPDIR}/my.cnf" |
757 |
+ doins "${TMPDIR}/my.cnf" |
758 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" |
759 |
+ cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die |
760 |
+ eprefixify "${TMPDIR}/50-distro-client.cnf" |
761 |
+ doins "${TMPDIR}/50-distro-client.cnf" |
762 |
+ |
763 |
+ if use server ; then |
764 |
+ mycnf_src="my.cnf.distro-server" |
765 |
+ sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ |
766 |
+ "${FILESDIR}/${mycnf_src}" \ |
767 |
+ > "${TMPDIR}/my.cnf.ok" || die |
768 |
+ |
769 |
+ if use prefix ; then |
770 |
+ sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ |
771 |
+ "${TMPDIR}/my.cnf.ok" || die |
772 |
+ fi |
773 |
+ |
774 |
+ if use latin1 ; then |
775 |
+ sed -i \ |
776 |
+ -e "/character-set/s|utf8|latin1|g" \ |
777 |
+ "${TMPDIR}/my.cnf.ok" || die |
778 |
+ fi |
779 |
+ |
780 |
+ eprefixify "${TMPDIR}/my.cnf.ok" |
781 |
+ |
782 |
+ newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf |
783 |
+ fi |
784 |
+ |
785 |
+ #Remove mytop if perl is not selected |
786 |
+ [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" |
787 |
+} |
788 |
+ |
789 |
+pkg_config() { |
790 |
+ _getoptval() { |
791 |
+ local mypd="${EROOT%/}"/usr/bin/my_print_defaults |
792 |
+ local section="$1" |
793 |
+ local flag="--${2}=" |
794 |
+ local extra_options="${3}" |
795 |
+ "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" |
796 |
+ } |
797 |
+ local old_MY_DATADIR="${MY_DATADIR}" |
798 |
+ local old_HOME="${HOME}" |
799 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
800 |
+ export HOME=${EPREFIX}/root |
801 |
+ |
802 |
+ # Make sure the vars are correctly initialized |
803 |
+ mysql_init_vars |
804 |
+ |
805 |
+ [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" |
806 |
+ if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then |
807 |
+ die "Minimal builds do NOT include the MySQL server" |
808 |
+ fi |
809 |
+ |
810 |
+ if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]] ; then |
811 |
+ local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}" |
812 |
+ MY_DATADIR_s="${MY_DATADIR_s%%/}" |
813 |
+ local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}" |
814 |
+ old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" |
815 |
+ |
816 |
+ if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]] ; then |
817 |
+ if [[ -d "${MY_DATADIR_s}" ]] ; then |
818 |
+ ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" |
819 |
+ ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" |
820 |
+ else |
821 |
+ elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" |
822 |
+ mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ |
823 |
+ || die "Moving MY_DATADIR failed" |
824 |
+ fi |
825 |
+ else |
826 |
+ ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" |
827 |
+ if [[ -d "${MY_DATADIR_s}" ]] ; then |
828 |
+ ewarn "Attempting to use ${MY_DATADIR_s}" |
829 |
+ else |
830 |
+ eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" |
831 |
+ die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" |
832 |
+ fi |
833 |
+ fi |
834 |
+ fi |
835 |
+ |
836 |
+ local pwd1="a" |
837 |
+ local pwd2="b" |
838 |
+ local maxtry=15 |
839 |
+ |
840 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
841 |
+ local tmp_mysqld_password_source= |
842 |
+ |
843 |
+ for tmp_mysqld_password_source in mysql client ; do |
844 |
+ einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." |
845 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" |
846 |
+ if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then |
847 |
+ if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then |
848 |
+ ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" |
849 |
+ MYSQL_ROOT_PASSWORD= |
850 |
+ continue |
851 |
+ fi |
852 |
+ |
853 |
+ einfo "Found password in '${tmp_mysqld_password_source}' section!" |
854 |
+ break |
855 |
+ fi |
856 |
+ done |
857 |
+ |
858 |
+ # Sometimes --show is required to display passwords in some implementations of my_print_defaults |
859 |
+ if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then |
860 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" |
861 |
+ fi |
862 |
+ |
863 |
+ unset tmp_mysqld_password_source |
864 |
+ fi |
865 |
+ MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)" |
866 |
+ # These are dir+prefix |
867 |
+ MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)" |
868 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
869 |
+ MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)" |
870 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
871 |
+ |
872 |
+ if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]] ; then |
873 |
+ einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" |
874 |
+ install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR" |
875 |
+ fi |
876 |
+ |
877 |
+ if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]] ; then |
878 |
+ einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" |
879 |
+ install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN" |
880 |
+ fi |
881 |
+ |
882 |
+ if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]] ; then |
883 |
+ einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" |
884 |
+ install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG" |
885 |
+ fi |
886 |
+ |
887 |
+ if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then |
888 |
+ ewarn "You have already a MySQL database in place." |
889 |
+ ewarn "(${ROOT%/}/${MY_DATADIR}/*)" |
890 |
+ ewarn "Please rename or delete it if you wish to replace it." |
891 |
+ die "MySQL database already exists!" |
892 |
+ fi |
893 |
+ |
894 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
895 |
+ # localhost. Also causes weird failures. |
896 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
897 |
+ |
898 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
899 |
+ |
900 |
+ einfo "Please provide a password for the mysql 'root' user now" |
901 |
+ einfo "or through the ${HOME}/.my.cnf file." |
902 |
+ ewarn "Avoid [\"'\\_%] characters in the password" |
903 |
+ read -rsp " >" pwd1 ; echo |
904 |
+ |
905 |
+ einfo "Retype the password" |
906 |
+ read -rsp " >" pwd2 ; echo |
907 |
+ |
908 |
+ if [[ "x$pwd1" != "x$pwd2" ]] ; then |
909 |
+ die "Passwords are not the same" |
910 |
+ fi |
911 |
+ MYSQL_ROOT_PASSWORD="${pwd1}" |
912 |
+ unset pwd1 pwd2 |
913 |
+ fi |
914 |
+ |
915 |
+ local options |
916 |
+ local sqltmp="$(emktemp)" |
917 |
+ |
918 |
+ # Fix bug 446200. Don't reference host my.cnf, needs to come first, |
919 |
+ # see http://bugs.mysql.com/bug.php?id=31312 |
920 |
+ use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" |
921 |
+ |
922 |
+ # Figure out which options we need to disable to do the setup |
923 |
+ local helpfile="${TMPDIR%/}/mysqld-help" |
924 |
+ "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null |
925 |
+ for opt in host-cache name-resolve networking slave-start \ |
926 |
+ federated ssl log-bin relay-log slow-query-log external-locking \ |
927 |
+ log-slave-updates \ |
928 |
+ ; do |
929 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
930 |
+ egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" |
931 |
+ done |
932 |
+ |
933 |
+ einfo "Creating the mysql database and setting proper permissions on it ..." |
934 |
+ |
935 |
+ # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it |
936 |
+ PID_DIR="${EROOT%/}/var/run/mysqld" |
937 |
+ if [[ ! -d "${PID_DIR}" ]] ; then |
938 |
+ install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory" |
939 |
+ fi |
940 |
+ |
941 |
+ if [[ ! -d "${MY_DATADIR}" ]] ; then |
942 |
+ install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory" |
943 |
+ fi |
944 |
+ |
945 |
+ pushd "${TMPDIR}" &>/dev/null || die |
946 |
+ |
947 |
+ # Filling timezones, see |
948 |
+ # http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
949 |
+ echo "USE mysql;" >"${sqltmp}" |
950 |
+ "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null |
951 |
+ chown mysql "${sqltmp}" || die |
952 |
+ |
953 |
+ # --initialize-insecure will not set root password |
954 |
+ # --initialize would set a random one in the log which we don't need as we set it ourselves |
955 |
+ local cmd=( "${EROOT%/}/usr/sbin/mysqld" "--initialize-insecure" "--init-file='${sqltmp}'" ) |
956 |
+ cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" ) |
957 |
+ einfo "Command: ${cmd[*]}" |
958 |
+ su -s /bin/sh -c "${cmd[*]}" mysql \ |
959 |
+ >"${TMPDIR%/}"/mysql_install_db.log 2>&1 |
960 |
+ if [[ $? -ne 0 ]] ; then |
961 |
+ grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2 |
962 |
+ die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log" |
963 |
+ fi |
964 |
+ popd &>/dev/null || die |
965 |
+ [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \ |
966 |
+ || die "MySQL databases not installed" |
967 |
+ |
968 |
+ use prefix || options="${options} --user=mysql" |
969 |
+ |
970 |
+ local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock" |
971 |
+ local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid" |
972 |
+ local mysqld="${EROOT%/}/usr/sbin/mysqld \ |
973 |
+ ${options} \ |
974 |
+ $(use prefix || echo --user=mysql) \ |
975 |
+ --log-warnings=0 \ |
976 |
+ --basedir=${EROOT%/}/usr \ |
977 |
+ --datadir=${ROOT%/}/${MY_DATADIR} \ |
978 |
+ --max_allowed_packet=8M \ |
979 |
+ --net_buffer_length=16K \ |
980 |
+ --socket=${socket} \ |
981 |
+ --pid-file=${pidfile} \ |
982 |
+ --tmpdir=${ROOT}/${MYSQL_TMPDIR}" |
983 |
+ #einfo "About to start mysqld: ${mysqld}" |
984 |
+ ebegin "Starting mysqld" |
985 |
+ einfo "Command ${mysqld}" |
986 |
+ ${mysqld} & |
987 |
+ rc=$? |
988 |
+ while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do |
989 |
+ maxtry=$((${maxtry}-1)) |
990 |
+ echo -n "." |
991 |
+ sleep 1 |
992 |
+ done |
993 |
+ eend $rc |
994 |
+ |
995 |
+ if ! [[ -S "${socket}" ]] ; then |
996 |
+ die "Completely failed to start up mysqld with: ${mysqld}" |
997 |
+ fi |
998 |
+ |
999 |
+ ebegin "Setting root password" |
1000 |
+ # Do this from memory, as we don't want clear text passwords in temp files |
1001 |
+ local sql="ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${MYSQL_ROOT_PASSWORD}'" |
1002 |
+ "${EROOT%/}/usr/bin/mysql" \ |
1003 |
+ --no-defaults \ |
1004 |
+ "--socket=${socket}" \ |
1005 |
+ -hlocalhost \ |
1006 |
+ -e "${sql}" |
1007 |
+ eend $? |
1008 |
+ |
1009 |
+ # Stop the server and cleanup |
1010 |
+ einfo "Stopping the server ..." |
1011 |
+ kill $(< "${pidfile}" ) |
1012 |
+ rm -f "${sqltmp}" |
1013 |
+ wait %1 |
1014 |
+ einfo "Done" |
1015 |
+} |