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