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