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