1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
|
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
# @ECLASS: mysql-cmake.eclass
# @MAINTAINER:
# Maintainers:
# - MySQL Team <mysql-bugs@gentoo.org>
# - Robin H. Johnson <robbat2@gentoo.org>
# - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
# - Brian Evans <grknight@gentoo.org>
# @BLURB: This eclass provides the support for cmake based mysql releases
# @DESCRIPTION:
# The mysql-cmake.eclass provides the support to build the mysql
# ebuilds using the cmake build system. This eclass provides
# the src_prepare, src_configure, src_compile, and src_install
# phase hooks.
inherit cmake-utils flag-o-matic multilib prefix eutils
#
# HELPER FUNCTIONS:
#
# @FUNCTION: mysql_cmake_disable_test
# @DESCRIPTION:
# Helper function to disable specific tests.
mysql-cmake_disable_test() {
local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
rawtestname="${1}" ; shift
reason="${@}"
ewarn "test '${rawtestname}' disabled: '${reason}'"
testsuite="${rawtestname/.*}"
testname="${rawtestname/*.}"
for mysql_disabled_file in \
${S}/mysql-test/disabled.def \
${S}/mysql-test/t/disabled.def ; do
[[ -f ${mysql_disabled_file} ]] && break
done
#mysql_disabled_file="${S}/mysql-test/t/disabled.def"
#einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
echo ${testname} : ${reason} >> "${mysql_disabled_file}"
if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then
for mysql_disabled_file in \
${S}/mysql-test/suite/${testsuite}/disabled.def \
${S}/mysql-test/suite/${testsuite}/t/disabled.def \
FAILED ; do
[[ -f ${mysql_disabled_file} ]] && break
done
if [[ ${mysql_disabled_file} != "FAILED" ]]; then
echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
else
for mysql_disabled_dir in \
${S}/mysql-test/suite/${testsuite} \
${S}/mysql-test/suite/${testsuite}/t \
FAILED ; do
[[ -d ${mysql_disabled_dir} ]] && break
done
if [[ ${mysql_disabled_dir} != "FAILED" ]]; then
echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
else
ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
fi
fi
fi
}
# @FUNCTION: mysql-cmake_use_plugin
# @DESCRIPTION:
# Helper function to enable/disable plugins by use flags
# cmake-utils_use_with is not enough as some references check WITH_ (0|1)
# and some check WITHOUT_. Also, this can easily extend to non-storage plugins.
mysql-cmake_use_plugin() {
[[ -z $2 ]] && die "mysql-cmake_use_plugin <USE flag> <flag name>"
if use_if_iuse $1 ; then
echo "-DWITH_$2=1 -DPLUGIN_$2=YES"
else
echo "-DWITHOUT_$2=1 -DWITH_$2=0 -DPLUGIN_$2=NO"
fi
}
# @FUNCTION: configure_cmake_locale
# @DESCRIPTION:
# Helper function to configure locale cmake options
configure_cmake_locale() {
if use_if_iuse minimal ; then
:
elif ! in_iuse server || use_if_iuse server ; then
if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
ewarn "You MUST file bugs without these variables set."
mycmakeargs+=(
-DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
-DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
)
elif ! use latin1 ; then
mycmakeargs+=(
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
)
else
mycmakeargs+=(
-DDEFAULT_CHARSET=latin1
-DDEFAULT_COLLATION=latin1_swedish_ci
)
fi
fi
}
# @FUNCTION: configure_cmake_minimal
# @DESCRIPTION:
# Helper function to configure minimal build
configure_cmake_minimal() {
mycmakeargs+=(
-DWITHOUT_SERVER=1
-DWITHOUT_EMBEDDED_SERVER=1
-DEXTRA_CHARSETS=none
-DINSTALL_SQLBENCHDIR=
-DWITHOUT_ARCHIVE_STORAGE_ENGINE=1
-DWITHOUT_BLACKHOLE_STORAGE_ENGINE=1
-DWITHOUT_CSV_STORAGE_ENGINE=1
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DWITHOUT_HEAP_STORAGE_ENGINE=1
-DWITHOUT_INNOBASE_STORAGE_ENGINE=1
-DWITHOUT_MYISAMMRG_STORAGE_ENGINE=1
-DWITHOUT_MYISAM_STORAGE_ENGINE=1
-DWITHOUT_PARTITION_STORAGE_ENGINE=1
-DPLUGIN_ARCHIVE=NO
-DPLUGIN_BLACKHOLE=NO
-DPLUGIN_CSV=NO
-DPLUGIN_FEDERATED=NO
-DPLUGIN_HEAP=NO
-DPLUGIN_INNOBASE=NO
-DPLUGIN_MYISAMMRG=NO
-DPLUGIN_MYISAM=NO
-DPLUGIN_PARTITION=NO
)
}
# @FUNCTION: configure_cmake_standard
# @DESCRIPTION:
# Helper function to configure standard build
configure_cmake_standard() {
mycmakeargs+=(
-DEXTRA_CHARSETS=all
-DMYSQL_USER=mysql
-DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
$(cmake-utils_use_disable !static SHARED)
$(cmake-utils_use_with debug)
$(cmake-utils_use_with embedded EMBEDDED_SERVER)
$(cmake-utils_use_with profiling)
$(cmake-utils_use_enable systemtap DTRACE)
)
if use static; then
mycmakeargs+=( -DWITH_PIC=1 )
fi
if use jemalloc; then
mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
fi
if use tcmalloc; then
mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
fi
# Storage engines
mycmakeargs+=(
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_CSV_STORAGE_ENGINE=1
-DWITH_HEAP_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_MYISAMMRG_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_PARTITION_STORAGE_ENGINE=1
)
if in_iuse pbxt ; then
mycmakeargs+=( $(cmake-utils_use_with pbxt PBXT_STORAGE_ENGINE) )
fi
if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
# Federated{,X} must be treated special otherwise they will not be built as plugins
if ! use extraengine ; then
mycmakeargs+=(
-DWITHOUT_FEDERATED_STORAGE_ENGINE=1
-DPLUGIN_FEDERATED=0
-DWITHOUT_FEDERATEDX_STORAGE_ENGINE=1
-DPLUGIN_FEDERATEDX=0 )
fi
mycmakeargs+=(
$(mysql-cmake_use_plugin oqgraph OQGRAPH)
$(mysql-cmake_use_plugin sphinx SPHINX)
$(mysql-cmake_use_plugin tokudb TOKUDB)
$(mysql-cmake_use_plugin pam AUTH_PAM)
)
if mysql_version_is_at_least 10.0.5 ; then
# CassandraSE needs Apache Thrift which is not in portage
mycmakeargs+=(
-DWITHOUT_CASSANDRA=1 -DWITH_CASSANDRA=0
-DPLUGIN_CASSANDRA=NO
$(mysql-cmake_use_plugin extraengine SEQUENCE)
$(mysql-cmake_use_plugin extraengine SPIDER)
$(mysql-cmake_use_plugin extraengine CONNECT)
-DCONNECT_WITH_MYSQL=1
$(cmake-utils_use xml CONNECT_WITH_LIBXML2)
$(cmake-utils_use odbc CONNECT_WITH_ODBC)
)
fi
if in_iuse mroonga ; then
use mroonga || mycmakeargs+=( -DWITHOUT_MROONGA=1 )
else
mycmakeargs+=( -DWITHOUT_MROONGA=1 )
fi
if in_iuse galera ; then
mycmakeargs+=( $(cmake-utils_use_with galera WSREP) )
fi
if mysql_version_is_at_least "10.1.1" ; then
mycmakeargs+=( $(cmake-utils_use_with innodb-lz4 INNODB_LZ4)
$(cmake-utils_use_with innodb-lzo INNODB_LZO) )
fi
if mysql_version_is_at_least "10.1.2" ; then
mycmakeargs+=( $(mysql-cmake_use_plugin cracklib CRACKLIB_PASSWORD_CHECK ) )
fi
else
mycmakeargs+=( $(cmake-utils_use_with extraengine FEDERATED_STORAGE_ENGINE) )
fi
if [[ ${PN} == "percona-server" ]]; then
mycmakeargs+=(
$(cmake-utils_use_with pam)
)
fi
if [[ ${PN} == "mysql-cluster" ]]; then
# TODO: This really should include the following options,
# but the memcached package doesn't install the files it seeks.
# -DWITH_BUNDLED_MEMCACHED=OFF
# -DMEMCACHED_HOME=${EPREFIX}/usr
mycmakeargs+=(
-DWITH_BUNDLED_LIBEVENT=OFF
$(cmake-utils_use_with java NDB_JAVA)
)
fi
}
#
# EBUILD FUNCTIONS
#
# @FUNCTION: mysql-cmake_src_prepare
# @DESCRIPTION:
# Apply patches to the source code and remove unneeded bundled libs.
mysql-cmake_src_prepare() {
debug-print-function ${FUNCNAME} "$@"
cd "${S}"
if [[ ${MY_EXTRAS_VER} != none ]]; then
# Apply the patches for this MySQL version
EPATCH_SUFFIX="patch"
mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory"
# Clean out old items
rm -f "${EPATCH_SOURCE}"/*
# Now link in right patches
mysql_mv_patches
# And apply
epatch
fi
# last -fPIC fixup, per bug #305873
i="${S}"/storage/innodb_plugin/plug.in
[[ -f ${i} ]] && sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}"
rm -f "scripts/mysqlbug"
if use jemalloc && ! ( [[ ${PN} == "mariadb" ]] && mysql_version_is_at_least "5.5.33" ); then
echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die
fi
if use tcmalloc; then
echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
fi
if in_iuse tokudb ; then
# Don't build bundled xz-utils
rm -f "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake"
touch "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake"
sed -i 's/ build_lzma//' "${S}/storage/tokudb/ft-index/ft/CMakeLists.txt" || die
fi
# Remove the bundled groonga if it exists
# There is no CMake flag, it simply checks for existance
if [[ -d "${S}"/storage/mroonga/vendor/groonga ]] ; then
rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
fi
epatch_user
}
# @FUNCTION: mysql-cmake_src_configure
# @DESCRIPTION:
# Configure mysql to build the code for Gentoo respecting the use flags.
mysql-cmake_src_configure() {
debug-print-function ${FUNCNAME} "$@"
CMAKE_BUILD_TYPE="RelWithDebInfo"
# debug hack wrt #497532
mycmakeargs=(
-DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
-DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
-DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
-DSYSCONFDIR=${EPREFIX}/etc/mysql
-DINSTALL_BINDIR=bin
-DINSTALL_DOCDIR=share/doc/${P}
-DINSTALL_DOCREADMEDIR=share/doc/${P}
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_INFODIR=share/info
-DINSTALL_LIBDIR=$(get_libdir)
-DINSTALL_ELIBDIR=$(get_libdir)/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
-DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
-DINSTALL_SBINDIR=sbin
-DINSTALL_SCRIPTDIR=share/mysql/scripts
-DINSTALL_SQLBENCHDIR=share/mysql
-DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
-DWITH_COMMENT="Gentoo Linux ${PF}"
$(cmake-utils_use_with test UNIT_TESTS)
-DWITH_LIBEDIT=0
-DWITH_ZLIB=system
-DWITHOUT_LIBWRAP=1
-DENABLED_LOCAL_INFILE=1
$(cmake-utils_use_enable static-libs STATIC_LIBS)
-DWITH_SSL=$(usex ssl system bundled)
-DWITH_DEFAULT_COMPILER_OPTIONS=0
-DWITH_DEFAULT_FEATURE_SET=0
)
if in_iuse bindist ; then
mycmakeargs+=(
-DWITH_READLINE=$(usex bindist 1 0)
-DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
$(usex bindist -DHAVE_BFD_H=0 '')
)
fi
mycmakeargs+=( -DWITH_EDITLINE=system )
if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
mycmakeargs+=(
-DWITH_JEMALLOC=$(usex jemalloc system)
)
mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
fi
configure_cmake_locale
if use_if_iuse minimal ; then
configure_cmake_minimal
else
configure_cmake_standard
fi
# Bug #114895, bug #110149
filter-flags "-O" "-O[01]"
CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
CXXFLAGS="${CXXFLAGS} -felide-constructors"
# Causes linkage failures. Upstream bug #59607 removes it
if ! mysql_version_is_at_least "5.6" ; then
CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
fi
# As of 5.7, exceptions and rtti are used!
if ! mysql_version_is_at_least "5.7" ; then
CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
fi
export CXXFLAGS
# bug #283926, with GCC4.4, this is required to get correct behavior.
append-flags -fno-strict-aliasing
cmake-utils_src_configure
}
# @FUNCTION: mysql-cmake_src_compile
# @DESCRIPTION:
# Compile the mysql code.
mysql-cmake_src_compile() {
debug-print-function ${FUNCNAME} "$@"
cmake-utils_src_compile
}
# @FUNCTION: mysql-cmake_src_install
# @DESCRIPTION:
# Install mysql.
mysql-cmake_src_install() {
debug-print-function ${FUNCNAME} "$@"
# Make sure the vars are correctly initialized
mysql_init_vars
cmake-utils_src_install
if ! in_iuse tools || use_if_iuse tools ; then
# Convenience links
einfo "Making Convenience links for mysqlcheck multi-call binary"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair"
dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize"
fi
if [[ -z ${HAS_TOOLS_PATCH} ]] ; then
# Create a mariadb_config symlink
[[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && dosym "/usr/bin/mysql_config" "/usr/bin/mariadb_config"
fi
# INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
rm -Rf "${ED}/usr/data"
# Various junk (my-*.cnf moved elsewhere)
einfo "Removing duplicate /usr/share/mysql files"
# Unless they explicitly specific USE=test, then do not install the
# testsuite. It DOES have a use to be installed, esp. when you want to do a
# validation of your database configuration after tuning it.
if ! use test ; then
rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test
fi
# Configuration stuff
case ${MYSQL_PV_MAJOR} in
5.[1-4]*) mysql_mycnf_version="5.1" ;;
5.5) mysql_mycnf_version="5.5" ;;
5.[6-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.6" ;;
esac
einfo "Building default my.cnf (${mysql_mycnf_version})"
insinto "${MY_SYSCONFDIR#${EPREFIX}}"
[[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
mycnf_src="my.cnf-${mysql_mycnf_version}"
sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
"${FILESDIR}/${mycnf_src}" \
> "${TMPDIR}/my.cnf.ok" || die
use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok"
if use latin1 ; then
sed -i \
-e "/character-set/s|utf8|latin1|g" \
"${TMPDIR}/my.cnf.ok" || die
fi
eprefixify "${TMPDIR}/my.cnf.ok"
newins "${TMPDIR}/my.cnf.ok" my.cnf
# Minimal builds don't have the MySQL server
if use_if_iuse minimal ; then
:
elif ! in_iuse server || use_if_iuse server ; then
einfo "Creating initial directories"
# Empty directories ...
diropts "-m0750"
if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then
dodir "${MY_DATADIR#${EPREFIX}}"
keepdir "${MY_DATADIR#${EPREFIX}}"
chown -R mysql:mysql "${D}/${MY_DATADIR}"
fi
diropts "-m0755"
for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
dodir "${folder}"
keepdir "${folder}"
chown -R mysql:mysql "${ED}/${folder}"
done
fi
# Minimal builds don't have the MySQL server
if use_if_iuse minimal ; then
:
elif ! in_iuse server || use_if_iuse server; then
einfo "Including support files and sample configurations"
docinto "support-files"
for script in \
"${S}"/support-files/my-*.cnf.sh \
"${S}"/support-files/magic \
"${S}"/support-files/ndb-config-2-node.ini.sh
do
[[ -f $script ]] && dodoc "${script}"
done
docinto "scripts"
for script in "${S}"/scripts/mysql* ; do
[[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}"
done
fi
#Remove mytop if perl is not selected
[[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && ! use perl \
&& rm -f "${ED}/usr/bin/mytop"
in_iuse client-libs && ! use client-libs && return
# Percona has decided to rename libmysqlclient to libperconaserverclient
# Use a symlink to preserve linkages for those who don't use mysql_config
if [[ ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.5.36" ; then
dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient.so
dosym libperconaserverclient.so /usr/$(get_libdir)/libmysqlclient_r.so
if use static-libs ; then
dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient.a
dosym libperconaserverclient.a /usr/$(get_libdir)/libmysqlclient_r.a
fi
fi
}
|