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