1 |
commit: 9e2abd1b8a389deed8495e26a90a5a1f58a06936 |
2 |
Author: Brian Evans <grknight <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Aug 5 01:11:42 2018 +0000 |
4 |
Commit: Brian Evans <grknight <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Aug 5 01:15:07 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9e2abd1b |
7 |
|
8 |
dev-db/mysql: Version bump for 5.7.23 |
9 |
|
10 |
Package-Manager: Portage-2.3.44, Repoman-2.3.10 |
11 |
|
12 |
dev-db/mysql/Manifest | 1 + |
13 |
dev-db/mysql/mysql-5.7.23.ebuild | 845 +++++++++++++++++++++++++++++++++++++++ |
14 |
2 files changed, 846 insertions(+) |
15 |
|
16 |
diff --git a/dev-db/mysql/Manifest b/dev-db/mysql/Manifest |
17 |
index 4e692c4fc2f..94021f19b0e 100644 |
18 |
--- a/dev-db/mysql/Manifest |
19 |
+++ b/dev-db/mysql/Manifest |
20 |
@@ -5,6 +5,7 @@ DIST mysql-5.6.39.tar.gz 32110958 BLAKE2B 2f279c6745bc995c860bb4f2868409136e112c |
21 |
DIST mysql-5.6.40.tar.gz 32083035 BLAKE2B efcc078341bae239df28ac0504111aa34926885ae47edb5011352b56552a5a3abd1f824f8cbdc23d8d667592b8f5510946ef18c3efa61865dbbc7f4bb8a2d4a0 SHA512 c8e458b4cd34cae87f1b088ed2188bd00de8cdc42709d5964e82fa2e4aaecfc12a75ae006c54ffa0d3d286fbdef9704d0cbb83436437d5705fb8921d960e758c |
22 |
DIST mysql-5.6.41.tar.gz 32111985 BLAKE2B 5ccad59333525b354db4fa892857e237cddf8fe1a4d289c6e410c31d6142a71d3ce4dab8d954fa9932ec1f83b50e8eccd5845e082deaaa56f1c0c5e21b2ce6c0 SHA512 a62d7a68c6bb49de33f8c9e634bce53cb453a87238e92967115e8e928fa9ed291727b8bd5a5271a0b5b634d957eb310c745edfb14b6be1deb9099bb757aa2cff |
23 |
DIST mysql-boost-5.7.22.tar.gz 48985783 BLAKE2B 208d684e038366824de4bfbe87b6761f91d05fc5cd46cfa89eb627025fb726efe2d7a08a8ce252fed369e399d2d4921bb93c446a296b617320c53ce351fc17c2 SHA512 186c9e9735114e312c65531c70e6b0b9b48b0fe14384b7a6ebfac2c1f91c3f4ac223d06e27a424fc75f57e0aaf2f74d6a8411a8ab9c6fed45c499068d0f1dc2a |
24 |
+DIST mysql-boost-5.7.23.tar.gz 49025014 BLAKE2B 669f10779bc2cda866d6bd876b4efe55fb4b0c796f596f66513a3ca85f322e2a03e9879eecd72a69729a0cb71d408c46cdd9086ae456712b4adff6ae7c584c97 SHA512 e4317f89d108a68652cd95e41ffd670c37b6663aabd6af3985d18052fb7e8d8879b5822399caf9091cecc0a949ec588c121c87cfd60d69941f68d0ecbedd0953 |
25 |
DIST mysql-extras-20171121-1518Z.tar.bz2 313539 BLAKE2B c397fdf7ffb3fcbcecda20933e18234062a9500dcf4031e9b17131e2a1f23dca7535ed33ff541fc075eb9995c67a9a8fd7261d7524dd42d8d333543c368b4c15 SHA512 dd0d4a00c0ed710e786d157a73f02c6f555ab7a68e57014d958627096a4245a0b45d22ec860dc5389002d106554e80166661c0b6ddcadff1f737e3fa195badda |
26 |
DIST mysql-extras-20180214-0024Z.tar.bz2 316686 BLAKE2B a893e2975a8062ab236f642d158a7833656942adb31d467b784a9224e7dd87872c3784bb29e93b620a58cd9a835d65248f1a817cdbafa574b5949e2b4262108a SHA512 ad0e81695a70954ad107fe104f9140be24e53d499aed6c123e68e1a062ec5cc90c70f6272fdc014e567794e331301e656ba01b22c2c7a1afaf11e14a9190fb0b |
27 |
DIST mysql-extras-20180312-2011Z.tar.bz2 319047 BLAKE2B 1da22a0c763a85a6350122c0c56aef4999279c1ef7cf99bcec28348acc83964eb257bb4340c1a21bdcd3b1eb024b23fa62879bed8679c410d847324cb7e24b82 SHA512 b0aa9fc8fbc050451ef147cee99b00cf10d34a71641837821e78655241f7d79a94fe2efb4cef9a23fe9741e08ada2fc0b58ef3b3663752bc567babfbcaa547c8 |
28 |
|
29 |
diff --git a/dev-db/mysql/mysql-5.7.23.ebuild b/dev-db/mysql/mysql-5.7.23.ebuild |
30 |
new file mode 100644 |
31 |
index 00000000000..aad033f5ecc |
32 |
--- /dev/null |
33 |
+++ b/dev-db/mysql/mysql-5.7.23.ebuild |
34 |
@@ -0,0 +1,845 @@ |
35 |
+# Copyright 1999-2018 Gentoo Foundation |
36 |
+# Distributed under the terms of the GNU General Public License v2 |
37 |
+ |
38 |
+EAPI="6" |
39 |
+MY_EXTRAS_VER="20180804-2323Z" |
40 |
+ |
41 |
+CMAKE_MAKEFILE_GENERATOR=emake |
42 |
+ |
43 |
+# Keeping eutils in EAPI=6 for emktemp in pkg_config |
44 |
+ |
45 |
+inherit eutils flag-o-matic prefix toolchain-funcs \ |
46 |
+ user cmake-utils multilib-minimal |
47 |
+ |
48 |
+SRC_URI="http://cdn.mysql.com/Downloads/MySQL-5.7/${PN}-boost-${PV}.tar.gz |
49 |
+ https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-${PV}.tar.gz |
50 |
+ http://downloads.mysql.com/archives/MySQL-5.7/${PN}-boost-${PV}.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://www.mysql.com/" |
63 |
+DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" |
64 |
+LICENSE="GPL-2" |
65 |
+SLOT="0/18" |
66 |
+IUSE="client-libs cracklib debug jemalloc latin1 libressl numa +perl profiling selinux |
67 |
+ +server static static-libs systemtap tcmalloc test yassl" |
68 |
+ |
69 |
+# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests |
70 |
+RESTRICT="libressl? ( test )" |
71 |
+ |
72 |
+REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )" |
73 |
+ |
74 |
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" |
75 |
+ |
76 |
+# Shorten the path because the socket path length must be shorter than 107 chars |
77 |
+# and we will run a mysql server during test phase |
78 |
+S="${WORKDIR}/mysql" |
79 |
+ |
80 |
+if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then |
81 |
+ inherit git-r3 |
82 |
+ EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git" |
83 |
+ EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras" |
84 |
+ EGIT_CLONE_TYPE=shallow |
85 |
+ MY_PATCH_DIR="${WORKDIR}/mysql-extras" |
86 |
+else |
87 |
+ MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" |
88 |
+fi |
89 |
+ |
90 |
+PATCHES=( |
91 |
+ "${MY_PATCH_DIR}"/20001_all_fix-minimal-build-cmake-mysql-5.7.patch |
92 |
+ "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.7.patch |
93 |
+# "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.7.6.patch |
94 |
+ "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.7.10.patch |
95 |
+ "${MY_PATCH_DIR}"/20018_all_mysql-5.7.21-without-clientlibs-tools.patch |
96 |
+) |
97 |
+ |
98 |
+# Be warned, *DEPEND are version-dependant |
99 |
+# These are used for both runtime and compiletime |
100 |
+# MULTILIB_USEDEP only set for libraries used by the client library |
101 |
+COMMON_DEPEND=" |
102 |
+ kernel_linux? ( |
103 |
+ sys-process/procps:0= |
104 |
+ dev-libs/libaio:0= |
105 |
+ ) |
106 |
+ net-misc/curl |
107 |
+ >=sys-apps/sed-4 |
108 |
+ >=sys-apps/texinfo-4.7-r1 |
109 |
+ jemalloc? ( dev-libs/jemalloc:0= ) |
110 |
+ tcmalloc? ( dev-util/google-perftools:0= ) |
111 |
+ systemtap? ( >=dev-util/systemtap-1.3:0= ) |
112 |
+ !yassl? ( |
113 |
+ client-libs? ( |
114 |
+ !libressl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] ) |
115 |
+ libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] ) |
116 |
+ ) |
117 |
+ !client-libs? ( |
118 |
+ !libressl? ( >=dev-libs/openssl-1.0.0:0= ) |
119 |
+ libressl? ( dev-libs/libressl:0= ) |
120 |
+ ) |
121 |
+ ) |
122 |
+ client-libs? ( >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?] ) |
123 |
+ !client-libs? ( >=sys-libs/zlib-1.2.3:0= ) |
124 |
+ sys-libs/ncurses:0= |
125 |
+ server? ( |
126 |
+ >=app-arch/lz4-0_p131:= |
127 |
+ >=dev-libs/boost-1.65.0:= |
128 |
+ numa? ( sys-process/numactl ) |
129 |
+ ) |
130 |
+ !client-libs? ( dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] ) |
131 |
+" |
132 |
+DEPEND="virtual/yacc |
133 |
+ dev-libs/protobuf |
134 |
+ static? ( sys-libs/ncurses[static-libs] ) |
135 |
+ || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) |
136 |
+ ${COMMON_DEPEND}" |
137 |
+RDEPEND="selinux? ( sec-policy/selinux-mysql ) |
138 |
+ client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c dev-libs/protobuf:= ) |
139 |
+ !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster |
140 |
+ server? ( !prefix? ( dev-db/mysql-init-scripts ) ) |
141 |
+ ${COMMON_DEPEND} |
142 |
+" |
143 |
+# For other stuff to bring us in |
144 |
+# dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
145 |
+PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
146 |
+ |
147 |
+pkg_setup() { |
148 |
+ if [[ ${MERGE_TYPE} != binary ]] ; then |
149 |
+ local GCC_MAJOR_SET=$(gcc-major-version) |
150 |
+ local GCC_MINOR_SET=$(gcc-minor-version) |
151 |
+ # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on |
152 |
+ # non x86{,_64} arches |
153 |
+ if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \ |
154 |
+ ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then |
155 |
+ eerror "${PN} needs to be built with gcc-4.7 or later." |
156 |
+ eerror "Please use gcc-config to switch to gcc-4.7 or later version." |
157 |
+ die |
158 |
+ fi |
159 |
+ fi |
160 |
+ if has test ${FEATURES} && \ |
161 |
+ use server && ! has userpriv ${FEATURES} ; then |
162 |
+ eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
163 |
+ fi |
164 |
+ |
165 |
+ # This should come after all of the die statements |
166 |
+ enewgroup mysql 60 || die "problem adding 'mysql' group" |
167 |
+ enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" |
168 |
+} |
169 |
+ |
170 |
+pkg_preinst() { |
171 |
+ # Here we need to see if the implementation switched client libraries |
172 |
+ # We check if this is a new instance of the package and a client library already exists |
173 |
+ local SHOW_ABI_MESSAGE libpath |
174 |
+ if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then |
175 |
+ libpath=$(readlink "${EROOT}usr/$(get_libdir)/libmysqlclient.so") |
176 |
+ elog "Due to ABI changes when switching between different client libraries," |
177 |
+ elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." |
178 |
+ elog "Please run: revdep-rebuild --library ${libpath}" |
179 |
+ ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" |
180 |
+ fi |
181 |
+} |
182 |
+ |
183 |
+pkg_postinst() { |
184 |
+ # Make sure the vars are correctly initialized |
185 |
+ mysql_init_vars |
186 |
+ |
187 |
+ # Create log directory securely if it does not exist |
188 |
+ [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
189 |
+ |
190 |
+ if use server ; then |
191 |
+ if [[ -z "${REPLACING_VERSIONS}" ]] ; then |
192 |
+ einfo |
193 |
+ elog "You might want to run:" |
194 |
+ elog "\"emerge --config =${CATEGORY}/${PF}\"" |
195 |
+ elog "if this is a new install." |
196 |
+ elog |
197 |
+ elog "If you are switching server implentations, you should run the" |
198 |
+ elog "mysql_upgrade tool." |
199 |
+ einfo |
200 |
+ else |
201 |
+ einfo |
202 |
+ elog "If you are upgrading major versions, you should run the" |
203 |
+ elog "mysql_upgrade tool." |
204 |
+ einfo |
205 |
+ fi |
206 |
+ fi |
207 |
+ |
208 |
+ # Note about configuration change |
209 |
+ einfo |
210 |
+ elog "This version of mysql reorganizes the configuration from a single my.cnf" |
211 |
+ elog "to several files in /etc/mysql/${PN}.d." |
212 |
+ elog "Please backup any changes you made to /etc/mysql/my.cnf" |
213 |
+ elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension." |
214 |
+ elog "You may have as many files as needed and they are read alphabetically." |
215 |
+ elog "Be sure the options have the appropitate section headers, i.e. [mysqld]." |
216 |
+ einfo |
217 |
+} |
218 |
+ |
219 |
+src_unpack() { |
220 |
+ unpack ${A} |
221 |
+ # Grab the patches |
222 |
+ [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack |
223 |
+ |
224 |
+ mv -f "${WORKDIR}/${P}" "${S}" || die |
225 |
+} |
226 |
+ |
227 |
+src_prepare() { |
228 |
+ if use jemalloc ; then |
229 |
+ echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die |
230 |
+ fi |
231 |
+ if use tcmalloc; then |
232 |
+ echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die |
233 |
+ fi |
234 |
+ # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux |
235 |
+ if [[ -d "${S}/support-files/SELinux" ]] ; then |
236 |
+ echo > "${S}/support-files/SELinux/CMakeLists.txt" || die |
237 |
+ fi |
238 |
+ |
239 |
+ if use libressl ; then |
240 |
+ sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \ |
241 |
+ "${S}/cmake/ssl.cmake" || die |
242 |
+ fi |
243 |
+ |
244 |
+ sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die |
245 |
+ |
246 |
+ cmake-utils_src_prepare |
247 |
+} |
248 |
+ |
249 |
+src_configure(){ |
250 |
+ # bug 508724 mariadb cannot use ld.gold |
251 |
+ tc-ld-disable-gold |
252 |
+ # Bug #114895, bug #110149 |
253 |
+ filter-flags "-O" "-O[01]" |
254 |
+ |
255 |
+ append-cxxflags -felide-constructors |
256 |
+ |
257 |
+ # bug #283926, with GCC4.4, this is required to get correct behavior. |
258 |
+ append-flags -fno-strict-aliasing |
259 |
+ |
260 |
+ if use client-libs ; then |
261 |
+ multilib-minimal_src_configure |
262 |
+ else |
263 |
+ multilib_src_configure |
264 |
+ fi |
265 |
+} |
266 |
+ |
267 |
+multilib_src_configure() { |
268 |
+ debug-print-function ${FUNCNAME} "$@" |
269 |
+ |
270 |
+ if ! multilib_is_native_abi && ! use client-libs ; then |
271 |
+ return |
272 |
+ fi |
273 |
+ |
274 |
+ CMAKE_BUILD_TYPE="RelWithDebInfo" |
275 |
+ |
276 |
+ # debug hack wrt #497532 |
277 |
+ mycmakeargs=( |
278 |
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
279 |
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
280 |
+ -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" |
281 |
+ -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" |
282 |
+ -DSYSCONFDIR="${EPREFIX}/etc/mysql" |
283 |
+ -DINSTALL_BINDIR=bin |
284 |
+ -DINSTALL_DOCDIR=share/doc/${PF} |
285 |
+ -DINSTALL_DOCREADMEDIR=share/doc/${PF} |
286 |
+ -DINSTALL_INCLUDEDIR=include/mysql |
287 |
+ -DINSTALL_INFODIR=share/info |
288 |
+ -DINSTALL_LIBDIR=$(get_libdir) |
289 |
+ -DINSTALL_MANDIR=share/man |
290 |
+ -DINSTALL_MYSQLSHAREDIR=share/mysql |
291 |
+ -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin |
292 |
+ -DINSTALL_SCRIPTDIR=share/mysql/scripts |
293 |
+ -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" |
294 |
+ -DINSTALL_SBINDIR=sbin |
295 |
+ -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" |
296 |
+ -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" |
297 |
+ -DWITH_UNIT_TESTS=$(usex test ON OFF) |
298 |
+ ### TODO: make this system but issues with UTF-8 prevent it |
299 |
+ -DWITH_EDITLINE=bundled |
300 |
+ -DWITH_ZLIB=system |
301 |
+ -DWITH_LIBWRAP=0 |
302 |
+ -DENABLED_LOCAL_INFILE=1 |
303 |
+ -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" |
304 |
+ -DWITH_DEFAULT_COMPILER_OPTIONS=0 |
305 |
+ -DWITH_DEFAULT_FEATURE_SET=0 |
306 |
+ # The build forces this to be defined when cross-compiling. We pass it |
307 |
+ # all the time for simplicity and to make sure it is actually correct. |
308 |
+ -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) |
309 |
+ -DWITH_RAPID=OFF |
310 |
+ -DWITH_LIBEVENT=NO |
311 |
+ -DWITH_CURL=system |
312 |
+ -DWITH_BOOST="${S}/boost" |
313 |
+ -DWITH_PROTOBUF=system |
314 |
+ ) |
315 |
+ if use test ; then |
316 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) |
317 |
+ else |
318 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) |
319 |
+ fi |
320 |
+ |
321 |
+ if ! use yassl ; then |
322 |
+ mycmakeargs+=( -DWITH_SSL=system ) |
323 |
+ else |
324 |
+ mycmakeargs+=( -DWITH_SSL=bundled ) |
325 |
+ fi |
326 |
+ |
327 |
+ if ! use client-libs ; then |
328 |
+ mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) |
329 |
+ fi |
330 |
+ |
331 |
+ # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION |
332 |
+ # systemtap only works on native ABI bug 530132 |
333 |
+ if multilib_is_native_abi; then |
334 |
+ mycmakeargs+=( |
335 |
+ -DENABLE_DTRACE=$(usex systemtap) |
336 |
+ ) |
337 |
+ else |
338 |
+ mycmakeargs+=( |
339 |
+ -DWITHOUT_TOOLS=1 |
340 |
+ -DWITH_READLINE=1 |
341 |
+ -DENABLE_DTRACE=0 |
342 |
+ ) |
343 |
+ fi |
344 |
+ |
345 |
+ if multilib_is_native_abi && use server ; then |
346 |
+ |
347 |
+ mycmakeargs+=( |
348 |
+ -DWITH_LZ4=system |
349 |
+ -DWITH_NUMA=$(usex numa ON OFF) |
350 |
+ ) |
351 |
+ |
352 |
+ if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then |
353 |
+ ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" |
354 |
+ ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." |
355 |
+ ewarn "You MUST file bugs without these variables set." |
356 |
+ |
357 |
+ mycmakeargs+=( |
358 |
+ -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} |
359 |
+ -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} |
360 |
+ ) |
361 |
+ |
362 |
+ elif ! use latin1 ; then |
363 |
+ mycmakeargs+=( |
364 |
+ -DDEFAULT_CHARSET=utf8 |
365 |
+ -DDEFAULT_COLLATION=utf8_general_ci |
366 |
+ ) |
367 |
+ else |
368 |
+ mycmakeargs+=( |
369 |
+ -DDEFAULT_CHARSET=latin1 |
370 |
+ -DDEFAULT_COLLATION=latin1_swedish_ci |
371 |
+ ) |
372 |
+ fi |
373 |
+ mycmakeargs+=( |
374 |
+ -DEXTRA_CHARSETS=all |
375 |
+ -DDISABLE_SHARED=$(usex static YES NO) |
376 |
+ -DWITH_DEBUG=$(usex debug) |
377 |
+ -DWITH_EMBEDDED_SERVER=OFF |
378 |
+ -DENABLED_PROFILING=$(usex profiling) |
379 |
+ ) |
380 |
+ |
381 |
+ if use static; then |
382 |
+ mycmakeargs+=( -DWITH_PIC=1 ) |
383 |
+ fi |
384 |
+ |
385 |
+ # Storage engines |
386 |
+ mycmakeargs+=( |
387 |
+ -DWITH_EXAMPLE_STORAGE_ENGINE=0 |
388 |
+ -DWITH_ARCHIVE_STORAGE_ENGINE=1 |
389 |
+ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 |
390 |
+ -DWITH_CSV_STORAGE_ENGINE=1 |
391 |
+ -DWITH_HEAP_STORAGE_ENGINE=1 |
392 |
+ -DWITH_INNOBASE_STORAGE_ENGINE=1 |
393 |
+ -DWITH_MYISAMMRG_STORAGE_ENGINE=1 |
394 |
+ -DWITH_MYISAM_STORAGE_ENGINE=1 |
395 |
+ -DWITH_PARTITION_STORAGE_ENGINE=1 |
396 |
+ -DWITH_INNODB_MEMCACHED=0 |
397 |
+ ) |
398 |
+ |
399 |
+ else |
400 |
+ mycmakeargs+=( |
401 |
+ -DWITHOUT_SERVER=1 |
402 |
+ -DWITH_EMBEDDED_SERVER=OFF |
403 |
+ -DEXTRA_CHARSETS=none |
404 |
+ ) |
405 |
+ fi |
406 |
+ |
407 |
+ cmake-utils_src_configure |
408 |
+} |
409 |
+ |
410 |
+src_compile() { |
411 |
+ if use client-libs ; then |
412 |
+ multilib-minimal_src_compile |
413 |
+ else |
414 |
+ multilib_src_compile |
415 |
+ fi |
416 |
+} |
417 |
+ |
418 |
+multilib_src_compile() { |
419 |
+ cmake-utils_src_compile |
420 |
+} |
421 |
+ |
422 |
+src_install() { |
423 |
+ local MULTILIB_WRAPPED_HEADERS |
424 |
+ local MULTILIB_CHOST_TOOLS |
425 |
+ if use client-libs ; then |
426 |
+ # headers with ABI specific data |
427 |
+ MULTILIB_WRAPPED_HEADERS=( |
428 |
+ /usr/include/mysql/server/my_config.h |
429 |
+ /usr/include/mysql/server/mysql_version.h ) |
430 |
+ |
431 |
+ # wrap the config scripts |
432 |
+ MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config ) |
433 |
+ multilib-minimal_src_install |
434 |
+ else |
435 |
+ multilib_src_install |
436 |
+ multilib_src_install_all |
437 |
+ fi |
438 |
+} |
439 |
+ |
440 |
+# Intentionally override eclass function |
441 |
+multilib_src_install() { |
442 |
+ |
443 |
+ cmake-utils_src_install |
444 |
+ |
445 |
+ # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. |
446 |
+ find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die |
447 |
+} |
448 |
+ |
449 |
+multilib_src_install_all() { |
450 |
+ # Make sure the vars are correctly initialized |
451 |
+ mysql_init_vars |
452 |
+ |
453 |
+ # Convenience links |
454 |
+ einfo "Making Convenience links for mysqlcheck multi-call binary" |
455 |
+ dosym "mysqlcheck" "/usr/bin/mysqlanalyze" |
456 |
+ dosym "mysqlcheck" "/usr/bin/mysqlrepair" |
457 |
+ dosym "mysqlcheck" "/usr/bin/mysqloptimize" |
458 |
+ |
459 |
+ # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir |
460 |
+ if [[ -d "${ED}/usr/data" ]] ; then |
461 |
+ rm -Rf "${ED}/usr/data" || die |
462 |
+ fi |
463 |
+ |
464 |
+ # Unless they explicitly specific USE=test, then do not install the |
465 |
+ # testsuite. It DOES have a use to be installed, esp. when you want to do a |
466 |
+ # validation of your database configuration after tuning it. |
467 |
+ if ! use test ; then |
468 |
+ rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" |
469 |
+ fi |
470 |
+ |
471 |
+ # Configuration stuff |
472 |
+ einfo "Building default configuration ..." |
473 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}" |
474 |
+ [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf |
475 |
+ cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die |
476 |
+ eprefixify "${TMPDIR}/my.cnf" |
477 |
+ doins "${TMPDIR}/my.cnf" |
478 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" |
479 |
+ cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die |
480 |
+ eprefixify "${TMPDIR}/50-distro-client.cnf" |
481 |
+ doins "${TMPDIR}/50-distro-client.cnf" |
482 |
+ |
483 |
+ if use server ; then |
484 |
+ mycnf_src="my.cnf.distro-server" |
485 |
+ sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ |
486 |
+ "${FILESDIR}/${mycnf_src}" \ |
487 |
+ > "${TMPDIR}/my.cnf.ok" || die |
488 |
+ if use prefix ; then |
489 |
+ sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ |
490 |
+ "${TMPDIR}/my.cnf.ok" || die |
491 |
+ fi |
492 |
+ if use latin1 ; then |
493 |
+ sed -i \ |
494 |
+ -e "/character-set/s|utf8|latin1|g" \ |
495 |
+ "${TMPDIR}/my.cnf.ok" || die |
496 |
+ fi |
497 |
+ eprefixify "${TMPDIR}/my.cnf.ok" |
498 |
+ newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf |
499 |
+ |
500 |
+ einfo "Including support files and sample configurations" |
501 |
+ docinto "support-files" |
502 |
+ local script |
503 |
+ for script in \ |
504 |
+ "${S}"/support-files/magic |
505 |
+ do |
506 |
+ [[ -f "$script" ]] && dodoc "${script}" |
507 |
+ done |
508 |
+ |
509 |
+ docinto "scripts" |
510 |
+ for script in "${S}"/scripts/mysql* ; do |
511 |
+ [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}" |
512 |
+ done |
513 |
+ fi |
514 |
+ |
515 |
+ #Remove mytop if perl is not selected |
516 |
+ [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" |
517 |
+} |
518 |
+ |
519 |
+# Official test instructions: |
520 |
+# USE='perl server' \ |
521 |
+# FEATURES='test userpriv -usersandbox' \ |
522 |
+# ebuild mysql-X.X.XX.ebuild \ |
523 |
+# digest clean package |
524 |
+src_test() { |
525 |
+ |
526 |
+ _disable_test() { |
527 |
+ local rawtestname reason |
528 |
+ rawtestname="${1}" ; shift |
529 |
+ reason="${@}" |
530 |
+ ewarn "test '${rawtestname}' disabled: '${reason}'" |
531 |
+ echo ${rawtestname} : ${reason} >> "${T}/disabled.def" |
532 |
+ } |
533 |
+ |
534 |
+ local TESTDIR="${BUILD_DIR}/mysql-test" |
535 |
+ local retstatus_unit |
536 |
+ local retstatus_tests |
537 |
+ |
538 |
+ if ! use server ; then |
539 |
+ einfo "Skipping server tests due to minimal build." |
540 |
+ return 0 |
541 |
+ fi |
542 |
+ |
543 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
544 |
+ # localhost. Also causes weird failures. |
545 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
546 |
+ |
547 |
+ if [[ $UID -eq 0 ]]; then |
548 |
+ die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
549 |
+ fi |
550 |
+ has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox" |
551 |
+ |
552 |
+ einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" |
553 |
+ |
554 |
+ # Run CTest (test-units) |
555 |
+ cmake-utils_src_test |
556 |
+ retstatus_unit=$? |
557 |
+ |
558 |
+ # Ensure that parallel runs don't die |
559 |
+ export MTR_BUILD_THREAD="$((${RANDOM} % 100))" |
560 |
+ # Enable parallel testing, auto will try to detect number of cores |
561 |
+ # You may set this by hand. |
562 |
+ # The default maximum is 8 unless MTR_MAX_PARALLEL is increased |
563 |
+ export MTR_PARALLEL="${MTR_PARALLEL:-auto}" |
564 |
+ |
565 |
+ # create directories because mysqladmin might run out of order |
566 |
+ mkdir -p "${T}"/var-tests{,/log} || die |
567 |
+ |
568 |
+ # Run mysql tests |
569 |
+ pushd "${TESTDIR}" > /dev/null || die |
570 |
+ |
571 |
+ touch "${T}/disabled.def" |
572 |
+ # These are failing in MySQL 5.7 for now and are believed to be |
573 |
+ # false positives: |
574 |
+ # |
575 |
+ local t |
576 |
+ |
577 |
+ for t in auth_sec.keyring_udf federated.federated_plugin ; do |
578 |
+ _disable_test "$t" "False positives in Gentoo" |
579 |
+ done |
580 |
+ |
581 |
+ # run mysql-test tests |
582 |
+ perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" |
583 |
+ retstatus_tests=$? |
584 |
+ |
585 |
+ popd > /dev/null || die |
586 |
+ |
587 |
+ # Cleanup is important for these testcases. |
588 |
+ pkill -9 -f "${S}/ndb" 2>/dev/null |
589 |
+ pkill -9 -f "${S}/sql" 2>/dev/null |
590 |
+ |
591 |
+ local failures="" |
592 |
+ [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" |
593 |
+ [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" |
594 |
+ |
595 |
+ [[ -z "$failures" ]] || die "Test failures: $failures" |
596 |
+ einfo "Tests successfully completed" |
597 |
+} |
598 |
+ |
599 |
+mysql_init_vars() { |
600 |
+ MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX%/}/usr/share/mysql"} |
601 |
+ MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX%/}/etc/mysql"} |
602 |
+ MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX%/}/var/lib/mysql"} |
603 |
+ MY_LOGDIR=${MY_LOGDIR="${EPREFIX%/}/var/log/mysql"} |
604 |
+ |
605 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
606 |
+ MY_DATADIR="" |
607 |
+ if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then |
608 |
+ MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ |
609 |
+ | sed -ne '/datadir/s|^--datadir=||p' \ |
610 |
+ | tail -n1` |
611 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
612 |
+ MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ |
613 |
+ | sed -e 's/.*=\s*//' \ |
614 |
+ | tail -n1` |
615 |
+ fi |
616 |
+ fi |
617 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
618 |
+ MY_DATADIR="${MY_LOCALSTATEDIR}" |
619 |
+ einfo "Using default MY_DATADIR" |
620 |
+ fi |
621 |
+ elog "MySQL MY_DATADIR is ${MY_DATADIR}" |
622 |
+ |
623 |
+ if [[ -z "${PREVIOUS_DATADIR}" ]] ; then |
624 |
+ if [[ -e "${MY_DATADIR}" ]] ; then |
625 |
+ # If you get this and you're wondering about it, see bug #207636 |
626 |
+ elog "MySQL datadir found in ${MY_DATADIR}" |
627 |
+ elog "A new one will not be created." |
628 |
+ PREVIOUS_DATADIR="yes" |
629 |
+ else |
630 |
+ PREVIOUS_DATADIR="no" |
631 |
+ fi |
632 |
+ export PREVIOUS_DATADIR |
633 |
+ fi |
634 |
+ else |
635 |
+ if [[ ${EBUILD_PHASE} == "config" ]]; then |
636 |
+ local new_MY_DATADIR |
637 |
+ new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ |
638 |
+ | sed -ne '/datadir/s|^--datadir=||p' \ |
639 |
+ | tail -n1` |
640 |
+ |
641 |
+ if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then |
642 |
+ ewarn "MySQL MY_DATADIR has changed" |
643 |
+ ewarn "from ${MY_DATADIR}" |
644 |
+ ewarn "to ${new_MY_DATADIR}" |
645 |
+ MY_DATADIR="${new_MY_DATADIR}" |
646 |
+ fi |
647 |
+ fi |
648 |
+ fi |
649 |
+ |
650 |
+ export MY_SHAREDSTATEDIR MY_SYSCONFDIR |
651 |
+ export MY_LOCALSTATEDIR MY_LOGDIR |
652 |
+ export MY_DATADIR |
653 |
+} |
654 |
+ |
655 |
+pkg_config() { |
656 |
+ _getoptval() { |
657 |
+ local mypd="${EROOT%/}"/usr/bin/my_print_defaults |
658 |
+ local section="$1" |
659 |
+ local flag="--${2}=" |
660 |
+ local extra_options="${3}" |
661 |
+ "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" |
662 |
+ } |
663 |
+ local old_MY_DATADIR="${MY_DATADIR}" |
664 |
+ local old_HOME="${HOME}" |
665 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
666 |
+ export HOME=${EPREFIX%/}/root |
667 |
+ |
668 |
+ # Make sure the vars are correctly initialized |
669 |
+ mysql_init_vars |
670 |
+ |
671 |
+ [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" |
672 |
+ if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then |
673 |
+ die "Minimal builds do NOT include the MySQL server" |
674 |
+ fi |
675 |
+ |
676 |
+ if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then |
677 |
+ local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}" |
678 |
+ MY_DATADIR_s="${MY_DATADIR_s%%/}" |
679 |
+ local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}" |
680 |
+ old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" |
681 |
+ |
682 |
+ if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then |
683 |
+ if [[ -d "${MY_DATADIR_s}" ]]; then |
684 |
+ ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" |
685 |
+ ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" |
686 |
+ else |
687 |
+ elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" |
688 |
+ mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ |
689 |
+ || die "Moving MY_DATADIR failed" |
690 |
+ fi |
691 |
+ else |
692 |
+ ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" |
693 |
+ if [[ -d "${MY_DATADIR_s}" ]]; then |
694 |
+ ewarn "Attempting to use ${MY_DATADIR_s}" |
695 |
+ else |
696 |
+ eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" |
697 |
+ die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" |
698 |
+ fi |
699 |
+ fi |
700 |
+ fi |
701 |
+ |
702 |
+ local pwd1="a" |
703 |
+ local pwd2="b" |
704 |
+ local maxtry=15 |
705 |
+ |
706 |
+ if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
707 |
+ local tmp_mysqld_password_source= |
708 |
+ |
709 |
+ for tmp_mysqld_password_source in mysql client; do |
710 |
+ einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." |
711 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" |
712 |
+ if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then |
713 |
+ if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then |
714 |
+ ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" |
715 |
+ MYSQL_ROOT_PASSWORD= |
716 |
+ continue |
717 |
+ fi |
718 |
+ |
719 |
+ einfo "Found password in '${tmp_mysqld_password_source}' section!" |
720 |
+ break |
721 |
+ fi |
722 |
+ done |
723 |
+ |
724 |
+ # Sometimes --show is required to display passwords in some implementations of my_print_defaults |
725 |
+ if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then |
726 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" |
727 |
+ fi |
728 |
+ |
729 |
+ unset tmp_mysqld_password_source |
730 |
+ fi |
731 |
+ MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)" |
732 |
+ # These are dir+prefix |
733 |
+ MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)" |
734 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
735 |
+ MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)" |
736 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
737 |
+ |
738 |
+ if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]]; then |
739 |
+ einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" |
740 |
+ install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR" |
741 |
+ fi |
742 |
+ if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]]; then |
743 |
+ einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" |
744 |
+ install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN" |
745 |
+ fi |
746 |
+ if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]]; then |
747 |
+ einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" |
748 |
+ install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG" |
749 |
+ fi |
750 |
+ |
751 |
+ if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then |
752 |
+ ewarn "You have already a MySQL database in place." |
753 |
+ ewarn "(${ROOT%/}/${MY_DATADIR}/*)" |
754 |
+ ewarn "Please rename or delete it if you wish to replace it." |
755 |
+ die "MySQL database already exists!" |
756 |
+ fi |
757 |
+ |
758 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
759 |
+ # localhost. Also causes weird failures. |
760 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
761 |
+ |
762 |
+ if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
763 |
+ |
764 |
+ einfo "Please provide a password for the mysql 'root' user now" |
765 |
+ einfo "or through the ${HOME}/.my.cnf file." |
766 |
+ ewarn "Avoid [\"'\\_%] characters in the password" |
767 |
+ read -rsp " >" pwd1 ; echo |
768 |
+ |
769 |
+ einfo "Retype the password" |
770 |
+ read -rsp " >" pwd2 ; echo |
771 |
+ |
772 |
+ if [[ "x$pwd1" != "x$pwd2" ]] ; then |
773 |
+ die "Passwords are not the same" |
774 |
+ fi |
775 |
+ MYSQL_ROOT_PASSWORD="${pwd1}" |
776 |
+ unset pwd1 pwd2 |
777 |
+ fi |
778 |
+ |
779 |
+ local options |
780 |
+ local sqltmp="$(emktemp)" |
781 |
+ |
782 |
+ # Fix bug 446200. Don't reference host my.cnf, needs to come first, |
783 |
+ # see http://bugs.mysql.com/bug.php?id=31312 |
784 |
+ use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" |
785 |
+ |
786 |
+ # Figure out which options we need to disable to do the setup |
787 |
+ local helpfile="${TMPDIR%/}/mysqld-help" |
788 |
+ "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null |
789 |
+ for opt in host-cache name-resolve networking slave-start \ |
790 |
+ federated ssl log-bin relay-log slow-query-log external-locking \ |
791 |
+ log-slave-updates \ |
792 |
+ ; do |
793 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
794 |
+ egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" |
795 |
+ done |
796 |
+ |
797 |
+ einfo "Creating the mysql database and setting proper permissions on it ..." |
798 |
+ |
799 |
+ # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it |
800 |
+ PID_DIR="${EROOT%/}/var/run/mysqld" |
801 |
+ if [[ ! -d "${PID_DIR}" ]]; then |
802 |
+ install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory" |
803 |
+ fi |
804 |
+ |
805 |
+ if [[ ! -d "${MY_DATADIR}" ]]; then |
806 |
+ install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory" |
807 |
+ fi |
808 |
+ |
809 |
+ pushd "${TMPDIR}" &>/dev/null || die |
810 |
+ |
811 |
+ # Filling timezones, see |
812 |
+ # http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
813 |
+ echo "USE mysql;" >"${sqltmp}" |
814 |
+ "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null |
815 |
+ chown mysql "${sqltmp}" || die |
816 |
+ |
817 |
+ # --initialize-insecure will not set root password |
818 |
+ # --initialize would set a random one in the log which we don't need as we set it ourselves |
819 |
+ local cmd=( "${EROOT%/}/usr/sbin/mysqld" "--initialize-insecure" "--init-file='${sqltmp}'" ) |
820 |
+ cmd+=( "--basedir=${EPREFIX%/}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" ) |
821 |
+ einfo "Command: ${cmd[*]}" |
822 |
+ su -s /bin/sh -c "${cmd[*]}" mysql \ |
823 |
+ >"${TMPDIR%/}"/mysql_install_db.log 2>&1 |
824 |
+ if [ $? -ne 0 ]; then |
825 |
+ grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2 |
826 |
+ die "Failed to initialize mysqld. Please review ${EPREFIX%/}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log" |
827 |
+ fi |
828 |
+ popd &>/dev/null || die |
829 |
+ [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \ |
830 |
+ || die "MySQL databases not installed" |
831 |
+ |
832 |
+ use prefix || options="${options} --user=mysql" |
833 |
+ |
834 |
+ local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock" |
835 |
+ local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid" |
836 |
+ local mysqld="${EROOT%/}/usr/sbin/mysqld \ |
837 |
+ ${options} \ |
838 |
+ $(use prefix || echo --user=mysql) \ |
839 |
+ --log-warnings=0 \ |
840 |
+ --basedir=${EROOT%/}/usr \ |
841 |
+ --datadir=${ROOT%/}/${MY_DATADIR} \ |
842 |
+ --max_allowed_packet=8M \ |
843 |
+ --net_buffer_length=16K \ |
844 |
+ --socket=${socket} \ |
845 |
+ --pid-file=${pidfile} |
846 |
+ --tmpdir=${ROOT}/${MYSQL_TMPDIR}" |
847 |
+ #einfo "About to start mysqld: ${mysqld}" |
848 |
+ ebegin "Starting mysqld" |
849 |
+ einfo "Command ${mysqld}" |
850 |
+ ${mysqld} & |
851 |
+ rc=$? |
852 |
+ while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do |
853 |
+ maxtry=$((${maxtry}-1)) |
854 |
+ echo -n "." |
855 |
+ sleep 1 |
856 |
+ done |
857 |
+ eend $rc |
858 |
+ |
859 |
+ if ! [[ -S "${socket}" ]]; then |
860 |
+ die "Completely failed to start up mysqld with: ${mysqld}" |
861 |
+ fi |
862 |
+ |
863 |
+ ebegin "Setting root password" |
864 |
+ # Do this from memory, as we don't want clear text passwords in temp files |
865 |
+ local sql="ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${MYSQL_ROOT_PASSWORD}'" |
866 |
+ "${EROOT%/}/usr/bin/mysql" \ |
867 |
+ --no-defaults \ |
868 |
+ "--socket=${socket}" \ |
869 |
+ -hlocalhost \ |
870 |
+ -e "${sql}" |
871 |
+ eend $? |
872 |
+ |
873 |
+ # Stop the server and cleanup |
874 |
+ einfo "Stopping the server ..." |
875 |
+ kill $(< "${pidfile}" ) |
876 |
+ rm -f "${sqltmp}" |
877 |
+ wait %1 |
878 |
+ einfo "Done" |
879 |
+} |