Gentoo Archives: gentoo-commits

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