Gentoo Archives: gentoo-commits

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