/[gentoo-x86]/eclass/mysql-multilib.eclass
Gentoo

Contents of /eclass/mysql-multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Thu Jul 31 22:26:07 2014 UTC (6 years, 3 months ago) by grknight
Branch: MAIN
Changes since 1.3: +4 -1 lines
Update mysql cmake eclasses to prevent upstream from setting default features and CFLAGS

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/mysql-multilib.eclass,v 1.3 2014/07/31 02:31:09 grknight Exp $
4
5 # @ECLASS: mysql-multilib.eclass
6 # @MAINTAINER:
7 # Maintainers:
8 # - MySQL Team <mysql-bugs@gentoo.org>
9 # - Robin H. Johnson <robbat2@gentoo.org>
10 # - Jorge Manuel B. S. Vicetto <jmbsvicetto@gentoo.org>
11 # - Brian Evans <grknight@gentoo.org>
12 # @BLURB: This eclass provides most of the functions for mysql ebuilds
13 # @DESCRIPTION:
14 # The mysql-multilib.eclass is the base eclass to build the mysql and
15 # alternative projects (mariadb and percona) ebuilds.
16 # This eclass uses the mysql-cmake eclass for the
17 # specific bits related to the build system.
18 # It provides the src_unpack, src_prepare, src_configure, src_compile,
19 # src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm
20 # phase hooks.
21
22 MYSQL_EXTRAS=""
23
24 # @ECLASS-VARIABLE: MYSQL_EXTRAS_VER
25 # @DESCRIPTION:
26 # The version of the MYSQL_EXTRAS repo to use to build mysql
27 # Use "none" to disable it's use
28 [[ ${MY_EXTRAS_VER} == "live" ]] && MYSQL_EXTRAS="git-r3"
29
30 inherit eutils flag-o-matic ${MYSQL_EXTRAS} mysql-cmake mysql_fx versionator \
31 toolchain-funcs user cmake-utils multilib-minimal
32
33 #
34 # Supported EAPI versions and export functions
35 #
36
37 case "${EAPI:-0}" in
38 5) ;;
39 *) die "Unsupported EAPI: ${EAPI}" ;;
40 esac
41
42 EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config
43
44 #
45 # VARIABLES:
46 #
47
48 # Shorten the path because the socket path length must be shorter than 107 chars
49 # and we will run a mysql server during test phase
50 S="${WORKDIR}/mysql"
51
52 [[ ${MY_EXTRAS_VER} == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
53 if [[ ${MY_EXTRAS_VER} == "live" ]]; then
54 EGIT_REPO_URI="git://git.overlays.gentoo.org/proj/mysql-extras.git"
55 EGIT_CHECKOUT_DIR=${WORKDIR}/mysql-extras
56 EGIT_CLONE_TYPE=shallow
57 fi
58
59 # @ECLASS-VARIABLE: MYSQL_PV_MAJOR
60 # @DESCRIPTION:
61 # Upstream MySQL considers the first two parts of the version number to be the
62 # major version. Upgrades that change major version should always run
63 # mysql_upgrade.
64 MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
65
66 # Cluster is a special case...
67 if [[ "${PN}" == "mysql-cluster" ]]; then
68 case $PV in
69 7.2*|7.3*) MYSQL_PV_MAJOR=5.5 ;;
70 esac
71 fi
72
73 # MariaDB has left the numbering schema but keeping compatibility
74 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
75 case ${PV} in
76 10.0*|10.1*) MYSQL_PV_MAJOR="5.6" ;;
77 esac
78 fi
79
80 # @ECLASS-VARIABLE: MYSQL_VERSION_ID
81 # @DESCRIPTION:
82 # MYSQL_VERSION_ID will be:
83 # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
84 # This is an important part, because many of the choices the MySQL ebuild will do
85 # depend on this variable.
86 # In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
87 # We also strip off upstream's trailing letter that they use to respin tarballs
88 MYSQL_VERSION_ID=""
89 tpv="${PV%[a-z]}"
90 tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
91 for vatom in 0 1 2 3 ; do
92 # pad to length 2
93 tpv[${vatom}]="00${tpv[${vatom}]}"
94 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
95 done
96 # strip leading "0" (otherwise it's considered an octal number by BASH)
97 MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
98
99 # This eclass should only be used with at least mysql-5.5.35
100 mysql_version_is_at_least "5.5.35" || die "This eclass should only be used with >=mysql-5.5.35"
101
102 # @ECLASS-VARIABLE: XTRADB_VER
103 # @DEFAULT_UNSET
104 # @DESCRIPTION:
105 # Version of the XTRADB storage engine
106
107 # @ECLASS-VARIABLE: PERCONA_VER
108 # @DEFAULT_UNSET
109 # @DESCRIPTION:
110 # Designation by PERCONA for a MySQL version to apply an XTRADB release
111
112 # Work out the default SERVER_URI correctly
113 if [[ -z ${SERVER_URI} ]]; then
114 [[ -z ${MY_PV} ]] && MY_PV="${PV//_/-}"
115 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
116 # Beginning with 5.5, MariaDB stopped putting beta, alpha or rc on their tarball names
117 mysql_version_is_at_least "5.5" && MARIA_FULL_PV=$(get_version_component_range 1-3) || \
118 MARIA_FULL_PV=$(replace_version_separator 3 '-' ${MY_PV})
119 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
120 SERVER_URI="
121 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
122 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
123 http://mirror.jmu.edu/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
124 http://mirrors.coreix.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
125 http://mirrors.syringanetworks.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
126 http://mirrors.fe.up.pt/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
127 http://mirror2.hs-esslingen.de/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
128 "
129 if [[ ${PN} == "mariadb-galera" ]]; then
130 MY_SOURCEDIR="${PN%%-galera}-${MARIA_FULL_PV}"
131 fi
132 elif [[ ${PN} == "percona-server" ]]; then
133 PERCONA_PN="Percona-Server"
134 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
135 MY_PV=$(get_version_component_range 1-3 ${PV})
136 PERCONA_RELEASE=$(get_version_component_range 4-5 ${PV})
137 PERCONA_RC=$(get_version_component_range 6 ${PV})
138 SERVER_URI="http://www.percona.com/redir/downloads/${PERCONA_PN}-${MIRROR_PV}/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}/source/tarball/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}.tar.gz"
139 # http://www.percona.com/redir/downloads/Percona-Server-5.5/LATEST/source/tarball/Percona-Server-5.5.30-rel30.2.tar.gz
140 # http://www.percona.com/redir/downloads/Percona-Server-5.6/Percona-Server-5.6.13-rc60.5/source/tarball/Percona-Server-5.6.13-rc60.5.tar.gz
141 else
142 if [[ "${PN}" == "mysql-cluster" ]] ; then
143 URI_DIR="MySQL-Cluster"
144 URI_FILE="mysql-cluster-gpl"
145 else
146 URI_DIR="MySQL"
147 URI_FILE="mysql"
148 fi
149 URI_A="${URI_FILE}-${MY_PV}.tar.gz"
150 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
151 # Recently upstream switched to an archive site, and not on mirrors
152 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
153 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
154 fi
155 fi
156
157 # Define correct SRC_URIs
158 SRC_URI="${SERVER_URI}"
159
160 # Gentoo patches to MySQL
161 if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then
162 SRC_URI="${SRC_URI}
163 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
164 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
165 http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
166 http://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
167 fi
168
169 DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
170 HOMEPAGE="http://www.mysql.com/"
171 if [[ ${PN} == "mariadb" ]]; then
172 HOMEPAGE="http://mariadb.org/"
173 DESCRIPTION="An enhanced, drop-in replacement for MySQL"
174 fi
175 if [[ ${PN} == "mariadb-galera" ]]; then
176 HOMEPAGE="http://mariadb.org/"
177 DESCRIPTION="An enhanced, drop-in replacement for MySQL with Galera Replication"
178 fi
179 if [[ ${PN} == "percona-server" ]]; then
180 HOMEPAGE="http://www.percona.com/software/percona-server"
181 DESCRIPTION="An enhanced, drop-in replacement for MySQL from the Percona team"
182 fi
183 LICENSE="GPL-2"
184 SLOT="0"
185
186 IUSE="+community cluster debug embedded extraengine jemalloc latin1 max-idx-128 minimal
187 +perl profiling selinux ssl systemtap static static-libs tcmalloc test"
188
189 # This probably could be simplified, but the syntax would have to be just right
190 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
191 IUSE="bindist ${IUSE}"
192 elif [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
193 mysql_check_version_range "5.5.37 to 5.6.11.99" ; then
194 IUSE="bindist ${IUSE}"
195 elif [[ ${PN} == "mysql-cluster" ]] && \
196 mysql_check_version_range "7.2 to 7.2.99.99" ; then
197 IUSE="bindist ${IUSE}"
198 fi
199
200 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
201 IUSE="${IUSE} oqgraph pam sphinx tokudb"
202 # 5.5.33 and 10.0.5 add TokuDB. Authors strongly recommend jemalloc or perfomance suffers
203 mysql_version_is_at_least "10.0.5" && IUSE="${IUSE} odbc xml" && \
204 REQUIRED_USE="odbc? ( extraengine !minimal ) xml? ( extraengine !minimal )"
205 REQUIRED_USE="${REQUIRED_USE} minimal? ( !oqgraph !sphinx ) tokudb? ( jemalloc )"
206 fi
207
208 if [[ ${PN} == "percona-server" ]]; then
209 IUSE="${IUSE} pam"
210 fi
211
212 REQUIRED_USE="
213 ${REQUIRED_USE} tcmalloc? ( !jemalloc ) jemalloc? ( !tcmalloc )
214 minimal? ( !cluster !extraengine !embedded ) static? ( !ssl )"
215
216 #
217 # DEPENDENCIES:
218 #
219
220 # Be warned, *DEPEND are version-dependant
221 # These are used for both runtime and compiletime
222 # MULTILIB_USEDEP only set for libraries used by the client library
223 DEPEND="
224 ssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
225 kernel_linux? (
226 sys-process/procps:0=
227 dev-libs/libaio:0=
228 )
229 >=sys-apps/sed-4
230 >=sys-apps/texinfo-4.7-r1
231 >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
232 !dev-db/mariadb-native-client[mysqlcompat]
233 jemalloc? ( dev-libs/jemalloc:0=[${MULTILIB_USEDEP}] )
234 tcmalloc? ( dev-util/google-perftools:0= )
235 systemtap? ( >=dev-util/systemtap-1.3:0= )
236 "
237
238 # dev-db/mysql-5.6.12+ only works with dev-libs/libedit
239 # This probably could be simplified
240 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
241 mysql_version_is_at_least "5.6.12" ; then
242 DEPEND="${DEPEND} dev-libs/libedit"
243 elif [[ ${PN} == "mysql-cluster" ]] && mysql_version_is_at_least "7.3"; then
244 DEPEND="${DEPEND} dev-libs/libedit"
245 else
246 DEPEND="${DEPEND} !bindist? ( >=sys-libs/readline-4.1:0=[${MULTILIB_USEDEP}] )"
247 fi
248
249 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
250 # Bug 441700 MariaDB >=5.3 include custom mytop
251 DEPEND="${DEPEND}
252 oqgraph? ( >=dev-libs/boost-1.40.0:0= )
253 !minimal? ( pam? ( virtual/pam:0= ) )
254 perl? ( !dev-db/mytop )"
255 if mysql_version_is_at_least "10.0.5" ; then
256 DEPEND="${DEPEND}
257 odbc? ( dev-db/unixODBC:0= )
258 xml? ( dev-libs/libxml2:2= )
259 "
260 fi
261 mysql_version_is_at_least "10.0.7" && DEPEND="${DEPEND} oqgraph? ( dev-libs/judy:0= )"
262 if mysql_version_is_at_least "10.0.9" ; then
263 DEPEND="${DEPEND} >=dev-libs/libpcre-8.35:3="
264 fi
265 fi
266
267 # Having different flavours at the same time is not a good idea
268 for i in "mysql" "mariadb" "mariadb-galera" "percona-server" "mysql-cluster" ; do
269 [[ ${i} == ${PN} ]] ||
270 DEPEND="${DEPEND} !dev-db/${i}"
271 done
272
273 if [[ ${PN} == "mysql-cluster" ]] ; then
274 # TODO: This really should include net-misc/memcached
275 # but the package does not install the files it seeks.
276 mysql_version_is_at_least "7.2.3" && \
277 DEPEND="${DEPEND} dev-libs/libevent:0="
278 fi
279
280 # prefix: first need to implement something for #196294
281 # TODO: check emul-linux-x86-db dep when it is multilib enabled
282 RDEPEND="${DEPEND}
283 !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )
284 selinux? ( sec-policy/selinux-mysql )
285 abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] )
286 "
287
288 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
289 # Bug 455016 Add dependencies of mytop
290 RDEPEND="${RDEPEND} perl? (
291 virtual/perl-Getopt-Long
292 dev-perl/TermReadKey
293 virtual/perl-Term-ANSIColor
294 virtual/perl-Time-HiRes ) "
295 fi
296
297 if [[ ${PN} == "mariadb-galera" ]] ; then
298 # The wsrep API version must match between the ebuild and sys-cluster/galera.
299 # This will be indicated by WSREP_REVISION in the ebuild and the first number
300 # in the version of sys-cluster/galera
301 RDEPEND="${RDEPEND}
302 =sys-cluster/galera-${WSREP_REVISION}*
303 "
304 fi
305
306 if [[ ${PN} == "mysql-cluster" ]] ; then
307 mysql_version_is_at_least "7.2.9" && RDEPEND="${RDEPEND} java? ( >=virtual/jre-1.6 )" && \
308 DEPEND="${DEPEND} java? ( >=virtual/jdk-1.6 )"
309 fi
310
311 # compile-time-only
312 DEPEND="${DEPEND}
313 virtual/yacc
314 static? ( sys-libs/ncurses[static-libs] )
315 >=dev-util/cmake-2.8.9
316 "
317
318 # For other stuff to bring us in
319 # dev-perl/DBD-mysql is needed by some scripts installed by MySQL
320 PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
321 ~virtual/mysql-${MYSQL_PV_MAJOR}"
322
323 # my_config.h includes ABI specific data
324 MULTILIB_WRAPPED_HEADERS=( /usr/include/mysql/my_config.h /usr/include/mysql/private/embedded_priv.h )
325
326 #
327 # HELPER FUNCTIONS:
328 #
329
330 # @FUNCTION: mysql-multilib_disable_test
331 # @DESCRIPTION:
332 # Helper function to disable specific tests.
333 mysql-multilib_disable_test() {
334 mysql-cmake_disable_test "$@"
335 }
336
337 #
338 # EBUILD FUNCTIONS
339 #
340
341 # @FUNCTION: mysql-multilib_pkg_setup
342 # @DESCRIPTION:
343 # Perform some basic tests and tasks during pkg_setup phase:
344 # die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
345 # create new user and group for mysql
346 # warn about deprecated features
347 mysql-multilib_pkg_setup() {
348
349 if has test ${FEATURES} ; then
350 if ! use minimal ; then
351 if ! has userpriv ${FEATURES} ; then
352 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
353 fi
354 fi
355 fi
356
357 # This should come after all of the die statements
358 enewgroup mysql 60 || die "problem adding 'mysql' group"
359 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
360
361 if use cluster && [[ "${PN}" != "mysql-cluster" ]]; then
362 ewarn "Upstream has noted that the NDB cluster support in the 5.0 and"
363 ewarn "5.1 series should NOT be put into production. In the near"
364 ewarn "future, it will be disabled from building."
365 fi
366
367 if [[ ${PN} == "mysql-cluster" ]] ; then
368 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_setup
369 fi
370
371 if use_if_iuse tokudb && [[ $(gcc-major-version) -lt 4 || $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 7 ]] ; then
372 eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
373 eerror "Please use gcc-config to switch to gcc-4.7 or later version."
374 die
375 fi
376
377 }
378
379 # @FUNCTION: mysql-multilib_src_unpack
380 # @DESCRIPTION:
381 # Unpack the source code
382 mysql-multilib_src_unpack() {
383
384 # Initialize the proper variables first
385 mysql_init_vars
386
387 unpack ${A}
388 # Grab the patches
389 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
390
391 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
392 }
393
394 # @FUNCTION: mysql-multilib_src_prepare
395 # @DESCRIPTION:
396 # Apply patches to the source code and remove unneeded bundled libs.
397 mysql-multilib_src_prepare() {
398 mysql-cmake_src_prepare "$@"
399 if [[ ${PN} == "mysql-cluster" ]] ; then
400 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_src_prepare
401 fi
402 }
403
404
405 # @FUNCTION: mysql-multilib_src_configure
406 # @DESCRIPTION:
407 # Configure mysql to build the code for Gentoo respecting the use flags.
408 mysql-multilib_src_configure() {
409 multilib-minimal_src_configure
410 }
411
412 multilib_src_configure() {
413
414 debug-print-function ${FUNCNAME} "$@"
415
416 CMAKE_BUILD_TYPE="RelWithDebInfo"
417
418 # debug hack wrt #497532
419 mycmakeargs=(
420 -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
421 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
422 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
423 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
424 -DSYSCONFDIR=${EPREFIX}/etc/mysql
425 -DINSTALL_BINDIR=bin
426 -DINSTALL_DOCDIR=share/doc/${P}
427 -DINSTALL_DOCREADMEDIR=share/doc/${P}
428 -DINSTALL_INCLUDEDIR=include/mysql
429 -DINSTALL_INFODIR=share/info
430 -DINSTALL_LIBDIR=$(get_libdir)
431 -DINSTALL_ELIBDIR=$(get_libdir)/mysql
432 -DINSTALL_MANDIR=share/man
433 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
434 -DINSTALL_MYSQLSHAREDIR=share/mysql
435 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
436 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
437 -DINSTALL_SBINDIR=sbin
438 -DINSTALL_SCRIPTDIR=share/mysql/scripts
439 -DINSTALL_SQLBENCHDIR=share/mysql
440 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
441 -DWITH_COMMENT="Gentoo Linux ${PF}"
442 $(cmake-utils_use_with test UNIT_TESTS)
443 -DWITH_LIBEDIT=0
444 -DWITH_ZLIB=system
445 -DWITHOUT_LIBWRAP=1
446 -DENABLED_LOCAL_INFILE=1
447 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
448 -DWITH_SSL=$(usex ssl system bundled)
449 -DWITH_DEFAULT_COMPILER_OPTIONS=0
450 -DWITH_DEFAULT_FEATURE_SET=0
451 )
452
453 if in_iuse bindist ; then
454 mycmakeargs+=(
455 -DWITH_READLINE=$(usex bindist 1 0)
456 -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
457 $(usex bindist -DHAVE_BFD_H=0 '')
458 )
459 fi
460
461 mycmakeargs+=( -DWITH_EDITLINE=system )
462
463 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
464 mycmakeargs+=(
465 -DWITH_JEMALLOC=$(usex jemalloc system)
466 )
467
468 mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
469 fi
470
471 configure_cmake_locale
472
473 if multilib_is_native_abi && ! use minimal ; then
474 configure_cmake_standard
475 else
476 configure_cmake_minimal
477 fi
478
479 # Bug #114895, bug #110149
480 filter-flags "-O" "-O[01]"
481
482 CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
483 CXXFLAGS="${CXXFLAGS} -felide-constructors -fno-rtti"
484 # Causes linkage failures. Upstream bug #59607 removes it
485 if ! mysql_version_is_at_least "5.6" ; then
486 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
487 fi
488 # As of 5.7, exceptions are used!
489 if ! mysql_version_is_at_least "5.7" ; then
490 CXXFLAGS="${CXXFLAGS} -fno-exceptions"
491 fi
492 export CXXFLAGS
493
494 # bug #283926, with GCC4.4, this is required to get correct behavior.
495 append-flags -fno-strict-aliasing
496
497 cmake-utils_src_configure
498 }
499
500 mysql-multilib_src_compile() {
501 local _cmake_args=( "${@}" )
502
503 multilib-minimal_src_compile
504 }
505
506 multilib_src_compile() {
507 cmake-utils_src_compile "${_cmake_args[@]}"
508 }
509
510
511 # @FUNCTION: mysql-multilib_src_install
512 # @DESCRIPTION:
513 # Install mysql.
514 mysql-multilib_src_install() {
515 multilib-minimal_src_install
516 }
517
518 multilib_src_install() {
519 debug-print-function ${FUNCNAME} "$@"
520
521 if multilib_is_native_abi; then
522 mysql-cmake_src_install
523 else
524 cmake-utils_src_install
525 if ! use minimal && [[ "${PN}" == "mariadb" || "${PN}" == "mariadb-galera" ]] ; then
526 insinto /usr/include/mysql/private
527 doins "${S}"/sql/*.h
528 fi
529 fi
530 }
531
532 # @FUNCTION: mysql-multilib_pkg_preinst
533 # @DESCRIPTION:
534 # Call java-pkg-opt-2 eclass when mysql-cluster is installed
535 mysql-multilib_pkg_preinst() {
536 debug-print-function ${FUNCNAME} "$@"
537
538 if [[ ${PN} == "mysql-cluster" ]] ; then
539 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_preinst
540 fi
541 }
542
543 # @FUNCTION: mysql-multilib_pkg_postinst
544 # @DESCRIPTION:
545 # Run post-installation tasks:
546 # create the dir for logfiles if non-existant
547 # touch the logfiles and secure them
548 # install scripts
549 # issue required steps for optional features
550 # issue deprecation warnings
551 mysql-multilib_pkg_postinst() {
552 debug-print-function ${FUNCNAME} "$@"
553
554 # Make sure the vars are correctly initialized
555 mysql_init_vars
556
557 # Check FEATURES="collision-protect" before removing this
558 [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
559
560 # Secure the logfiles
561 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
562 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
563 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
564
565 # Minimal builds don't have the MySQL server
566 if ! use minimal ; then
567 docinto "support-files"
568 for script in \
569 support-files/my-*.cnf \
570 support-files/magic \
571 support-files/ndb-config-2-node.ini
572 do
573 [[ -f "${script}" ]] \
574 && dodoc "${script}"
575 done
576
577 docinto "scripts"
578 for script in scripts/mysql* ; do
579 if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then
580 dodoc "${script}"
581 fi
582 done
583
584 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
585 if use_if_iuse pam ; then
586 einfo
587 elog "This install includes the PAM authentication plugin."
588 elog "To activate and configure the PAM plugin, please read:"
589 elog "https://kb.askmonty.org/en/pam-authentication-plugin/"
590 einfo
591 fi
592 fi
593
594 einfo
595 elog "You might want to run:"
596 elog "\"emerge --config =${CATEGORY}/${PF}\""
597 elog "if this is a new install."
598 einfo
599
600 einfo
601 elog "If you are upgrading major versions, you should run the"
602 elog "mysql_upgrade tool."
603 einfo
604
605 if [[ ${PN} == "mariadb-galera" ]] ; then
606 einfo
607 elog "Be sure to edit the my.cnf file to activate your cluster settings."
608 elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
609 elog "The first time the cluster is activated, you should add"
610 elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
611 elog "This option should then be removed for subsequent starts."
612 einfo
613 fi
614 fi
615 }
616
617 # @FUNCTION: mysql-multilib_getopt
618 # @DESCRIPTION:
619 # Use my_print_defaults to extract specific config options
620 mysql-multilib_getopt() {
621 local mypd="${EROOT}"/usr/bin/my_print_defaults
622 section="$1"
623 flag="--${2}="
624 "${mypd}" $section | sed -n "/^${flag}/p"
625 }
626
627 # @FUNCTION: mysql-multilib_getoptval
628 # @DESCRIPTION:
629 # Use my_print_defaults to extract specific config options
630 mysql-multilib_getoptval() {
631 local mypd="${EROOT}"/usr/bin/my_print_defaults
632 section="$1"
633 flag="--${2}="
634 "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
635 }
636
637 # @FUNCTION: mysql-multilib_pkg_config
638 # @DESCRIPTION:
639 # Configure mysql environment.
640 mysql-multilib_pkg_config() {
641
642 debug-print-function ${FUNCNAME} "$@"
643
644 local old_MY_DATADIR="${MY_DATADIR}"
645 local old_HOME="${HOME}"
646 # my_print_defaults needs to read stuff in $HOME/.my.cnf
647 export HOME=${EPREFIX}/root
648
649 # Make sure the vars are correctly initialized
650 mysql_init_vars
651
652 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
653
654 if built_with_use ${CATEGORY}/${PN} minimal ; then
655 die "Minimal builds do NOT include the MySQL server"
656 fi
657
658 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
659 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
660 MY_DATADIR_s="${MY_DATADIR_s%%/}"
661 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
662 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
663
664 if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
665 if [[ -d "${MY_DATADIR_s}" ]]; then
666 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
667 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
668 else
669 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
670 mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
671 || die "Moving MY_DATADIR failed"
672 fi
673 else
674 ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
675 if [[ -d "${MY_DATADIR_s}" ]]; then
676 ewarn "Attempting to use ${MY_DATADIR_s}"
677 else
678 eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
679 die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
680 fi
681 fi
682 fi
683
684 local pwd1="a"
685 local pwd2="b"
686 local maxtry=15
687
688 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
689 MYSQL_ROOT_PASSWORD="$(mysql-multilib_getoptval 'client mysql' password)"
690 fi
691 MYSQL_TMPDIR="$(mysql-multilib_getoptval mysqld tmpdir)"
692 # These are dir+prefix
693 MYSQL_RELAY_LOG="$(mysql-multilib_getoptval mysqld relay-log)"
694 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
695 MYSQL_LOG_BIN="$(mysql-multilib_getoptval mysqld log-bin)"
696 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
697
698 if [[ ! -d "${ROOT}"/$MYSQL_TMPDIR ]]; then
699 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
700 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
701 fi
702 if [[ ! -d "${ROOT}"/$MYSQL_LOG_BIN ]]; then
703 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
704 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
705 fi
706 if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
707 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
708 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
709 fi
710
711 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
712 ewarn "You have already a MySQL database in place."
713 ewarn "(${ROOT}/${MY_DATADIR}/*)"
714 ewarn "Please rename or delete it if you wish to replace it."
715 die "MySQL database already exists!"
716 fi
717
718 # Bug #213475 - MySQL _will_ object strenously if your machine is named
719 # localhost. Also causes weird failures.
720 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
721
722 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
723
724 einfo "Please provide a password for the mysql 'root' user now"
725 einfo "or through the ${HOME}/.my.cnf file."
726 ewarn "Avoid [\"'\\_%] characters in the password"
727 read -rsp " >" pwd1 ; echo
728
729 einfo "Retype the password"
730 read -rsp " >" pwd2 ; echo
731
732 if [[ "x$pwd1" != "x$pwd2" ]] ; then
733 die "Passwords are not the same"
734 fi
735 MYSQL_ROOT_PASSWORD="${pwd1}"
736 unset pwd1 pwd2
737 fi
738
739 local options
740 local sqltmp="$(emktemp)"
741
742 # Fix bug 446200. Don't reference host my.cnf, needs to come first,
743 # see http://bugs.mysql.com/bug.php?id=31312
744 use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
745
746 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
747 [[ -r "${help_tables}" ]] \
748 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
749 || touch "${TMPDIR}/fill_help_tables.sql"
750 help_tables="${TMPDIR}/fill_help_tables.sql"
751
752 # Figure out which options we need to disable to do the setup
753 helpfile="${TMPDIR}/mysqld-help"
754 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
755 for opt in grant-tables host-cache name-resolve networking slave-start \
756 federated ssl log-bin relay-log slow-query-log external-locking \
757 ndbcluster log-slave-updates \
758 ; do
759 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
760 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
761 done
762 # But some options changed names
763 egrep -sq external-locking "${helpfile}" && \
764 options="${options/skip-locking/skip-external-locking}"
765
766 use prefix || options="${options} --user=mysql"
767
768 # MySQL 5.6+ needs InnoDB
769 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] ; then
770 mysql_version_is_at_least "5.6" || options="${options} --loose-skip-innodb"
771 fi
772
773 einfo "Creating the mysql database and setting proper"
774 einfo "permissions on it ..."
775
776 # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
777 PID_DIR="${EROOT}/var/run/mysqld"
778 if [[ ! -d "${PID_DIR}" ]]; then
779 mkdir -p "${PID_DIR}" || die "Could not create pid directory"
780 chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
781 chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
782 fi
783
784 pushd "${TMPDIR}" &>/dev/null
785 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
786 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
787 [[ -f ${cmd} ]] || cmd=${EROOT}usr/bin/mysql_install_db
788 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${ROOT}/${MY_DATADIR}' '--tmpdir=${ROOT}/${MYSQL_TMPDIR}'"
789 einfo "Command: $cmd"
790 eval $cmd \
791 >"${TMPDIR}"/mysql_install_db.log 2>&1
792 if [ $? -ne 0 ]; then
793 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
794 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
795 fi
796 popd &>/dev/null
797 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
798 || die "MySQL databases not installed"
799 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
800 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
801
802 # Filling timezones, see
803 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
804 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
805
806 if [[ -r "${help_tables}" ]] ; then
807 cat "${help_tables}" >> "${sqltmp}"
808 fi
809
810 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
811 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
812 local mysqld="${EROOT}/usr/sbin/mysqld \
813 ${options} \
814 $(use prefix || echo --user=mysql) \
815 --log-warnings=0 \
816 --basedir=${EROOT}/usr \
817 --datadir=${ROOT}/${MY_DATADIR} \
818 --max_allowed_packet=8M \
819 --net_buffer_length=16K \
820 --default-storage-engine=MyISAM \
821 --socket=${socket} \
822 --pid-file=${pidfile}
823 --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
824 #einfo "About to start mysqld: ${mysqld}"
825 ebegin "Starting mysqld"
826 einfo "Command ${mysqld}"
827 ${mysqld} &
828 rc=$?
829 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
830 maxtry=$((${maxtry}-1))
831 echo -n "."
832 sleep 1
833 done
834 eend $rc
835
836 if ! [[ -S "${socket}" ]]; then
837 die "Completely failed to start up mysqld with: ${mysqld}"
838 fi
839
840 ebegin "Setting root password"
841 # Do this from memory, as we don't want clear text passwords in temp files
842 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
843 "${EROOT}/usr/bin/mysql" \
844 --socket=${socket} \
845 -hlocalhost \
846 -e "${sql}"
847 eend $?
848
849 ebegin "Loading \"zoneinfo\", this step may require a few seconds ..."
850 "${EROOT}/usr/bin/mysql" \
851 --socket=${socket} \
852 -hlocalhost \
853 -uroot \
854 --password="${MYSQL_ROOT_PASSWORD}" \
855 mysql < "${sqltmp}"
856 rc=$?
857 eend $?
858 [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
859
860 # Stop the server and cleanup
861 einfo "Stopping the server ..."
862 kill $(< "${pidfile}" )
863 rm -f "${sqltmp}"
864 wait %1
865 einfo "Done"
866 }

  ViewVC Help
Powered by ViewVC 1.1.20