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/mariadb/
Date: Thu, 27 Jul 2017 22:55:21
Message-Id: 1501196101.c3c4fce5e5171d4ec5ac6e6ec4e2ff84580ab107.grknight@gentoo
1 commit: c3c4fce5e5171d4ec5ac6e6ec4e2ff84580ab107
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jul 27 22:55:01 2017 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Thu Jul 27 22:55:01 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c3c4fce5
7
8 dev-db/mariadb: New revision which removes the mysql-multilib-r1 eclass
9
10 Package-Manager: Portage-2.3.6, Repoman-2.3.3
11
12 dev-db/mariadb/mariadb-10.2.7-r1.ebuild | 1062 +++++++++++++++++++++++++++++++
13 1 file changed, 1062 insertions(+)
14
15 diff --git a/dev-db/mariadb/mariadb-10.2.7-r1.ebuild b/dev-db/mariadb/mariadb-10.2.7-r1.ebuild
16 new file mode 100644
17 index 00000000000..2cfec9966ae
18 --- /dev/null
19 +++ b/dev-db/mariadb/mariadb-10.2.7-r1.ebuild
20 @@ -0,0 +1,1062 @@
21 +# Copyright 1999-2017 Gentoo Foundation
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +EAPI="6"
25 +MY_EXTRAS_VER="20170727-0052Z"
26 +# The wsrep API version must match between upstream WSREP and sys-cluster/galera major number
27 +WSREP_REVISION="25"
28 +SUBSLOT="18"
29 +MYSQL_PV_MAJOR="5.6"
30 +
31 +JAVA_PKG_OPT_USE="jdbc"
32 +
33 +# Keeping eutils in EAPI=6 for emktemp in pkg_config
34 +
35 +inherit eutils systemd flag-o-matic prefix toolchain-funcs \
36 + java-pkg-opt-2 user cmake-utils multilib-minimal
37 +
38 +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz "
39 +
40 +# Gentoo patches to MySQL
41 +if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then
42 + SRC_URI="${SRC_URI}
43 + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
44 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
45 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
46 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2
47 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2"
48 +fi
49 +
50 +HOMEPAGE="http://mariadb.org/"
51 +DESCRIPTION="An enhanced, drop-in replacement for MySQL"
52 +LICENSE="GPL-2 LGPL-2.1+"
53 +SLOT="0/${SUBSLOT:-0}"
54 +IUSE="+backup bindist cracklib debug embedded extraengine galera innodb-lz4
55 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 libressl mroonga
56 + odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx
57 + sst-rsync sst-xtrabackup static static-libs systemd systemtap tcmalloc
58 + test tokudb xml yassl"
59 +
60 +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests
61 +RESTRICT="!bindist? ( bindist ) libressl? ( test )"
62 +
63 +REQUIRED_USE="jdbc? ( extraengine server !static )
64 + server? ( tokudb? ( jemalloc !tcmalloc ) )
65 + !server? ( !extraengine !embedded )
66 + ?? ( tcmalloc jemalloc )
67 + static? ( yassl !pam )"
68 +
69 +# REMEMBER: also update eclass/mysql*.eclass before committing!
70 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris"
71 +
72 +# Shorten the path because the socket path length must be shorter than 107 chars
73 +# and we will run a mysql server during test phase
74 +S="${WORKDIR}/mysql"
75 +
76 +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then
77 + MY_PATCH_DIR="${WORKDIR}/mysql-extras"
78 +else
79 + MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}"
80 +fi
81 +
82 +PATCHES=(
83 + "${MY_PATCH_DIR}"/20015_all_mariadb-pkgconfig-location.patch
84 + "${MY_PATCH_DIR}"/20018_all_mariadb-10.2.7-without-clientlibs-tools.patch
85 + "${MY_PATCH_DIR}"/20024_all_mariadb-10.2.6-mysql_st-regression.patch
86 + "${MY_PATCH_DIR}"/20025_all_mariadb-10.2.6-gssapi-detect.patch
87 +)
88 +
89 +# Be warned, *DEPEND are version-dependant
90 +# These are used for both runtime and compiletime
91 +# MULTILIB_USEDEP only set for libraries used by the client library
92 +COMMON_DEPEND="
93 + kernel_linux? (
94 + sys-process/procps:0=
95 + dev-libs/libaio:0=
96 + )
97 + >=sys-apps/sed-4
98 + >=sys-apps/texinfo-4.7-r1
99 + !dev-db/mariadb-connector-c[mysqlcompat]
100 + jemalloc? ( dev-libs/jemalloc:0= )
101 + tcmalloc? ( dev-util/google-perftools:0= )
102 + systemtap? ( >=dev-util/systemtap-1.3:0= )
103 + !yassl? (
104 + !libressl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] )
105 + libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] )
106 + )
107 + >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?]
108 + sys-libs/ncurses:0=
109 + mroonga? ( app-text/groonga-normalizer-mysql )
110 + kerberos? ( virtual/krb5[${MULTILIB_USEDEP}] )
111 + !bindist? (
112 + sys-libs/binutils-libs:0=
113 + >=sys-libs/readline-4.1:0=
114 + )
115 + server? (
116 + backup? ( app-arch/libarchive:0= )
117 + cracklib? ( sys-libs/cracklib:0= )
118 + extraengine? (
119 + odbc? ( dev-db/unixODBC:0= )
120 + xml? ( dev-libs/libxml2:2= )
121 + )
122 + innodb-lz4? ( app-arch/lz4 )
123 + innodb-lzo? ( dev-libs/lzo )
124 + innodb-snappy? ( app-arch/snappy )
125 + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= )
126 + pam? ( virtual/pam:0= )
127 + systemd? ( sys-apps/systemd:= )
128 + tokudb? ( app-arch/snappy )
129 + )
130 + >=dev-libs/libpcre-8.35:3=
131 +"
132 +DEPEND="virtual/yacc
133 + static? ( sys-libs/ncurses[static-libs] )
134 + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
135 + server? ( extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) )
136 + ${COMMON_DEPEND}"
137 +RDEPEND="selinux? ( sec-policy/selinux-mysql )
138 + abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] )
139 + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
140 + server? ( !prefix? ( dev-db/mysql-init-scripts ) )
141 + !<virtual/mysql-5.6-r4
142 + ${COMMON_DEPEND}
143 + server? ( galera? (
144 + sys-apps/iproute2
145 + =sys-cluster/galera-${WSREP_REVISION}*
146 + sst-rsync? ( sys-process/lsof )
147 + sst-xtrabackup? ( net-misc/socat[ssl] )
148 + ) )
149 + perl? ( !dev-db/mytop
150 + virtual/perl-Getopt-Long
151 + dev-perl/TermReadKey
152 + virtual/perl-Term-ANSIColor
153 + virtual/perl-Time-HiRes )
154 + server? ( extraengine? ( jdbc? ( >=virtual/jre-1.6 ) ) )
155 +"
156 +# For other stuff to bring us in
157 +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
158 +# xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed
159 +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )
160 + server? ( ~virtual/mysql-${MYSQL_PV_MAJOR}[embedded=,static=] )
161 + virtual/libmysqlclient:${SLOT}[${MULTILIB_USEDEP},static-libs=]
162 + server? ( galera? ( sst-xtrabackup? ( || ( >=dev-db/xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) ) ) )"
163 +
164 +pkg_setup() {
165 + if [[ ${MERGE_TYPE} != binary ]] ; then
166 + local GCC_MAJOR_SET=$(gcc-major-version)
167 + local GCC_MINOR_SET=$(gcc-minor-version)
168 + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \
169 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
170 + eerror "${PN} with tokudb needs to be built with gcc-4.7 or later."
171 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
172 + die
173 + fi
174 + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on
175 + # non x86{,_64} arches
176 + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \
177 + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then
178 + eerror "${PN} needs to be built with gcc-4.7 or later."
179 + eerror "Please use gcc-config to switch to gcc-4.7 or later version."
180 + die
181 + fi
182 + fi
183 + java-pkg-opt-2_pkg_setup
184 + if has test ${FEATURES} && \
185 + use server && ! has userpriv ${FEATURES} ; then
186 + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
187 + fi
188 +
189 + # This should come after all of the die statements
190 + enewgroup mysql 60 || die "problem adding 'mysql' group"
191 + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user"
192 +}
193 +
194 +pkg_preinst() {
195 + java-pkg-opt-2_pkg_preinst
196 +
197 + # Here we need to see if the implementation switched client libraries
198 + # We check if this is a new instance of the package and a client library already exists
199 + local SHOW_ABI_MESSAGE libpath
200 + if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then
201 + libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so")
202 + elog "Due to ABI changes when switching between different client libraries,"
203 + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient."
204 + elog "Please run: revdep-rebuild --library ${libpath}"
205 + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries"
206 + fi
207 +}
208 +
209 +pkg_postinst() {
210 + # Make sure the vars are correctly initialized
211 + mysql_init_vars
212 +
213 + # Check FEATURES="collision-protect" before removing this
214 + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}"
215 +
216 + # Secure the logfiles
217 + touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err}
218 + chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql*
219 + chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql*
220 +
221 + # Minimal builds don't have the MySQL server
222 + if use server ; then
223 + docinto "support-files"
224 + dodoc support-files/magic
225 +
226 + docinto "scripts"
227 + for script in scripts/mysql* ; do
228 + if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then
229 + dodoc "${script}"
230 + fi
231 + done
232 +
233 + if use pam; then
234 + einfo
235 + elog "This install includes the PAM authentication plugin."
236 + elog "To activate and configure the PAM plugin, please read:"
237 + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/"
238 + einfo
239 + fi
240 +
241 + if [[ -z "${REPLACING_VERSIONS}" ]] ; then
242 + einfo
243 + elog "You might want to run:"
244 + elog "\"emerge --config =${CATEGORY}/${PF}\""
245 + elog "if this is a new install."
246 + elog
247 + elog "If you are switching server implentations, you should run the"
248 + elog "mysql_upgrade tool."
249 + einfo
250 + else
251 + einfo
252 + elog "If you are upgrading major versions, you should run the"
253 + elog "mysql_upgrade tool."
254 + einfo
255 + fi
256 +
257 + if use galera ; then
258 + einfo
259 + elog "Be sure to edit the my.cnf file to activate your cluster settings."
260 + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\""
261 + elog "The first time the cluster is activated, you should add"
262 + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node."
263 + elog "This option should then be removed for subsequent starts."
264 + einfo
265 + fi
266 + fi
267 +
268 + # Note about configuration change
269 + einfo
270 + elog "This version of mariadb reorganizes the configuration from a single my.cnf"
271 + elog "to several files in /etc/mysql/${PN}.d."
272 + elog "Please backup any changes you made to /etc/mysql/my.cnf"
273 + elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension."
274 + elog "You may have as many files as needed and they are read alphabetically."
275 + elog "Be sure the options have the appropitate section headers, i.e. [mysqld]."
276 + einfo
277 +}
278 +
279 +src_unpack() {
280 +
281 + # Initialize the proper variables first
282 + mysql_init_vars
283 +
284 + unpack ${A}
285 + # Grab the patches
286 + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack
287 +
288 + mv -f "${WORKDIR}/${P}" "${S}" || die
289 +}
290 +
291 +src_prepare() {
292 + java-pkg-opt-2_src_prepare
293 + if use tcmalloc; then
294 + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt"
295 + fi
296 +
297 + # Don't build bundled xz-utils for tokudb
298 + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die
299 + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die
300 + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die
301 +
302 + # Remove the bundled groonga
303 + # There is no CMake flag, it simply checks for existance
304 + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga"
305 +
306 + eapply "${PATCHES[@]}"
307 + eapply_user
308 +}
309 +
310 +src_configure(){
311 + # bug 508724 mariadb cannot use ld.gold
312 + tc-ld-disable-gold
313 + # Bug #114895, bug #110149
314 + filter-flags "-O" "-O[01]"
315 +
316 + append-cxxflags -felide-constructors
317 +
318 + # bug #283926, with GCC4.4, this is required to get correct behavior.
319 + append-flags -fno-strict-aliasing
320 +
321 + multilib-minimal_src_configure
322 +}
323 +
324 +multilib_src_configure() {
325 + debug-print-function ${FUNCNAME} "$@"
326 +
327 + CMAKE_BUILD_TYPE="RelWithDebInfo"
328 +
329 + # debug hack wrt #497532
330 + mycmakeargs=(
331 + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
332 + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
333 + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr"
334 + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
335 + -DSYSCONFDIR="${EPREFIX}/etc/mysql"
336 + -DINSTALL_BINDIR=bin
337 + -DINSTALL_DOCDIR=share/doc/${PF}
338 + -DINSTALL_DOCREADMEDIR=share/doc/${PF}
339 + -DINSTALL_INCLUDEDIR=include/mysql
340 + -DINSTALL_INFODIR=share/info
341 + -DINSTALL_LIBDIR=$(get_libdir)
342 + -DINSTALL_MANDIR=share/man
343 + -DINSTALL_MYSQLSHAREDIR=share/mariadb
344 + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin
345 + -DINSTALL_SCRIPTDIR=share/mariadb/scripts
346 + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
347 + -DINSTALL_SBINDIR=sbin
348 + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb"
349 + -DWITH_COMMENT="Gentoo Linux ${PF}"
350 + -DWITH_UNIT_TESTS=$(usex test ON OFF)
351 + -DWITH_LIBEDIT=0
352 + -DWITH_ZLIB=system
353 + -DWITHOUT_LIBWRAP=1
354 + -DENABLED_LOCAL_INFILE=1
355 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
356 + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock"
357 + -DWITH_DEFAULT_COMPILER_OPTIONS=0
358 + -DWITH_DEFAULT_FEATURE_SET=0
359 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)"
360 + -DENABLE_STATIC_LIBS=$(usex static-libs ON OFF)
361 + # The build forces this to be defined when cross-compiling. We pass it
362 + # all the time for simplicity and to make sure it is actually correct.
363 + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
364 + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)"
365 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
366 + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF)
367 + -DCONC_WITH_EXTERNAL_ZLIB=YES
368 + -DWITH_EXTERNAL_ZLIB=YES
369 + -DSUFFIX_INSTALL_DIR=""
370 + -DWITH_UNITTEST=OFF
371 + )
372 + if use test ; then
373 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test )
374 + else
375 + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
376 + fi
377 +
378 + if ! use yassl ; then
379 + mycmakeargs+=( -DWITH_SSL=system )
380 + else
381 + mycmakeargs+=( -DWITH_SSL=bundled )
382 + fi
383 +
384 + if ! multilib_is_native_abi ; then
385 + mycmakeargs+=( -DWITHOUT_TOOLS=1 )
386 + fi
387 +
388 + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION
389 + if multilib_is_native_abi; then
390 + mycmakeargs+=(
391 + -DWITH_READLINE=$(usex bindist 1 0)
392 + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1)
393 + )
394 + else
395 + mycmakeargs+=(
396 + -DWITH_READLINE=1
397 + -DNOT_FOR_DISTRIBUTION=0
398 + )
399 + fi
400 +
401 + if multilib_is_native_abi && use server ; then
402 +
403 + # Federated{,X} must be treated special otherwise they will not be built as plugins
404 + if ! use extraengine ; then
405 + mycmakeargs+=(
406 + -DPLUGIN_FEDERATED=NO
407 + -DPLUGIN_FEDERATEDX=NO )
408 + fi
409 +
410 + mycmakeargs+=(
411 + -DWITH_JEMALLOC=$(usex jemalloc system)
412 + -DWITH_PCRE=system
413 + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO)
414 + -DPLUGIN_SPHINX=$(usex sphinx YES NO)
415 + -DPLUGIN_TOKUDB=$(usex tokudb YES NO)
416 + -DPLUGIN_AUTH_PAM=$(usex pam YES NO)
417 + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO)
418 + -DPLUGIN_CASSANDRA=NO
419 + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO)
420 + -DPLUGIN_SPIDER=$(usex extraengine YES NO)
421 + -DPLUGIN_CONNECT=$(usex extraengine YES NO)
422 + -DCONNECT_WITH_MYSQL=1
423 + -DCONNECT_WITH_LIBXML2=$(usex xml)
424 + -DCONNECT_WITH_ODBC=$(usex odbc)
425 + -DCONNECT_WITH_JDBC=$(usex jdbc)
426 + -DWITH_WSREP=$(usex galera)
427 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
428 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
429 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
430 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
431 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
432 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
433 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
434 + -DINSTALL_SQLBENCHDIR=share/mariadb
435 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
436 + )
437 + if use test ; then
438 + # This is needed for the new client lib which tests a real, open server
439 + mycmakeargs+=( -DSKIP_TESTS=ON )
440 + fi
441 +
442 + # systemd is only linked to for server notification
443 + mycmakeargs+=( -DWITH_SYSTEMD=$(usex systemd) )
444 +
445 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
446 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
447 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
448 + ewarn "You MUST file bugs without these variables set."
449 +
450 + mycmakeargs+=(
451 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
452 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
453 + )
454 +
455 + elif ! use latin1 ; then
456 + mycmakeargs+=(
457 + -DDEFAULT_CHARSET=utf8
458 + -DDEFAULT_COLLATION=utf8_general_ci
459 + )
460 + else
461 + mycmakeargs+=(
462 + -DDEFAULT_CHARSET=latin1
463 + -DDEFAULT_COLLATION=latin1_swedish_ci
464 + )
465 + fi
466 + mycmakeargs+=(
467 + -DEXTRA_CHARSETS=all
468 + -DMYSQL_USER=mysql
469 + -DDISABLE_SHARED=$(usex static YES NO)
470 + -DWITH_DEBUG=$(usex debug)
471 + -DWITH_EMBEDDED_SERVER=$(usex embedded)
472 + -DWITH_PROFILING=$(usex profiling)
473 + )
474 +
475 + if use static; then
476 + mycmakeargs+=( -DWITH_PIC=1 )
477 + fi
478 +
479 + if use jemalloc || use tcmalloc ; then
480 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
481 + fi
482 +
483 + # Storage engines
484 + mycmakeargs+=(
485 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
486 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
487 + -DWITH_CSV_STORAGE_ENGINE=1
488 + -DWITH_HEAP_STORAGE_ENGINE=1
489 + -DWITH_INNOBASE_STORAGE_ENGINE=1
490 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
491 + -DWITH_MYISAM_STORAGE_ENGINE=1
492 + -DWITH_PARTITION_STORAGE_ENGINE=1
493 + )
494 +
495 + else
496 + mycmakeargs+=(
497 + -DWITHOUT_SERVER=1
498 + -DWITHOUT_EMBEDDED_SERVER=1
499 + -DEXTRA_CHARSETS=none
500 + -DINSTALL_SQLBENCHDIR=
501 + -DWITH_SYSTEMD=NO
502 + )
503 + fi
504 +
505 + # systemtap only works on native ABI bug 530132
506 + if multilib_is_native_abi; then
507 + mycmakeargs+=( -DENABLE_DTRACE=$(usex systemtap) )
508 + else
509 + mycmakeargs+=( -DENABLE_DTRACE=0 )
510 + fi
511 +
512 + cmake-utils_src_configure
513 +}
514 +
515 +src_compile() {
516 + multilib-minimal_src_compile
517 +}
518 +
519 +multilib_src_compile() {
520 + cmake-utils_src_compile
521 +}
522 +
523 +src_install() {
524 + # headers with ABI specific data
525 + local MULTILIB_WRAPPED_HEADERS=(
526 + /usr/include/mysql/my_config.h
527 + /usr/include/mysql/private/embedded_priv.h
528 + /usr/include/mysql/mysql_version.h
529 + /usr/include/mariadb/mariadb_version.h
530 + /usr/include/mysql/mariadb_version.h
531 + /usr/include/mysql/private/probes_mysql_nodtrace.h
532 + /usr/include/mysql/private/probes_mysql_dtrace.h )
533 +
534 + # wrap the config scripts
535 + local MULTILIB_CHOST_TOOLS=( /usr/bin/mariadb_config /usr/bin/mysql_config )
536 + multilib-minimal_src_install
537 +}
538 +
539 +# Intentionally override eclass function
540 +multilib_src_install() {
541 + cmake-utils_src_install
542 +
543 + # Make sure the vars are correctly initialized
544 + mysql_init_vars
545 +
546 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
547 + if [[ -f "${D}${MY_INCLUDEDIR}/private/config.h" ]] ; then
548 + rm "${D}${MY_INCLUDEDIR}/private/config.h" || die
549 + fi
550 +
551 + if ! multilib_is_native_abi && use server ; then
552 + insinto /usr/include/mysql/private
553 + doins "${S}"/sql/*.h
554 + fi
555 +
556 + # Install compatible symlinks to libmysqlclient
557 +# use static-libs && dosym libmariadbclient.a "${EPREFIX}/usr/$(get_libdir)/libmysqlclient.a"
558 +# dosym libmariadb.so.3 "${EPREFIX}/usr/$(get_libdir)/libmysqlclient.so"
559 + dosym libmariadb.so.3 "${EPREFIX}/usr/$(get_libdir)/libmysqlclient.so.${SUBSLOT}"
560 +
561 + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
562 + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
563 +}
564 +
565 +multilib_src_install_all() {
566 + # Make sure the vars are correctly initialized
567 + mysql_init_vars
568 +
569 + # Convenience links
570 + einfo "Making Convenience links for mysqlcheck multi-call binary"
571 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
572 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
573 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
574 +
575 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
576 + if [[ -d "${ED}/usr/data" ]] ; then
577 + rm -Rf "${ED}/usr/data" || die
578 + fi
579 +
580 + # Unless they explicitly specific USE=test, then do not install the
581 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
582 + # validation of your database configuration after tuning it.
583 + if ! use test ; then
584 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
585 + fi
586 +
587 + # Configuration stuff
588 + einfo "Building default configuration ..."
589 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
590 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
591 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
592 + eprefixify "${TMPDIR}/my.cnf"
593 + doins "${TMPDIR}/my.cnf"
594 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
595 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
596 + eprefixify "${TMPDIR}/50-distro-client.cnf"
597 + doins "${TMPDIR}/50-distro-client.cnf"
598 +
599 + if use server ; then
600 + mycnf_src="my.cnf.distro-server"
601 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
602 + "${FILESDIR}/${mycnf_src}" \
603 + > "${TMPDIR}/my.cnf.ok" || die
604 + if use prefix ; then
605 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
606 + "${TMPDIR}/my.cnf.ok" || die
607 + fi
608 + if use latin1 ; then
609 + sed -i \
610 + -e "/character-set/s|utf8|latin1|g" \
611 + "${TMPDIR}/my.cnf.ok" || die
612 + fi
613 + eprefixify "${TMPDIR}/my.cnf.ok"
614 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
615 + einfo "Creating initial directories"
616 + # Empty directories ...
617 + diropts "-m0750"
618 + if [[ "${PREVIOUS_DATADIR}" != "yes" ]] ; then
619 + dodir "${MY_DATADIR#${EPREFIX}}"
620 + keepdir "${MY_DATADIR#${EPREFIX}}"
621 + chown -R mysql:mysql "${D}/${MY_DATADIR}"
622 + fi
623 +
624 + diropts "-m0755"
625 + local folder
626 + for folder in "${MY_LOGDIR#${EPREFIX}}" ; do
627 + dodir "${folder}"
628 + keepdir "${folder}"
629 + chown -R mysql:mysql "${ED}/${folder}"
630 + done
631 +
632 + einfo "Including support files and sample configurations"
633 + docinto "support-files"
634 + local script
635 + for script in \
636 + "${S}"/support-files/magic
637 + do
638 + [[ -f "$script" ]] && dodoc "${script}"
639 + done
640 +
641 + docinto "scripts"
642 + for script in "${S}"/scripts/mysql* ; do
643 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
644 + done
645 + fi
646 +
647 + #Remove mytop if perl is not selected
648 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
649 +}
650 +
651 +# Official test instructions:
652 +# USE='embedded extraengine perl server static-libs' \
653 +# FEATURES='test userpriv -usersandbox' \
654 +# ebuild mariadb-X.X.XX.ebuild \
655 +# digest clean package
656 +multilib_src_test() {
657 +
658 + if ! multilib_is_native_abi ; then
659 + einfo "Server tests not available on non-native abi".
660 + return 0;
661 + fi
662 +
663 + _disable_test() {
664 +
665 + local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir
666 + rawtestname="${1}" ; shift
667 + reason="${@}"
668 + ewarn "test '${rawtestname}' disabled: '${reason}'"
669 +
670 + testsuite="${rawtestname/.*}"
671 + testname="${rawtestname/*.}"
672 + for mysql_disabled_file in \
673 + "${S}/mysql-test/disabled.def" \
674 + "${S}/mysql-test/t/disabled.def" ; do
675 + [[ -f ${mysql_disabled_file} ]] && break
676 + done
677 + #mysql_disabled_file="${S}/mysql-test/t/disabled.def"
678 + #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}"
679 + echo ${testname} : ${reason} >> "${mysql_disabled_file}"
680 +
681 + if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then
682 + for mysql_disabled_file in \
683 + "${S}/mysql-test/suite/${testsuite}/disabled.def" \
684 + "${S}/mysql-test/suite/${testsuite}/t/disabled.def" \
685 + FAILED ; do
686 + [[ -f ${mysql_disabled_file} ]] && break
687 + done
688 + if [[ ${mysql_disabled_file} != "FAILED" ]]; then
689 + echo "${testname} : ${reason}" >> "${mysql_disabled_file}"
690 + else
691 + for mysql_disabled_dir in \
692 + "${S}/mysql-test/suite/${testsuite}" \
693 + "${S}/mysql-test/suite/${testsuite}/t" \
694 + FAILED ; do
695 + [[ -d ${mysql_disabled_dir} ]] && break
696 + done
697 + if [[ ${mysql_disabled_dir} != "FAILED" ]]; then
698 + echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def"
699 + else
700 + ewarn "Could not find testsuite disabled.def location for ${rawtestname}"
701 + fi
702 + fi
703 + fi
704 + }
705 +
706 + local TESTDIR="${BUILD_DIR}/mysql-test"
707 + local retstatus_unit
708 + local retstatus_tests
709 +
710 + if ! use server ; then
711 + einfo "Skipping server tests due to minimal build."
712 + return 0
713 + fi
714 +
715 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
716 + # localhost. Also causes weird failures.
717 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
718 +
719 + if [[ $UID -eq 0 ]]; then
720 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
721 + fi
722 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
723 +
724 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
725 +
726 + # Run CTest (test-units)
727 + cmake-utils_src_test
728 + retstatus_unit=$?
729 +
730 + # Ensure that parallel runs don't die
731 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
732 + # Enable parallel testing, auto will try to detect number of cores
733 + # You may set this by hand.
734 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
735 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
736 +
737 + # create directories because mysqladmin might run out of order
738 + mkdir -p "${T}"/var-tests{,/log}
739 +
740 + # Run mysql tests
741 + pushd "${TESTDIR}" || die
742 +
743 + # These are failing in MariaDB 10.0 for now and are believed to be
744 + # false positives:
745 + #
746 + # main.mysql_client_test, main.mysql_client_test_nonblock
747 + # main.mysql_client_test_comp:
748 + # segfaults at random under Portage only, suspect resource limits.
749 +
750 + local t
751 + for t in plugins.cracklib_password_check plugins.two_password_validations ; do
752 + _disable_test "$t" "False positive due to varying policies"
753 + done
754 +
755 + for t in main.mysql_client_test main.mysql_client_test_nonblock \
756 + main.mysql_client_test_comp ; do
757 + _disable_test "$t" "False positives in Gentoo"
758 + done
759 +
760 + # run mysql-test tests
761 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder
762 + retstatus_tests=$?
763 +
764 + popd || die
765 +
766 + # Cleanup is important for these testcases.
767 + pkill -9 -f "${S}/ndb" 2>/dev/null
768 + pkill -9 -f "${S}/sql" 2>/dev/null
769 +
770 + local failures=""
771 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
772 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
773 +
774 + [[ -z "$failures" ]] || eerror "Test failures: $failures"
775 + einfo "Tests successfully completed"
776 +}
777 +
778 +mysql_init_vars() {
779 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
780 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
781 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
782 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
783 + MY_INCLUDEDIR=${MY_INCLUDEDIR="${EPREFIX}/usr/include/mysql"}
784 + MY_LIBDIR=${MY_LIBDIR="${EPREFIX}/usr/$(get_libdir)/mysql"}
785 +
786 + if [[ -z "${MY_DATADIR}" ]] ; then
787 + MY_DATADIR=""
788 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
789 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
790 + | sed -ne '/datadir/s|^--datadir=||p' \
791 + | tail -n1`
792 + if [[ -z "${MY_DATADIR}" ]] ; then
793 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
794 + | sed -e 's/.*=\s*//' \
795 + | tail -n1`
796 + fi
797 + fi
798 + if [[ -z "${MY_DATADIR}" ]] ; then
799 + MY_DATADIR="${MY_LOCALSTATEDIR}"
800 + einfo "Using default MY_DATADIR"
801 + fi
802 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
803 +
804 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
805 + if [[ -e "${MY_DATADIR}" ]] ; then
806 + # If you get this and you're wondering about it, see bug #207636
807 + elog "MySQL datadir found in ${MY_DATADIR}"
808 + elog "A new one will not be created."
809 + PREVIOUS_DATADIR="yes"
810 + else
811 + PREVIOUS_DATADIR="no"
812 + fi
813 + export PREVIOUS_DATADIR
814 + fi
815 + else
816 + if [[ ${EBUILD_PHASE} == "config" ]]; then
817 + local new_MY_DATADIR
818 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
819 + | sed -ne '/datadir/s|^--datadir=||p' \
820 + | tail -n1`
821 +
822 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
823 + ewarn "MySQL MY_DATADIR has changed"
824 + ewarn "from ${MY_DATADIR}"
825 + ewarn "to ${new_MY_DATADIR}"
826 + MY_DATADIR="${new_MY_DATADIR}"
827 + fi
828 + fi
829 + fi
830 +
831 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
832 + export MY_LIBDIR MY_LOCALSTATEDIR MY_LOGDIR
833 + export MY_INCLUDEDIR MY_DATADIR
834 +}
835 +
836 +pkg_config() {
837 + _getoptval() {
838 + local mypd="${EROOT}"/usr/bin/my_print_defaults
839 + local section="$1"
840 + local flag="--${2}="
841 + local extra_options="${3}"
842 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
843 + }
844 + local old_MY_DATADIR="${MY_DATADIR}"
845 + local old_HOME="${HOME}"
846 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
847 + export HOME=${EPREFIX}/root
848 +
849 + # Make sure the vars are correctly initialized
850 + mysql_init_vars
851 +
852 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
853 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
854 + die "Minimal builds do NOT include the MySQL server"
855 + fi
856 +
857 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
858 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
859 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
860 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
861 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
862 +
863 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
864 + if [[ -d "${MY_DATADIR_s}" ]]; then
865 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
866 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
867 + else
868 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
869 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
870 + || die "Moving MY_DATADIR failed"
871 + fi
872 + else
873 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
874 + if [[ -d "${MY_DATADIR_s}" ]]; then
875 + ewarn "Attempting to use ${MY_DATADIR_s}"
876 + else
877 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
878 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
879 + fi
880 + fi
881 + fi
882 +
883 + local pwd1="a"
884 + local pwd2="b"
885 + local maxtry=15
886 +
887 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
888 + local tmp_mysqld_password_source=
889 +
890 + for tmp_mysqld_password_source in mysql client; do
891 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
892 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
893 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
894 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
895 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
896 + MYSQL_ROOT_PASSWORD=
897 + continue
898 + fi
899 +
900 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
901 + break
902 + fi
903 + done
904 +
905 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
906 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
907 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
908 + fi
909 +
910 + unset tmp_mysqld_password_source
911 + fi
912 + MYSQL_TMPDIR="$(_getoptval '--mysqld' tmpdir)"
913 + # These are dir+prefix
914 + MYSQL_RELAY_LOG="$(_getoptval '--mysqld' relay-log)"
915 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
916 + MYSQL_LOG_BIN="$(_getoptval '--mysqld' log-bin)"
917 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
918 +
919 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
920 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
921 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
922 + fi
923 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
924 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
925 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
926 + fi
927 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
928 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
929 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
930 + fi
931 +
932 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
933 + ewarn "You have already a MySQL database in place."
934 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
935 + ewarn "Please rename or delete it if you wish to replace it."
936 + die "MySQL database already exists!"
937 + fi
938 +
939 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
940 + # localhost. Also causes weird failures.
941 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
942 +
943 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
944 +
945 + einfo "Please provide a password for the mysql 'root' user now"
946 + einfo "or through the ${HOME}/.my.cnf file."
947 + ewarn "Avoid [\"'\\_%] characters in the password"
948 + read -rsp " >" pwd1 ; echo
949 +
950 + einfo "Retype the password"
951 + read -rsp " >" pwd2 ; echo
952 +
953 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
954 + die "Passwords are not the same"
955 + fi
956 + MYSQL_ROOT_PASSWORD="${pwd1}"
957 + unset pwd1 pwd2
958 + fi
959 +
960 + local options
961 + local sqltmp="$(emktemp)"
962 +
963 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
964 + # see http://bugs.mysql.com/bug.php?id=31312
965 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
966 +
967 + local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql"
968 + [[ -r "${help_tables}" ]] \
969 + && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \
970 + || touch "${TMPDIR}/fill_help_tables.sql"
971 + help_tables="${TMPDIR}/fill_help_tables.sql"
972 +
973 + # Figure out which options we need to disable to do the setup
974 + local helpfile="${TMPDIR}/mysqld-help"
975 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
976 + for opt in grant-tables host-cache name-resolve networking slave-start \
977 + federated ssl log-bin relay-log slow-query-log external-locking \
978 + log-slave-updates \
979 + ; do
980 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
981 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
982 + done
983 + # But some options changed names
984 + egrep -sq external-locking "${helpfile}" && \
985 + options="${options/skip-locking/skip-external-locking}"
986 +
987 + use prefix || options="${options} --user=mysql"
988 +
989 + einfo "Creating the mysql database and setting proper permissions on it ..."
990 +
991 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
992 + PID_DIR="${EROOT}/var/run/mysqld"
993 + if [[ ! -d "${PID_DIR}" ]]; then
994 + mkdir -p "${PID_DIR}" || die "Could not create pid directory"
995 + chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory"
996 + chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory"
997 + fi
998 +
999 + pushd "${TMPDIR}" &>/dev/null
1000 +
1001 + # Filling timezones, see
1002 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
1003 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
1004 +
1005 + local cmd=( "${EROOT}usr/share/mysql/scripts/mysql_install_db" )
1006 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
1007 + if [[ -r "${help_tables}" ]] ; then
1008 + cat "${help_tables}" >> "${sqltmp}"
1009 + fi
1010 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
1011 + einfo "Command: ${cmd[*]}"
1012 + "${cmd[@]}" \
1013 + >"${TMPDIR}"/mysql_install_db.log 2>&1
1014 + if [ $? -ne 0 ]; then
1015 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
1016 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
1017 + fi
1018 + popd &>/dev/null
1019 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
1020 + || die "MySQL databases not installed"
1021 + chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null
1022 + chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null
1023 +
1024 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
1025 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
1026 + local mysqld="${EROOT}/usr/sbin/mysqld \
1027 + ${options} \
1028 + $(use prefix || echo --user=mysql) \
1029 + --log-warnings=0 \
1030 + --basedir=${EROOT}/usr \
1031 + --datadir=${ROOT}/${MY_DATADIR} \
1032 + --max_allowed_packet=8M \
1033 + --net_buffer_length=16K \
1034 + --default-storage-engine=MyISAM \
1035 + --socket=${socket} \
1036 + --pid-file=${pidfile}
1037 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
1038 + #einfo "About to start mysqld: ${mysqld}"
1039 + ebegin "Starting mysqld"
1040 + einfo "Command ${mysqld}"
1041 + ${mysqld} &
1042 + rc=$?
1043 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
1044 + maxtry=$((${maxtry}-1))
1045 + echo -n "."
1046 + sleep 1
1047 + done
1048 + eend $rc
1049 +
1050 + if ! [[ -S "${socket}" ]]; then
1051 + die "Completely failed to start up mysqld with: ${mysqld}"
1052 + fi
1053 +
1054 + ebegin "Setting root password"
1055 + # Do this from memory, as we don't want clear text passwords in temp files
1056 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
1057 + "${EROOT}/usr/bin/mysql" \
1058 + "--socket=${socket}" \
1059 + -hlocalhost \
1060 + -e "${sql}"
1061 + eend $?
1062 +
1063 + if [[ -n "${sqltmp}" ]] ; then
1064 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
1065 + "${EROOT}/usr/bin/mysql" \
1066 + "--socket=${socket}" \
1067 + -hlocalhost \
1068 + -uroot \
1069 + --password="${MYSQL_ROOT_PASSWORD}" \
1070 + mysql < "${sqltmp}"
1071 + rc=$?
1072 + eend $?
1073 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
1074 + fi
1075 +
1076 + # Stop the server and cleanup
1077 + einfo "Stopping the server ..."
1078 + kill $(< "${pidfile}" )
1079 + rm -f "${sqltmp}"
1080 + wait %1
1081 + einfo "Done"
1082 +}