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/
Date: Fri, 14 Sep 2018 23:16:11
Message-Id: 1536966954.af4bf7f4b7e1add5bcb4ef05410ed3cf2b940b03.grknight@gentoo
1 commit: af4bf7f4b7e1add5bcb4ef05410ed3cf2b940b03
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Fri Sep 14 23:03:48 2018 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Fri Sep 14 23:15:54 2018 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=af4bf7f4
7
8 dev-db/mysql: Backport changes from 5.6.41 into 5.6.40-r2
9
10 Package-Manager: Portage-2.3.49, Repoman-2.3.10
11
12 dev-db/mysql/mysql-5.6.40-r2.ebuild | 768 ++++++++++++++++++++++++++++++++++++
13 1 file changed, 768 insertions(+)
14
15 diff --git a/dev-db/mysql/mysql-5.6.40-r2.ebuild b/dev-db/mysql/mysql-5.6.40-r2.ebuild
16 new file mode 100644
17 index 00000000000..7ec34a50aad
18 --- /dev/null
19 +++ b/dev-db/mysql/mysql-5.6.40-r2.ebuild
20 @@ -0,0 +1,768 @@
21 +# Copyright 1999-2018 Gentoo Foundation
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI="6"
25 +MY_EXTRAS_VER="20180804-2323Z"
26 +
27 +CMAKE_MAKEFILE_GENERATOR=emake
28 +
29 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
30 +
31 +inherit eutils flag-o-matic prefix toolchain-funcs \
32 + user cmake-utils multilib-build
33 +
34 +SRC_URI="http://cdn.mysql.com/Downloads/MySQL-5.6/${P}.tar.gz
35 + https://cdn.mysql.com/archives/mysql-5.6/${P}.tar.gz
36 + http://downloads.mysql.com/archives/MySQL-5.6/${P}.tar.gz"
37 +
38 +# Gentoo patches to MySQL
39 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then
40 + SRC_URI="${SRC_URI}
41 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
42 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
43 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
44 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
45 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
46 +fi
47 +
48 +HOMEPAGE="https://www.mysql.com/"
49 +DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
50 +LICENSE="GPL-2"
51 +SLOT="0/18"
52 +IUSE="client-libs cracklib debug jemalloc latin1 libressl numa +perl profiling selinux
53 + +server static static-libs systemtap tcmalloc test yassl"
54 +
55 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
56 +RESTRICT="libressl? ( test )"
57 +
58 +REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )"
59 +
60 +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
61 +
62 +# Shorten the path because the socket path length must be shorter than 107 chars
63 +# and we will run a mysql server during test phase
64 +S="${WORKDIR}/mysql"
65 +
66 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
67 + inherit git-r3
68 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git"
69 + EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras"
70 + EGIT_CLONE_TYPE=shallow
71 + MY_PATCH_DIR="${WORKDIR}/mysql-extras"
72 +else
73 + MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}"
74 +fi
75 +
76 +PATCHES=(
77 + "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch
78 + "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch
79 + "${MY_PATCH_DIR}"/20006_all_cmake_elib-mysql-5.6.35.patch
80 + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch
81 + "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch
82 + "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch
83 + "${MY_PATCH_DIR}"/20018_all_mysql-5.6.25-without-clientlibs-tools.patch
84 + "${MY_PATCH_DIR}"/20027_all_mysql-5.5-perl5.26-includes.patch
85 + "${MY_PATCH_DIR}"/20028_all_mysql-5.6-gcc7.patch
86 + "${MY_PATCH_DIR}"/20031_all_mysql-5.6-fix-monitor.test.patch
87 +)
88 +
89 +# Be warned, *DEPEND are version-dependant
90 +# These are used for both runtime and compiletime
91 +COMMON_DEPEND="
92 + kernel_linux? (
93 + sys-process/procps:0=
94 + dev-libs/libaio:0=
95 + )
96 + net-misc/curl
97 + >=sys-apps/sed-4
98 + >=sys-apps/texinfo-4.7-r1
99 + jemalloc? ( dev-libs/jemalloc:0= )
100 + tcmalloc? ( dev-util/google-perftools:0= )
101 + systemtap? ( >=dev-util/systemtap-1.3:0= )
102 + !yassl? (
103 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
104 + libressl? ( dev-libs/libressl:0= )
105 + )
106 + >=sys-libs/zlib-1.2.3:0=
107 + sys-libs/ncurses:0=
108 + server? (
109 + numa? ( sys-process/numactl )
110 + )
111 + !client-libs? ( dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] )
112 +"
113 +DEPEND="virtual/yacc
114 + static? ( sys-libs/ncurses[static-libs] )
115 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
116 + ${COMMON_DEPEND}"
117 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
118 + client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c )
119 + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
120 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
121 + ${COMMON_DEPEND}
122 +"
123 +# For other stuff to bring us in
124 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
125 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
126 +
127 +pkg_setup() {
128 + if [[ ${MERGE_TYPE} != binary ]] ; then
129 + local GCC_MAJOR_SET=$(gcc-major-version)
130 + local GCC_MINOR_SET=$(gcc-minor-version)
131 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
132 + # non x86{,_64} arches
133 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
134 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
135 + eerror "${PN} needs to be built with gcc-4.7 or later."
136 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
137 + die
138 + fi
139 + fi
140 + if has test ${FEATURES} && \
141 + use server && ! has userpriv ${FEATURES} ; then
142 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
143 + fi
144 +
145 + # This should come after all of the die statements
146 + enewgroup mysql 60 || die "problem adding 'mysql' group"
147 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
148 +}
149 +
150 +pkg_preinst() {
151 + # Here we need to see if the implementation switched client libraries
152 + # We check if this is a new instance of the package and a client library already exists
153 + local SHOW_ABI_MESSAGE libpath
154 + if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
155 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
156 + elog "Due to ABI changes when switching between different client libraries,"
157 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
158 + elog "Please run: revdep-rebuild --library ${libpath}"
159 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
160 + fi
161 +}
162 +
163 +pkg_postinst() {
164 + # Make sure the vars are correctly initialized
165 + mysql_init_vars
166 +
167 + # Create log directory securely if it does not exist
168 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
169 +
170 + if use server ; then
171 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
172 + einfo
173 + elog "You might want to run:"
174 + elog "\"emerge --config =${CATEGORY}/${PF}\""
175 + elog "if this is a new install."
176 + elog
177 + elog "If you are switching server implentations, you should run the"
178 + elog "mysql_upgrade tool."
179 + einfo
180 + else
181 + einfo
182 + elog "If you are upgrading major versions, you should run the"
183 + elog "mysql_upgrade tool."
184 + einfo
185 + fi
186 + fi
187 +}
188 +
189 +src_unpack() {
190 + unpack ${A}
191 + # Grab the patches
192 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
193 +
194 + mv -f "${WORKDIR}/${P}" "${S}" || die
195 +}
196 +
197 +src_prepare() {
198 + _disable_engine() {
199 + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die
200 + }
201 +
202 + _disable_plugin() {
203 + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die
204 + }
205 +
206 + if use jemalloc ; then
207 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
208 + fi
209 + if use tcmalloc; then
210 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die
211 + fi
212 + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
213 + if [[ -d "${S}/support-files/SELinux" ]] ; then
214 + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
215 + fi
216 +
217 + if use libressl ; then
218 + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \
219 + "${S}/cmake/ssl.cmake" || die
220 + fi
221 +
222 + sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die
223 +
224 + local plugin
225 + local server_plugins=( semisync )
226 + local test_plugins=( audit_null daemon_example fulltext )
227 + if ! use server; then # These plugins are for the server
228 + for plugin in "${server_plugins[@]}" ; do
229 + _disable_plugin "${plugin}"
230 + done
231 + fi
232 +
233 + if ! use test; then # These plugins are only used during testing
234 + for plugin in "${test_plugins[@]}" ; do
235 + _disable_plugin "${plugin}"
236 + done
237 + fi
238 +
239 + # Don't build example
240 + _disable_engine example
241 + _disable_engine ndb
242 + _disable_plugin innodb_memcached
243 +
244 + cmake-utils_src_prepare
245 +}
246 +
247 +src_configure(){
248 + # bug 508724 mariadb cannot use ld.gold
249 + tc-ld-disable-gold
250 + # Bug #114895, bug #110149
251 + filter-flags "-O" "-O[01]"
252 +
253 + append-cxxflags -felide-constructors
254 +
255 + # bug #283926, with GCC4.4, this is required to get correct behavior.
256 + append-flags -fno-strict-aliasing
257 +
258 + CMAKE_BUILD_TYPE="RelWithDebInfo"
259 +
260 + # debug hack wrt #497532
261 + mycmakeargs=(
262 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
263 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
264 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
265 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
266 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
267 + -DINSTALL_BINDIR=bin
268 + -DINSTALL_DOCDIR=share/doc/${PF}
269 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
270 + -DINSTALL_INCLUDEDIR=include/mysql
271 + -DINSTALL_INFODIR=share/info
272 + -DINSTALL_LIBDIR=$(get_libdir)
273 + -DINSTALL_MANDIR=share/man
274 + -DINSTALL_MYSQLSHAREDIR=share/mysql
275 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
276 + -DINSTALL_SCRIPTDIR=share/mysql/scripts
277 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
278 + -DINSTALL_SBINDIR=sbin
279 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
280 + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
281 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
282 + ### TODO: make this system but issues with UTF-8 prevent it
283 + -DWITH_EDITLINE=bundled
284 + -DWITH_ZLIB=system
285 + -DWITH_LIBWRAP=0
286 + -DENABLED_LOCAL_INFILE=1
287 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
288 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
289 + -DWITH_DEFAULT_FEATURE_SET=0
290 + # The build forces this to be defined when cross-compiling. We pass it
291 + # all the time for simplicity and to make sure it is actually correct.
292 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
293 + -DWITH_LIBEVENT=NO
294 + -DWITHOUT_CLIENTLIBS=YES
295 + -DENABLE_DTRACE=$(usex systemtap)
296 + -DWITH_SSL=$(usex yassl bundled system)
297 + -DINSTALL_MYSQLTESTDIR=$(usex test 'share/mysql/mysql-test' '')
298 + -DWITHOUT_VALIDATE_PASSWORD=1
299 + )
300 +
301 + if use server ; then
302 +
303 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
304 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
305 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
306 + ewarn "You MUST file bugs without these variables set."
307 +
308 + mycmakeargs+=(
309 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
310 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
311 + )
312 +
313 + elif ! use latin1 ; then
314 + mycmakeargs+=(
315 + -DDEFAULT_CHARSET=utf8
316 + -DDEFAULT_COLLATION=utf8_general_ci
317 + )
318 + else
319 + mycmakeargs+=(
320 + -DDEFAULT_CHARSET=latin1
321 + -DDEFAULT_COLLATION=latin1_swedish_ci
322 + )
323 + fi
324 + mycmakeargs+=(
325 + -DWITH_NUMA=$(usex numa ON OFF)
326 + -DEXTRA_CHARSETS=all
327 + -DDISABLE_SHARED=$(usex static YES NO)
328 + -DWITH_DEBUG=$(usex debug)
329 + -DWITH_EMBEDDED_SERVER=OFF
330 + -DENABLED_PROFILING=$(usex profiling)
331 + )
332 +
333 + if use static; then
334 + mycmakeargs+=( -DWITH_PIC=1 )
335 + fi
336 +
337 + # Storage engines
338 + mycmakeargs+=(
339 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
340 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
341 + -DWITH_CSV_STORAGE_ENGINE=1
342 + -DWITH_HEAP_STORAGE_ENGINE=1
343 + -DWITH_INNOBASE_STORAGE_ENGINE=1
344 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
345 + -DWITH_MYISAM_STORAGE_ENGINE=1
346 + -DWITH_PARTITION_STORAGE_ENGINE=1
347 + -DWITH_INNODB_MEMCACHED=0
348 + )
349 +
350 + else
351 + mycmakeargs+=(
352 + -DWITHOUT_SERVER=1
353 + -DWITH_EMBEDDED_SERVER=OFF
354 + -DEXTRA_CHARSETS=none
355 + )
356 + fi
357 +
358 + cmake-utils_src_configure
359 +}
360 +
361 +src_compile() {
362 + cmake-utils_src_compile
363 +}
364 +
365 +src_install() {
366 + cmake-utils_src_install
367 +
368 + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
369 + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
370 + # Make sure the vars are correctly initialized
371 + mysql_init_vars
372 +
373 + # Convenience links
374 + einfo "Making Convenience links for mysqlcheck multi-call binary"
375 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
376 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
377 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
378 +
379 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
380 + if [[ -d "${ED}/usr/data" ]] ; then
381 + rm -Rf "${ED}/usr/data" || die
382 + fi
383 +
384 + # Unless they explicitly specific USE=test, then do not install the
385 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
386 + # validation of your database configuration after tuning it.
387 + if ! use test ; then
388 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
389 + fi
390 +
391 + # Configuration stuff
392 + einfo "Building default configuration ..."
393 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
394 + [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf
395 + local mycnf_src="my.cnf-5.6"
396 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
397 + "${FILESDIR%/}/${mycnf_src}" \
398 + > "${TMPDIR%/}/my.cnf.ok" || die
399 + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok"
400 + if use latin1 ; then
401 + sed -i \
402 + -e "/character-set/s|utf8|latin1|g" \
403 + "${TMPDIR%/}/my.cnf.ok" || die
404 + fi
405 + eprefixify "${TMPDIR%/}/my.cnf.ok"
406 + newins "${TMPDIR}/my.cnf.ok" my.cnf
407 +
408 + if use server ; then
409 + einfo "Including support files and sample configurations"
410 + docinto "support-files"
411 + local script
412 + for script in \
413 + "${S}"/support-files/magic
414 + do
415 + [[ -f "$script" ]] && dodoc "${script}"
416 + done
417 +
418 + docinto "scripts"
419 + for script in "${S}"/scripts/mysql* ; do
420 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
421 + done
422 + fi
423 +
424 + #Remove mytop if perl is not selected
425 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
426 +}
427 +
428 +# Official test instructions:
429 +# USE='perl server static-libs' \
430 +# FEATURES='test userpriv -usersandbox' \
431 +# ebuild mysql-X.X.XX.ebuild \
432 +# digest clean package
433 +src_test() {
434 +
435 + _disable_test() {
436 + local rawtestname reason
437 + rawtestname="${1}" ; shift
438 + reason="${@}"
439 + ewarn "test '${rawtestname}' disabled: '${reason}'"
440 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
441 + }
442 +
443 + local TESTDIR="${BUILD_DIR}/mysql-test"
444 + local retstatus_unit
445 + local retstatus_tests
446 +
447 + if ! use server ; then
448 + einfo "Skipping server tests due to minimal build."
449 + return 0
450 + fi
451 +
452 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
453 + # localhost. Also causes weird failures.
454 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
455 +
456 + if [[ $UID -eq 0 ]]; then
457 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
458 + fi
459 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
460 +
461 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
462 +
463 + # Run CTest (test-units)
464 + cmake-utils_src_test
465 + retstatus_unit=$?
466 +
467 + # Ensure that parallel runs don't die
468 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
469 + # Enable parallel testing, auto will try to detect number of cores
470 + # You may set this by hand.
471 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
472 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
473 +
474 + # create directories because mysqladmin might run out of order
475 + mkdir -p "${T}"/var-tests{,/log} || die
476 +
477 + # Run mysql tests
478 + pushd "${TESTDIR}" > /dev/null || die
479 +
480 + touch "${T}/disabled.def"
481 + # These are failing in MySQL 5.7 for now and are believed to be
482 + # false positives:
483 + #
484 + local t
485 +
486 + for t in auth_sec.keyring_udf federated.federated_plugin ; do
487 + _disable_test "$t" "False positives in Gentoo"
488 + done
489 +
490 + # run mysql-test tests
491 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
492 + retstatus_tests=$?
493 +
494 + popd > /dev/null || die
495 +
496 + # Cleanup is important for these testcases.
497 + pkill -9 -f "${S}/ndb" 2>/dev/null
498 + pkill -9 -f "${S}/sql" 2>/dev/null
499 +
500 + local failures=""
501 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
502 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
503 +
504 + [[ -z "$failures" ]] || die "Test failures: $failures"
505 + einfo "Tests successfully completed"
506 +}
507 +
508 +mysql_init_vars() {
509 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX%/}/usr/share/mysql"}
510 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX%/}/etc/mysql"}
511 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX%/}/var/lib/mysql"}
512 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX%/}/var/log/mysql"}
513 +
514 + if [[ -z "${MY_DATADIR}" ]] ; then
515 + MY_DATADIR=""
516 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
517 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
518 + | sed -ne '/datadir/s|^--datadir=||p' \
519 + | tail -n1`
520 + if [[ -z "${MY_DATADIR}" ]] ; then
521 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
522 + | sed -e 's/.*=\s*//' \
523 + | tail -n1`
524 + fi
525 + fi
526 + if [[ -z "${MY_DATADIR}" ]] ; then
527 + MY_DATADIR="${MY_LOCALSTATEDIR}"
528 + einfo "Using default MY_DATADIR"
529 + fi
530 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
531 +
532 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
533 + if [[ -e "${MY_DATADIR}" ]] ; then
534 + # If you get this and you're wondering about it, see bug #207636
535 + elog "MySQL datadir found in ${MY_DATADIR}"
536 + elog "A new one will not be created."
537 + PREVIOUS_DATADIR="yes"
538 + else
539 + PREVIOUS_DATADIR="no"
540 + fi
541 + export PREVIOUS_DATADIR
542 + fi
543 + else
544 + if [[ ${EBUILD_PHASE} == "config" ]]; then
545 + local new_MY_DATADIR
546 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
547 + | sed -ne '/datadir/s|^--datadir=||p' \
548 + | tail -n1`
549 +
550 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
551 + ewarn "MySQL MY_DATADIR has changed"
552 + ewarn "from ${MY_DATADIR}"
553 + ewarn "to ${new_MY_DATADIR}"
554 + MY_DATADIR="${new_MY_DATADIR}"
555 + fi
556 + fi
557 + fi
558 +
559 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
560 + export MY_LOCALSTATEDIR MY_LOGDIR
561 + export MY_DATADIR
562 +}
563 +
564 +pkg_config() {
565 + _getoptval() {
566 + local mypd="${EROOT%/}"/usr/bin/my_print_defaults
567 + local section="$1"
568 + local flag="--${2}="
569 + local extra_options="${3}"
570 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
571 + }
572 + local old_MY_DATADIR="${MY_DATADIR}"
573 + local old_HOME="${HOME}"
574 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
575 + export HOME=${EPREFIX%/}/root
576 +
577 + # Make sure the vars are correctly initialized
578 + mysql_init_vars
579 +
580 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
581 + if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then
582 + die "Minimal builds do NOT include the MySQL server"
583 + fi
584 +
585 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
586 + local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}"
587 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
588 + local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}"
589 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
590 +
591 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
592 + if [[ -d "${MY_DATADIR_s}" ]]; then
593 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
594 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
595 + else
596 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
597 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
598 + || die "Moving MY_DATADIR failed"
599 + fi
600 + else
601 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
602 + if [[ -d "${MY_DATADIR_s}" ]]; then
603 + ewarn "Attempting to use ${MY_DATADIR_s}"
604 + else
605 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
606 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
607 + fi
608 + fi
609 + fi
610 +
611 + local pwd1="a"
612 + local pwd2="b"
613 + local maxtry=15
614 +
615 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
616 + local tmp_mysqld_password_source=
617 +
618 + for tmp_mysqld_password_source in mysql client; do
619 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
620 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
621 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
622 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
623 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
624 + MYSQL_ROOT_PASSWORD=
625 + continue
626 + fi
627 +
628 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
629 + break
630 + fi
631 + done
632 +
633 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
634 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
635 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
636 + fi
637 +
638 + unset tmp_mysqld_password_source
639 + fi
640 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
641 + # These are dir+prefix
642 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
643 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
644 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
645 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
646 +
647 + if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]]; then
648 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
649 + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR"
650 + fi
651 + if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]]; then
652 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
653 + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN"
654 + fi
655 + if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]]; then
656 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
657 + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG"
658 + fi
659 +
660 + if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then
661 + ewarn "You have already a MySQL database in place."
662 + ewarn "(${ROOT%/}/${MY_DATADIR}/*)"
663 + ewarn "Please rename or delete it if you wish to replace it."
664 + die "MySQL database already exists!"
665 + fi
666 +
667 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
668 + # localhost. Also causes weird failures.
669 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
670 +
671 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
672 +
673 + einfo "Please provide a password for the mysql 'root' user now"
674 + einfo "or through the ${HOME}/.my.cnf file."
675 + ewarn "Avoid [\"'\\_%] characters in the password"
676 + read -rsp " >" pwd1 ; echo
677 +
678 + einfo "Retype the password"
679 + read -rsp " >" pwd2 ; echo
680 +
681 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
682 + die "Passwords are not the same"
683 + fi
684 + MYSQL_ROOT_PASSWORD="${pwd1}"
685 + unset pwd1 pwd2
686 + fi
687 +
688 + local options
689 + local sqltmp="$(emktemp)"
690 +
691 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
692 + # see http://bugs.mysql.com/bug.php?id=31312
693 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
694 +
695 + # Figure out which options we need to disable to do the setup
696 + local helpfile="${TMPDIR%/}/mysqld-help"
697 + "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
698 + for opt in host-cache name-resolve networking slave-start \
699 + federated ssl log-bin relay-log slow-query-log external-locking \
700 + log-slave-updates \
701 + ; do
702 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
703 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
704 + done
705 +
706 + einfo "Creating the mysql database and setting proper permissions on it ..."
707 +
708 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
709 + PID_DIR="${EROOT%/}/var/run/mysqld"
710 + if [[ ! -d "${PID_DIR}" ]]; then
711 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
712 + fi
713 +
714 + if [[ ! -d "${MY_DATADIR}" ]]; then
715 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
716 + fi
717 +
718 + pushd "${TMPDIR}" &>/dev/null || die
719 +
720 + # Filling timezones, see
721 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
722 + echo "USE mysql;" >"${sqltmp}"
723 + "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null
724 + chown mysql "${sqltmp}" || die
725 +
726 + # --initialize-insecure will not set root password
727 + # --initialize would set a random one in the log which we don't need as we set it ourselves
728 + local cmd=( "${EROOT%/}/usr/sbin/mysqld" "--initialize-insecure" "--init-file='${sqltmp}'" )
729 + cmd+=( "--basedir=${EPREFIX%/}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" )
730 + einfo "Command: ${cmd[*]}"
731 + su -s /bin/sh -c "${cmd[*]}" mysql \
732 + >"${TMPDIR%/}"/mysql_install_db.log 2>&1
733 + if [ $? -ne 0 ]; then
734 + grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2
735 + die "Failed to initialize mysqld. Please review ${EPREFIX%/}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log"
736 + fi
737 + popd &>/dev/null || die
738 + [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \
739 + || die "MySQL databases not installed"
740 +
741 + use prefix || options="${options} --user=mysql"
742 +
743 + local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock"
744 + local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid"
745 + local mysqld="${EROOT%/}/usr/sbin/mysqld \
746 + ${options} \
747 + $(use prefix || echo --user=mysql) \
748 + --log-warnings=0 \
749 + --basedir=${EROOT%/}/usr \
750 + --datadir=${ROOT%/}/${MY_DATADIR} \
751 + --max_allowed_packet=8M \
752 + --net_buffer_length=16K \
753 + --socket=${socket} \
754 + --pid-file=${pidfile}
755 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
756 + #einfo "About to start mysqld: ${mysqld}"
757 + ebegin "Starting mysqld"
758 + einfo "Command ${mysqld}"
759 + ${mysqld} &
760 + rc=$?
761 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
762 + maxtry=$((${maxtry}-1))
763 + echo -n "."
764 + sleep 1
765 + done
766 + eend $rc
767 +
768 + if ! [[ -S "${socket}" ]]; then
769 + die "Completely failed to start up mysqld with: ${mysqld}"
770 + fi
771 +
772 + ebegin "Setting root password"
773 + # Do this from memory, as we don't want clear text passwords in temp files
774 + local sql="ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${MYSQL_ROOT_PASSWORD}'"
775 + "${EROOT%/}/usr/bin/mysql" \
776 + --no-defaults \
777 + "--socket=${socket}" \
778 + -hlocalhost \
779 + -e "${sql}"
780 + eend $?
781 +
782 + # Stop the server and cleanup
783 + einfo "Stopping the server ..."
784 + kill $(< "${pidfile}" )
785 + rm -f "${sqltmp}"
786 + wait %1
787 + einfo "Done"
788 +}