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