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