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, 02 Nov 2017 14:01:50
Message-Id: 1509631145.77a8b6e70119d520e28c9b098395617bb6ac0a5b.grknight@gentoo
1 commit: 77a8b6e70119d520e28c9b098395617bb6ac0a5b
2 Author: Brian Evans <grknight <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 2 13:59:05 2017 +0000
4 Commit: Brian Evans <grknight <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 2 13:59:05 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=77a8b6e7
7
8 dev-db/mariadb: Version bump for 10.2.10
9
10 Package-Manager: Portage-2.3.13, Repoman-2.3.4
11
12 dev-db/mariadb/Manifest | 1 +
13 dev-db/mariadb/mariadb-10.2.10.ebuild | 971 ++++++++++++++++++++++++++++++++++
14 2 files changed, 972 insertions(+)
15
16 diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest
17 index 5433725ba0d..c880ad04625 100644
18 --- a/dev-db/mariadb/Manifest
19 +++ b/dev-db/mariadb/Manifest
20 @@ -4,6 +4,7 @@ DIST mariadb-10.0.33.tar.gz 69211872 SHA256 e3e3d583c51761aee2fcd0e51bfa7d592c12
21 DIST mariadb-10.1.24.tar.gz 61780687 SHA256 b3df99ae5b1ec8cf6cede4cbc4ae3f54ce66464549cba6d56d9ff4d24e4d551e SHA512 0b8d81b53f6866a81f33559ce57ebf956fec3ba25da0bd58c8bee3b2ecc00a6c370340000209d18463f84501d3ba35994b51ef99224616c37cd38d2fc87b73e9 WHIRLPOOL 91261a05e3d8b0cad925c382e0cf9a40fcfd3d35ae320c4a9860db110cb5655d1e1f992f9dea8987e50a07dd4a66aa42c9a3470a7acb3d0d706bcef7bc890122
22 DIST mariadb-10.1.26.tar.gz 61887132 SHA256 ba88b1cb9967dea2909938a34ba89373b162b0d83e5c98a0f1c94540156bf73d SHA512 a7505c579728b58eb6a92bdee1f5dfea5c10c8389cb7a31eb99fe2c6bc416593925cf9708d3dec91ede12eb4e232098a0833af2185bdd60bc593c89d255f3c0b WHIRLPOOL 8fe0c23f70b441a1f8d32d1fedcd033443641288ef1a20c49fbedfe6f5da95cb82125faa68f676fd68c441d4bf096101f364e1b3976f54229f5d9d0d10edbe21
23 DIST mariadb-10.1.28.tar.gz 67559689 SHA256 292dc8fff420c4bdaf3a2c3381ec3c99292965db2b09de0d7fec414c00032bbd SHA512 ca10d28f6b966719c7488c2b4ba928b65cbe9dc32ccf2a28d29c4d0c2d46ea1c59c3e339230017b317132dcd216925a71769dfba80a7d6321079c74ac41926d8 WHIRLPOOL d8ff24346a9e8ada4a9ec0ea8fd7657ff4972d43347afb7a9d7725293437ba70e0035c365738084b1e4828344861f000bd963260176524da2188c2c3a1389f67
24 +DIST mariadb-10.2.10.tar.gz 72388999 SHA256 5c7b83c4d2f7501ef9f187d8c97688a24fd3e53dc43bb388f8e1cead61a92fc2 SHA512 39c198009f8b19f4a08226ef9842b50e24636580b67c1c92d59c61cce3aa1edbd466e253c281dfcdfc58ab573ae9a59aaacb0ce3e8b82222043ddd849fc3e239 WHIRLPOOL b64e99254764556d6de947e254a45c5c2743d9e825ee109354b3101641048b3509dd26471abdb6f7b90f3a208ac7d2d13ad70cbb966e05ac49b26ef2ecb12e6e
25 DIST mariadb-10.2.9.tar.gz 70858881 SHA256 12e0a01c52591ee77cf0f940fe65df024457fa16c70f08c6116048d576096124 SHA512 11ba0913144d7298ffa4c0a0128a3d1525a39b8205ffc580311751cf25a4e86159e46a32d3c8330c4ea028cdd50643eb5381651df654751ca3e4fb3d4698a373 WHIRLPOOL dba0a8dfd5079b314ffc399e116abf8582bdaf51657dfe6e72247ab92da874aca97af4ca27dbcfdca5634c926598a853b7a8ecd8a61fee453c2764085a05b949
26 DIST mariadb-5.5.58.tar.gz 45784323 SHA256 26fdf8784a51e5d6f7624c0f4528433a6188065dd1bf92ef69e27db6b0a41002 SHA512 c5c8b52c613a1a3f30de2cd1d8e390f8110b0891af78ee2a24ef2c4b7b8c5f2e140970ca89865e8277e7486dbfd0ad01c1fdbf8791c67a9793392247d68fec63 WHIRLPOOL b507f3aaaced5da716de1a131dc4e69ace6f2ccd2ac58614d3d722b46b0b271ab0a452aef03b78d499b961f39a057ece5169f5af6fcce2e840aecd77ebf9295e
27 DIST mysql-extras-20160721-1526Z.tar.bz2 301788 SHA256 45198f8adb4a61fdd89a5d3c7966ce2fe9241381510e1f7b93e793502a32dfcb SHA512 c7450039780e4e2684c932ba7c291c1de25dd1a64e4c6e88aa13b790768b4100955f36ae4a3bf983569ea23b43be02da6dad3d5985c1163ec9e8aa91f0efd85d WHIRLPOOL becdf0d4d7b8b5a269246d2fcf1bc09c4313046468b264f07394ae9f1de2f736ad3fff8cad35e544df7a3623688050e6fb9635dfea3876ea082d19cf9fe88927
28
29 diff --git a/dev-db/mariadb/mariadb-10.2.10.ebuild b/dev-db/mariadb/mariadb-10.2.10.ebuild
30 new file mode 100644
31 index 00000000000..821eb9665f4
32 --- /dev/null
33 +++ b/dev-db/mariadb/mariadb-10.2.10.ebuild
34 @@ -0,0 +1,971 @@
35 +# Copyright 1999-2017 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 + -DWITH_WSREP=$(usex galera)
423 + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF)
424 + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF)
425 + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF)
426 + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO)
427 + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO)
428 + -DWITH_MARIABACKUP=$(usex backup ON OFF)
429 + -DWITH_LIBARCHIVE=$(usex backup ON OFF)
430 + -DINSTALL_SQLBENCHDIR=share/mariadb
431 + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO)
432 + # systemd is only linked to for server notification
433 + -DWITH_SYSTEMD=$(usex systemd yes no)
434 + -DWITH_NUMA=$(usex numa ON OFF)
435 + )
436 + if use test ; then
437 + # This is needed for the new client lib which tests a real, open server
438 + mycmakeargs+=( -DSKIP_TESTS=ON )
439 + fi
440 +
441 + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then
442 + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
443 + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
444 + ewarn "You MUST file bugs without these variables set."
445 +
446 + mycmakeargs+=(
447 + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
448 + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
449 + )
450 +
451 + elif ! use latin1 ; then
452 + mycmakeargs+=(
453 + -DDEFAULT_CHARSET=utf8
454 + -DDEFAULT_COLLATION=utf8_general_ci
455 + )
456 + else
457 + mycmakeargs+=(
458 + -DDEFAULT_CHARSET=latin1
459 + -DDEFAULT_COLLATION=latin1_swedish_ci
460 + )
461 + fi
462 + mycmakeargs+=(
463 + -DEXTRA_CHARSETS=all
464 + -DMYSQL_USER=mysql
465 + -DDISABLE_SHARED=$(usex static YES NO)
466 + -DWITH_DEBUG=$(usex debug)
467 + -DWITH_EMBEDDED_SERVER=$(usex embedded)
468 + -DWITH_PROFILING=$(usex profiling)
469 + )
470 +
471 + if use static; then
472 + mycmakeargs+=( -DWITH_PIC=1 )
473 + fi
474 +
475 + if use jemalloc || use tcmalloc ; then
476 + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF )
477 + fi
478 +
479 + # Storage engines
480 + mycmakeargs+=(
481 + -DWITH_ARCHIVE_STORAGE_ENGINE=1
482 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1
483 + -DWITH_CSV_STORAGE_ENGINE=1
484 + -DWITH_HEAP_STORAGE_ENGINE=1
485 + -DWITH_INNOBASE_STORAGE_ENGINE=1
486 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1
487 + -DWITH_MYISAM_STORAGE_ENGINE=1
488 + -DWITH_PARTITION_STORAGE_ENGINE=1
489 + )
490 +
491 + else
492 + mycmakeargs+=(
493 + -DWITHOUT_SERVER=1
494 + -DWITHOUT_EMBEDDED_SERVER=1
495 + -DEXTRA_CHARSETS=none
496 + -DINSTALL_SQLBENCHDIR=
497 + -DWITH_SYSTEMD=no
498 + )
499 + fi
500 +
501 + cmake-utils_src_configure
502 +}
503 +
504 +src_compile() {
505 + multilib-minimal_src_compile
506 +}
507 +
508 +multilib_src_compile() {
509 + cmake-utils_src_compile
510 +}
511 +
512 +src_install() {
513 + # headers with ABI specific data
514 + local MULTILIB_WRAPPED_HEADERS=(
515 + /usr/include/mysql/server/my_config.h
516 + /usr/include/mysql/server/private/embedded_priv.h
517 + /usr/include/mysql/server/mysql_version.h
518 + /usr/include/mariadb/mariadb_version.h
519 + /usr/include/mysql/mariadb_version.h
520 + /usr/include/mysql/server/private/probes_mysql_nodtrace.h
521 + /usr/include/mysql/server/private/probes_mysql_dtrace.h )
522 +
523 + # wrap the config scripts
524 + local MULTILIB_CHOST_TOOLS=( /usr/bin/mariadb_config /usr/bin/mysql_config )
525 + multilib-minimal_src_install
526 +}
527 +
528 +# Intentionally override eclass function
529 +multilib_src_install() {
530 + cmake-utils_src_install
531 +
532 + # Make sure the vars are correctly initialized
533 + mysql_init_vars
534 +
535 + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used
536 + if [[ -f "${D}/usr/include/mysql/server/private/config.h" ]] ; then
537 + rm "${D}/usr/include/mysql/server/private/config.h" || die
538 + fi
539 +
540 + if ! multilib_is_native_abi && use server ; then
541 + insinto /usr/include/mysql/server/private
542 + doins "${S}"/sql/*.h
543 + fi
544 +
545 + # Install compatible symlinks to libmysqlclient
546 +# use static-libs && dosym libmariadbclient.a "${EPREFIX}/usr/$(get_libdir)/libmysqlclient.a"
547 +# dosym libmariadb.so.3 "${EPREFIX}/usr/$(get_libdir)/libmysqlclient.so"
548 + dosym libmariadb.so.3 "${EPREFIX}/usr/$(get_libdir)/libmysqlclient.so.${SUBSLOT}"
549 +
550 + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
551 + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
552 +}
553 +
554 +multilib_src_install_all() {
555 + # Make sure the vars are correctly initialized
556 + mysql_init_vars
557 +
558 + # Convenience links
559 + einfo "Making Convenience links for mysqlcheck multi-call binary"
560 + dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
561 + dosym "mysqlcheck" "/usr/bin/mysqlrepair"
562 + dosym "mysqlcheck" "/usr/bin/mysqloptimize"
563 +
564 + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
565 + if [[ -d "${ED}/usr/data" ]] ; then
566 + rm -Rf "${ED}/usr/data" || die
567 + fi
568 +
569 + # Unless they explicitly specific USE=test, then do not install the
570 + # testsuite. It DOES have a use to be installed, esp. when you want to do a
571 + # validation of your database configuration after tuning it.
572 + if ! use test ; then
573 + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test"
574 + fi
575 +
576 + # Configuration stuff
577 + einfo "Building default configuration ..."
578 + insinto "${MY_SYSCONFDIR#${EPREFIX}}"
579 + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
580 + cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die
581 + eprefixify "${TMPDIR}/my.cnf"
582 + doins "${TMPDIR}/my.cnf"
583 + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d"
584 + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
585 + eprefixify "${TMPDIR}/50-distro-client.cnf"
586 + doins "${TMPDIR}/50-distro-client.cnf"
587 +
588 + if use server ; then
589 + mycnf_src="my.cnf.distro-server"
590 + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
591 + "${FILESDIR}/${mycnf_src}" \
592 + > "${TMPDIR}/my.cnf.ok" || die
593 + if use prefix ; then
594 + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
595 + "${TMPDIR}/my.cnf.ok" || die
596 + fi
597 + if use latin1 ; then
598 + sed -i \
599 + -e "/character-set/s|utf8|latin1|g" \
600 + "${TMPDIR}/my.cnf.ok" || die
601 + fi
602 + eprefixify "${TMPDIR}/my.cnf.ok"
603 + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
604 +
605 + einfo "Including support files and sample configurations"
606 + docinto "support-files"
607 + local script
608 + for script in \
609 + "${S}"/support-files/magic
610 + do
611 + [[ -f "$script" ]] && dodoc "${script}"
612 + done
613 +
614 + docinto "scripts"
615 + for script in "${S}"/scripts/mysql* ; do
616 + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}"
617 + done
618 + fi
619 +
620 + #Remove mytop if perl is not selected
621 + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
622 +}
623 +
624 +# Official test instructions:
625 +# USE='extraengine perl server static-libs' \
626 +# FEATURES='test userpriv -usersandbox' \
627 +# ebuild mariadb-X.X.XX.ebuild \
628 +# digest clean package
629 +multilib_src_test() {
630 +
631 + if ! multilib_is_native_abi ; then
632 + einfo "Server tests not available on non-native abi".
633 + return 0;
634 + fi
635 +
636 + _disable_test() {
637 + local rawtestname reason
638 + rawtestname="${1}" ; shift
639 + reason="${@}"
640 + ewarn "test '${rawtestname}' disabled: '${reason}'"
641 + echo ${rawtestname} : ${reason} >> "${T}/disabled.def"
642 + }
643 +
644 + local TESTDIR="${BUILD_DIR}/mysql-test"
645 + local retstatus_unit
646 + local retstatus_tests
647 +
648 + if ! use server ; then
649 + einfo "Skipping server tests due to minimal build."
650 + return 0
651 + fi
652 +
653 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
654 + # localhost. Also causes weird failures.
655 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
656 +
657 + if [[ $UID -eq 0 ]]; then
658 + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
659 + fi
660 + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox"
661 +
662 + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}"
663 +
664 + # Run CTest (test-units)
665 + cmake-utils_src_test
666 + retstatus_unit=$?
667 +
668 + # Ensure that parallel runs don't die
669 + export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
670 + # Enable parallel testing, auto will try to detect number of cores
671 + # You may set this by hand.
672 + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased
673 + export MTR_PARALLEL="${MTR_PARALLEL:-auto}"
674 +
675 + # create directories because mysqladmin might run out of order
676 + mkdir -p "${T}"/var-tests{,/log} || die
677 +
678 + # Run mysql tests
679 + pushd "${TESTDIR}" > /dev/null || die
680 +
681 + touch "${T}/disabled.def"
682 + # These are failing in MariaDB 10.0 for now and are believed to be
683 + # false positives:
684 + #
685 + # main.mysql_client_test, main.mysql_client_test_nonblock
686 + # main.mysql_client_test_comp:
687 + # segfaults at random under Portage only, suspect resource limits.
688 +
689 + local t
690 + for t in plugins.cracklib_password_check plugins.two_password_validations ; do
691 + _disable_test "$t" "False positive due to varying policies"
692 + done
693 +
694 + for t in main.mysql_client_test main.mysql_client_test_nonblock \
695 + main.mysql_client_test_comp ; do
696 + _disable_test "$t" "False positives in Gentoo"
697 + done
698 +
699 + # run mysql-test tests
700 + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
701 + retstatus_tests=$?
702 +
703 + popd > /dev/null || die
704 +
705 + # Cleanup is important for these testcases.
706 + pkill -9 -f "${S}/ndb" 2>/dev/null
707 + pkill -9 -f "${S}/sql" 2>/dev/null
708 +
709 + local failures=""
710 + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
711 + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
712 +
713 + [[ -z "$failures" ]] || die "Test failures: $failures"
714 + einfo "Tests successfully completed"
715 +}
716 +
717 +mysql_init_vars() {
718 + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"}
719 + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
720 + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
721 + MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
722 +
723 + if [[ -z "${MY_DATADIR}" ]] ; then
724 + MY_DATADIR=""
725 + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then
726 + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
727 + | sed -ne '/datadir/s|^--datadir=||p' \
728 + | tail -n1`
729 + if [[ -z "${MY_DATADIR}" ]] ; then
730 + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \
731 + | sed -e 's/.*=\s*//' \
732 + | tail -n1`
733 + fi
734 + fi
735 + if [[ -z "${MY_DATADIR}" ]] ; then
736 + MY_DATADIR="${MY_LOCALSTATEDIR}"
737 + einfo "Using default MY_DATADIR"
738 + fi
739 + elog "MySQL MY_DATADIR is ${MY_DATADIR}"
740 +
741 + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then
742 + if [[ -e "${MY_DATADIR}" ]] ; then
743 + # If you get this and you're wondering about it, see bug #207636
744 + elog "MySQL datadir found in ${MY_DATADIR}"
745 + elog "A new one will not be created."
746 + PREVIOUS_DATADIR="yes"
747 + else
748 + PREVIOUS_DATADIR="no"
749 + fi
750 + export PREVIOUS_DATADIR
751 + fi
752 + else
753 + if [[ ${EBUILD_PHASE} == "config" ]]; then
754 + local new_MY_DATADIR
755 + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \
756 + | sed -ne '/datadir/s|^--datadir=||p' \
757 + | tail -n1`
758 +
759 + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then
760 + ewarn "MySQL MY_DATADIR has changed"
761 + ewarn "from ${MY_DATADIR}"
762 + ewarn "to ${new_MY_DATADIR}"
763 + MY_DATADIR="${new_MY_DATADIR}"
764 + fi
765 + fi
766 + fi
767 +
768 + export MY_SHAREDSTATEDIR MY_SYSCONFDIR
769 + export MY_LOCALSTATEDIR MY_LOGDIR
770 + export MY_DATADIR
771 +}
772 +
773 +pkg_config() {
774 + _getoptval() {
775 + local mypd="${EROOT}"/usr/bin/my_print_defaults
776 + local section="$1"
777 + local flag="--${2}="
778 + local extra_options="${3}"
779 + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp"
780 + }
781 + local old_MY_DATADIR="${MY_DATADIR}"
782 + local old_HOME="${HOME}"
783 + # my_print_defaults needs to read stuff in $HOME/.my.cnf
784 + export HOME=${EPREFIX}/root
785 +
786 + # Make sure the vars are correctly initialized
787 + mysql_init_vars
788 +
789 + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR"
790 + if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then
791 + die "Minimal builds do NOT include the MySQL server"
792 + fi
793 +
794 + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then
795 + local MY_DATADIR_s="${ROOT}/${MY_DATADIR}"
796 + MY_DATADIR_s="${MY_DATADIR_s%%/}"
797 + local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}"
798 + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}"
799 +
800 + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then
801 + if [[ -d "${MY_DATADIR_s}" ]]; then
802 + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist"
803 + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}"
804 + else
805 + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}"
806 + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \
807 + || die "Moving MY_DATADIR failed"
808 + fi
809 + else
810 + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist"
811 + if [[ -d "${MY_DATADIR_s}" ]]; then
812 + ewarn "Attempting to use ${MY_DATADIR_s}"
813 + else
814 + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist"
815 + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}"
816 + fi
817 + fi
818 + fi
819 +
820 + local pwd1="a"
821 + local pwd2="b"
822 + local maxtry=15
823 +
824 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
825 + local tmp_mysqld_password_source=
826 +
827 + for tmp_mysqld_password_source in mysql client; do
828 + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
829 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
830 + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then
831 + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then
832 + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
833 + MYSQL_ROOT_PASSWORD=
834 + continue
835 + fi
836 +
837 + einfo "Found password in '${tmp_mysqld_password_source}' section!"
838 + break
839 + fi
840 + done
841 +
842 + # Sometimes --show is required to display passwords in some implementations of my_print_defaults
843 + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then
844 + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
845 + fi
846 +
847 + unset tmp_mysqld_password_source
848 + fi
849 + MYSQL_TMPDIR="$(_getoptval '--mysqld' tmpdir)"
850 + # These are dir+prefix
851 + MYSQL_RELAY_LOG="$(_getoptval '--mysqld' relay-log)"
852 + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
853 + MYSQL_LOG_BIN="$(_getoptval '--mysqld' log-bin)"
854 + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
855 +
856 + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then
857 + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR"
858 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR"
859 + fi
860 + if [[ ! -d "${ROOT}/$MYSQL_LOG_BIN" ]]; then
861 + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN"
862 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN"
863 + fi
864 + if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]]; then
865 + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG"
866 + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG"
867 + fi
868 +
869 + if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then
870 + ewarn "You have already a MySQL database in place."
871 + ewarn "(${ROOT}/${MY_DATADIR}/*)"
872 + ewarn "Please rename or delete it if you wish to replace it."
873 + die "MySQL database already exists!"
874 + fi
875 +
876 + # Bug #213475 - MySQL _will_ object strenously if your machine is named
877 + # localhost. Also causes weird failures.
878 + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
879 +
880 + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then
881 +
882 + einfo "Please provide a password for the mysql 'root' user now"
883 + einfo "or through the ${HOME}/.my.cnf file."
884 + ewarn "Avoid [\"'\\_%] characters in the password"
885 + read -rsp " >" pwd1 ; echo
886 +
887 + einfo "Retype the password"
888 + read -rsp " >" pwd2 ; echo
889 +
890 + if [[ "x$pwd1" != "x$pwd2" ]] ; then
891 + die "Passwords are not the same"
892 + fi
893 + MYSQL_ROOT_PASSWORD="${pwd1}"
894 + unset pwd1 pwd2
895 + fi
896 +
897 + local options
898 + local sqltmp="$(emktemp)"
899 +
900 + # Fix bug 446200. Don't reference host my.cnf, needs to come first,
901 + # see http://bugs.mysql.com/bug.php?id=31312
902 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'"
903 +
904 + # Figure out which options we need to disable to do the setup
905 + local helpfile="${TMPDIR}/mysqld-help"
906 + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
907 + for opt in grant-tables host-cache name-resolve networking slave-start \
908 + federated ssl log-bin relay-log slow-query-log external-locking \
909 + log-slave-updates \
910 + ; do
911 + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
912 + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}"
913 + done
914 +
915 + einfo "Creating the mysql database and setting proper permissions on it ..."
916 +
917 + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it
918 + PID_DIR="${EROOT}/var/run/mysqld"
919 + if [[ ! -d "${PID_DIR}" ]]; then
920 + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory"
921 + fi
922 +
923 + if [[ ! -d "${MY_DATADIR}" ]]; then
924 + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory"
925 + fi
926 +
927 + pushd "${TMPDIR}" &>/dev/null || die
928 +
929 + # Filling timezones, see
930 + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html
931 + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null
932 +
933 + local cmd=( "${EROOT}usr/share/mariadb/scripts/mysql_install_db" )
934 + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" )
935 + cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}/${MY_DATADIR}" "--tmpdir=${ROOT}/${MYSQL_TMPDIR}" )
936 + einfo "Command: ${cmd[*]}"
937 + su -s /bin/sh -c "${cmd[*]}" mysql \
938 + >"${TMPDIR}"/mysql_install_db.log 2>&1
939 + if [ $? -ne 0 ]; then
940 + grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2
941 + die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log"
942 + fi
943 + popd &>/dev/null || die
944 + [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \
945 + || die "MySQL databases not installed"
946 +
947 + use prefix || options="${options} --user=mysql"
948 +
949 + local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock"
950 + local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid"
951 + local mysqld="${EROOT}/usr/sbin/mysqld \
952 + ${options} \
953 + --log-warnings=0 \
954 + --basedir=${EROOT}/usr \
955 + --datadir=${ROOT}/${MY_DATADIR} \
956 + --max_allowed_packet=8M \
957 + --net_buffer_length=16K \
958 + --socket=${socket} \
959 + --pid-file=${pidfile}
960 + --tmpdir=${ROOT}/${MYSQL_TMPDIR}"
961 + #einfo "About to start mysqld: ${mysqld}"
962 + ebegin "Starting mysqld"
963 + einfo "Command ${mysqld}"
964 + ${mysqld} &
965 + rc=$?
966 + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do
967 + maxtry=$((${maxtry}-1))
968 + echo -n "."
969 + sleep 1
970 + done
971 + eend $rc
972 +
973 + if ! [[ -S "${socket}" ]]; then
974 + die "Completely failed to start up mysqld with: ${mysqld}"
975 + fi
976 +
977 + ebegin "Setting root password"
978 + # Do this from memory, as we don't want clear text passwords in temp files
979 + local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES"
980 + "${EROOT}/usr/bin/mysql" \
981 + "--socket=${socket}" \
982 + -hlocalhost \
983 + -e "${sql}"
984 + eend $?
985 +
986 + if [[ -n "${sqltmp}" ]] ; then
987 + ebegin "Loading \"zoneinfo\", this step may require a few seconds"
988 + "${EROOT}/usr/bin/mysql" \
989 + "--socket=${socket}" \
990 + -hlocalhost \
991 + -uroot \
992 + --password="${MYSQL_ROOT_PASSWORD}" \
993 + mysql < "${sqltmp}"
994 + rc=$?
995 + eend $?
996 + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!"
997 + fi
998 +
999 + # Stop the server and cleanup
1000 + einfo "Stopping the server ..."
1001 + kill $(< "${pidfile}" )
1002 + rm -f "${sqltmp}"
1003 + wait %1
1004 + einfo "Done"
1005 +}