Gentoo Archives: gentoo-commits

From: Brian Evans <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/mysql-cluster/files/, dev-db/mysql-cluster/
Date: Mon, 21 Jan 2019 00:25:12
Message-Id: 1548030106.8a2e3eaf446f2ceff0d3406d00995a8fcc5ddbe4.grknight@gentoo
1 commit: 8a2e3eaf446f2ceff0d3406d00995a8fcc5ddbe4
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 21 00:21:46 2019 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 21 00:21:46 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8a2e3eaf
7
8 dev-db/mysql-cluster: Version bumps
9
10 Package-Manager: Portage-2.3.56, Repoman-2.3.12
11 Signed-off-by: Brian Evans <grknight <AT> gentoo.org>
12
13 dev-db/mysql-cluster/Manifest | 4 +
14 dev-db/mysql-cluster/files/7.2.34-client.patch | 25 +
15 dev-db/mysql-cluster/metadata.xml | 1 +
16 dev-db/mysql-cluster/mysql-cluster-7.2.34.ebuild | 804 ++++++++++++++++++++++
17 dev-db/mysql-cluster/mysql-cluster-7.3.22.ebuild | 820 +++++++++++++++++++++++
18 dev-db/mysql-cluster/mysql-cluster-7.4.21.ebuild | 820 +++++++++++++++++++++++
19 6 files changed, 2474 insertions(+)
20
21 diff --git a/dev-db/mysql-cluster/Manifest b/dev-db/mysql-cluster/Manifest
22 index 85a2b3e987a..59b46cc17dc 100644
23 --- a/dev-db/mysql-cluster/Manifest
24 +++ b/dev-db/mysql-cluster/Manifest
25 @@ -1,5 +1,9 @@
26 DIST mysql-cluster-gpl-7.2.31.tar.gz 25109340 BLAKE2B c0af2b85c9760636f35ab461997ac5e8e5d20085dbfef6e7a265931e743b288a4cdb8e282f7e9436daa8b9e060fe110f5522c640e2e2a7f0b54fe2686ebb751b SHA512 ab6a7ad2bb981e8351d1d337eb0a75ad952da6f100a6c17a02c629936c4a3bad5701ead6ccf9b912ba0412d3442b6ad87c8e0c5409b84f10af8ec86a7c44b881
27 +DIST mysql-cluster-gpl-7.2.34.tar.gz 25114728 BLAKE2B b9337cf8ae6742c58f92ae64b8a636c8e54e6db3be45b329a695700a55a89b77839a5417c949ae37b2897d3bbd1274e41efcacde735f40d1de9ae14b16dd4576 SHA512 b73a3d13665a6efdad1e0e18e61780d8b99621ab46269a98723b9ddd9526edb77b5418947cb88b8d287c73eba7659aced363d747df18596ac34eb701ec83623c
28 DIST mysql-cluster-gpl-7.3.19.tar.gz 41340089 BLAKE2B 25ca93a9bcc41fb03ba0e4d34a1c672ddee3db7ff76fcf483187483dec16d8bffaaf1ab0704b4bed6ebb57681768429f7088757769d6b23dfa757517eef767ea SHA512 2d12124ec6b7ffa904538f21b676b15e093b3720d067b6eaffe609310ffd6261308ddcfbba4ce259f73d8e905f96bdcd21c5b7ec8fb940d2e9a8ec64c0f397a3
29 +DIST mysql-cluster-gpl-7.3.22.tar.gz 41356026 BLAKE2B 055a3f8590f0e2e53f8620244bd2ca7d619ab5549de7b33c4d41d2fabd260d98eaabdc0169488a6d018bcafc4458433e21b65025827998a31e9abc1deb5101ae SHA512 ccb9f3429e6ccb2dbb53d98f54abeae3c3128e65dc69c41918324630fef665f48d3c3af2d60bf1cce4e28c492e525c6bbc32cc8a39a9ea47988184adeafd5bd3
30 DIST mysql-cluster-gpl-7.4.17.tar.gz 41691695 BLAKE2B 9a9641a4962e625364fe9739d0954eeac8d773cb106e05c3cebd9ce94843246db679a1e81db383a861f9cec052193fa1ca80b34fb05d80ffbe248c29094476d2 SHA512 eaeab8b4c62e4b503210c269cf3147cb1fd3690e9bdb291a6bb46c874adf958166ccdf5b8766a09ec14d7fd63e3aff3e4b1f1527201e50e86e588507aa01767f
31 +DIST mysql-cluster-gpl-7.4.21.tar.gz 41718490 BLAKE2B 4578e477b345c85ccf12e4ea79893dda9b33bf35722ff8c6d706f150d8506d07b5e49a8e69e37cb3c8ff449832c80f72430924559b4a6d209d11d31cc2a67ca4 SHA512 48f475806608c0f6e0c45cc9c3b3851678153e17cf5c74114b2ca7a75eee455798c8decb857738eecb3fe664930e378e1d399509a954a7073802285eb87801b5
32 DIST mysql-extras-20171108-2050Z.tar.bz2 313241 BLAKE2B 83900f96392edb97c47007ba0faa4c259b7a3c6f17a7ed7161c7c632ac2466f9ab59777e6c17fdeeb8553650ea654633e3b10cf6f8e7692fbee4ebc5db495aea SHA512 830e6bac6fcead4b2d9649f6aaf6ec6573f86ce3c1a8bc1be6c89a408d69bfb81136baa7273d4449688d683b832880c2470970cd737c2b07cc7a1c2ce9c5a0b6
33 DIST mysql-extras-20171121-1518Z.tar.bz2 313539 BLAKE2B c397fdf7ffb3fcbcecda20933e18234062a9500dcf4031e9b17131e2a1f23dca7535ed33ff541fc075eb9995c67a9a8fd7261d7524dd42d8d333543c368b4c15 SHA512 dd0d4a00c0ed710e786d157a73f02c6f555ab7a68e57014d958627096a4245a0b45d22ec860dc5389002d106554e80166661c0b6ddcadff1f737e3fa195badda
34 +DIST mysql-extras-20190121-0015Z.tar.bz2 330807 BLAKE2B d5beae3d5a493e01d57130f835cd0d7dcbf53af389f9b933446ab43b86f96c85b5858a7a56ffe882ee63371ab96f0226e04f710dfb119ddd91b5c5685d0999bc SHA512 2f092b8e1e2f836d19e4663d383be876d498bca0ee005a690f48ba1797e9e5b648c4a15c36885faa286ce12a49386bf2898940e19eb1d288e7ee084968821a05
35
36 diff --git a/dev-db/mysql-cluster/files/7.2.34-client.patch b/dev-db/mysql-cluster/files/7.2.34-client.patch
37 new file mode 100644
38 index 00000000000..fbf163bf250
39 --- /dev/null
40 +++ b/dev-db/mysql-cluster/files/7.2.34-client.patch
41 @@ -0,0 +1,25 @@
42 +From b6c038d4366d003ae00120c96e39a892e5d675c1 Mon Sep 17 00:00:00 2001
43 +From: Tor Didriksen <tor.didriksen@××××××.com>
44 +Date: Wed, 18 Jul 2018 10:22:21 +0200
45 +Subject: [PATCH] Fix build break with modern compilers:
46 +
47 +client/mysql.cc: In function void build_completion_hash(bool, bool):
48 +client/mysql.cc:2674:37: error: invalid conversion from char to char* [-fpermissive]
49 + field_names[i][num_fields*2]= '\0';
50 +---
51 + client/mysql.cc | 2 +-
52 + 1 file changed, 1 insertion(+), 1 deletion(-)
53 +
54 +diff --git a/client/mysql.cc b/client/mysql.cc
55 +index 8510361a54e..bc32a58f37e 100644
56 +--- a/client/mysql.cc
57 ++++ b/client/mysql.cc
58 +@@ -2671,7 +2671,7 @@ You can turn off this feature to get a quicker startup with -A\n\n");
59 + mysql_free_result(fields);
60 + break;
61 + }
62 +- field_names[i][num_fields*2]= '\0';
63 ++ field_names[i][num_fields*2]= NULL;
64 + j=0;
65 + while ((sql_field=mysql_fetch_field(fields)))
66 + {
67
68 diff --git a/dev-db/mysql-cluster/metadata.xml b/dev-db/mysql-cluster/metadata.xml
69 index e769804157d..75d88ec7fb1 100644
70 --- a/dev-db/mysql-cluster/metadata.xml
71 +++ b/dev-db/mysql-cluster/metadata.xml
72 @@ -6,6 +6,7 @@
73 <name>MySQL</name>
74 </maintainer>
75 <use>
76 + <flag name="client-libs">Build the client libraries from the server package instead of the C Connector packages (not recommended)</flag>
77 <flag name="cluster">Add support for NDB clustering</flag>
78 <flag name="community">Enables the community features from upstream.</flag>
79 <flag name="embedded">Build embedded server (libmysqld)</flag>
80
81 diff --git a/dev-db/mysql-cluster/mysql-cluster-7.2.34.ebuild b/dev-db/mysql-cluster/mysql-cluster-7.2.34.ebuild
82 new file mode 100644
83 index 00000000000..c4b0ad5dc5f
84 --- /dev/null
85 +++ b/dev-db/mysql-cluster/mysql-cluster-7.2.34.ebuild
86 @@ -0,0 +1,804 @@
87 +# Copyright 1999-2019 Gentoo Authors
88 +# Distributed under the terms of the GNU General Public License v2
89 +
90 +EAPI="6"
91 +MY_EXTRAS_VER="20190121-0015Z"
92 +
93 +#fails to build with ninja
94 +CMAKE_MAKEFILE_GENERATOR=emake
95 +
96 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
97 +inherit eutils flag-o-matic prefix toolchain-funcs java-pkg-opt-2 user cmake-utils
98 +
99 +MY_PN="mysql-cluster-gpl"
100 +SRC_URI="https://cdn.mysql.com/Downloads/MySQL-Cluster-7.2/${MY_PN}-${PV}.tar.gz
101 + https://downloads.mysql.com/archives/MySQL-Cluster-7.2/${MY_PN}-${PV}.tar.gz"
102 +# Gentoo patches to MySQL
103 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then
104 + SRC_URI="${SRC_URI}
105 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
106 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
107 +fi
108 +
109 +HOMEPAGE="https://mysql.com/"
110 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
111 +LICENSE="GPL-2"
112 +SLOT="0"
113 +IUSE="bindist client-libs debug extraengine java jemalloc latin1 libressl
114 + +perl profiling selinux +server static static-libs systemtap tcmalloc
115 + test yassl"
116 +
117 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
118 +RESTRICT="!bindist? ( bindist ) libressl? ( test )"
119 +
120 +REQUIRED_USE="?? ( tcmalloc jemalloc )
121 + static? ( yassl )"
122 +
123 +KEYWORDS="~amd64 ~x86"
124 +
125 +# Shorten the path because the socket path length must be shorter than 107 chars
126 +# and we will run a mysql server during test phase
127 +S="${WORKDIR}/mysql"
128 +
129 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
130 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras"
131 + inherit git-r3
132 + EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
133 + EGIT_CHECKOUT_DIR="${WORKDIR%/}/mysql-extras"
134 + EGIT_CLONE_TYPE=shallow
135 +else
136 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras-${MY_EXTRAS_VER}"
137 +fi
138 +
139 +PATCHES=(
140 + "${MY_PATCH_DIR}/01050_all_mysql_config_cleanup-5.5.patch"
141 + "${MY_PATCH_DIR}/02040_all_embedded-library-shared-5.5.10.patch"
142 + "${MY_PATCH_DIR}/20001_all_fix-minimal-build-cmake-mysql-5.5.41.patch"
143 + "${MY_PATCH_DIR}/20002_all_mysql-va-list.patch"
144 + "${MY_PATCH_DIR}/20006_all_cmake_elib-mysql-cluster-7.2.34.patch"
145 + "${MY_PATCH_DIR}/20007_all_cmake-debug-werror-5.6.22.patch"
146 + "${MY_PATCH_DIR}/20008_all_mysql-tzinfo-symlink-5.6.37.patch"
147 + "${MY_PATCH_DIR}/20009_all_mysql_myodbc_symbol_fix-5.5.38.patch"
148 + "${MY_PATCH_DIR}/20018_all_mysql-cluster-7.2.34-without-clientlibs-tools.patch"
149 + "${MY_PATCH_DIR}/20027_all_mysql-5.5-perl5.26-includes.patch"
150 + "${FILESDIR}/7.2.34-client.patch"
151 +)
152 +
153 +# Be warned, *DEPEND are version-dependant
154 +# These are used for both runtime and compiletime
155 +COMMON_DEPEND="
156 + kernel_linux? (
157 + sys-process/procps:0=
158 + dev-libs/libaio:0=
159 + )
160 + dev-libs/libevent:0=
161 + >=sys-apps/sed-4
162 + >=sys-apps/texinfo-4.7-r1
163 + jemalloc? ( dev-libs/jemalloc:0= )
164 + tcmalloc? ( dev-util/google-perftools:0= )
165 + systemtap? ( >=dev-util/systemtap-1.3:0= )
166 + !yassl? (
167 + !libressl? ( dev-libs/openssl:0= !>=dev-libs/openssl-1.1 )
168 + libressl? ( dev-libs/libressl:0= )
169 + )
170 + >=sys-libs/zlib-1.2.3:0=
171 + sys-libs/ncurses:0=
172 + !bindist? (
173 + >=sys-libs/readline-4.1:0=
174 + )
175 +"
176 +DEPEND="virtual/yacc
177 + static? ( sys-libs/ncurses[static-libs] )
178 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
179 + java? ( >=virtual/jdk-1.6 )
180 + ${COMMON_DEPEND}"
181 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
182 + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql
183 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
184 + ${COMMON_DEPEND}
185 + java? ( >=virtual/jre-1.6 )
186 + perl? ( !dev-db/mytop
187 + virtual/perl-Getopt-Long
188 + dev-perl/TermReadKey
189 + virtual/perl-Term-ANSIColor
190 + virtual/perl-Time-HiRes )
191 +"
192 +# For other stuff to bring us in
193 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
194 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
195 +
196 +pkg_setup() {
197 + if [[ ${MERGE_TYPE} != binary ]] ; then
198 + local GCC_MAJOR_SET=$(gcc-major-version)
199 + local GCC_MINOR_SET=$(gcc-minor-version)
200 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
201 + # non x86{,_64} arches
202 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
203 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
204 + eerror "${PN} needs to be built with gcc-4.7 or later."
205 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
206 + die
207 + fi
208 + fi
209 + if has test ${FEATURES} && \
210 + use server && ! has userpriv ${FEATURES} ; then
211 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
212 + fi
213 +
214 + # This should come after all of the die statements
215 + enewgroup mysql 60 || die "problem adding 'mysql' group"
216 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
217 +
218 + java-pkg-opt-2_pkg_setup
219 +}
220 +
221 +pkg_postinst() {
222 + # Make sure the vars are correctly initialized
223 + mysql_init_vars
224 +
225 + # Create log directory securely if it does not exist
226 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
227 +
228 + if use server ; then
229 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
230 + einfo
231 + elog "You might want to run:"
232 + elog "\"emerge --config =${CATEGORY}/${PF}\""
233 + elog "if this is a new install."
234 + elog
235 + elog "If you are switching server implentations, you should run the"
236 + elog "mysql_upgrade tool."
237 + einfo
238 + else
239 + einfo
240 + elog "If you are upgrading major versions, you should run the"
241 + elog "mysql_upgrade tool."
242 + einfo
243 + fi
244 +
245 + einfo
246 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
247 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
248 + elog "The first time the cluster is activated, you should add"
249 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
250 + elog "This option should then be removed for subsequent starts."
251 + einfo
252 + fi
253 +}
254 +
255 +src_unpack() {
256 + unpack ${A}
257 + # Grab the patches
258 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR%/}/mysql-extras" git-r3_src_unpack
259 +
260 + mv -f "${WORKDIR%/}/${MY_PN}-${PV}" "${S}" || die
261 +}
262 +
263 +src_prepare() {
264 + _disable_engine() {
265 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
266 + }
267 +
268 + _disable_plugin() {
269 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
270 + }
271 +
272 + if use tcmalloc; then
273 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S%/}/sql/CMakeLists.txt" || die
274 + fi
275 +
276 + if use jemalloc; then
277 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S%/}/sql/CMakeLists.txt" || die
278 + fi
279 +
280 + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
281 + if [[ -d "${S}/support-files/SELinux" ]] ; then
282 + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
283 + fi
284 +
285 + if use libressl ; then
286 + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \
287 + "${S}/cmake/ssl.cmake" || die
288 + fi
289 +
290 + local plugin
291 + local server_plugins=( semisync )
292 + local test_plugins=( audit_null daemon_example fulltext )
293 + if ! use server; then # These plugins are for the server
294 + for plugin in "${server_plugins[@]}" ; do
295 + _disable_plugin "${plugin}"
296 + done
297 + fi
298 +
299 + if ! use test; then # These plugins are only used during testing
300 + for plugin in "${test_plugins[@]}" ; do
301 + _disable_plugin "${plugin}"
302 + done
303 + fi
304 +
305 + # Don't build example
306 + _disable_engine example
307 +
308 + cmake-utils_src_prepare
309 + java-pkg-opt-2_src_prepare
310 +}
311 +
312 +src_configure(){
313 + # Bug #114895, bug #110149
314 + filter-flags "-O" "-O[01]"
315 +
316 + append-cxxflags -felide-constructors
317 +
318 + # bug #283926, with GCC4.4, this is required to get correct behavior.
319 + append-flags -fno-strict-aliasing
320 +
321 + CMAKE_BUILD_TYPE="RelWithDebInfo"
322 +
323 + # debug hack wrt #497532
324 + mycmakeargs=(
325 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
326 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
327 + -DCMAKE_INSTALL_PREFIX="${EPREFIX%/}/usr"
328 + -DDEFAULT_SYSCONFDIR="${EPREFIX%/}/etc/mysql"
329 + -DINSTALL_BINDIR=bin
330 + -DINSTALL_DOCDIR=share/doc/${PF}
331 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
332 + -DINSTALL_INCLUDEDIR=include/mysql
333 + -DINSTALL_INFODIR=share/info
334 + -DINSTALL_LIBDIR=$(get_libdir)
335 + -DINSTALL_MANDIR=share/man
336 + -DINSTALL_MYSQLSHAREDIR=share/mysql
337 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
338 + -DINSTALL_SCRIPTDIR=share/mysql/scripts
339 + -DINSTALL_MYSQLDATADIR="${EPREFIX%/}/var/lib/mysql"
340 + -DINSTALL_SBINDIR=sbin
341 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX%/}/usr/share/mysql"
342 + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
343 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
344 + -DWITH_ZLIB=system
345 + -DENABLED_LOCAL_INFILE=1
346 + -DMYSQL_UNIX_ADDR="${EPREFIX%/}/var/run/mysqld/mysqld.sock"
347 + # The build forces this to be defined when cross-compiling. We pass it
348 + # all the time for simplicity and to make sure it is actually correct.
349 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
350 + -DWITHOUT_CLIENTLIBS=YES
351 + -DWITH_READLINE=$(usex bindist 1 0)
352 + -DENABLE_DTRACE=$(usex systemtap)
353 + -DWITH_BUNDLED_LIBEVENT=OFF
354 + -DWITH_NDB_JAVA=$(usex java ON OFF)
355 + )
356 + if use test ; then
357 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
358 + else
359 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
360 + fi
361 +
362 + if ! use yassl ; then
363 + mycmakeargs+=( -DWITH_SSL=system )
364 + else
365 + mycmakeargs+=( -DWITH_SSL=bundled )
366 + fi
367 +
368 + if use server ; then
369 +
370 + # Federated must be treated special otherwise they will not be built as plugins
371 + if ! use extraengine ; then
372 + mycmakeargs+=( -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 )
373 + fi
374 +
375 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
376 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
377 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
378 + ewarn "You MUST file bugs without these variables set."
379 +
380 + mycmakeargs+=(
381 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
382 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
383 + )
384 +
385 + elif ! use latin1 ; then
386 + mycmakeargs+=(
387 + -DDEFAULT_CHARSET=utf8
388 + -DDEFAULT_COLLATION=utf8_general_ci
389 + )
390 + else
391 + mycmakeargs+=(
392 + -DDEFAULT_CHARSET=latin1
393 + -DDEFAULT_COLLATION=latin1_swedish_ci
394 + )
395 + fi
396 + mycmakeargs+=(
397 + -DINSTALL_SQLBENCHDIR=share/mysql
398 + -DEXTRA_CHARSETS=all
399 + -DDISABLE_SHARED=$(usex static YES NO)
400 + -DWITH_EMBEDDED_SERVER=OFF
401 + )
402 +
403 + if use profiling ; then
404 + # Setting to OFF doesn't work: Once set, profiling options will be added
405 + # to `mysqld --help` output via sql/sys_vars.cc causing
406 + # "main.mysqld--help-notwin" test to fail
407 + mycmakeargs+=( -DENABLED_PROFILING=ON )
408 + fi
409 +
410 + if use static; then
411 + mycmakeargs+=( -DWITH_PIC=1 )
412 + fi
413 +
414 + # Storage engines
415 + mycmakeargs+=(
416 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
417 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
418 + -DWITH_CSV_STORAGE_ENGINE=1
419 + -DWITH_HEAP_STORAGE_ENGINE=1
420 + -DWITH_INNOBASE_STORAGE_ENGINE=1
421 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
422 + -DWITH_MYISAM_STORAGE_ENGINE=1
423 + -DWITH_PARTITION_STORAGE_ENGINE=1
424 + )
425 +
426 + else
427 + mycmakeargs+=(
428 + -DWITHOUT_SERVER=1
429 + -DEXTRA_CHARSETS=none
430 + -DINSTALL_SQLBENCHDIR=
431 + )
432 + fi
433 +
434 + cmake-utils_src_configure
435 +}
436 +
437 +src_compile() {
438 + cmake-utils_src_compile
439 +}
440 +
441 +src_install() {
442 + cmake-utils_src_install
443 +
444 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
445 + if [[ -f "${ED%/}/usr/include/mysql/server/private/config.h" ]] ; then
446 + rm "${ED%/}/usr/include/mysql/server/private/config.h" || die
447 + fi
448 +
449 + # Make sure the vars are correctly initialized
450 + mysql_init_vars
451 +
452 + # Convenience links
453 + einfo "Making Convenience links for mysqlcheck multi-call binary"
454 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
455 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
456 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
457 +
458 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
459 + if [[ -d "${ED%/}/usr/data" ]] ; then
460 + rm -Rf "${ED%/}/usr/data" || die
461 + fi
462 +
463 + # Unless they explicitly specific USE=test, then do not install the
464 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
465 + # validation of your database configuration after tuning it.
466 + if ! use test ; then
467 + rm -rf "${D%/}/${MY_SHAREDSTATEDIR}/mysql-test"
468 + fi
469 +
470 + # Configuration stuff
471 + einfo "Building default configuration ..."
472 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
473 + [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf
474 + local mycnf_src="my.cnf-5.5"
475 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
476 + "${FILESDIR%/}/${mycnf_src}" \
477 + > "${TMPDIR%/}/my.cnf.ok" || die
478 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok"
479 + if use latin1 ; then
480 + sed -i \
481 + -e "/character-set/s|utf8|latin1|g" \
482 + "${TMPDIR%/}/my.cnf.ok" || die
483 + fi
484 + eprefixify "${TMPDIR%/}/my.cnf.ok"
485 + newins "${TMPDIR}/my.cnf.ok" my.cnf
486 +
487 + if use server ; then
488 + einfo "Including support files and sample configurations"
489 + docinto "support-files"
490 + local script
491 + for script in \
492 + "${S%/}"/support-files/magic \
493 + "${S%/}"/support-files/ndb-config-2-node.ini
494 + do
495 + [[ -f "$script" ]] && dodoc "${script}"
496 + done
497 +
498 + docinto "scripts"
499 + for script in "${S%/}"/scripts/mysql* ; do
500 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
501 + done
502 + fi
503 +
504 + #Remove mytop if perl is not selected
505 + [[ -e "${ED%/}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED%/}/usr/bin/mytop"
506 +}
507 +
508 +# Official test instructions:
509 +# USE='extraengine perl server' \
510 +# FEATURES='test userpriv -usersandbox' \
511 +# ebuild mysql-X.X.XX.ebuild \
512 +# digest clean package
513 +src_test() {
514 +
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.5 for now and are believed to be
562 + # false positives:
563 + #
564 + # main.mysql_client_test, main.mysql_client_test_nonblock
565 + # main.mysql_client_test_comp:
566 + # segfaults at random under Portage only, suspect resource limits.
567 +
568 + local t
569 + for t in main.mysql_client_test \
570 + binlog.binlog_statement_insert_delayed main.information_schema \
571 + main.mysqld--help-notwin main.flush_read_lock_kill \
572 + sys_vars.plugin_dir_basic main.openssl_1 \
573 + main.mysqlhotcopy_archive main.mysqlhotcopy_myisam \
574 + ndb.ndbinfo ndb_binlog.ndb_binlog_index ; do
575 + _disable_test "$t" "False positives in Gentoo"
576 + done
577 +
578 + _disable_test main.mysqldump "Extra expected warning not recorded in test results"
579 +
580 + if ! use client-libs ; then
581 + _disable_test main.plugin_auth "Needs client libraries built"
582 + fi
583 +
584 + # run mysql-test tests
585 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
586 + retstatus_tests=$?
587 +
588 + popd > /dev/null || die
589 +
590 + # Cleanup is important for these testcases.
591 + pkill -9 -f "${S}/ndb" 2>/dev/null
592 + pkill -9 -f "${S}/sql" 2>/dev/null
593 +
594 + local failures=""
595 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
596 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
597 +
598 + [[ -z "$failures" ]] || die "Test failures: $failures"
599 + einfo "Tests successfully completed"
600 +}
601 +
602 +mysql_init_vars() {
603 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
604 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
605 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
606 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
607 +
608 + if [[ -z "${MY_DATADIR}" ]] ; then
609 + MY_DATADIR=""
610 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
611 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
612 + | sed -ne '/datadir/s|^--datadir=||p' \
613 + | tail -n1`
614 + if [[ -z "${MY_DATADIR}" ]] ; then
615 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
616 + | sed -e 's/.*=\s*//' \
617 + | tail -n1`
618 + fi
619 + fi
620 + if [[ -z "${MY_DATADIR}" ]] ; then
621 + MY_DATADIR="${MY_LOCALSTATEDIR}"
622 + einfo "Using default MY_DATADIR"
623 + fi
624 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
625 +
626 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
627 + if [[ -e "${MY_DATADIR}" ]] ; then
628 + # If you get this and you're wondering about it, see bug #207636
629 + elog "MySQL datadir found in ${MY_DATADIR}"
630 + elog "A new one will not be created."
631 + PREVIOUS_DATADIR="yes"
632 + else
633 + PREVIOUS_DATADIR="no"
634 + fi
635 + export PREVIOUS_DATADIR
636 + fi
637 + else
638 + if [[ ${EBUILD_PHASE} == "config" ]]; then
639 + local new_MY_DATADIR
640 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
641 + | sed -ne '/datadir/s|^--datadir=||p' \
642 + | tail -n1`
643 +
644 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
645 + ewarn "MySQL MY_DATADIR has changed"
646 + ewarn "from ${MY_DATADIR}"
647 + ewarn "to ${new_MY_DATADIR}"
648 + MY_DATADIR="${new_MY_DATADIR}"
649 + fi
650 + fi
651 + fi
652 +
653 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
654 + export MY_LOCALSTATEDIR MY_LOGDIR
655 + export MY_DATADIR
656 +}
657 +
658 +pkg_config() {
659 + _getoptval() {
660 + local mypd="${EROOT}"/usr/bin/my_print_defaults
661 + local section="$1"
662 + local flag="--${2}="
663 + local extra_options="${3}"
664 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
665 + }
666 + local old_MY_DATADIR="${MY_DATADIR}"
667 + local old_HOME="${HOME}"
668 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
669 + export HOME=${EPREFIX}/root
670 +
671 + # Make sure the vars are correctly initialized
672 + mysql_init_vars
673 +
674 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
675 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
676 + die "Minimal builds do NOT include the MySQL server"
677 + fi
678 +
679 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
680 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
681 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
682 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
683 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
684 +
685 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
686 + if [[ -d "${MY_DATADIR_s}" ]]; then
687 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
688 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
689 + else
690 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
691 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
692 + || die "Moving MY_DATADIR failed"
693 + fi
694 + else
695 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
696 + if [[ -d "${MY_DATADIR_s}" ]]; then
697 + ewarn "Attempting to use ${MY_DATADIR_s}"
698 + else
699 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
700 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
701 + fi
702 + fi
703 + fi
704 +
705 + local pwd1="a"
706 + local pwd2="b"
707 + local maxtry=15
708 +
709 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
710 + local tmp_mysqld_password_source=
711 +
712 + for tmp_mysqld_password_source in mysql client; do
713 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
714 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
715 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
716 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
717 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
718 + MYSQL_ROOT_PASSWORD=
719 + continue
720 + fi
721 +
722 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
723 + break
724 + fi
725 + done
726 +
727 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
728 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
729 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
730 + fi
731 +
732 + unset tmp_mysqld_password_source
733 + fi
734 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
735 + # These are dir+prefix
736 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
737 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
738 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
739 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
740 +
741 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
742 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
743 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
744 + fi
745 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
746 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
747 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
748 + fi
749 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
750 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
751 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
752 + fi
753 +
754 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
755 + ewarn "You have already a MySQL database in place."
756 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
757 + ewarn "Please rename or delete it if you wish to replace it."
758 + die "MySQL database already exists!"
759 + fi
760 +
761 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
762 + # localhost. Also causes weird failures.
763 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
764 +
765 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
766 +
767 + einfo "Please provide a password for the mysql 'root' user now"
768 + einfo "or through the ${HOME}/.my.cnf file."
769 + ewarn "Avoid [\"'\\_%] characters in the password"
770 + read -rsp " >" pwd1 ; echo
771 +
772 + einfo "Retype the password"
773 + read -rsp " >" pwd2 ; echo
774 +
775 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
776 + die "Passwords are not the same"
777 + fi
778 + MYSQL_ROOT_PASSWORD="${pwd1}"
779 + unset pwd1 pwd2
780 + fi
781 +
782 + local options
783 + local sqltmp="$(emktemp)"
784 +
785 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
786 + # see http://bugs.mysql.com/bug.php?id=31312
787 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
788 +
789 + # Figure out which options we need to disable to do the setup
790 + local helpfile="${TMPDIR}/mysqld-help"
791 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
792 + for opt in grant-tables host-cache name-resolve networking slave-start \
793 + federated ssl log-bin relay-log slow-query-log external-locking \
794 + log-slave-updates \
795 + ; do
796 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
797 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
798 + done
799 +
800 + einfo "Creating the mysql database and setting proper permissions on it ..."
801 +
802 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
803 + PID_DIR="${EROOT}/var/run/mysqld"
804 + if [[ ! -d "${PID_DIR}" ]]; then
805 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
806 + fi
807 +
808 + if [[ ! -d "${MY_DATADIR}" ]]; then
809 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
810 + fi
811 +
812 + pushd "${TMPDIR}" &>/dev/null || die
813 +
814 + # Filling timezones, see
815 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
816 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
817 +
818 + local cmd=( "${EROOT}usr/share/mysql/scripts/mysql_install_db" )
819 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
820 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
821 + einfo "Command: ${cmd[*]}"
822 + su -s /bin/sh -c "${cmd[*]}" mysql \
823 + >"${TMPDIR}"/mysql_install_db.log 2>&1
824 + if [ $? -ne 0 ]; then
825 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
826 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
827 + fi
828 + popd &>/dev/null || die
829 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
830 + || die "MySQL databases not installed"
831 +
832 + use prefix || options="${options} --user=mysql"
833 +
834 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
835 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
836 + local mysqld="${EROOT}/usr/sbin/mysqld \
837 + ${options} \
838 + --log-warnings=0 \
839 + --basedir=${EROOT}/usr \
840 + --datadir=${ROOT}/${MY_DATADIR} \
841 + --max_allowed_packet=8M \
842 + --net_buffer_length=16K \
843 + --socket=${socket} \
844 + --pid-file=${pidfile} \
845 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
846 + #einfo "About to start mysqld: ${mysqld}"
847 + ebegin "Starting mysqld"
848 + einfo "Command ${mysqld}"
849 + ${mysqld} &
850 + rc=$?
851 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
852 + maxtry=$((${maxtry}-1))
853 + echo -n "."
854 + sleep 1
855 + done
856 + eend $rc
857 +
858 + if ! [[ -S "${socket}" ]]; then
859 + die "Completely failed to start up mysqld with: ${mysqld}"
860 + fi
861 +
862 + ebegin "Setting root password"
863 + # Do this from memory, as we don't want clear text passwords in temp files
864 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
865 + "${EROOT}/usr/bin/mysql" \
866 + "--socket=${socket}" \
867 + -hlocalhost \
868 + -e "${sql}"
869 + eend $?
870 +
871 + if [[ -n "${sqltmp}" ]] ; then
872 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
873 + "${EROOT}/usr/bin/mysql" \
874 + "--socket=${socket}" \
875 + -hlocalhost \
876 + -uroot \
877 + --password="${MYSQL_ROOT_PASSWORD}" \
878 + mysql < "${sqltmp}"
879 + rc=$?
880 + eend $?
881 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
882 + fi
883 +
884 + # Stop the server and cleanup
885 + einfo "Stopping the server ..."
886 + kill $(< "${pidfile}" )
887 + rm -f "${sqltmp}"
888 + wait %1
889 + einfo "Done"
890 +}
891
892 diff --git a/dev-db/mysql-cluster/mysql-cluster-7.3.22.ebuild b/dev-db/mysql-cluster/mysql-cluster-7.3.22.ebuild
893 new file mode 100644
894 index 00000000000..283dd6b1089
895 --- /dev/null
896 +++ b/dev-db/mysql-cluster/mysql-cluster-7.3.22.ebuild
897 @@ -0,0 +1,820 @@
898 +# Copyright 1999-2019 Gentoo Authors
899 +# Distributed under the terms of the GNU General Public License v2
900 +
901 +EAPI="6"
902 +MY_EXTRAS_VER="20190121-0015Z"
903 +
904 +#fails to build with ninja
905 +CMAKE_MAKEFILE_GENERATOR=emake
906 +
907 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
908 +inherit eutils flag-o-matic prefix toolchain-funcs java-utils-2 user cmake-utils
909 +
910 +MY_PN="mysql-cluster-gpl"
911 +SRC_URI="https://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/${MY_PN}-${PV}.tar.gz
912 + https://downloads.mysql.com/archives/MySQL-Cluster-7.3/${MY_PN}-${PV}.tar.gz"
913 +# Gentoo patches to MySQL
914 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then
915 + SRC_URI="${SRC_URI}
916 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
917 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
918 +fi
919 +
920 +HOMEPAGE="https://mysql.com/"
921 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
922 +LICENSE="GPL-2"
923 +SLOT="0"
924 +IUSE="client-libs debug extraengine jemalloc latin1 libressl numa
925 + +perl profiling selinux +server static static-libs systemtap tcmalloc
926 + test yassl"
927 +
928 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
929 +RESTRICT="libressl? ( test )"
930 +
931 +REQUIRED_USE="?? ( tcmalloc jemalloc )
932 + ?? ( yassl libressl )
933 + static? ( yassl !libressl )"
934 +
935 +KEYWORDS="~amd64 ~x86"
936 +
937 +# Shorten the path because the socket path length must be shorter than 107 chars
938 +# and we will run a mysql server during test phase
939 +S="${WORKDIR}/mysql"
940 +
941 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
942 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras"
943 + inherit git-r3
944 + EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
945 + EGIT_CHECKOUT_DIR="${WORKDIR%/}/mysql-extras"
946 + EGIT_CLONE_TYPE=shallow
947 +else
948 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras-${MY_EXTRAS_VER}"
949 +fi
950 +
951 +PATCHES=(
952 + "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch
953 + "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch
954 + "${MY_PATCH_DIR}"/20006_all_cmake_elib-mysql-5.6.35.patch
955 + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch
956 + "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch
957 + "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch
958 + "${MY_PATCH_DIR}"/20018_all_mysql-cluster-7.3.22-without-clientlibs-tools.patch
959 + "${MY_PATCH_DIR}"/20027_all_mysql-5.5-perl5.26-includes.patch
960 + "${MY_PATCH_DIR}"/20028_all_mysql-5.6-gcc7.patch
961 + "${MY_PATCH_DIR}"/20031_all_mysql-5.6-fix-monitor.test.patch
962 + "${MY_PATCH_DIR}"/20036_all_mysql-5.6-fix-rpl_semi_sync_shutdown_hang.test.patch
963 + "${MY_PATCH_DIR}"/30000_all_mysql-cluster-multilib-property.patch
964 +)
965 +
966 +# Be warned, *DEPEND are version-dependant
967 +# These are used for both runtime and compiletime
968 +COMMON_DEPEND="
969 + kernel_linux? (
970 + sys-process/procps:0=
971 + dev-libs/libaio:0=
972 + )
973 + dev-libs/libevent:0=
974 + >=sys-apps/sed-4
975 + >=sys-apps/texinfo-4.7-r1
976 + jemalloc? ( dev-libs/jemalloc:0= )
977 + numa? ( sys-process/numactl )
978 + tcmalloc? ( dev-util/google-perftools:0= )
979 + systemtap? ( >=dev-util/systemtap-1.3:0= )
980 + !yassl? (
981 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
982 + libressl? ( dev-libs/libressl:0= )
983 + )
984 + >=sys-libs/zlib-1.2.3:0=
985 + sys-libs/ncurses:0=
986 + ${JAVA_PKG_E_DEPEND}
987 +"
988 +DEPEND="virtual/yacc
989 + static? ( sys-libs/ncurses[static-libs] )
990 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
991 + >=virtual/jdk-1.6
992 + test? ( dev-perl/JSON )
993 + ${COMMON_DEPEND}"
994 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
995 + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql
996 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
997 + ${COMMON_DEPEND}
998 + >=virtual/jre-1.6
999 + perl? ( !dev-db/mytop
1000 + virtual/perl-Getopt-Long
1001 + dev-perl/TermReadKey
1002 + virtual/perl-Term-ANSIColor
1003 + virtual/perl-Time-HiRes )
1004 +"
1005 +# For other stuff to bring us in
1006 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
1007 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
1008 +
1009 +pkg_setup() {
1010 + if [[ ${MERGE_TYPE} != binary ]] ; then
1011 + local GCC_MAJOR_SET=$(gcc-major-version)
1012 + local GCC_MINOR_SET=$(gcc-minor-version)
1013 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
1014 + # non x86{,_64} arches
1015 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
1016 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
1017 + eerror "${PN} needs to be built with gcc-4.7 or later."
1018 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
1019 + die
1020 + fi
1021 + fi
1022 + if has test ${FEATURES} && \
1023 + use server && ! has userpriv ${FEATURES} ; then
1024 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
1025 + fi
1026 +
1027 + # This should come after all of the die statements
1028 + enewgroup mysql 60 || die "problem adding 'mysql' group"
1029 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
1030 +
1031 + java-pkg_init
1032 +}
1033 +
1034 +pkg_postinst() {
1035 + # Make sure the vars are correctly initialized
1036 + mysql_init_vars
1037 +
1038 + # Create log directory securely if it does not exist
1039 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
1040 +
1041 + if use server ; then
1042 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
1043 + einfo
1044 + elog "You might want to run:"
1045 + elog "\"emerge --config =${CATEGORY}/${PF}\""
1046 + elog "if this is a new install."
1047 + elog
1048 + elog "If you are switching server implentations, you should run the"
1049 + elog "mysql_upgrade tool."
1050 + einfo
1051 + else
1052 + einfo
1053 + elog "If you are upgrading major versions, you should run the"
1054 + elog "mysql_upgrade tool."
1055 + einfo
1056 + fi
1057 +
1058 + einfo
1059 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
1060 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
1061 + elog "The first time the cluster is activated, you should add"
1062 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
1063 + elog "This option should then be removed for subsequent starts."
1064 + einfo
1065 + fi
1066 +}
1067 +
1068 +src_unpack() {
1069 + unpack ${A}
1070 + # Grab the patches
1071 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR%/}/mysql-extras" git-r3_src_unpack
1072 +
1073 + mv -f "${WORKDIR%/}/${MY_PN}-${PV}" "${S}" || die
1074 +}
1075 +
1076 +src_prepare() {
1077 + _disable_engine() {
1078 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
1079 + }
1080 +
1081 + _disable_plugin() {
1082 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
1083 + }
1084 +
1085 + if use tcmalloc; then
1086 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S%/}/sql/CMakeLists.txt" || die
1087 + fi
1088 +
1089 + if use jemalloc; then
1090 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S%/}/sql/CMakeLists.txt" || die
1091 + fi
1092 +
1093 + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
1094 + if [[ -d "${S}/support-files/SELinux" ]] ; then
1095 + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
1096 + fi
1097 +
1098 + if use libressl ; then
1099 + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \
1100 + "${S}/cmake/ssl.cmake" || die
1101 + fi
1102 +
1103 + local plugin
1104 + local server_plugins=( semisync )
1105 + local test_plugins=( audit_null daemon_example fulltext )
1106 + if ! use server; then # These plugins are for the server
1107 + for plugin in "${server_plugins[@]}" ; do
1108 + _disable_plugin "${plugin}"
1109 + done
1110 + fi
1111 +
1112 + if ! use test; then # These plugins are only used during testing
1113 + for plugin in "${test_plugins[@]}" ; do
1114 + _disable_plugin "${plugin}"
1115 + done
1116 + fi
1117 +
1118 + # Don't build example
1119 + _disable_engine example
1120 +
1121 + cmake-utils_src_prepare
1122 + java-utils-2_src_prepare
1123 +}
1124 +
1125 +src_configure(){
1126 + # Bug #114895, bug #110149
1127 + filter-flags "-O" "-O[01]"
1128 +
1129 + append-cxxflags -felide-constructors
1130 +
1131 + # bug #283926, with GCC4.4, this is required to get correct behavior.
1132 + append-flags -fno-strict-aliasing
1133 +
1134 + CMAKE_BUILD_TYPE="RelWithDebInfo"
1135 +
1136 + # debug hack wrt #497532
1137 + mycmakeargs=(
1138 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1139 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1140 + -DCMAKE_INSTALL_PREFIX="${EPREFIX%/}/usr"
1141 + -DDEFAULT_SYSCONFDIR="${EPREFIX%/}/etc/mysql"
1142 + -DINSTALL_BINDIR=bin
1143 + -DINSTALL_DOCDIR=share/doc/${PF}
1144 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
1145 + -DINSTALL_INCLUDEDIR=include/mysql
1146 + -DINSTALL_INFODIR=share/info
1147 + -DINSTALL_LIBDIR=$(get_libdir)
1148 + -DINSTALL_MANDIR=share/man
1149 + -DINSTALL_MYSQLSHAREDIR=share/mysql
1150 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
1151 + -DINSTALL_SCRIPTDIR=share/mysql/scripts
1152 + -DINSTALL_MYSQLDATADIR="${EPREFIX%/}/var/lib/mysql"
1153 + -DINSTALL_SBINDIR=sbin
1154 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX%/}/usr/share/mysql"
1155 + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
1156 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
1157 + -DWITH_EDITLINE=bundled
1158 + -DWITH_ZLIB=system
1159 + -DWITH_LIBWRAP=OFF
1160 + -DENABLED_LOCAL_INFILE=1
1161 + -DMYSQL_UNIX_ADDR="${EPREFIX%/}/var/run/mysqld/mysqld.sock"
1162 + # The build forces this to be defined when cross-compiling. We pass it
1163 + # all the time for simplicity and to make sure it is actually correct.
1164 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
1165 + -DWITHOUT_CLIENTLIBS=YES
1166 + -DENABLE_DTRACE=$(usex systemtap)
1167 + -DWITH_BUNDLED_LIBEVENT=OFF
1168 + )
1169 + if use test ; then
1170 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
1171 + else
1172 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
1173 + fi
1174 +
1175 + if ! use yassl ; then
1176 + mycmakeargs+=( -DWITH_SSL=system )
1177 + else
1178 + mycmakeargs+=( -DWITH_SSL=bundled )
1179 + fi
1180 +
1181 + if use server ; then
1182 +
1183 + # Federated must be treated special otherwise they will not be built as plugins
1184 + if ! use extraengine ; then
1185 + mycmakeargs+=( -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 )
1186 + fi
1187 +
1188 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
1189 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
1190 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
1191 + ewarn "You MUST file bugs without these variables set."
1192 +
1193 + mycmakeargs+=(
1194 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
1195 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
1196 + )
1197 +
1198 + elif ! use latin1 ; then
1199 + mycmakeargs+=(
1200 + -DDEFAULT_CHARSET=utf8
1201 + -DDEFAULT_COLLATION=utf8_general_ci
1202 + )
1203 + else
1204 + mycmakeargs+=(
1205 + -DDEFAULT_CHARSET=latin1
1206 + -DDEFAULT_COLLATION=latin1_swedish_ci
1207 + )
1208 + fi
1209 + mycmakeargs+=(
1210 + -DINSTALL_SQLBENCHDIR=share/mysql
1211 + -DEXTRA_CHARSETS=all
1212 + -DDISABLE_SHARED=$(usex static YES NO)
1213 + -DWITH_EMBEDDED_SERVER=OFF
1214 + -DWITHOUT_VALIDATE_PASSWORD=1
1215 + -DWITH_NUMA=$(usex numa ON OFF)
1216 + )
1217 +
1218 + if use profiling ; then
1219 + # Setting to OFF doesn't work: Once set, profiling options will be added
1220 + # to `mysqld --help` output via sql/sys_vars.cc causing
1221 + # "main.mysqld--help-notwin" test to fail
1222 + mycmakeargs+=( -DENABLED_PROFILING=ON )
1223 + fi
1224 +
1225 + if use static; then
1226 + mycmakeargs+=( -DWITH_PIC=1 )
1227 + fi
1228 +
1229 + # Storage engines
1230 + mycmakeargs+=(
1231 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
1232 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
1233 + -DWITH_CSV_STORAGE_ENGINE=1
1234 + -DWITH_HEAP_STORAGE_ENGINE=1
1235 + -DWITH_INNOBASE_STORAGE_ENGINE=1
1236 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
1237 + -DWITH_MYISAM_STORAGE_ENGINE=1
1238 + -DWITH_PARTITION_STORAGE_ENGINE=1
1239 + -DWITH_NDBCLUSTER=1
1240 + )
1241 +
1242 + else
1243 + mycmakeargs+=(
1244 + -DWITHOUT_SERVER=1
1245 + -DEXTRA_CHARSETS=none
1246 + -DINSTALL_SQLBENCHDIR=
1247 + )
1248 + fi
1249 +
1250 + cmake-utils_src_configure
1251 +}
1252 +
1253 +src_compile() {
1254 + cmake-utils_src_compile
1255 +}
1256 +
1257 +src_install() {
1258 + cmake-utils_src_install
1259 +
1260 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
1261 + if [[ -f "${ED%/}/usr/include/mysql/server/private/config.h" ]] ; then
1262 + rm "${ED%/}/usr/include/mysql/server/private/config.h" || die
1263 + fi
1264 +
1265 + # Make sure the vars are correctly initialized
1266 + mysql_init_vars
1267 +
1268 + # Convenience links
1269 + einfo "Making Convenience links for mysqlcheck multi-call binary"
1270 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
1271 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
1272 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
1273 +
1274 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
1275 + if [[ -d "${ED%/}/usr/data" ]] ; then
1276 + rm -Rf "${ED%/}/usr/data" || die
1277 + fi
1278 +
1279 + # Unless they explicitly specific USE=test, then do not install the
1280 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
1281 + # validation of your database configuration after tuning it.
1282 + if ! use test ; then
1283 + rm -rf "${D%/}/${MY_SHAREDSTATEDIR}/mysql-test"
1284 + fi
1285 +
1286 + # Configuration stuff
1287 + einfo "Building default configuration ..."
1288 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
1289 + [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf
1290 + local mycnf_src="my.cnf-5.6"
1291 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
1292 + "${FILESDIR%/}/${mycnf_src}" \
1293 + > "${TMPDIR%/}/my.cnf.ok" || die
1294 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok"
1295 + if use latin1 ; then
1296 + sed -i \
1297 + -e "/character-set/s|utf8|latin1|g" \
1298 + "${TMPDIR%/}/my.cnf.ok" || die
1299 + fi
1300 + eprefixify "${TMPDIR%/}/my.cnf.ok"
1301 + newins "${TMPDIR}/my.cnf.ok" my.cnf
1302 +
1303 + if use server ; then
1304 + einfo "Including support files and sample configurations"
1305 + docinto "support-files"
1306 + local script
1307 + for script in \
1308 + "${S%/}"/support-files/magic \
1309 + "${S%/}"/support-files/ndb-config-2-node.ini
1310 + do
1311 + [[ -f "$script" ]] && dodoc "${script}"
1312 + done
1313 +
1314 + docinto "scripts"
1315 + for script in "${S%/}"/scripts/mysql* ; do
1316 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
1317 + done
1318 + fi
1319 +
1320 + #Remove mytop if perl is not selected
1321 + [[ -e "${ED%/}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED%/}/usr/bin/mytop"
1322 +}
1323 +
1324 +# Official test instructions:
1325 +# USE='extraengine perl server' \
1326 +# FEATURES='test userpriv -usersandbox' \
1327 +# ebuild mysql-X.X.XX.ebuild \
1328 +# digest clean package
1329 +src_test() {
1330 +
1331 + _disable_test() {
1332 + local rawtestname reason
1333 + rawtestname="${1}" ; shift
1334 + reason="${@}"
1335 + ewarn "test '${rawtestname}' disabled: '${reason}'"
1336 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
1337 + }
1338 +
1339 + local TESTDIR="${BUILD_DIR}/mysql-test"
1340 + local retstatus_unit
1341 + local retstatus_tests
1342 +
1343 + if ! use server ; then
1344 + einfo "Skipping server tests due to minimal build."
1345 + return 0
1346 + fi
1347 +
1348 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
1349 + # localhost. Also causes weird failures.
1350 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1351 +
1352 + if [[ $UID -eq 0 ]]; then
1353 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
1354 + fi
1355 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
1356 +
1357 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
1358 +
1359 + # Run CTest (test-units)
1360 + cmake-utils_src_test
1361 + retstatus_unit=$?
1362 +
1363 + # Ensure that parallel runs don't die
1364 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
1365 + # Enable parallel testing, auto will try to detect number of cores
1366 + # You may set this by hand.
1367 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
1368 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
1369 +
1370 + # create directories because mysqladmin might run out of order
1371 + mkdir -p "${T}"/var-tests{,/log} || die
1372 +
1373 + # Run mysql tests
1374 + pushd "${TESTDIR}" > /dev/null || die
1375 +
1376 + touch "${T}/disabled.def"
1377 + # These are failing in MySQL 5.5 for now and are believed to be
1378 + # false positives:
1379 + #
1380 + # main.mysql_client_test, main.mysql_client_test_nonblock
1381 + # main.mysql_client_test_comp:
1382 + # segfaults at random under Portage only, suspect resource limits.
1383 +
1384 + local t
1385 + for t in main.mysql_client_test \
1386 + binlog.binlog_statement_insert_delayed main.information_schema \
1387 + main.mysqld--help-notwin main.flush_read_lock_kill \
1388 + sys_vars.plugin_dir_basic main.openssl_1 \
1389 + binlog.binlog_mysqlbinlog_filter \
1390 + perfschema.binlog_edge_mix perfschema.binlog_edge_stmt \
1391 + funcs_1.is_columns_mysql funcs_1.is_tables_mysql funcs_1.is_triggers \
1392 + main.mysqlhotcopy_archive main.mysqlhotcopy_myisam ; do
1393 + _disable_test "$t" "False positives in Gentoo"
1394 + done
1395 +
1396 + for t in \
1397 + ndb.ndbinfo ndb.ndb_tools_connect \
1398 + ndb_binlog.ndb_binlog_index ; do
1399 + _disable_test "$t" "False positives in Gentoo (NDB) (Latin1/UTF8)"
1400 + done
1401 +
1402 + _disable_test main.mysqldump "Extra expected warning not recorded in test results"
1403 +
1404 + if ! use client-libs ; then
1405 + _disable_test main.plugin_auth "Needs client libraries built"
1406 + fi
1407 +
1408 + # Set file limits higher so tests run
1409 + ulimit -n 3000
1410 +
1411 + # run mysql-test tests
1412 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
1413 + retstatus_tests=$?
1414 +
1415 + popd > /dev/null || die
1416 +
1417 + # Cleanup is important for these testcases.
1418 + pkill -9 -f "${S}/ndb" 2>/dev/null
1419 + pkill -9 -f "${S}/sql" 2>/dev/null
1420 +
1421 + local failures=""
1422 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
1423 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
1424 +
1425 + [[ -z "$failures" ]] || die "Test failures: $failures"
1426 + einfo "Tests successfully completed"
1427 +}
1428 +
1429 +mysql_init_vars() {
1430 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
1431 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
1432 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
1433 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
1434 +
1435 + if [[ -z "${MY_DATADIR}" ]] ; then
1436 + MY_DATADIR=""
1437 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
1438 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
1439 + | sed -ne '/datadir/s|^--datadir=||p' \
1440 + | tail -n1`
1441 + if [[ -z "${MY_DATADIR}" ]] ; then
1442 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
1443 + | sed -e 's/.*=\s*//' \
1444 + | tail -n1`
1445 + fi
1446 + fi
1447 + if [[ -z "${MY_DATADIR}" ]] ; then
1448 + MY_DATADIR="${MY_LOCALSTATEDIR}"
1449 + einfo "Using default MY_DATADIR"
1450 + fi
1451 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
1452 +
1453 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
1454 + if [[ -e "${MY_DATADIR}" ]] ; then
1455 + # If you get this and you're wondering about it, see bug #207636
1456 + elog "MySQL datadir found in ${MY_DATADIR}"
1457 + elog "A new one will not be created."
1458 + PREVIOUS_DATADIR="yes"
1459 + else
1460 + PREVIOUS_DATADIR="no"
1461 + fi
1462 + export PREVIOUS_DATADIR
1463 + fi
1464 + else
1465 + if [[ ${EBUILD_PHASE} == "config" ]]; then
1466 + local new_MY_DATADIR
1467 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
1468 + | sed -ne '/datadir/s|^--datadir=||p' \
1469 + | tail -n1`
1470 +
1471 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
1472 + ewarn "MySQL MY_DATADIR has changed"
1473 + ewarn "from ${MY_DATADIR}"
1474 + ewarn "to ${new_MY_DATADIR}"
1475 + MY_DATADIR="${new_MY_DATADIR}"
1476 + fi
1477 + fi
1478 + fi
1479 +
1480 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
1481 + export MY_LOCALSTATEDIR MY_LOGDIR
1482 + export MY_DATADIR
1483 +}
1484 +
1485 +pkg_config() {
1486 + _getoptval() {
1487 + local mypd="${EROOT}"/usr/bin/my_print_defaults
1488 + local section="$1"
1489 + local flag="--${2}="
1490 + local extra_options="${3}"
1491 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
1492 + }
1493 + local old_MY_DATADIR="${MY_DATADIR}"
1494 + local old_HOME="${HOME}"
1495 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
1496 + export HOME=${EPREFIX}/root
1497 +
1498 + # Make sure the vars are correctly initialized
1499 + mysql_init_vars
1500 +
1501 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
1502 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
1503 + die "Minimal builds do NOT include the MySQL server"
1504 + fi
1505 +
1506 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
1507 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
1508 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
1509 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
1510 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
1511 +
1512 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
1513 + if [[ -d "${MY_DATADIR_s}" ]]; then
1514 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
1515 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
1516 + else
1517 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
1518 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
1519 + || die "Moving MY_DATADIR failed"
1520 + fi
1521 + else
1522 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
1523 + if [[ -d "${MY_DATADIR_s}" ]]; then
1524 + ewarn "Attempting to use ${MY_DATADIR_s}"
1525 + else
1526 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
1527 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
1528 + fi
1529 + fi
1530 + fi
1531 +
1532 + local pwd1="a"
1533 + local pwd2="b"
1534 + local maxtry=15
1535 +
1536 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1537 + local tmp_mysqld_password_source=
1538 +
1539 + for tmp_mysqld_password_source in mysql client; do
1540 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
1541 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
1542 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
1543 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
1544 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
1545 + MYSQL_ROOT_PASSWORD=
1546 + continue
1547 + fi
1548 +
1549 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
1550 + break
1551 + fi
1552 + done
1553 +
1554 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
1555 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
1556 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
1557 + fi
1558 +
1559 + unset tmp_mysqld_password_source
1560 + fi
1561 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
1562 + # These are dir+prefix
1563 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
1564 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
1565 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
1566 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
1567 +
1568 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
1569 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
1570 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
1571 + fi
1572 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
1573 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
1574 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
1575 + fi
1576 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
1577 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
1578 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
1579 + fi
1580 +
1581 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
1582 + ewarn "You have already a MySQL database in place."
1583 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
1584 + ewarn "Please rename or delete it if you wish to replace it."
1585 + die "MySQL database already exists!"
1586 + fi
1587 +
1588 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
1589 + # localhost. Also causes weird failures.
1590 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1591 +
1592 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
1593 +
1594 + einfo "Please provide a password for the mysql 'root' user now"
1595 + einfo "or through the ${HOME}/.my.cnf file."
1596 + ewarn "Avoid [\"'\\_%] characters in the password"
1597 + read -rsp " >" pwd1 ; echo
1598 +
1599 + einfo "Retype the password"
1600 + read -rsp " >" pwd2 ; echo
1601 +
1602 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
1603 + die "Passwords are not the same"
1604 + fi
1605 + MYSQL_ROOT_PASSWORD="${pwd1}"
1606 + unset pwd1 pwd2
1607 + fi
1608 +
1609 + local options
1610 + local sqltmp="$(emktemp)"
1611 +
1612 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
1613 + # see http://bugs.mysql.com/bug.php?id=31312
1614 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
1615 +
1616 + # Figure out which options we need to disable to do the setup
1617 + local helpfile="${TMPDIR}/mysqld-help"
1618 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
1619 + for opt in grant-tables host-cache name-resolve networking slave-start \
1620 + federated ssl log-bin relay-log slow-query-log external-locking \
1621 + log-slave-updates \
1622 + ; do
1623 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1624 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
1625 + done
1626 +
1627 + einfo "Creating the mysql database and setting proper permissions on it ..."
1628 +
1629 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
1630 + PID_DIR="${EROOT}/var/run/mysqld"
1631 + if [[ ! -d "${PID_DIR}" ]]; then
1632 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
1633 + fi
1634 +
1635 + if [[ ! -d "${MY_DATADIR}" ]]; then
1636 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
1637 + fi
1638 +
1639 + pushd "${TMPDIR}" &>/dev/null || die
1640 +
1641 + # Filling timezones, see
1642 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1643 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
1644 +
1645 + local cmd=( "${EROOT}usr/share/mysql/scripts/mysql_install_db" )
1646 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
1647 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
1648 + einfo "Command: ${cmd[*]}"
1649 + su -s /bin/sh -c "${cmd[*]}" mysql \
1650 + >"${TMPDIR}"/mysql_install_db.log 2>&1
1651 + if [ $? -ne 0 ]; then
1652 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1653 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1654 + fi
1655 + popd &>/dev/null || die
1656 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1657 + || die "MySQL databases not installed"
1658 +
1659 + use prefix || options="${options} --user=mysql"
1660 +
1661 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1662 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1663 + local mysqld="${EROOT}/usr/sbin/mysqld \
1664 + ${options} \
1665 + --log-warnings=0 \
1666 + --basedir=${EROOT}/usr \
1667 + --datadir=${ROOT}/${MY_DATADIR} \
1668 + --max_allowed_packet=8M \
1669 + --net_buffer_length=16K \
1670 + --socket=${socket} \
1671 + --pid-file=${pidfile} \
1672 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
1673 + #einfo "About to start mysqld: ${mysqld}"
1674 + ebegin "Starting mysqld"
1675 + einfo "Command ${mysqld}"
1676 + ${mysqld} &
1677 + rc=$?
1678 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1679 + maxtry=$((${maxtry}-1))
1680 + echo -n "."
1681 + sleep 1
1682 + done
1683 + eend $rc
1684 +
1685 + if ! [[ -S "${socket}" ]]; then
1686 + die "Completely failed to start up mysqld with: ${mysqld}"
1687 + fi
1688 +
1689 + ebegin "Setting root password"
1690 + # Do this from memory, as we don't want clear text passwords in temp files
1691 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
1692 + "${EROOT}/usr/bin/mysql" \
1693 + "--socket=${socket}" \
1694 + -hlocalhost \
1695 + -e "${sql}"
1696 + eend $?
1697 +
1698 + if [[ -n "${sqltmp}" ]] ; then
1699 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1700 + "${EROOT}/usr/bin/mysql" \
1701 + "--socket=${socket}" \
1702 + -hlocalhost \
1703 + -uroot \
1704 + --password="${MYSQL_ROOT_PASSWORD}" \
1705 + mysql < "${sqltmp}"
1706 + rc=$?
1707 + eend $?
1708 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1709 + fi
1710 +
1711 + # Stop the server and cleanup
1712 + einfo "Stopping the server ..."
1713 + kill $(< "${pidfile}" )
1714 + rm -f "${sqltmp}"
1715 + wait %1
1716 + einfo "Done"
1717 +}
1718
1719 diff --git a/dev-db/mysql-cluster/mysql-cluster-7.4.21.ebuild b/dev-db/mysql-cluster/mysql-cluster-7.4.21.ebuild
1720 new file mode 100644
1721 index 00000000000..787367f6f5f
1722 --- /dev/null
1723 +++ b/dev-db/mysql-cluster/mysql-cluster-7.4.21.ebuild
1724 @@ -0,0 +1,820 @@
1725 +# Copyright 1999-2019 Gentoo Authors
1726 +# Distributed under the terms of the GNU General Public License v2
1727 +
1728 +EAPI="6"
1729 +MY_EXTRAS_VER="20190121-0015Z"
1730 +
1731 +#fails to build with ninja
1732 +CMAKE_MAKEFILE_GENERATOR=emake
1733 +
1734 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
1735 +inherit eutils flag-o-matic prefix toolchain-funcs java-utils-2 user cmake-utils
1736 +
1737 +MY_PN="mysql-cluster-gpl"
1738 +SRC_URI="https://cdn.mysql.com/Downloads/MySQL-Cluster-7.4/${MY_PN}-${PV}.tar.gz
1739 + https://downloads.mysql.com/archives/MySQL-Cluster-7.4/${MY_PN}-${PV}.tar.gz"
1740 +# Gentoo patches to MySQL
1741 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then
1742 + SRC_URI="${SRC_URI}
1743 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
1744 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
1745 +fi
1746 +
1747 +HOMEPAGE="https://mysql.com/"
1748 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
1749 +LICENSE="GPL-2"
1750 +SLOT="0"
1751 +IUSE="client-libs debug extraengine jemalloc latin1 libressl numa
1752 + +perl profiling selinux +server static static-libs systemtap tcmalloc
1753 + test yassl"
1754 +
1755 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
1756 +RESTRICT="libressl? ( test )"
1757 +
1758 +REQUIRED_USE="?? ( tcmalloc jemalloc )
1759 + ?? ( yassl libressl )
1760 + static? ( yassl !libressl )"
1761 +
1762 +KEYWORDS="~amd64 ~x86"
1763 +
1764 +# Shorten the path because the socket path length must be shorter than 107 chars
1765 +# and we will run a mysql server during test phase
1766 +S="${WORKDIR}/mysql"
1767 +
1768 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
1769 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras"
1770 + inherit git-r3
1771 + EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
1772 + EGIT_CHECKOUT_DIR="${WORKDIR%/}/mysql-extras"
1773 + EGIT_CLONE_TYPE=shallow
1774 +else
1775 + MY_PATCH_DIR="${WORKDIR%/}/mysql-extras-${MY_EXTRAS_VER}"
1776 +fi
1777 +
1778 +PATCHES=(
1779 + "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch
1780 + "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch
1781 + "${MY_PATCH_DIR}"/20006_all_cmake_elib-mysql-5.6.35.patch
1782 + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch
1783 + "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch
1784 + "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch
1785 + "${MY_PATCH_DIR}"/20018_all_mysql-cluster-7.3.22-without-clientlibs-tools.patch
1786 + "${MY_PATCH_DIR}"/20027_all_mysql-5.5-perl5.26-includes.patch
1787 + "${MY_PATCH_DIR}"/20028_all_mysql-5.6-gcc7.patch
1788 + "${MY_PATCH_DIR}"/20031_all_mysql-5.6-fix-monitor.test.patch
1789 + "${MY_PATCH_DIR}"/20036_all_mysql-5.6-fix-rpl_semi_sync_shutdown_hang.test.patch
1790 + "${MY_PATCH_DIR}"/30000_all_mysql-cluster-multilib-property.patch
1791 +)
1792 +
1793 +# Be warned, *DEPEND are version-dependant
1794 +# These are used for both runtime and compiletime
1795 +COMMON_DEPEND="
1796 + kernel_linux? (
1797 + sys-process/procps:0=
1798 + dev-libs/libaio:0=
1799 + )
1800 + dev-libs/libevent:0=
1801 + >=sys-apps/sed-4
1802 + >=sys-apps/texinfo-4.7-r1
1803 + jemalloc? ( dev-libs/jemalloc:0= )
1804 + numa? ( sys-process/numactl )
1805 + tcmalloc? ( dev-util/google-perftools:0= )
1806 + systemtap? ( >=dev-util/systemtap-1.3:0= )
1807 + !yassl? (
1808 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
1809 + libressl? ( dev-libs/libressl:0= )
1810 + )
1811 + >=sys-libs/zlib-1.2.3:0=
1812 + sys-libs/ncurses:0=
1813 + ${JAVA_PKG_E_DEPEND}
1814 +"
1815 +DEPEND="virtual/yacc
1816 + static? ( sys-libs/ncurses[static-libs] )
1817 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
1818 + >=virtual/jdk-1.6
1819 + test? ( dev-perl/JSON )
1820 + ${COMMON_DEPEND}"
1821 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
1822 + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql
1823 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
1824 + ${COMMON_DEPEND}
1825 + >=virtual/jre-1.6
1826 + perl? ( !dev-db/mytop
1827 + virtual/perl-Getopt-Long
1828 + dev-perl/TermReadKey
1829 + virtual/perl-Term-ANSIColor
1830 + virtual/perl-Time-HiRes )
1831 +"
1832 +# For other stuff to bring us in
1833 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
1834 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
1835 +
1836 +pkg_setup() {
1837 + if [[ ${MERGE_TYPE} != binary ]] ; then
1838 + local GCC_MAJOR_SET=$(gcc-major-version)
1839 + local GCC_MINOR_SET=$(gcc-minor-version)
1840 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
1841 + # non x86{,_64} arches
1842 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
1843 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
1844 + eerror "${PN} needs to be built with gcc-4.7 or later."
1845 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
1846 + die
1847 + fi
1848 + fi
1849 + if has test ${FEATURES} && \
1850 + use server && ! has userpriv ${FEATURES} ; then
1851 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
1852 + fi
1853 +
1854 + # This should come after all of the die statements
1855 + enewgroup mysql 60 || die "problem adding 'mysql' group"
1856 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
1857 +
1858 + java-pkg_init
1859 +}
1860 +
1861 +pkg_postinst() {
1862 + # Make sure the vars are correctly initialized
1863 + mysql_init_vars
1864 +
1865 + # Create log directory securely if it does not exist
1866 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
1867 +
1868 + if use server ; then
1869 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
1870 + einfo
1871 + elog "You might want to run:"
1872 + elog "\"emerge --config =${CATEGORY}/${PF}\""
1873 + elog "if this is a new install."
1874 + elog
1875 + elog "If you are switching server implentations, you should run the"
1876 + elog "mysql_upgrade tool."
1877 + einfo
1878 + else
1879 + einfo
1880 + elog "If you are upgrading major versions, you should run the"
1881 + elog "mysql_upgrade tool."
1882 + einfo
1883 + fi
1884 +
1885 + einfo
1886 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
1887 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
1888 + elog "The first time the cluster is activated, you should add"
1889 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
1890 + elog "This option should then be removed for subsequent starts."
1891 + einfo
1892 + fi
1893 +}
1894 +
1895 +src_unpack() {
1896 + unpack ${A}
1897 + # Grab the patches
1898 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR%/}/mysql-extras" git-r3_src_unpack
1899 +
1900 + mv -f "${WORKDIR%/}/${MY_PN}-${PV}" "${S}" || die
1901 +}
1902 +
1903 +src_prepare() {
1904 + _disable_engine() {
1905 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
1906 + }
1907 +
1908 + _disable_plugin() {
1909 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
1910 + }
1911 +
1912 + if use tcmalloc; then
1913 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S%/}/sql/CMakeLists.txt" || die
1914 + fi
1915 +
1916 + if use jemalloc; then
1917 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S%/}/sql/CMakeLists.txt" || die
1918 + fi
1919 +
1920 + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
1921 + if [[ -d "${S}/support-files/SELinux" ]] ; then
1922 + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
1923 + fi
1924 +
1925 + if use libressl ; then
1926 + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \
1927 + "${S}/cmake/ssl.cmake" || die
1928 + fi
1929 +
1930 + local plugin
1931 + local server_plugins=( semisync )
1932 + local test_plugins=( audit_null daemon_example fulltext )
1933 + if ! use server; then # These plugins are for the server
1934 + for plugin in "${server_plugins[@]}" ; do
1935 + _disable_plugin "${plugin}"
1936 + done
1937 + fi
1938 +
1939 + if ! use test; then # These plugins are only used during testing
1940 + for plugin in "${test_plugins[@]}" ; do
1941 + _disable_plugin "${plugin}"
1942 + done
1943 + fi
1944 +
1945 + # Don't build example
1946 + _disable_engine example
1947 +
1948 + cmake-utils_src_prepare
1949 + java-utils-2_src_prepare
1950 +}
1951 +
1952 +src_configure(){
1953 + # Bug #114895, bug #110149
1954 + filter-flags "-O" "-O[01]"
1955 +
1956 + append-cxxflags -felide-constructors
1957 +
1958 + # bug #283926, with GCC4.4, this is required to get correct behavior.
1959 + append-flags -fno-strict-aliasing
1960 +
1961 + CMAKE_BUILD_TYPE="RelWithDebInfo"
1962 +
1963 + # debug hack wrt #497532
1964 + mycmakeargs=(
1965 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1966 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1967 + -DCMAKE_INSTALL_PREFIX="${EPREFIX%/}/usr"
1968 + -DDEFAULT_SYSCONFDIR="${EPREFIX%/}/etc/mysql"
1969 + -DINSTALL_BINDIR=bin
1970 + -DINSTALL_DOCDIR=share/doc/${PF}
1971 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
1972 + -DINSTALL_INCLUDEDIR=include/mysql
1973 + -DINSTALL_INFODIR=share/info
1974 + -DINSTALL_LIBDIR=$(get_libdir)
1975 + -DINSTALL_MANDIR=share/man
1976 + -DINSTALL_MYSQLSHAREDIR=share/mysql
1977 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
1978 + -DINSTALL_SCRIPTDIR=share/mysql/scripts
1979 + -DINSTALL_MYSQLDATADIR="${EPREFIX%/}/var/lib/mysql"
1980 + -DINSTALL_SBINDIR=sbin
1981 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX%/}/usr/share/mysql"
1982 + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
1983 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
1984 + -DWITH_EDITLINE=bundled
1985 + -DWITH_ZLIB=system
1986 + -DWITH_LIBWRAP=OFF
1987 + -DENABLED_LOCAL_INFILE=1
1988 + -DMYSQL_UNIX_ADDR="${EPREFIX%/}/var/run/mysqld/mysqld.sock"
1989 + # The build forces this to be defined when cross-compiling. We pass it
1990 + # all the time for simplicity and to make sure it is actually correct.
1991 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
1992 + -DWITHOUT_CLIENTLIBS=YES
1993 + -DENABLE_DTRACE=$(usex systemtap)
1994 + -DWITH_BUNDLED_LIBEVENT=OFF
1995 + )
1996 + if use test ; then
1997 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
1998 + else
1999 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
2000 + fi
2001 +
2002 + if ! use yassl ; then
2003 + mycmakeargs+=( -DWITH_SSL=system )
2004 + else
2005 + mycmakeargs+=( -DWITH_SSL=bundled )
2006 + fi
2007 +
2008 + if use server ; then
2009 +
2010 + # Federated must be treated special otherwise they will not be built as plugins
2011 + if ! use extraengine ; then
2012 + mycmakeargs+=( -DWITHOUT_FEDERATED_STORAGE_ENGINE=1 )
2013 + fi
2014 +
2015 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
2016 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
2017 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
2018 + ewarn "You MUST file bugs without these variables set."
2019 +
2020 + mycmakeargs+=(
2021 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
2022 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
2023 + )
2024 +
2025 + elif ! use latin1 ; then
2026 + mycmakeargs+=(
2027 + -DDEFAULT_CHARSET=utf8
2028 + -DDEFAULT_COLLATION=utf8_general_ci
2029 + )
2030 + else
2031 + mycmakeargs+=(
2032 + -DDEFAULT_CHARSET=latin1
2033 + -DDEFAULT_COLLATION=latin1_swedish_ci
2034 + )
2035 + fi
2036 + mycmakeargs+=(
2037 + -DINSTALL_SQLBENCHDIR=share/mysql
2038 + -DEXTRA_CHARSETS=all
2039 + -DDISABLE_SHARED=$(usex static YES NO)
2040 + -DWITH_EMBEDDED_SERVER=OFF
2041 + -DWITHOUT_VALIDATE_PASSWORD=1
2042 + -DWITH_NUMA=$(usex numa ON OFF)
2043 + )
2044 +
2045 + if use profiling ; then
2046 + # Setting to OFF doesn't work: Once set, profiling options will be added
2047 + # to `mysqld --help` output via sql/sys_vars.cc causing
2048 + # "main.mysqld--help-notwin" test to fail
2049 + mycmakeargs+=( -DENABLED_PROFILING=ON )
2050 + fi
2051 +
2052 + if use static; then
2053 + mycmakeargs+=( -DWITH_PIC=1 )
2054 + fi
2055 +
2056 + # Storage engines
2057 + mycmakeargs+=(
2058 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
2059 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
2060 + -DWITH_CSV_STORAGE_ENGINE=1
2061 + -DWITH_HEAP_STORAGE_ENGINE=1
2062 + -DWITH_INNOBASE_STORAGE_ENGINE=1
2063 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
2064 + -DWITH_MYISAM_STORAGE_ENGINE=1
2065 + -DWITH_PARTITION_STORAGE_ENGINE=1
2066 + -DWITH_NDBCLUSTER=1
2067 + )
2068 +
2069 + else
2070 + mycmakeargs+=(
2071 + -DWITHOUT_SERVER=1
2072 + -DEXTRA_CHARSETS=none
2073 + -DINSTALL_SQLBENCHDIR=
2074 + )
2075 + fi
2076 +
2077 + cmake-utils_src_configure
2078 +}
2079 +
2080 +src_compile() {
2081 + cmake-utils_src_compile
2082 +}
2083 +
2084 +src_install() {
2085 + cmake-utils_src_install
2086 +
2087 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
2088 + if [[ -f "${ED%/}/usr/include/mysql/server/private/config.h" ]] ; then
2089 + rm "${ED%/}/usr/include/mysql/server/private/config.h" || die
2090 + fi
2091 +
2092 + # Make sure the vars are correctly initialized
2093 + mysql_init_vars
2094 +
2095 + # Convenience links
2096 + einfo "Making Convenience links for mysqlcheck multi-call binary"
2097 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
2098 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
2099 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
2100 +
2101 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
2102 + if [[ -d "${ED%/}/usr/data" ]] ; then
2103 + rm -Rf "${ED%/}/usr/data" || die
2104 + fi
2105 +
2106 + # Unless they explicitly specific USE=test, then do not install the
2107 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
2108 + # validation of your database configuration after tuning it.
2109 + if ! use test ; then
2110 + rm -rf "${D%/}/${MY_SHAREDSTATEDIR}/mysql-test"
2111 + fi
2112 +
2113 + # Configuration stuff
2114 + einfo "Building default configuration ..."
2115 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
2116 + [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf
2117 + local mycnf_src="my.cnf-5.6"
2118 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
2119 + "${FILESDIR%/}/${mycnf_src}" \
2120 + > "${TMPDIR%/}/my.cnf.ok" || die
2121 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok"
2122 + if use latin1 ; then
2123 + sed -i \
2124 + -e "/character-set/s|utf8|latin1|g" \
2125 + "${TMPDIR%/}/my.cnf.ok" || die
2126 + fi
2127 + eprefixify "${TMPDIR%/}/my.cnf.ok"
2128 + newins "${TMPDIR}/my.cnf.ok" my.cnf
2129 +
2130 + if use server ; then
2131 + einfo "Including support files and sample configurations"
2132 + docinto "support-files"
2133 + local script
2134 + for script in \
2135 + "${S%/}"/support-files/magic \
2136 + "${S%/}"/support-files/ndb-config-2-node.ini
2137 + do
2138 + [[ -f "$script" ]] && dodoc "${script}"
2139 + done
2140 +
2141 + docinto "scripts"
2142 + for script in "${S%/}"/scripts/mysql* ; do
2143 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
2144 + done
2145 + fi
2146 +
2147 + #Remove mytop if perl is not selected
2148 + [[ -e "${ED%/}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED%/}/usr/bin/mytop"
2149 +}
2150 +
2151 +# Official test instructions:
2152 +# USE='extraengine perl server' \
2153 +# FEATURES='test userpriv -usersandbox' \
2154 +# ebuild mysql-X.X.XX.ebuild \
2155 +# digest clean package
2156 +src_test() {
2157 +
2158 + _disable_test() {
2159 + local rawtestname reason
2160 + rawtestname="${1}" ; shift
2161 + reason="${@}"
2162 + ewarn "test '${rawtestname}' disabled: '${reason}'"
2163 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
2164 + }
2165 +
2166 + local TESTDIR="${BUILD_DIR}/mysql-test"
2167 + local retstatus_unit
2168 + local retstatus_tests
2169 +
2170 + if ! use server ; then
2171 + einfo "Skipping server tests due to minimal build."
2172 + return 0
2173 + fi
2174 +
2175 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
2176 + # localhost. Also causes weird failures.
2177 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
2178 +
2179 + if [[ $UID -eq 0 ]]; then
2180 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
2181 + fi
2182 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
2183 +
2184 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
2185 +
2186 + # Run CTest (test-units)
2187 + cmake-utils_src_test
2188 + retstatus_unit=$?
2189 +
2190 + # Ensure that parallel runs don't die
2191 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
2192 + # Enable parallel testing, auto will try to detect number of cores
2193 + # You may set this by hand.
2194 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
2195 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
2196 +
2197 + # create directories because mysqladmin might run out of order
2198 + mkdir -p "${T}"/var-tests{,/log} || die
2199 +
2200 + # Run mysql tests
2201 + pushd "${TESTDIR}" > /dev/null || die
2202 +
2203 + touch "${T}/disabled.def"
2204 + # These are failing in MySQL 5.5 for now and are believed to be
2205 + # false positives:
2206 + #
2207 + # main.mysql_client_test, main.mysql_client_test_nonblock
2208 + # main.mysql_client_test_comp:
2209 + # segfaults at random under Portage only, suspect resource limits.
2210 +
2211 + local t
2212 + for t in main.mysql_client_test \
2213 + binlog.binlog_statement_insert_delayed main.information_schema \
2214 + main.mysqld--help-notwin main.flush_read_lock_kill \
2215 + sys_vars.plugin_dir_basic main.openssl_1 \
2216 + binlog.binlog_mysqlbinlog_filter \
2217 + perfschema.binlog_edge_mix perfschema.binlog_edge_stmt \
2218 + funcs_1.is_columns_mysql funcs_1.is_tables_mysql funcs_1.is_triggers \
2219 + main.mysqlhotcopy_archive main.mysqlhotcopy_myisam ; do
2220 + _disable_test "$t" "False positives in Gentoo"
2221 + done
2222 +
2223 + for t in \
2224 + ndb.ndbinfo ndb.ndb_tools_connect \
2225 + ndb_binlog.ndb_binlog_index ; do
2226 + _disable_test "$t" "False positives in Gentoo (NDB) (Latin1/UTF8)"
2227 + done
2228 +
2229 + _disable_test main.mysqldump "Extra expected warning not recorded in test results"
2230 +
2231 + if ! use client-libs ; then
2232 + _disable_test main.plugin_auth "Needs client libraries built"
2233 + fi
2234 +
2235 + # Set file limits higher so tests run
2236 + ulimit -n 3000
2237 +
2238 + # run mysql-test tests
2239 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
2240 + retstatus_tests=$?
2241 +
2242 + popd > /dev/null || die
2243 +
2244 + # Cleanup is important for these testcases.
2245 + pkill -9 -f "${S}/ndb" 2>/dev/null
2246 + pkill -9 -f "${S}/sql" 2>/dev/null
2247 +
2248 + local failures=""
2249 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
2250 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
2251 +
2252 + [[ -z "$failures" ]] || die "Test failures: $failures"
2253 + einfo "Tests successfully completed"
2254 +}
2255 +
2256 +mysql_init_vars() {
2257 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
2258 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
2259 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
2260 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
2261 +
2262 + if [[ -z "${MY_DATADIR}" ]] ; then
2263 + MY_DATADIR=""
2264 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
2265 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
2266 + | sed -ne '/datadir/s|^--datadir=||p' \
2267 + | tail -n1`
2268 + if [[ -z "${MY_DATADIR}" ]] ; then
2269 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
2270 + | sed -e 's/.*=\s*//' \
2271 + | tail -n1`
2272 + fi
2273 + fi
2274 + if [[ -z "${MY_DATADIR}" ]] ; then
2275 + MY_DATADIR="${MY_LOCALSTATEDIR}"
2276 + einfo "Using default MY_DATADIR"
2277 + fi
2278 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
2279 +
2280 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
2281 + if [[ -e "${MY_DATADIR}" ]] ; then
2282 + # If you get this and you're wondering about it, see bug #207636
2283 + elog "MySQL datadir found in ${MY_DATADIR}"
2284 + elog "A new one will not be created."
2285 + PREVIOUS_DATADIR="yes"
2286 + else
2287 + PREVIOUS_DATADIR="no"
2288 + fi
2289 + export PREVIOUS_DATADIR
2290 + fi
2291 + else
2292 + if [[ ${EBUILD_PHASE} == "config" ]]; then
2293 + local new_MY_DATADIR
2294 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
2295 + | sed -ne '/datadir/s|^--datadir=||p' \
2296 + | tail -n1`
2297 +
2298 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
2299 + ewarn "MySQL MY_DATADIR has changed"
2300 + ewarn "from ${MY_DATADIR}"
2301 + ewarn "to ${new_MY_DATADIR}"
2302 + MY_DATADIR="${new_MY_DATADIR}"
2303 + fi
2304 + fi
2305 + fi
2306 +
2307 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
2308 + export MY_LOCALSTATEDIR MY_LOGDIR
2309 + export MY_DATADIR
2310 +}
2311 +
2312 +pkg_config() {
2313 + _getoptval() {
2314 + local mypd="${EROOT}"/usr/bin/my_print_defaults
2315 + local section="$1"
2316 + local flag="--${2}="
2317 + local extra_options="${3}"
2318 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
2319 + }
2320 + local old_MY_DATADIR="${MY_DATADIR}"
2321 + local old_HOME="${HOME}"
2322 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
2323 + export HOME=${EPREFIX}/root
2324 +
2325 + # Make sure the vars are correctly initialized
2326 + mysql_init_vars
2327 +
2328 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
2329 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
2330 + die "Minimal builds do NOT include the MySQL server"
2331 + fi
2332 +
2333 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
2334 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
2335 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
2336 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
2337 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
2338 +
2339 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
2340 + if [[ -d "${MY_DATADIR_s}" ]]; then
2341 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
2342 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
2343 + else
2344 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
2345 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
2346 + || die "Moving MY_DATADIR failed"
2347 + fi
2348 + else
2349 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
2350 + if [[ -d "${MY_DATADIR_s}" ]]; then
2351 + ewarn "Attempting to use ${MY_DATADIR_s}"
2352 + else
2353 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
2354 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
2355 + fi
2356 + fi
2357 + fi
2358 +
2359 + local pwd1="a"
2360 + local pwd2="b"
2361 + local maxtry=15
2362 +
2363 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
2364 + local tmp_mysqld_password_source=
2365 +
2366 + for tmp_mysqld_password_source in mysql client; do
2367 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
2368 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
2369 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
2370 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
2371 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
2372 + MYSQL_ROOT_PASSWORD=
2373 + continue
2374 + fi
2375 +
2376 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
2377 + break
2378 + fi
2379 + done
2380 +
2381 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
2382 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
2383 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
2384 + fi
2385 +
2386 + unset tmp_mysqld_password_source
2387 + fi
2388 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
2389 + # These are dir+prefix
2390 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
2391 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
2392 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
2393 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
2394 +
2395 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
2396 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
2397 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
2398 + fi
2399 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
2400 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
2401 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
2402 + fi
2403 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
2404 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
2405 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
2406 + fi
2407 +
2408 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
2409 + ewarn "You have already a MySQL database in place."
2410 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
2411 + ewarn "Please rename or delete it if you wish to replace it."
2412 + die "MySQL database already exists!"
2413 + fi
2414 +
2415 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
2416 + # localhost. Also causes weird failures.
2417 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
2418 +
2419 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
2420 +
2421 + einfo "Please provide a password for the mysql 'root' user now"
2422 + einfo "or through the ${HOME}/.my.cnf file."
2423 + ewarn "Avoid [\"'\\_%] characters in the password"
2424 + read -rsp " >" pwd1 ; echo
2425 +
2426 + einfo "Retype the password"
2427 + read -rsp " >" pwd2 ; echo
2428 +
2429 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
2430 + die "Passwords are not the same"
2431 + fi
2432 + MYSQL_ROOT_PASSWORD="${pwd1}"
2433 + unset pwd1 pwd2
2434 + fi
2435 +
2436 + local options
2437 + local sqltmp="$(emktemp)"
2438 +
2439 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
2440 + # see http://bugs.mysql.com/bug.php?id=31312
2441 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
2442 +
2443 + # Figure out which options we need to disable to do the setup
2444 + local helpfile="${TMPDIR}/mysqld-help"
2445 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
2446 + for opt in grant-tables host-cache name-resolve networking slave-start \
2447 + federated ssl log-bin relay-log slow-query-log external-locking \
2448 + log-slave-updates \
2449 + ; do
2450 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
2451 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
2452 + done
2453 +
2454 + einfo "Creating the mysql database and setting proper permissions on it ..."
2455 +
2456 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
2457 + PID_DIR="${EROOT}/var/run/mysqld"
2458 + if [[ ! -d "${PID_DIR}" ]]; then
2459 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
2460 + fi
2461 +
2462 + if [[ ! -d "${MY_DATADIR}" ]]; then
2463 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
2464 + fi
2465 +
2466 + pushd "${TMPDIR}" &>/dev/null || die
2467 +
2468 + # Filling timezones, see
2469 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
2470 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
2471 +
2472 + local cmd=( "${EROOT}usr/share/mysql/scripts/mysql_install_db" )
2473 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
2474 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
2475 + einfo "Command: ${cmd[*]}"
2476 + su -s /bin/sh -c "${cmd[*]}" mysql \
2477 + >"${TMPDIR}"/mysql_install_db.log 2>&1
2478 + if [ $? -ne 0 ]; then
2479 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
2480 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
2481 + fi
2482 + popd &>/dev/null || die
2483 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
2484 + || die "MySQL databases not installed"
2485 +
2486 + use prefix || options="${options} --user=mysql"
2487 +
2488 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
2489 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
2490 + local mysqld="${EROOT}/usr/sbin/mysqld \
2491 + ${options} \
2492 + --log-warnings=0 \
2493 + --basedir=${EROOT}/usr \
2494 + --datadir=${ROOT}/${MY_DATADIR} \
2495 + --max_allowed_packet=8M \
2496 + --net_buffer_length=16K \
2497 + --socket=${socket} \
2498 + --pid-file=${pidfile} \
2499 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
2500 + #einfo "About to start mysqld: ${mysqld}"
2501 + ebegin "Starting mysqld"
2502 + einfo "Command ${mysqld}"
2503 + ${mysqld} &
2504 + rc=$?
2505 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
2506 + maxtry=$((${maxtry}-1))
2507 + echo -n "."
2508 + sleep 1
2509 + done
2510 + eend $rc
2511 +
2512 + if ! [[ -S "${socket}" ]]; then
2513 + die "Completely failed to start up mysqld with: ${mysqld}"
2514 + fi
2515 +
2516 + ebegin "Setting root password"
2517 + # Do this from memory, as we don't want clear text passwords in temp files
2518 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
2519 + "${EROOT}/usr/bin/mysql" \
2520 + "--socket=${socket}" \
2521 + -hlocalhost \
2522 + -e "${sql}"
2523 + eend $?
2524 +
2525 + if [[ -n "${sqltmp}" ]] ; then
2526 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
2527 + "${EROOT}/usr/bin/mysql" \
2528 + "--socket=${socket}" \
2529 + -hlocalhost \
2530 + -uroot \
2531 + --password="${MYSQL_ROOT_PASSWORD}" \
2532 + mysql < "${sqltmp}"
2533 + rc=$?
2534 + eend $?
2535 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
2536 + fi
2537 +
2538 + # Stop the server and cleanup
2539 + einfo "Stopping the server ..."
2540 + kill $(< "${pidfile}" )
2541 + rm -f "${sqltmp}"
2542 + wait %1
2543 + einfo "Done"
2544 +}