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

Contents of /eclass/mysql-multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.27 - (show annotations) (download)
Thu Jul 30 20:34:57 2015 UTC (3 years, 8 months ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.26: +25 -11 lines
Revert bad mycmakeargs changes and introduce 3 eclass variables to have extra defines in the ebuild

1 # Copyright 1999-2015 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.26 2015/07/30 14:04:41 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_pretend 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 # @ECLASS-VARIABLE: MYSQL_CMAKE_NATIVE_DEFINES
49 # @DESCRIPTION:
50 # Add extra CMake arguments for native multilib builds
51
52 # @ECLASS-VARIABLE: MYSQL_CMAKE_NONNATIVE_DEFINES
53 # @DESCRIPTION:
54 # Add extra CMake arguments for non-native multilib builds
55
56 # @ECLASS-VARIABLE: MYSQL_CMAKE_EXTRA_DEFINES
57 # @DESCRIPTION:
58 # Add extra CMake arguments
59
60 # Shorten the path because the socket path length must be shorter than 107 chars
61 # and we will run a mysql server during test phase
62 S="${WORKDIR}/mysql"
63
64 [[ ${MY_EXTRAS_VER} == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z"
65 if [[ ${MY_EXTRAS_VER} == "live" ]]; then
66 EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git"
67 EGIT_CHECKOUT_DIR=${WORKDIR}/mysql-extras
68 EGIT_CLONE_TYPE=shallow
69 fi
70
71 # @ECLASS-VARIABLE: MYSQL_PV_MAJOR
72 # @DESCRIPTION:
73 # Upstream MySQL considers the first two parts of the version number to be the
74 # major version. Upgrades that change major version should always run
75 # mysql_upgrade.
76 MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})"
77
78 # Cluster is a special case...
79 if [[ "${PN}" == "mysql-cluster" ]]; then
80 case $PV in
81 7.2*) MYSQL_PV_MAJOR=5.5 ;;
82 7.3*) MYSQL_PV_MAJOR=5.6 ;;
83 esac
84 fi
85
86 # MariaDB has left the numbering schema but keeping compatibility
87 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
88 case ${PV} in
89 10.0*) MYSQL_PV_MAJOR="5.6" ;;
90 10.1*) MYSQL_PV_MAJOR="5.6" ;;
91 esac
92 fi
93
94 # @ECLASS-VARIABLE: MYSQL_VERSION_ID
95 # @DESCRIPTION:
96 # MYSQL_VERSION_ID will be:
97 # major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99]
98 # This is an important part, because many of the choices the MySQL ebuild will do
99 # depend on this variable.
100 # In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803"
101 # We also strip off upstream's trailing letter that they use to respin tarballs
102 MYSQL_VERSION_ID=""
103 tpv="${PV%[a-z]}"
104 tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}"
105 for vatom in 0 1 2 3 ; do
106 # pad to length 2
107 tpv[${vatom}]="00${tpv[${vatom}]}"
108 MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}"
109 done
110 # strip leading "0" (otherwise it's considered an octal number by BASH)
111 MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"}
112
113 # This eclass should only be used with at least mysql-5.5.35
114 mysql_version_is_at_least "5.5.35" || die "This eclass should only be used with >=mysql-5.5.35"
115
116 # Work out the default SERVER_URI correctly
117 if [[ -z ${SERVER_URI} ]]; then
118 [[ -z ${MY_PV} ]] && MY_PV="${PV//_/-}"
119 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
120 # Beginning with 5.5, MariaDB stopped putting beta, alpha or rc on their tarball names
121 mysql_version_is_at_least "5.5" && MARIA_FULL_PV=$(get_version_component_range 1-3) || \
122 MARIA_FULL_PV=$(replace_version_separator 3 '-' ${MY_PV})
123 MARIA_FULL_P="${PN}-${MARIA_FULL_PV}"
124 SERVER_URI="
125 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
126 http://mirror.jmu.edu/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
127 http://mirrors.coreix.net/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
128 http://mirrors.syringanetworks.net/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
129 http://mirrors.fe.up.pt/pub/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
130 http://mirror2.hs-esslingen.de/mariadb/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz
131 http://ftp.osuosl.org/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
132 http://mirror.jmu.edu/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
133 http://mirrors.coreix.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
134 http://mirrors.syringanetworks.net/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
135 http://mirrors.fe.up.pt/pub/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
136 http://mirror2.hs-esslingen.de/mariadb/${MARIA_FULL_P}/kvm-tarbake-jaunty-x86/${MARIA_FULL_P}.tar.gz
137 "
138 if [[ ${PN} == "mariadb-galera" ]]; then
139 MY_SOURCEDIR="${PN%%-galera}-${MARIA_FULL_PV}"
140 fi
141 elif [[ ${PN} == "percona-server" ]]; then
142 PERCONA_PN="Percona-Server"
143 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
144 MY_PV=$(get_version_component_range 1-3 ${PV})
145 PERCONA_RELEASE=$(get_version_component_range 4-5 ${PV})
146 PERCONA_RC=$(get_version_component_range 6 ${PV})
147 SERVER_URI="http://www.percona.com/redir/downloads/${PERCONA_PN}-${MIRROR_PV}/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}/source/tarball/${PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}.tar.gz"
148 # http://www.percona.com/redir/downloads/Percona-Server-5.5/LATEST/source/tarball/Percona-Server-5.5.30-rel30.2.tar.gz
149 # 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
150 else
151 if [[ "${PN}" == "mysql-cluster" ]] ; then
152 URI_DIR="MySQL-Cluster"
153 URI_FILE="mysql-cluster-gpl"
154 else
155 URI_DIR="MySQL"
156 URI_FILE="mysql"
157 fi
158 URI_A="${URI_FILE}-${MY_PV}.tar.gz"
159 MIRROR_PV=$(get_version_component_range 1-2 ${PV})
160 # Recently upstream switched to an archive site, and not on mirrors
161 SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}
162 mirror://mysql/Downloads/${URI_DIR}-${PV%.*}/${URI_A}"
163 fi
164 fi
165
166 # Define correct SRC_URIs
167 SRC_URI="${SERVER_URI}"
168
169 # Gentoo patches to MySQL
170 if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then
171 SRC_URI="${SRC_URI}
172 mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
173 http://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
174 http://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
175 http://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
176 fi
177
178 DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
179 HOMEPAGE="http://www.mysql.com/"
180 if [[ ${PN} == "mariadb" ]]; then
181 HOMEPAGE="http://mariadb.org/"
182 DESCRIPTION="An enhanced, drop-in replacement for MySQL"
183 fi
184 if [[ ${PN} == "mariadb-galera" ]]; then
185 HOMEPAGE="http://mariadb.org/"
186 DESCRIPTION="An enhanced, drop-in replacement for MySQL with Galera Replication"
187 fi
188 if [[ ${PN} == "percona-server" ]]; then
189 HOMEPAGE="http://www.percona.com/software/percona-server"
190 DESCRIPTION="An enhanced, drop-in replacement for MySQL from the Percona team"
191 fi
192 LICENSE="GPL-2"
193 SLOT="0/${SUBSLOT:=0}"
194
195 IUSE="+community cluster debug embedded extraengine jemalloc latin1
196 +perl profiling selinux ssl systemtap static static-libs tcmalloc test"
197
198 ### Begin readline/libedit
199 ### If the world was perfect, we would use external libedit on both to have a similar experience
200 ### However libedit does not seem to support UTF-8 keyboard input
201
202 # This probably could be simplified, but the syntax would have to be just right
203 #if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && \
204 # mysql_check_version_range "5.5.37 to 10.0.13.99" ; then
205 # IUSE="bindist ${IUSE}"
206 #elif [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
207 # mysql_check_version_range "5.5.37 to 5.6.11.99" ; then
208 # IUSE="bindist ${IUSE}"
209 #elif [[ ${PN} == "mysql-cluster" ]] && \
210 # mysql_check_version_range "7.2 to 7.2.99.99" ; then
211 # IUSE="bindist ${IUSE}"
212 #fi
213
214 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
215 IUSE="bindist ${IUSE}"
216 RESTRICT="${RESTRICT} !bindist? ( bindist )"
217 fi
218
219 ### End readline/libedit
220
221 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]]; then
222 IUSE="${IUSE} oqgraph pam sphinx tokudb"
223 # 5.5.33 and 10.0.5 add TokuDB. Authors strongly recommend jemalloc or perfomance suffers
224 mysql_version_is_at_least "10.0.5" && IUSE="${IUSE} odbc xml"
225 if [[ ${HAS_TOOLS_PATCH} ]] ; then
226 REQUIRED_USE="${REQUIRED_USE} !server? ( !oqgraph !sphinx ) tokudb? ( jemalloc )"
227 else
228 REQUIRED_USE="${REQUIRED_USE} minimal? ( !oqgraph !sphinx ) tokudb? ( jemalloc )"
229 fi
230 # MariaDB 10.1 introduces InnoDB/XtraDB compression with external libraries
231 # Choices are bzip2, lz4, lzma, lzo. bzip2 and lzma enabled by default as they are system libraries
232 mysql_version_is_at_least "10.1.1" && IUSE="${IUSE} innodb-lz4 innodb-lzo"
233
234 # 10.1.2 introduces a cracklib password checker
235 mysql_version_is_at_least "10.1.1" && IUSE="${IUSE} cracklib"
236 fi
237
238 if [[ -n "${WSREP_REVISION}" ]]; then
239 if [[ ${PN} == "mariadb" ]]; then
240 IUSE="${IUSE} galera sst-rsync sst-xtrabackup"
241 REQUIRED_USE="${REQUIRED_USE} sst-rsync? ( galera ) sst-xtrabackup? ( galera )"
242 else
243 IUSE="${IUSE} +sst-rsync sst-xtrabackup"
244 fi
245 fi
246
247 if [[ ${PN} == "percona-server" ]]; then
248 IUSE="${IUSE} pam"
249 fi
250
251 if [[ ${HAS_TOOLS_PATCH} ]] ; then
252 IUSE="${IUSE} client-libs +server +tools"
253 REQUIRED_USE="${REQUIRED_USE} !server? ( !extraengine !embedded ) server? ( tools ) || ( client-libs server tools )"
254 else
255 IUSE="${IUSE} minimal"
256 REQUIRED_USE="${REQUIRED_USE} minimal? ( !extraengine !embedded )"
257 fi
258
259 REQUIRED_USE="
260 ${REQUIRED_USE} tcmalloc? ( !jemalloc ) jemalloc? ( !tcmalloc )
261 static? ( !ssl )"
262
263 #
264 # DEPENDENCIES:
265 #
266
267 # Be warned, *DEPEND are version-dependant
268 # These are used for both runtime and compiletime
269 # MULTILIB_USEDEP only set for libraries used by the client library
270 DEPEND="
271 ssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
272 kernel_linux? (
273 sys-process/procps:0=
274 dev-libs/libaio:0=
275 )
276 >=sys-apps/sed-4
277 >=sys-apps/texinfo-4.7-r1
278 !dev-db/mariadb-native-client[mysqlcompat]
279 jemalloc? ( dev-libs/jemalloc:0= )
280 tcmalloc? ( dev-util/google-perftools:0= )
281 systemtap? ( >=dev-util/systemtap-1.3:0= )
282 "
283
284 if [[ ${HAS_TOOLS_PATCH} ]] ; then
285 DEPEND+="
286 client-libs? (
287 ssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
288 >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
289 )
290 !client-libs? (
291 ssl? ( >=dev-libs/openssl-1.0.0:0=[static-libs?] )
292 >=sys-libs/zlib-1.2.3:0=[static-libs?]
293 )
294 tools? ( sys-libs/ncurses ) embedded? ( sys-libs/ncurses )
295 "
296 else
297 DEPEND+="
298 ssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
299 >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
300 sys-libs/ncurses[${MULTILIB_USEDEP}]
301 "
302 fi
303
304 ### Begin readline/libedit
305 ### If the world was perfect, we would use external libedit on both to have a similar experience
306 ### However libedit does not seem to support UTF-8 keyboard input
307
308 # dev-db/mysql-5.6.12+ only works with dev-libs/libedit
309 # mariadb 10.0.14 fixes libedit detection. changed to follow mysql
310 # This probably could be simplified
311 #if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && \
312 # mysql_version_is_at_least "5.6.12" ; then
313 # DEPEND="${DEPEND} dev-libs/libedit:0=[${MULTILIB_USEDEP}]"
314 #elif [[ ${PN} == "mysql-cluster" ]] && mysql_version_is_at_least "7.3"; then
315 # DEPEND="${DEPEND} dev-libs/libedit:0=[${MULTILIB_USEDEP}]"
316 #elif [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && \
317 # mysql_version_is_at_least "10.0.14" ; then
318 # DEPEND="${DEPEND} dev-libs/libedit:0=[${MULTILIB_USEDEP}]"
319 #else
320 # DEPEND="${DEPEND} !bindist? ( >=sys-libs/readline-4.1:0=[${MULTILIB_USEDEP}] )"
321 #fi
322
323 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
324 # Readline is only used for the command-line and embedded example
325 if [[ ${HAS_TOOLS_PATCH} ]] ; then
326 DEPEND="${DEPEND} !bindist? ( tools? ( >=sys-libs/readline-4.1:0= ) embedded? ( >=sys-libs/readline-4.1:0= ) )"
327 else
328 DEPEND="${DEPEND} !bindist? ( >=sys-libs/readline-4.1:0=[${MULTILIB_USEDEP}] )"
329 fi
330 fi
331
332 ### End readline/libedit
333
334 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] ; then
335 if mysql_version_is_at_least "5.7.6" ; then DEPEND="${DEPEND} >=dev-libs/boost-1.57.0:0=" ; else
336 mysql_version_is_at_least "5.7.5" && DEPEND="${DEPEND} >=dev-libs/boost-1.56.0:0="
337 fi
338 fi
339
340 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
341 # Bug 441700 MariaDB >=5.3 include custom mytop
342 if [[ ${HAS_TOOLS_PATCH} ]] ; then
343 DEPEND="${DEPEND} server? ( pam? ( virtual/pam:0= ) )"
344 else
345 DEPEND="${DEPEND} !minimal? ( pam? ( virtual/pam:0= ) )"
346 fi
347 DEPEND="${DEPEND}
348 oqgraph? ( >=dev-libs/boost-1.40.0:0= )
349 perl? ( !dev-db/mytop )"
350 if mysql_version_is_at_least "10.0.5" ; then
351 DEPEND="${DEPEND}
352 extraengine? (
353 odbc? ( dev-db/unixODBC:0= )
354 xml? ( dev-libs/libxml2:2= )
355 )
356 "
357 fi
358 mysql_version_is_at_least "10.0.7" && DEPEND="${DEPEND} oqgraph? ( dev-libs/judy:0= )"
359 mysql_version_is_at_least "10.0.9" && DEPEND="${DEPEND} >=dev-libs/libpcre-8.35:3="
360
361 mysql_version_is_at_least "10.1.1" && DEPEND="${DEPEND}
362 innodb-lz4? ( app-arch/lz4 )
363 innodb-lzo? ( dev-libs/lzo )
364 "
365
366 mysql_version_is_at_least "10.1.2" && DEPEND="${DEPEND} cracklib? ( sys-libs/cracklib:0= )"
367 fi
368
369 if [[ ${PN} == "percona-server" ]] ; then
370 if [[ ${HAS_TOOLS_PATCH} ]] ; then
371 DEPEND="${DEPEND} server? ( pam? ( virtual/pam:0= ) )"
372 else
373 DEPEND="${DEPEND} !minimal? ( pam? ( virtual/pam:0= ) )"
374 fi
375 fi
376
377 # Having different flavours at the same time is not a good idea
378 for i in "mysql" "mariadb" "mariadb-galera" "percona-server" "mysql-cluster" ; do
379 [[ ${i} == ${PN} ]] ||
380 DEPEND="${DEPEND} !dev-db/${i}"
381 done
382
383 if [[ ${PN} == "mysql-cluster" ]] ; then
384 # TODO: This really should include net-misc/memcached
385 # but the package does not install the files it seeks.
386 mysql_version_is_at_least "7.2.3" && \
387 DEPEND="${DEPEND} dev-libs/libevent:0="
388 fi
389
390 # prefix: first need to implement something for #196294
391 # TODO: check emul-linux-x86-db dep when it is multilib enabled
392 RDEPEND="${DEPEND}
393 selinux? ( sec-policy/selinux-mysql )
394 abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] )
395 "
396
397 if [[ ${HAS_TOOLS_PATCH} ]] ; then
398 RDEPEND="${RDEPEND}
399 server? ( !prefix? ( dev-db/mysql-init-scripts ) )
400 !client-libs? ( virtual/libmysqlclient )
401 !<virtual/mysql-5.6-r4"
402 else
403 RDEPEND="${RDEPEND} !minimal? ( !prefix? ( dev-db/mysql-init-scripts ) )"
404 fi
405
406 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
407 # Bug 455016 Add dependencies of mytop
408 RDEPEND="${RDEPEND} perl? (
409 virtual/perl-Getopt-Long
410 dev-perl/TermReadKey
411 virtual/perl-Term-ANSIColor
412 virtual/perl-Time-HiRes ) "
413 fi
414
415 # @ECLASS-VARIABLE: WSREP_REVISION
416 # @DEFAULT_UNSET
417 # @DESCRIPTION:
418 # Version of the sys-cluster/galera API (major version in portage) to use for galera clustering
419
420 if [[ -n "${WSREP_REVISION}" ]] ; then
421 # The wsrep API version must match between the ebuild and sys-cluster/galera.
422 # This will be indicated by WSREP_REVISION in the ebuild and the first number
423 # in the version of sys-cluster/galera
424 #
425 # lsof is required as of 5.5.38 and 10.0.11 for the rsync sst
426
427 GALERA_RDEPEND="sys-apps/iproute2
428 =sys-cluster/galera-${WSREP_REVISION}*
429 "
430 if [[ ${PN} == "mariadb" ]]; then
431 GALERA_RDEPEND="galera? ( ${GALERA_RDEPEND} )"
432 fi
433 RDEPEND="${RDEPEND} ${GALERA_RDEPEND}
434 sst-rsync? ( sys-process/lsof )
435 sst-xtrabackup? (
436 net-misc/socat[ssl]
437 )
438 "
439 # Causes a circular dependency if DBD-mysql is not already installed
440 PDEPEND="${PDEPEND} sst-xtrabackup? ( >=dev-db/xtrabackup-bin-2.2.4 )"
441 fi
442
443 if [[ ${PN} == "mysql-cluster" ]] ; then
444 mysql_version_is_at_least "7.2.9" && RDEPEND="${RDEPEND} java? ( >=virtual/jre-1.6 )" && \
445 DEPEND="${DEPEND} java? ( >=virtual/jdk-1.6 )"
446 fi
447
448 # compile-time-only
449 # ncurses only needs multilib for compile time due to a binary that will be not installed
450 DEPEND="${DEPEND}
451 virtual/yacc
452 static? ( sys-libs/ncurses[static-libs] )
453 >=dev-util/cmake-2.8.9
454 "
455
456 # Transition dep until all ebuilds have client-libs patch and USE
457 if ! [[ ${HAS_TOOLS_PATCH} ]] ; then
458 DEPEND="${DEPEND} sys-libs/ncurses[${MULTILIB_USEDEP}]"
459 fi
460
461 # For other stuff to bring us in
462 # dev-perl/DBD-mysql is needed by some scripts installed by MySQL
463 PDEPEND="${PDEPEND} perl? ( >=dev-perl/DBD-mysql-2.9004 )
464 ~virtual/mysql-${MYSQL_PV_MAJOR}"
465
466 # my_config.h includes ABI specific data
467 MULTILIB_WRAPPED_HEADERS=( /usr/include/mysql/my_config.h /usr/include/mysql/private/embedded_priv.h )
468
469 [[ ${PN} == "mysql-cluster" ]] && \
470 MULTILIB_WRAPPED_HEADERS+=( /usr/include/mysql/storage/ndb/ndb_types.h )
471
472 [[ ${PN} == "mariadb" ]] && mysql_version_is_at_least "10.1.1" && \
473 MULTILIB_WRAPPED_HEADERS+=( /usr/include/mysql/mysql_version.h )
474
475 #
476 # HELPER FUNCTIONS:
477 #
478
479 # @FUNCTION: mysql-multilib_disable_test
480 # @DESCRIPTION:
481 # Helper function to disable specific tests.
482 mysql-multilib_disable_test() {
483 mysql-cmake_disable_test "$@"
484 }
485
486 #
487 # EBUILD FUNCTIONS
488 #
489
490 # @FUNCTION: mysql-multilib_pkg_pretend
491 # @DESCRIPTION:
492 # Perform some basic tests and tasks during pkg_pretend phase:
493 mysql-multilib_pkg_pretend() {
494 if [[ ${MERGE_TYPE} != binary ]] ; then
495 if use_if_iuse tokudb && [[ $(gcc-major-version) -lt 4 || \
496 $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 7 ]] ; then
497 eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
498 eerror "Please use gcc-config to switch to gcc-4.7 or later version."
499 die
500 fi
501 fi
502 if use_if_iuse cluster && [[ "${PN}" != "mysql-cluster" ]]; then
503 die "NDB Cluster support has been removed from all packages except mysql-cluster"
504 fi
505 }
506
507 # @FUNCTION: mysql-multilib_pkg_setup
508 # @DESCRIPTION:
509 # Perform some basic tests and tasks during pkg_setup phase:
510 # die if FEATURES="test", USE="-minimal" and not using FEATURES="userpriv"
511 # create new user and group for mysql
512 # warn about deprecated features
513 mysql-multilib_pkg_setup() {
514
515 if has test ${FEATURES} ; then
516 if use_if_iuse minimal ; then
517 :
518 elif ! in_iuse server || use_if_iuse server ; then
519 if ! has userpriv ${FEATURES} ; then
520 eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
521 fi
522 fi
523 fi
524
525 # This should come after all of the die statements
526 enewgroup mysql 60 || die "problem adding 'mysql' group"
527 enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
528
529 if [[ ${PN} == "mysql-cluster" ]] ; then
530 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_setup
531 fi
532 }
533
534 # @FUNCTION: mysql-multilib_src_unpack
535 # @DESCRIPTION:
536 # Unpack the source code
537 mysql-multilib_src_unpack() {
538
539 # Initialize the proper variables first
540 mysql_init_vars
541
542 unpack ${A}
543 # Grab the patches
544 [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
545
546 mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}"
547 }
548
549 # @FUNCTION: mysql-multilib_src_prepare
550 # @DESCRIPTION:
551 # Apply patches to the source code and remove unneeded bundled libs.
552 mysql-multilib_src_prepare() {
553 mysql-cmake_src_prepare "$@"
554 if [[ ${PN} == "mysql-cluster" ]] ; then
555 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_src_prepare
556 fi
557 }
558
559
560 # @FUNCTION: mysql-multilib_src_configure
561 # @DESCRIPTION:
562 # Configure mysql to build the code for Gentoo respecting the use flags.
563 mysql-multilib_src_configure() {
564 # Bug #114895, bug #110149
565 filter-flags "-O" "-O[01]"
566
567 CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
568 CXXFLAGS="${CXXFLAGS} -felide-constructors"
569 # Causes linkage failures. Upstream bug #59607 removes it
570 if ! mysql_version_is_at_least "5.6" ; then
571 CXXFLAGS="${CXXFLAGS} -fno-implicit-templates"
572 fi
573 # As of 5.7, exceptions are used!
574 if ! mysql_version_is_at_least "5.7" ; then
575 CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
576 fi
577 export CXXFLAGS
578
579 # bug #283926, with GCC4.4, this is required to get correct behavior.
580 append-flags -fno-strict-aliasing
581
582 # bug 508724 mariadb cannot use ld.gold
583 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
584 tc-ld-disable-gold
585 fi
586
587 multilib-minimal_src_configure
588 }
589
590 multilib_src_configure() {
591
592 debug-print-function ${FUNCNAME} "$@"
593
594 CMAKE_BUILD_TYPE="RelWithDebInfo"
595
596 if ! multilib_is_native_abi && in_iuse client-libs ; then
597 if ! use client-libs ; then
598 ewarn "Skipping multilib build due to client-libs USE disabled"
599 return 0
600 fi
601 fi
602
603 # debug hack wrt #497532
604 mycmakeargs=(
605 -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
606 -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug "" "-DNDEBUG")"
607 -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr
608 -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql
609 -DSYSCONFDIR=${EPREFIX}/etc/mysql
610 -DINSTALL_BINDIR=bin
611 -DINSTALL_DOCDIR=share/doc/${PF}
612 -DINSTALL_DOCREADMEDIR=share/doc/${PF}
613 -DINSTALL_INCLUDEDIR=include/mysql
614 -DINSTALL_INFODIR=share/info
615 -DINSTALL_LIBDIR=$(get_libdir)
616 -DINSTALL_ELIBDIR=$(get_libdir)/mysql
617 -DINSTALL_MANDIR=share/man
618 -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql
619 -DINSTALL_MYSQLSHAREDIR=share/mysql
620 -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test
621 -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
622 -DINSTALL_SBINDIR=sbin
623 -DINSTALL_SCRIPTDIR=share/mysql/scripts
624 -DINSTALL_SQLBENCHDIR=share/mysql
625 -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql
626 -DWITH_COMMENT="Gentoo Linux ${PF}"
627 $(cmake-utils_use_with test UNIT_TESTS)
628 -DWITH_LIBEDIT=0
629 -DWITH_ZLIB=system
630 -DWITHOUT_LIBWRAP=1
631 -DENABLED_LOCAL_INFILE=1
632 -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock
633 -DINSTALL_UNIX_ADDRDIR=${EPREFIX}/var/run/mysqld/mysqld.sock
634 -DWITH_SSL=$(usex ssl system bundled)
635 -DWITH_DEFAULT_COMPILER_OPTIONS=0
636 -DWITH_DEFAULT_FEATURE_SET=0
637 )
638
639 if in_iuse client-libs ; then
640 mycmakeargs+=( -DWITHOUT_CLIENTLIBS=$(usex client-libs 0 1) )
641 fi
642
643 if in_iuse tools ; then
644 if multilib_is_native_abi ; then
645 mycmakeargs+=( -DWITHOUT_TOOLS=$(usex tools 0 1) )
646 else
647 mycmakeargs+=( -DWITHOUT_TOOLS=1 )
648 fi
649 fi
650
651 if in_iuse bindist ; then
652 # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
653 if multilib_is_native_abi; then
654 mycmakeargs+=(
655 -DWITH_READLINE=$(usex bindist 1 0)
656 -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
657 )
658 elif ! in_iuse client-libs ; then
659 mycmakeargs+=(
660 -DWITH_READLINE=1
661 -DNOT_FOR_DISTRIBUTION=0
662 )
663 fi
664 fi
665
666 ### TODO: make this system but issues with UTF-8 prevent it
667 mycmakeargs+=( -DWITH_EDITLINE=bundled )
668
669 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] && multilib_is_native_abi ; then
670 mycmakeargs+=(
671 -DWITH_JEMALLOC=$(usex jemalloc system)
672 )
673
674 mysql_version_is_at_least "10.0.9" && mycmakeargs+=( -DWITH_PCRE=system )
675 fi
676
677 configure_cmake_locale
678
679 if use_if_iuse minimal ; then
680 configure_cmake_minimal
681 elif in_iuse server ; then
682 if multilib_is_native_abi && use server ; then
683 configure_cmake_standard
684 else
685 configure_cmake_minimal
686 fi
687 else
688 if multilib_is_native_abi ; then
689 configure_cmake_standard
690 else
691 configure_cmake_minimal
692 fi
693 fi
694
695 # systemtap only works on native ABI bug 530132
696 if multilib_is_native_abi; then
697 mycmakeargs+=( $(cmake-utils_use_enable systemtap DTRACE) )
698 [[ ${MYSQL_CMAKE_NATIVE_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_NATIVE_DEFINES} )
699 else
700 mycmakeargs+=( -DENABLE_DTRACE=0 )
701 [[ ${MYSQL_CMAKE_NONNATIVE_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_NONNATIVE_DEFINES} )
702 fi
703
704 [[ ${MYSQL_CMAKE_EXTRA_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_EXTRA_DEFINES} )
705
706 # Always build NDB with mysql-cluster for libndbclient
707 [[ ${PN} == "mysql-cluster" ]] && mycmakeargs+=(
708 -DWITH_NDBCLUSTER=1 -DWITH_PARTITION_STORAGE_ENGINE=1
709 -DWITHOUT_PARTITION_STORAGE_ENGINE=0 )
710
711 cmake-utils_src_configure
712 }
713
714 mysql-multilib_src_compile() {
715 local _cmake_args=( "${@}" )
716
717 multilib-minimal_src_compile
718 }
719
720 multilib_src_compile() {
721 if ! multilib_is_native_abi && in_iuse client-libs ; then
722 if ! use client-libs ; then
723 ewarn "Skipping multilib build due to client-libs USE disabled"
724 return 0
725 fi
726 fi
727
728 cmake-utils_src_compile "${_cmake_args[@]}"
729 }
730
731
732 # @FUNCTION: mysql-multilib_src_install
733 # @DESCRIPTION:
734 # Install mysql.
735 mysql-multilib_src_install() {
736 if ! in_iuse client-libs || use_if_iuse client-libs ; then
737 # wrap the config script
738 MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config )
739 fi
740
741 if in_iuse client-libs && ! use client-libs ; then
742 multilib_foreach_abi multilib_src_install
743 else
744 multilib-minimal_src_install
745 fi
746 }
747
748 multilib_src_install() {
749 debug-print-function ${FUNCNAME} "$@"
750
751 if ! multilib_is_native_abi && in_iuse client-libs ; then
752 if ! use client-libs ; then
753 ewarn "Skipping multilib build due to client-libs USE disabled"
754 return 0
755 fi
756 fi
757
758 if multilib_is_native_abi; then
759 mysql-cmake_src_install
760 else
761 cmake-utils_src_install
762 if [[ "${PN}" == "mariadb" || "${PN}" == "mariadb-galera" ]] ; then
763 if use_if_iuse minimal ; then
764 :
765 elif use_if_iuse server || ! in_iuse server ; then
766 insinto /usr/include/mysql/private
767 doins "${S}"/sql/*.h
768 fi
769 fi
770 fi
771 }
772
773 # @FUNCTION: mysql-multilib_pkg_preinst
774 # @DESCRIPTION:
775 # Call java-pkg-opt-2 eclass when mysql-cluster is installed
776 mysql-multilib_pkg_preinst() {
777 debug-print-function ${FUNCNAME} "$@"
778
779 if [[ ${PN} == "mysql-cluster" ]] ; then
780 mysql_version_is_at_least "7.2.9" && java-pkg-opt-2_pkg_preinst
781 fi
782 }
783
784 # @FUNCTION: mysql-multilib_pkg_postinst
785 # @DESCRIPTION:
786 # Run post-installation tasks:
787 # create the dir for logfiles if non-existant
788 # touch the logfiles and secure them
789 # install scripts
790 # issue required steps for optional features
791 # issue deprecation warnings
792 mysql-multilib_pkg_postinst() {
793 debug-print-function ${FUNCNAME} "$@"
794
795 # Make sure the vars are correctly initialized
796 mysql_init_vars
797
798 # Check FEATURES="collision-protect" before removing this
799 [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
800
801 # Secure the logfiles
802 touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
803 chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
804 chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
805
806 # Minimal builds don't have the MySQL server
807 if use_if_iuse minimal ; then
808 :
809 elif ! in_iuse server || use_if_iuse server ; then
810 docinto "support-files"
811 for script in \
812 support-files/my-*.cnf \
813 support-files/magic \
814 support-files/ndb-config-2-node.ini
815 do
816 [[ -f "${script}" ]] \
817 && dodoc "${script}"
818 done
819
820 docinto "scripts"
821 for script in scripts/mysql* ; do
822 if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then
823 dodoc "${script}"
824 fi
825 done
826
827 if [[ ${PN} == "mariadb" || ${PN} == "mariadb-galera" ]] ; then
828 if use_if_iuse pam ; then
829 einfo
830 elog "This install includes the PAM authentication plugin."
831 elog "To activate and configure the PAM plugin, please read:"
832 elog "https://kb.askmonty.org/en/pam-authentication-plugin/"
833 einfo
834 fi
835 fi
836
837 einfo
838 elog "You might want to run:"
839 elog "\"emerge --config =${CATEGORY}/${PF}\""
840 elog "if this is a new install."
841 einfo
842
843 einfo
844 elog "If you are upgrading major versions, you should run the"
845 elog "mysql_upgrade tool."
846 einfo
847
848 if [[ ${PN} == "mariadb-galera" ]] ; then
849 einfo
850 elog "Be sure to edit the my.cnf file to activate your cluster settings."
851 elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
852 elog "The first time the cluster is activated, you should add"
853 elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
854 elog "This option should then be removed for subsequent starts."
855 einfo
856 fi
857 fi
858 }
859
860 # @FUNCTION: mysql-multilib_getopt
861 # @DESCRIPTION:
862 # Use my_print_defaults to extract specific config options
863 mysql-multilib_getopt() {
864 local mypd="${EROOT}"/usr/bin/my_print_defaults
865 section="$1"
866 flag="--${2}="
867 "${mypd}" $section | sed -n "/^${flag}/p"
868 }
869
870 # @FUNCTION: mysql-multilib_getoptval
871 # @DESCRIPTION:
872 # Use my_print_defaults to extract specific config options
873 mysql-multilib_getoptval() {
874 local mypd="${EROOT}"/usr/bin/my_print_defaults
875 section="$1"
876 flag="--${2}="
877 "${mypd}" $section | sed -n "/^${flag}/s,${flag},,gp"
878 }
879
880 # @FUNCTION: mysql-multilib_pkg_config
881 # @DESCRIPTION:
882 # Configure mysql environment.
883 mysql-multilib_pkg_config() {
884
885 debug-print-function ${FUNCNAME} "$@"
886
887 local old_MY_DATADIR="${MY_DATADIR}"
888 local old_HOME="${HOME}"
889 # my_print_defaults needs to read stuff in $HOME/.my.cnf
890 export HOME=${EPREFIX}/root
891
892 # Make sure the vars are correctly initialized
893 mysql_init_vars
894
895 [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
896 if [[ ${HAS_TOOLS_PATCH} ]] ; then
897 if ! built_with_use ${CATEGORY}/${PN} server ; then
898 die "Minimal builds do NOT include the MySQL server"
899 fi
900 else
901 if built_with_use ${CATEGORY}/${PN} minimal ; then
902 die "Minimal builds do NOT include the MySQL server"
903 fi
904 fi
905
906 if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
907 local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
908 MY_DATADIR_s="${MY_DATADIR_s%%/}"
909 local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
910 old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
911
912 if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
913 if [[ -d "${MY_DATADIR_s}" ]]; then
914 ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
915 ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
916 else
917 elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
918 mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
919 || die "Moving MY_DATADIR failed"
920 fi
921 else
922 ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
923 if [[ -d "${MY_DATADIR_s}" ]]; then
924 ewarn "Attempting to use ${MY_DATADIR_s}"
925 else
926 eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
927 die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
928 fi
929 fi
930 fi
931
932 local pwd1="a"
933 local pwd2="b"
934 local maxtry=15
935
936 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
937 MYSQL_ROOT_PASSWORD="$(mysql-multilib_getoptval 'client mysql' password)"
938 fi
939 MYSQL_TMPDIR="$(mysql-multilib_getoptval mysqld tmpdir)"
940 # These are dir+prefix
941 MYSQL_RELAY_LOG="$(mysql-multilib_getoptval mysqld relay-log)"
942 MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
943 MYSQL_LOG_BIN="$(mysql-multilib_getoptval mysqld log-bin)"
944 MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
945
946 if [[ ! -d "${ROOT}"/$MYSQL_TMPDIR ]]; then
947 einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
948 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR
949 fi
950 if [[ ! -d "${ROOT}"/$MYSQL_LOG_BIN ]]; then
951 einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
952 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN
953 fi
954 if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then
955 einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
956 install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG
957 fi
958
959 if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
960 ewarn "You have already a MySQL database in place."
961 ewarn "(${ROOT}/${MY_DATADIR}/*)"
962 ewarn "Please rename or delete it if you wish to replace it."
963 die "MySQL database already exists!"
964 fi
965
966 # Bug #213475 - MySQL _will_ object strenously if your machine is named
967 # localhost. Also causes weird failures.
968 [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
969
970 if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
971
972 einfo "Please provide a password for the mysql 'root' user now"
973 einfo "or through the ${HOME}/.my.cnf file."
974 ewarn "Avoid [\"'\\_%] characters in the password"
975 read -rsp " >" pwd1 ; echo
976
977 einfo "Retype the password"
978 read -rsp " >" pwd2 ; echo
979
980 if [[ "x$pwd1" != "x$pwd2" ]] ; then
981 die "Passwords are not the same"
982 fi
983 MYSQL_ROOT_PASSWORD="${pwd1}"
984 unset pwd1 pwd2
985 fi
986
987 local options
988 local sqltmp="$(emktemp)"
989
990 # Fix bug 446200. Don't reference host my.cnf, needs to come first,
991 # see http://bugs.mysql.com/bug.php?id=31312
992 use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
993
994 local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
995 [[ -r "${help_tables}" ]] \
996 && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
997 || touch "${TMPDIR}/fill_help_tables.sql"
998 help_tables="${TMPDIR}/fill_help_tables.sql"
999
1000 # Figure out which options we need to disable to do the setup
1001 helpfile="${TMPDIR}/mysqld-help"
1002 ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null
1003 for opt in grant-tables host-cache name-resolve networking slave-start \
1004 federated ssl log-bin relay-log slow-query-log external-locking \
1005 ndbcluster log-slave-updates \
1006 ; do
1007 optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1008 egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
1009 done
1010 # But some options changed names
1011 egrep -sq external-locking "${helpfile}" && \
1012 options="${options/skip-locking/skip-external-locking}"
1013
1014 use prefix || options="${options} --user=mysql"
1015
1016 # MySQL 5.6+ needs InnoDB
1017 if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] ; then
1018 mysql_version_is_at_least "5.6" || options="${options} --loose-skip-innodb"
1019 fi
1020
1021 einfo "Creating the mysql database and setting proper permissions on it ..."
1022
1023 # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
1024 PID_DIR="${EROOT}/var/run/mysqld"
1025 if [[ ! -d "${PID_DIR}" ]]; then
1026 mkdir -p "${PID_DIR}" || die "Could not create pid directory"
1027 chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
1028 chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
1029 fi
1030
1031 pushd "${TMPDIR}" &>/dev/null
1032 #cmd="'${EROOT}/usr/share/mysql/scripts/mysql_install_db' '--basedir=${EPREFIX}/usr' ${options}"
1033 cmd=${EROOT}usr/share/mysql/scripts/mysql_install_db
1034 [[ -f ${cmd} ]] || cmd=${EROOT}usr/bin/mysql_install_db
1035 cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${ROOT}/${MY_DATADIR}' '--tmpdir=${ROOT}/${MYSQL_TMPDIR}'"
1036 einfo "Command: $cmd"
1037 eval $cmd \
1038 >"${TMPDIR}"/mysql_install_db.log 2>&1
1039 if [ $? -ne 0 ]; then
1040 grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1041 die "Failed to run mysql_install_db. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1042 fi
1043 popd &>/dev/null
1044 [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1045 || die "MySQL databases not installed"
1046 chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
1047 chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
1048
1049 # Filling timezones, see
1050 # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1051 "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
1052
1053 if [[ -r "${help_tables}" ]] ; then
1054 cat "${help_tables}" >> "${sqltmp}"
1055 fi
1056
1057 local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1058 local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1059 local mysqld="${EROOT}/usr/sbin/mysqld \
1060 ${options} \
1061 $(use prefix || echo --user=mysql) \
1062 --log-warnings=0 \
1063 --basedir=${EROOT}/usr \
1064 --datadir=${ROOT}/${MY_DATADIR} \
1065 --max_allowed_packet=8M \
1066 --net_buffer_length=16K \
1067 --default-storage-engine=MyISAM \
1068 --socket=${socket} \
1069 --pid-file=${pidfile}
1070 --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
1071 #einfo "About to start mysqld: ${mysqld}"
1072 ebegin "Starting mysqld"
1073 einfo "Command ${mysqld}"
1074 ${mysqld} &
1075 rc=$?
1076 while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1077 maxtry=$((${maxtry}-1))
1078 echo -n "."
1079 sleep 1
1080 done
1081 eend $rc
1082
1083 if ! [[ -S "${socket}" ]]; then
1084 die "Completely failed to start up mysqld with: ${mysqld}"
1085 fi
1086
1087 ebegin "Setting root password"
1088 # Do this from memory, as we don't want clear text passwords in temp files
1089 local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'"
1090 "${EROOT}/usr/bin/mysql" \
1091 --socket=${socket} \
1092 -hlocalhost \
1093 -e "${sql}"
1094 eend $?
1095
1096 ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1097 "${EROOT}/usr/bin/mysql" \
1098 --socket=${socket} \
1099 -hlocalhost \
1100 -uroot \
1101 --password="${MYSQL_ROOT_PASSWORD}" \
1102 mysql < "${sqltmp}"
1103 rc=$?
1104 eend $?
1105 [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1106
1107 # Stop the server and cleanup
1108 einfo "Stopping the server ..."
1109 kill $(< "${pidfile}" )
1110 rm -f "${sqltmp}"
1111 wait %1
1112 einfo "Done"
1113 }

  ViewVC Help
Powered by ViewVC 1.1.20