Gentoo Archives: gentoo-commits

From: Brian Evans <grknight@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/mysql:master commit in: dev-db/percona-server/
Date: Wed, 28 Mar 2018 19:50:22
Message-Id: 1522266610.cb0da0048c74f19e11cd8273529482414259776b.grknight@gentoo
1 commit: cb0da0048c74f19e11cd8273529482414259776b
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 28 19:49:46 2018 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 28 19:50:10 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/mysql.git/commit/?id=cb0da004
7
8 dev-db/percona-server: Add new testing revision without client-libs
9
10 dev-db/percona-server/Manifest | 24 +-
11 dev-db/percona-server/metadata.xml | 2 +
12 .../percona-server-5.6.39.83.1-r1.ebuild | 955 +++++++++++++++++++++
13 3 files changed, 959 insertions(+), 22 deletions(-)
14
15 diff --git a/dev-db/percona-server/Manifest b/dev-db/percona-server/Manifest
16 index 0f12bab..52dad70 100644
17 --- a/dev-db/percona-server/Manifest
18 +++ b/dev-db/percona-server/Manifest
19 @@ -1,29 +1,9 @@
20 ------BEGIN PGP SIGNED MESSAGE-----
21 -Hash: SHA256
22 -
23 DIST mysql-extras-20150717-1707Z.tar.bz2 1491956 SHA256 d67cc1e2c581ab7c57122b7d29864643869799893a95a158a18e14201d4ffc10 SHA512 3a7cb07773099e766f8e796d4e555d42874b85285cc2c7c60220370cc6aafc36a60eb340008637298d85d83f529e73392895a81c1438ffccff9eb8f354b29ba9 WHIRLPOOL 11e75f4b696e2547c1da40e69d8ab75df4bf7080426204c040632f24846407b07d71061c09c4ff4a1d21a9d14a94769d8f8ef62421d0aecd99efe832caf4dd22
24 DIST mysql-extras-20151105-2051Z.tar.bz2 1490187 SHA256 129d79c2064b08b0afad69e04e27991bf4103c20ccea39c133239b1dd822a49f SHA512 af34a44275b06c1626eb5952b3643b5663b8a1fb1d9ff18a67d51c02daaa51c4476df407d38ab607cc41842b47e5dd7b4cef8ae380a41eb80923df8052b9e521 WHIRLPOOL 01702ca4e2033fbc70db3ab2dd166b2e31072ea0f6bdd42d00c27ae0c0afab5c8451c4dcc90cce6d46f9ea056017e273f7c719e1cfabf969293bdcd15241f5b3
25 DIST mysql-extras-20160307-1854Z.tar.bz2 298005 SHA256 a6516841d24670a1802e28fd66d4f540b16367396e6b2f687b8429b8e6a5d865 SHA512 d90081bd910dfffe6e1ac250465c0dbd9968edbdfe08f25f213ec328028fbb6fdb016816846c7fcee9202b9b93f4868edaff44ee04a0554cc93c6ecbf088db8f WHIRLPOOL f971804db83f42d717da318deeb647c1b294fa0967db7073e7f83d0fa15476d68089201430aaa882d90d5223a41a1a1668cfbe82bb897dcf864925e3da715c10
26 +DIST mysql-extras-20180312-2011Z.tar.bz2 319047 SHA256 5d83747593b2276ecaf253b193814df2bfe170de57ceb7565e3d9f215df92254 SHA512 b0aa9fc8fbc050451ef147cee99b00cf10d34a71641837821e78655241f7d79a94fe2efb4cef9a23fe9741e08ada2fc0b58ef3b3663752bc567babfbcaa547c8 WHIRLPOOL 29085d38c285e62fa5925e70e01fda98ce5582e660b84fa09992049b5c222d1c14e73b94c63cb754bd94df00ce154b24ea5d4ee472de1766b6941cb05503c493
27 DIST percona-server-5.6.26-74.0.tar.gz 54819177 SHA256 9156038d84bd1190a5b5df963877876584d30bd515ba3ad39e65a532430c1608 SHA512 1874b5e5d40da3ba6a9ea5bf15b7b851b4c067edf3cbca4139c078536000010acaecb8ee94933f5c4482ea091967a30f042b3bd08bef5e3716cae0be8607410e WHIRLPOOL fd8d712d3ed1a785ad455d9d83f537303ad9b58d0562cf73adaba71527ab42513e0682b568aced5601b419e738f9d904d09bb37f387feaa42944795461e96b8e
28 DIST percona-server-5.6.27-75.0.tar.gz 54907367 SHA256 7dc4a4efadaee25e11fd78838f4ad2c0d7921ac9cc3b95068626f918c0add8d7 SHA512 c58fe18e3af7c88d9a3269c0b6a20c367bc80af6b3c1ab072fb380787f6b0ad44c8471134e366b7a9572fc4d16a4260d81a26f384aadab4bca99efcf521d3201 WHIRLPOOL 403a7efdbfb8bdaa5cecf72930be351b8762f17ce7166dffcff307e86a69f742546c85ff5badefab182dd001080ed49e71d2d5d587b74801cc22ccba682ac418
29 DIST percona-server-5.6.27-76.0.tar.gz 54946650 SHA256 36d5c1c9a94712874b4d6e12c7e48d1f13c1fffb0ff976bc93aedbb4f73a0fef SHA512 64e2b1643bb06aefd59a1e1caddd31931b4b39ce5cd575ec3ec92f8c824887d112aa17573b10d596996579088c34e729eed83c37d63dd8cbef6755f0c0086805 WHIRLPOOL b203ba373ce312c1e10f0f96ba0fe8722ddc29c218bd075539f868426ad20c4d02c2307756c98fd2c7e21b45398d92c1b2b5145218b503bb0962bcafd908de12
30 DIST percona-server-5.6.29-76.2.tar.gz 55032788 SHA256 23217feafc92222f313aeeb6e1806d110c35e50cf0b5f74510a9f8babe22e4b9 SHA512 0765ba02dcceaa3e4cb8f1b7261982f66ea5a14982723a9eb0a47177d03c18ffb3e647f10736780f6312dccb23f082ebcdd1f6330f9bf08ec714e43bf9fb4e57 WHIRLPOOL 8d719fbf0ec5ac4e0e80c40140bbf9a796c4ef1cb3ef1d0f8b92d14385c7e1af49063f0f176ab57e86a31d9729224354a3f72d331330d1a4907d41d6ab5fd92d
31 ------BEGIN PGP SIGNATURE-----
32 -Version: GnuPG v2.1
33 -
34 -iQJ8BAEBCABmBQJW4GlsXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
35 -ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ2NkMyRTQ0RUQ5MEUzMjc1OEU3RDU1QzBE
36 -MUY3ODFFRkY5RjRBM0I2AAoJENH3ge/59KO2tGEQAJEULXtlJj3QYq997PwAaPVZ
37 -R062zgzSeLS0/qHeSbbWZ/4V9Zu9yVJ/vDlLDqnarFsb0F2xyKhjQFMqflWmv6Z1
38 -q0HDYnJi8CC8Cezpg0XcRudhjSzotyMIOAmKWRerNLwmFH13UjOdsQ8yb7H2IxF9
39 -WyEsjzRjTPd/IGuUyj1afP9Ywi0TVjkWqdxyPNpkaGppbR5IfvQOUsPUFXddqSXp
40 -tDXWzaD4gOqvCXfVSfcRvI2moALzqBzPUqopGo8gPeGVQeu9STewKRUP9Uql76wX
41 -UiG0qe16Bo0oevW4wOSUbqcqqjtkqWtg72nw+bdhVzHZic4NZWGfN45QUn/c/BxF
42 -anQKSNJorSRNeWeOJiA8KOaunx4qgApgtdeYmECPbg1IXzbXvRDW0ZPdTAi+AVfr
43 -/RSU4HuLDJa2tPbO+Z980Wc+SjZLlleYzOGs33S+vmND/ErKKeRUG2bv8+CPEXeJ
44 -ExxKfZzuRiftcTXjePOvCX38o5Ioe/oL//pCiGtuft01e/pBjluxdBjGSKZjbVrU
45 -HmXy3ELvZrP+3ZD6C5IRJsQJSjdJvPO5HF9Cg8QKtwfNIUUomGHhV+Oob2WK56ss
46 -3H2MFCF2UY7E1m2aOfFw5zxjAuOkIxj9H4QsUYO3nlTvWn2q15v97KepioI87kUj
47 -zEG8hTGnMvnNO4XfsHeU
48 -=FeZt
49 ------END PGP SIGNATURE-----
50 +DIST percona-server-5.6.39-83.1.tar.gz 56307662 SHA256 48939062738cd5e7769381e31ec581492317ff48c19d0b7ce362e0e61b5d01e2 SHA512 d014bc0ebf8d8f1842b4a79eb0a868e3c9e0e33d3eb3cbf301b5504dcb341e1f2a0d6c2c4003666f59fbf75eb274356ee6b059ff2cddf2b457143ee5e1aba471 WHIRLPOOL 505b784cec2ef81e9bb82c73efb9ae465463b93e465ba6b4e2ec21f55d310acea4b4203dcba8a7e39ad0c8d4060a94c9eab6a26f5f4bed1024e1a81212246783
51
52 diff --git a/dev-db/percona-server/metadata.xml b/dev-db/percona-server/metadata.xml
53 index 5bf3153..fc692a4 100644
54 --- a/dev-db/percona-server/metadata.xml
55 +++ b/dev-db/percona-server/metadata.xml
56 @@ -16,8 +16,10 @@
57 <flag name="jemalloc">Use <pkg>dev-libs/jemalloc</pkg> for allocations.</flag>
58 <flag name="latin1">Use LATIN1 encoding instead of UTF8</flag>
59 <flag name="libressl">Enable SSL connections and crypto functions using <pkg>dev-libs/libressl</pkg></flag>
60 + <flag name="numa">Enable NUMA support using <pkg>sys-process/numactl</pkg> (NUMA kernel support is also required)</flag>
61 <flag name="openssl">Enable SSL connections and crypto functions using <pkg>dev-libs/openssl</pkg></flag>
62 <flag name="profiling">Add support for statement profiling (requires USE=community).</flag>
63 + <flag name="rocksdb">Add support for RocksDB; a key/value, LSM database optimized for flash storage</flag>
64 <flag name="server">Build the server program</flag>
65 <flag name="systemtap">Build support for profiling and tracing using <pkg>dev-util/systemtap</pkg></flag>
66 <flag name="test">Install upstream testsuites for end use.</flag>
67
68 diff --git a/dev-db/percona-server/percona-server-5.6.39.83.1-r1.ebuild b/dev-db/percona-server/percona-server-5.6.39.83.1-r1.ebuild
69 new file mode 100644
70 index 0000000..2083794
71 --- /dev/null
72 +++ b/dev-db/percona-server/percona-server-5.6.39.83.1-r1.ebuild
73 @@ -0,0 +1,955 @@
74 +# Copyright 1999-2018 Gentoo Foundation
75 +# Distributed under the terms of the GNU General Public License v2
76 +
77 +EAPI="6"
78 +MY_EXTRAS_VER="20180312-2011Z"
79 +PYTHON_COMPAT=( python2_7 )
80 +CMAKE_MAKEFILE_GENERATOR=emake
81 +
82 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
83 +
84 +inherit linux-info python-any-r1 eutils flag-o-matic prefix toolchain-funcs \
85 + user cmake-utils multilib-minimal versionator
86 +MY_PV=$(replace_version_separator 3 '-')
87 +MY_PN="Percona-Server"
88 +MY_MAJOR_PV=$(get_version_component_range 1-2)
89 +SRC_URI="https://www.percona.com/downloads/${MY_PN}-${MY_MAJOR_PV}/${MY_PN}-${MY_PV}/source/tarball/${PN}-${MY_PV}.tar.gz"
90 +
91 +# Gentoo patches to MySQL
92 +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then
93 + SRC_URI="${SRC_URI}
94 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
95 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
96 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
97 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
98 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
99 +fi
100 +
101 +HOMEPAGE="https://www.percona.com/software/percona-server"
102 +DESCRIPTION="An enhanced, drop-in replacement for MySQL from the Percona team"
103 +LICENSE="GPL-2"
104 +SLOT="0/18"
105 +IUSE="-client-libs cracklib debug jemalloc latin1 libressl numa pam +perl profiling rocksdb selinux
106 + +server static static-libs systemtap tcmalloc test tokudb tokudb-backup-plugin yassl"
107 +
108 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
109 +RESTRICT="libressl? ( test )"
110 +
111 +REQUIRED_USE="tokudb-backup-plugin? ( tokudb ) tokudb? ( jemalloc !tcmalloc ) ?? ( tcmalloc jemalloc ) static? ( yassl )"
112 +
113 +KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
114 +
115 +# Shorten the path because the socket path length must be shorter than 107 chars
116 +# and we will run a mysql server during test phase
117 +S="${WORKDIR}/mysql"
118 +
119 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
120 + inherit git-r3
121 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git"
122 + EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras"
123 + EGIT_CLONE_TYPE=shallow
124 + MY_PATCH_DIR="${WORKDIR}/mysql-extras"
125 +else
126 + MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}"
127 +fi
128 +
129 +PATCHES=(
130 + "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch
131 + "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch
132 + "${MY_PATCH_DIR}"/20001_all_fix-minimal-build-cmake-mysql-5.6.20.patch
133 + "${MY_PATCH_DIR}"/20006_all_cmake_elib-percona-5.6.34.patch
134 + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch
135 + "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch
136 + "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch
137 + "${MY_PATCH_DIR}"/20018_all_percona-server-5.6.25-without-clientlibs-tools.patch
138 +)
139 +
140 +# Be warned, *DEPEND are version-dependant
141 +# These are used for both runtime and compiletime
142 +# MULTILIB_USEDEP only set for libraries used by the client library
143 +COMMON_DEPEND="
144 + kernel_linux? (
145 + sys-process/procps:0=
146 + dev-libs/libaio:0=
147 + )
148 + >=sys-apps/sed-4
149 + >=sys-apps/texinfo-4.7-r1
150 + jemalloc? ( dev-libs/jemalloc:0= )
151 + tcmalloc? ( dev-util/google-perftools:0= )
152 + systemtap? ( >=dev-util/systemtap-1.3:0= )
153 + !yassl? (
154 + client-libs? (
155 + !libressl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
156 + libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] )
157 + )
158 + !client-libs? (
159 + !libressl? ( >=dev-libs/openssl-1.0.0:0= )
160 + libressl? ( dev-libs/libressl:0= )
161 + )
162 + )
163 + client-libs? ( >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?] )
164 + !client-libs? ( >=sys-libs/zlib-1.2.3:0= )
165 + sys-libs/ncurses:0=
166 + server? (
167 + >=app-arch/lz4-0_p131:=
168 + >=dev-libs/boost-1.65.0:=
169 + numa? ( sys-process/numactl )
170 + pam? ( virtual/pam:0= )
171 + tokudb? ( app-arch/snappy )
172 + tokudb-backup-plugin? ( dev-util/valgrind )
173 + )
174 +"
175 +DEPEND="virtual/yacc
176 + static? ( sys-libs/ncurses[static-libs] )
177 + test? (
178 + $(python_gen_any_dep 'dev-python/mysql-python[${PYTHON_USEDEP}]')
179 + dev-perl/JSON
180 + )
181 + ${COMMON_DEPEND}"
182 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
183 + abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] )
184 + client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c )
185 + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
186 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
187 + ${COMMON_DEPEND}
188 +"
189 +# For other stuff to bring us in
190 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
191 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
192 + !client-libs? ( dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] )"
193 +
194 +pkg_pretend() {
195 + if use numa; then
196 + local CONFIG_CHECK="~NUMA"
197 +
198 + local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
199 + WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
200 +
201 + check_extra_config
202 + fi
203 +}
204 +
205 +python_check_deps() {
206 + has_version "dev-python/mysql-python[${PYTHON_USEDEP}]"
207 +}
208 +
209 +pkg_setup() {
210 + if [[ ${MERGE_TYPE} != binary ]] ; then
211 + local GCC_MAJOR_SET=$(gcc-major-version)
212 + local GCC_MINOR_SET=$(gcc-minor-version)
213 + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
214 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
215 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
216 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
217 + die
218 + fi
219 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
220 + # non x86{,_64} arches
221 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
222 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
223 + eerror "${PN} needs to be built with gcc-4.7 or later."
224 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
225 + die
226 + fi
227 + fi
228 + if has test ${FEATURES} && \
229 + use server && ! has userpriv ${FEATURES} ; then
230 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
231 + fi
232 +
233 + # This should come after all of the die statements
234 + enewgroup mysql 60 || die "problem adding 'mysql' group"
235 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
236 +}
237 +
238 +pkg_preinst() {
239 + # Here we need to see if the implementation switched client libraries
240 + # We check if this is a new instance of the package and a client library already exists
241 + local SHOW_ABI_MESSAGE libpath
242 + if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
243 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
244 + elog "Due to ABI changes when switching between different client libraries,"
245 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
246 + elog "Please run: revdep-rebuild --library ${libpath}"
247 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
248 + fi
249 +}
250 +
251 +pkg_postinst() {
252 + # Make sure the vars are correctly initialized
253 + mysql_init_vars
254 +
255 + # Create log directory securely if it does not exist
256 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
257 +
258 + if use server ; then
259 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
260 + einfo
261 + elog "You might want to run:"
262 + elog "\"emerge --config =${CATEGORY}/${PF}\""
263 + elog "if this is a new install."
264 + elog
265 + elog "If you are switching server implentations, you should run the"
266 + elog "mysql_upgrade tool."
267 + einfo
268 + else
269 + einfo
270 + elog "If you are upgrading major versions, you should run the"
271 + elog "mysql_upgrade tool."
272 + einfo
273 + fi
274 + fi
275 +
276 + # Note about configuration change
277 + einfo
278 + elog "This version of mysql reorganizes the configuration from a single my.cnf"
279 + elog "to several files in /etc/mysql/${PN}.d."
280 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
281 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
282 + elog "You may have as many files as needed and they are read alphabetically."
283 + elog "Be sure the options have the appropitate section headers, i.e. [mysqld]."
284 + einfo
285 +}
286 +
287 +src_unpack() {
288 + unpack ${A}
289 + # Grab the patches
290 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
291 +
292 + mv -f "${WORKDIR}/${PN}-${MY_PV}" "${S}" || die
293 +}
294 +
295 +src_prepare() {
296 + if use jemalloc ; then
297 + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
298 + fi
299 + if use tcmalloc; then
300 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die
301 + fi
302 +
303 + # Don't build bundled xz-utils
304 + if [[ -d "${S}/storage/tokudb/ft-index" ]] ; then
305 + echo > "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die
306 + sed -i 's/ build_lzma//' "${S}/storage/tokudb/ft-index/ft/CMakeLists.txt" || die
307 + elif [[ -d "${S}/storage/tokudb/PerconaFT" ]] ; then
308 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
309 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
310 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
311 + fi
312 +
313 + if [[ -d "${S}/plugin/tokudb-backup-plugin" ]] && ! use tokudb-backup-plugin ; then
314 + rm -r "${S}/plugin/tokudb-backup-plugin/Percona-TokuBackup" || die
315 + fi
316 +
317 + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
318 + if [[ -d "${S}/support-files/SELinux" ]] ; then
319 + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
320 + fi
321 +
322 + if use libressl ; then
323 + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \
324 + "${S}/cmake/ssl.cmake" || die
325 + fi
326 +
327 + cmake-utils_src_prepare
328 +}
329 +
330 +src_configure(){
331 + # bug 508724 mariadb cannot use ld.gold
332 + tc-ld-disable-gold
333 + # Bug #114895, bug #110149
334 + filter-flags "-O" "-O[01]"
335 +
336 + append-cxxflags -felide-constructors
337 +
338 + # bug #283926, with GCC4.4, this is required to get correct behavior.
339 + append-flags -fno-strict-aliasing
340 +
341 + if use client-libs ; then
342 + multilib-minimal_src_configure
343 + else
344 + multilib_src_configure
345 + fi
346 +}
347 +
348 +multilib_src_configure() {
349 + debug-print-function ${FUNCNAME} "$@"
350 +
351 + if ! multilib_is_native_abi && ! use client-libs ; then
352 + return
353 + fi
354 +
355 + CMAKE_BUILD_TYPE="RelWithDebInfo"
356 +
357 + # debug hack wrt #497532
358 + mycmakeargs=(
359 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
360 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
361 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
362 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
363 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
364 + -DINSTALL_BINDIR=bin
365 + -DINSTALL_DOCDIR=share/doc/${PF}
366 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
367 + -DINSTALL_INCLUDEDIR=include/mysql
368 + -DINSTALL_INFODIR=share/info
369 + -DINSTALL_LIBDIR=$(get_libdir)
370 + -DINSTALL_MANDIR=share/man
371 + -DINSTALL_MYSQLSHAREDIR=share/mysql
372 + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
373 + -DINSTALL_SCRIPTDIR=share/mysql/scripts
374 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
375 + -DINSTALL_SBINDIR=sbin
376 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
377 + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
378 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
379 + ### TODO: make this system but issues with UTF-8 prevent it
380 + -DWITH_EDITLINE=bundled
381 + -DWITH_ZLIB=system
382 + -DWITH_LIBWRAP=0
383 + -DENABLED_LOCAL_INFILE=1
384 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
385 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
386 + -DWITH_DEFAULT_FEATURE_SET=0
387 + # The build forces this to be defined when cross-compiling. We pass it
388 + # all the time for simplicity and to make sure it is actually correct.
389 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
390 + -DWITH_LIBEVENT=NO
391 + )
392 + if use test ; then
393 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
394 + else
395 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
396 + fi
397 +
398 + if ! use yassl ; then
399 + mycmakeargs+=( -DWITH_SSL=system )
400 + else
401 + mycmakeargs+=( -DWITH_SSL=bundled )
402 + fi
403 +
404 + if ! use client-libs ; then
405 + mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
406 + fi
407 +
408 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
409 + # systemtap only works on native ABI bug 530132
410 + if multilib_is_native_abi; then
411 + mycmakeargs+=(
412 + -DENABLE_DTRACE=$(usex systemtap)
413 + )
414 + else
415 + mycmakeargs+=(
416 + -DWITHOUT_TOOLS=1
417 + -DWITH_READLINE=1
418 + -DENABLE_DTRACE=0
419 + )
420 + fi
421 +
422 + if multilib_is_native_abi && use server ; then
423 +
424 + mycmakeargs+=(
425 + -DWITH_PAM=$(usex pam)
426 + -DWITH_NUMA=$(usex numa ON OFF)
427 + )
428 +
429 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
430 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
431 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
432 + ewarn "You MUST file bugs without these variables set."
433 +
434 + mycmakeargs+=(
435 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
436 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
437 + )
438 +
439 + elif ! use latin1 ; then
440 + mycmakeargs+=(
441 + -DDEFAULT_CHARSET=utf8
442 + -DDEFAULT_COLLATION=utf8_general_ci
443 + )
444 + else
445 + mycmakeargs+=(
446 + -DDEFAULT_CHARSET=latin1
447 + -DDEFAULT_COLLATION=latin1_swedish_ci
448 + )
449 + fi
450 + mycmakeargs+=(
451 + -DEXTRA_CHARSETS=all
452 + -DDISABLE_SHARED=$(usex static YES NO)
453 + -DWITH_DEBUG=$(usex debug)
454 + -DWITH_EMBEDDED_SERVER=OFF
455 + -DENABLED_PROFILING=$(usex profiling)
456 + )
457 +
458 + if use static; then
459 + mycmakeargs+=( -DWITH_PIC=1 )
460 + fi
461 +
462 + if use jemalloc || use tcmalloc ; then
463 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
464 + fi
465 +
466 + # Storage engines
467 + mycmakeargs+=(
468 + -DWITH_EXAMPLE_STORAGE_ENGINE=0
469 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
470 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
471 + -DWITH_CSV_STORAGE_ENGINE=1
472 + -DWITH_HEAP_STORAGE_ENGINE=1
473 + -DWITH_INNOBASE_STORAGE_ENGINE=1
474 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
475 + -DWITH_MYISAM_STORAGE_ENGINE=1
476 + -DWITH_PARTITION_STORAGE_ENGINE=1
477 + -DWITH_INNODB_MEMCACHED=0
478 + -DWITH_ROCKSDB=$(usex rocksdb 1 0)
479 + $(usex tokudb '' -DWITHOUT_TOKUDB=1)
480 + )
481 +
482 + if use tokudb ; then
483 + # TokuDB Backup plugin requires valgrind unconditionally
484 + mycmakeargs+=(
485 + $(usex tokudb-backup-plugin '' -DTOKUDB_BACKUP_DISABLED=1)
486 + )
487 + fi
488 +
489 + else
490 + mycmakeargs+=(
491 + -DWITHOUT_SERVER=1
492 + -DWITH_EMBEDDED_SERVER=OFF
493 + -DEXTRA_CHARSETS=none
494 + )
495 + fi
496 +
497 + cmake-utils_src_configure
498 +}
499 +
500 +src_compile() {
501 + if use client-libs ; then
502 + multilib-minimal_src_compile
503 + else
504 + multilib_src_compile
505 + fi
506 +}
507 +
508 +multilib_src_compile() {
509 + cmake-utils_src_compile
510 +}
511 +
512 +src_install() {
513 + local MULTILIB_WRAPPED_HEADERS
514 + local MULTILIB_CHOST_TOOLS
515 + if use client-libs ; then
516 + # headers with ABI specific data
517 + MULTILIB_WRAPPED_HEADERS=(
518 + /usr/include/mysql/server/my_config.h
519 + /usr/include/mysql/server/mysql_version.h )
520 +
521 + # wrap the config scripts
522 + MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config )
523 + multilib-minimal_src_install
524 + else
525 + multilib_src_install
526 + multilib_src_install_all
527 + fi
528 +}
529 +
530 +# Intentionally override eclass function
531 +multilib_src_install() {
532 +
533 + cmake-utils_src_install
534 +
535 + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
536 + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
537 +}
538 +
539 +multilib_src_install_all() {
540 + # Make sure the vars are correctly initialized
541 + mysql_init_vars
542 +
543 + # Convenience links
544 + einfo "Making Convenience links for mysqlcheck multi-call binary"
545 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
546 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
547 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
548 +
549 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
550 + if [[ -d "${ED}/usr/data" ]] ; then
551 + rm -Rf "${ED}/usr/data" || die
552 + fi
553 +
554 + # Unless they explicitly specific USE=test, then do not install the
555 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
556 + # validation of your database configuration after tuning it.
557 + if ! use test ; then
558 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
559 + fi
560 +
561 + # Configuration stuff
562 + einfo "Building default configuration ..."
563 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
564 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
565 + cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
566 + eprefixify "${TMPDIR}/my.cnf"
567 + doins "${TMPDIR}/my.cnf"
568 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
569 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
570 + eprefixify "${TMPDIR}/50-distro-client.cnf"
571 + doins "${TMPDIR}/50-distro-client.cnf"
572 +
573 + if use server ; then
574 + mycnf_src="my.cnf.distro-server"
575 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
576 + "${FILESDIR}/${mycnf_src}" \
577 + > "${TMPDIR}/my.cnf.ok" || die
578 + if use prefix ; then
579 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
580 + "${TMPDIR}/my.cnf.ok" || die
581 + fi
582 + if use latin1 ; then
583 + sed -i \
584 + -e "/character-set/s|utf8|latin1|g" \
585 + "${TMPDIR}/my.cnf.ok" || die
586 + fi
587 + eprefixify "${TMPDIR}/my.cnf.ok"
588 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
589 +
590 + einfo "Including support files and sample configurations"
591 + docinto "support-files"
592 + local script
593 + for script in \
594 + "${S}"/support-files/magic
595 + do
596 + [[ -f "$script" ]] && dodoc "${script}"
597 + done
598 +
599 + docinto "scripts"
600 + for script in "${S}"/scripts/mysql* ; do
601 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
602 + done
603 + fi
604 +
605 + #Remove mytop if perl is not selected
606 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
607 +}
608 +
609 +# Official test instructions:
610 +# USE='perl server static-libs' \
611 +# FEATURES='test userpriv -usersandbox' \
612 +# ebuild mysql-X.X.XX.ebuild \
613 +# digest clean package
614 +src_test() {
615 +
616 + _disable_test() {
617 + local rawtestname reason
618 + rawtestname="${1}" ; shift
619 + reason="${@}"
620 + ewarn "test '${rawtestname}' disabled: '${reason}'"
621 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
622 + }
623 +
624 + local TESTDIR="${BUILD_DIR}/mysql-test"
625 + local retstatus_unit
626 + local retstatus_tests
627 +
628 + if ! use server ; then
629 + einfo "Skipping server tests due to minimal build."
630 + return 0
631 + fi
632 +
633 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
634 + # localhost. Also causes weird failures.
635 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
636 +
637 + if [[ $UID -eq 0 ]]; then
638 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
639 + fi
640 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
641 +
642 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
643 +
644 + # Run CTest (test-units)
645 + cmake-utils_src_test
646 + retstatus_unit=$?
647 +
648 + # Ensure that parallel runs don't die
649 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
650 + # Enable parallel testing, auto will try to detect number of cores
651 + # You may set this by hand.
652 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
653 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
654 +
655 + # create directories because mysqladmin might run out of order
656 + mkdir -p "${T}"/var-tests{,/log} || die
657 +
658 + # Run mysql tests
659 + pushd "${TESTDIR}" > /dev/null || die
660 +
661 + touch "${T}/disabled.def"
662 + # These are failing in MySQL 5.7 for now and are believed to be
663 + # false positives:
664 + #
665 + # main.mysql_client_test, main.mysql_client_test_nonblock
666 + # main.mysql_client_test_comp:
667 + # segfaults at random under Portage only, suspect resource limits.
668 +
669 + local t
670 + for t in main.mysql_client_test \
671 + binlog.binlog_statement_insert_delayed main.information_schema \
672 + main.mysqld--help-notwin binlog.binlog_mysqlbinlog_filter \
673 + perfschema.binlog_edge_mix perfschema.binlog_edge_stmt \
674 + funcs_1.is_columns_mysql funcs_1.is_tables_mysql funcs_1.is_triggers \
675 + main.variables main.myisam main.merge_recover \
676 + engines/funcs.db_alter_character_set engines/funcs.db_alter_character_set_collate \
677 + engines/funcs.db_alter_collate_ascii engines/funcs.db_alter_collate_utf8 \
678 + engines/funcs.db_create_character_set engines/funcs.db_create_character_set_collate \
679 + main.percona_bug1289599 main.mysqlhotcopy_archive main.mysqlhotcopy_myisam ; do
680 + _disable_test "$t" "False positives in Gentoo"
681 + done
682 +
683 + if use numa && use kernel_linux ; then
684 + # bug 584880
685 + if ! linux_config_exists || ! linux_chkconfig_present NUMA ; then
686 + for t in sys_vars.innodb_buffer_pool_populate_basic ; do
687 + _disable_test "$t" "Test $t requires system with NUMA support"
688 + done
689 + fi
690 + fi
691 +
692 + if ! use extraengine ; then
693 + # bug 401673, 530766
694 + for t in federated.federated_plugin ; do
695 + _disable_test "$t" "Test $t requires USE=extraengine (Need federated engine)"
696 + done
697 + fi
698 +
699 + # Set file limits higher so tests run
700 + if ! ulimit -n 16500 1>/dev/null 2>&1; then
701 + # Upper limit comes from parts.partition_* tests
702 + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
703 +
704 + if ! ulimit -n 4162 1>/dev/null 2>&1; then
705 + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
706 + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
707 +
708 + if ! ulimit -n 3000 1>/dev/null 2>&1; then
709 + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
710 + else
711 + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
712 + fi
713 + else
714 + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
715 + fi
716 + else
717 + einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
718 + fi
719 +
720 + python_setup
721 + # run mysql-test tests
722 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" \
723 + --testcase-timeout=30 --reorder --skip-test-list="${T}/disabled.def"
724 + retstatus_tests=$?
725 +
726 + popd > /dev/null || die
727 +
728 + # Cleanup is important for these testcases.
729 + pkill -9 -f "${S}/ndb" 2>/dev/null
730 + pkill -9 -f "${S}/sql" 2>/dev/null
731 +
732 + local failures=""
733 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
734 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
735 +
736 + [[ -z "$failures" ]] || die "Test failures: $failures"
737 + einfo "Tests successfully completed"
738 +}
739 +
740 +mysql_init_vars() {
741 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
742 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
743 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
744 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
745 +
746 + if [[ -z "${MY_DATADIR}" ]] ; then
747 + MY_DATADIR=""
748 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
749 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
750 + | sed -ne '/datadir/s|^--datadir=||p' \
751 + | tail -n1`
752 + if [[ -z "${MY_DATADIR}" ]] ; then
753 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
754 + | sed -e 's/.*=\s*//' \
755 + | tail -n1`
756 + fi
757 + fi
758 + if [[ -z "${MY_DATADIR}" ]] ; then
759 + MY_DATADIR="${MY_LOCALSTATEDIR}"
760 + einfo "Using default MY_DATADIR"
761 + fi
762 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
763 +
764 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
765 + if [[ -e "${MY_DATADIR}" ]] ; then
766 + # If you get this and you're wondering about it, see bug #207636
767 + elog "MySQL datadir found in ${MY_DATADIR}"
768 + elog "A new one will not be created."
769 + PREVIOUS_DATADIR="yes"
770 + else
771 + PREVIOUS_DATADIR="no"
772 + fi
773 + export PREVIOUS_DATADIR
774 + fi
775 + else
776 + if [[ ${EBUILD_PHASE} == "config" ]]; then
777 + local new_MY_DATADIR
778 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
779 + | sed -ne '/datadir/s|^--datadir=||p' \
780 + | tail -n1`
781 +
782 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
783 + ewarn "MySQL MY_DATADIR has changed"
784 + ewarn "from ${MY_DATADIR}"
785 + ewarn "to ${new_MY_DATADIR}"
786 + MY_DATADIR="${new_MY_DATADIR}"
787 + fi
788 + fi
789 + fi
790 +
791 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
792 + export MY_LOCALSTATEDIR MY_LOGDIR
793 + export MY_DATADIR
794 +}
795 +
796 +pkg_config() {
797 + _getoptval() {
798 + local mypd="${EROOT}"/usr/bin/my_print_defaults
799 + local section="$1"
800 + local flag="--${2}="
801 + local extra_options="${3}"
802 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
803 + }
804 + local old_MY_DATADIR="${MY_DATADIR}"
805 + local old_HOME="${HOME}"
806 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
807 + export HOME=${EPREFIX}/root
808 +
809 + # Make sure the vars are correctly initialized
810 + mysql_init_vars
811 +
812 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
813 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
814 + die "Minimal builds do NOT include the MySQL server"
815 + fi
816 +
817 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
818 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
819 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
820 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
821 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
822 +
823 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
824 + if [[ -d "${MY_DATADIR_s}" ]]; then
825 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
826 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
827 + else
828 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
829 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
830 + || die "Moving MY_DATADIR failed"
831 + fi
832 + else
833 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
834 + if [[ -d "${MY_DATADIR_s}" ]]; then
835 + ewarn "Attempting to use ${MY_DATADIR_s}"
836 + else
837 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
838 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
839 + fi
840 + fi
841 + fi
842 +
843 + local pwd1="a"
844 + local pwd2="b"
845 + local maxtry=15
846 +
847 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
848 + local tmp_mysqld_password_source=
849 +
850 + for tmp_mysqld_password_source in mysql client; do
851 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
852 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
853 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
854 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
855 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
856 + MYSQL_ROOT_PASSWORD=
857 + continue
858 + fi
859 +
860 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
861 + break
862 + fi
863 + done
864 +
865 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
866 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
867 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
868 + fi
869 +
870 + unset tmp_mysqld_password_source
871 + fi
872 + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)"
873 + # These are dir+prefix
874 + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)"
875 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
876 + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)"
877 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
878 +
879 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
880 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
881 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
882 + fi
883 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
884 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
885 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
886 + fi
887 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
888 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
889 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
890 + fi
891 +
892 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
893 + ewarn "You have already a MySQL database in place."
894 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
895 + ewarn "Please rename or delete it if you wish to replace it."
896 + die "MySQL database already exists!"
897 + fi
898 +
899 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
900 + # localhost. Also causes weird failures.
901 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
902 +
903 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
904 +
905 + einfo "Please provide a password for the mysql 'root' user now"
906 + einfo "or through the ${HOME}/.my.cnf file."
907 + ewarn "Avoid [\"'\\_%] characters in the password"
908 + read -rsp " >" pwd1 ; echo
909 +
910 + einfo "Retype the password"
911 + read -rsp " >" pwd2 ; echo
912 +
913 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
914 + die "Passwords are not the same"
915 + fi
916 + MYSQL_ROOT_PASSWORD="${pwd1}"
917 + unset pwd1 pwd2
918 + fi
919 +
920 + local options
921 + local sqltmp="$(emktemp)"
922 +
923 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
924 + # see http://bugs.mysql.com/bug.php?id=31312
925 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
926 +
927 + # Figure out which options we need to disable to do the setup
928 + local helpfile="${TMPDIR}/mysqld-help"
929 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
930 + for opt in grant-tables host-cache name-resolve networking slave-start \
931 + federated ssl log-bin relay-log slow-query-log external-locking \
932 + log-slave-updates \
933 + ; do
934 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
935 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
936 + done
937 +
938 + einfo "Creating the mysql database and setting proper permissions on it ..."
939 +
940 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
941 + PID_DIR="${EROOT}/var/run/mysqld"
942 + if [[ ! -d "${PID_DIR}" ]]; then
943 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
944 + fi
945 +
946 + if [[ ! -d "${MY_DATADIR}" ]]; then
947 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
948 + fi
949 +
950 + pushd "${TMPDIR}" &>/dev/null || die
951 +
952 + # Filling timezones, see
953 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
954 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
955 +
956 + local cmd=( "${EROOT}usr/share/mysql/scripts/mysql_install_db" )
957 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
958 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
959 + einfo "Command: ${cmd[*]}"
960 + su -s /bin/sh -c "${cmd[*]}" mysql \
961 + >"${TMPDIR}"/mysql_install_db.log 2>&1
962 + if [ $? -ne 0 ]; then
963 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
964 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
965 + fi
966 + popd &>/dev/null || die
967 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
968 + || die "MySQL databases not installed"
969 +
970 + use prefix || options="${options} --user=mysql"
971 +
972 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
973 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
974 + local mysqld="${EROOT}/usr/sbin/mysqld \
975 + ${options} \
976 + --log-warnings=0 \
977 + --basedir=${EROOT}/usr \
978 + --datadir=${ROOT}/${MY_DATADIR} \
979 + --max_allowed_packet=8M \
980 + --net_buffer_length=16K \
981 + --socket=${socket} \
982 + --pid-file=${pidfile}
983 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
984 + #einfo "About to start mysqld: ${mysqld}"
985 + ebegin "Starting mysqld"
986 + einfo "Command ${mysqld}"
987 + ${mysqld} &
988 + rc=$?
989 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
990 + maxtry=$((${maxtry}-1))
991 + echo -n "."
992 + sleep 1
993 + done
994 + eend $rc
995 +
996 + if ! [[ -S "${socket}" ]]; then
997 + die "Completely failed to start up mysqld with: ${mysqld}"
998 + fi
999 +
1000 + ebegin "Setting root password"
1001 + # Do this from memory, as we don't want clear text passwords in temp files
1002 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
1003 + "${EROOT}/usr/bin/mysql" \
1004 + "--socket=${socket}" \
1005 + -hlocalhost \
1006 + -e "${sql}"
1007 + eend $?
1008 +
1009 + if [[ -n "${sqltmp}" ]] ; then
1010 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1011 + "${EROOT}/usr/bin/mysql" \
1012 + "--socket=${socket}" \
1013 + -hlocalhost \
1014 + -uroot \
1015 + --password="${MYSQL_ROOT_PASSWORD}" \
1016 + mysql < "${sqltmp}"
1017 + rc=$?
1018 + eend $?
1019 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1020 + fi
1021 +
1022 + # Stop the server and cleanup
1023 + einfo "Stopping the server ..."
1024 + kill $(< "${pidfile}" )
1025 + rm -f "${sqltmp}"
1026 + wait %1
1027 + einfo "Done"
1028 +}