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