1 |
commit: 454a039a0ff6d84719488b2433e6702f0cb54484 |
2 |
Author: Brian Evans <grknight <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Dec 11 21:48:38 2015 +0000 |
4 |
Commit: Brian Evans <grknight <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Dec 11 21:48:38 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/mysql.git/commit/?id=454a039a |
7 |
|
8 |
Push experimental eclass revision to test |
9 |
|
10 |
Signed-off-by: Brian Evans <grknight <AT> gentoo.org> |
11 |
|
12 |
dev-db/mariadb/mariadb-10.1.9-r1.ebuild | 207 ++++ |
13 |
.../percona-server-5.6.26.74.0-r1.ebuild | 173 ++++ |
14 |
eclass/mysql-multilib-r1.eclass | 1043 ++++++++++++++++++++ |
15 |
3 files changed, 1423 insertions(+) |
16 |
|
17 |
diff --git a/dev-db/mariadb/mariadb-10.1.9-r1.ebuild b/dev-db/mariadb/mariadb-10.1.9-r1.ebuild |
18 |
new file mode 100644 |
19 |
index 0000000..7ec76dd |
20 |
--- /dev/null |
21 |
+++ b/dev-db/mariadb/mariadb-10.1.9-r1.ebuild |
22 |
@@ -0,0 +1,207 @@ |
23 |
+# Copyright 1999-2015 Gentoo Foundation |
24 |
+# Distributed under the terms of the GNU General Public License v2 |
25 |
+# $Id$ |
26 |
+ |
27 |
+EAPI="5" |
28 |
+MY_EXTRAS_VER="20151123-1643Z" |
29 |
+# The wsrep API version must match between upstream WSREP and sys-cluster/galera major number |
30 |
+WSREP_REVISION="25" |
31 |
+SUBSLOT="18" |
32 |
+MYSQL_PV_MAJOR="5.6" |
33 |
+ |
34 |
+inherit toolchain-funcs mysql-multilib-r1 |
35 |
+ |
36 |
+HOMEPAGE="http://mariadb.org/" |
37 |
+DESCRIPTION="An enhanced, drop-in replacement for MySQL" |
38 |
+ |
39 |
+IUSE="bindist cracklib galera innodb-lz4 innodb-lzo innodb-snappy mroonga odbc oqgraph pam sphinx sst-rsync sst-xtrabackup tokudb systemd xml" |
40 |
+RESTRICT="!bindist? ( bindist )" |
41 |
+ |
42 |
+REQUIRED_USE="tokudb? ( jemalloc ) static? ( !pam )" |
43 |
+ |
44 |
+# REMEMBER: also update eclass/mysql*.eclass before committing! |
45 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~ia64 ~hppa ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd ~x86-freebsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" |
46 |
+ |
47 |
+# When MY_EXTRAS is bumped, the index should be revised to exclude these. |
48 |
+#EPATCH_EXCLUDE='' |
49 |
+ |
50 |
+COMMON_DEPEND=" |
51 |
+ mroonga? ( app-text/groonga-normalizer-mysql ) |
52 |
+ systemd? ( sys-apps/systemd:= ) |
53 |
+ !bindist? ( >=sys-libs/readline-4.1:0= ) |
54 |
+ server? ( |
55 |
+ cracklib? ( sys-libs/cracklib:0= ) |
56 |
+ extraengine? ( |
57 |
+ odbc? ( dev-db/unixODBC:0= ) |
58 |
+ xml? ( dev-libs/libxml2:2= ) |
59 |
+ ) |
60 |
+ innodb-lz4? ( app-arch/lz4 ) |
61 |
+ innodb-lzo? ( dev-libs/lzo ) |
62 |
+ innodb-snappy? ( app-arch/snappy ) |
63 |
+ oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) |
64 |
+ pam? ( virtual/pam:0= ) |
65 |
+ ) |
66 |
+ >=dev-libs/libpcre-8.35:3= |
67 |
+" |
68 |
+DEPEND="|| ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) |
69 |
+ ${COMMON_DEPEND}" |
70 |
+RDEPEND="${RDEPEND} ${COMMON_DEPEND} |
71 |
+ galera? ( |
72 |
+ sys-apps/iproute2 |
73 |
+ =sys-cluster/galera-${WSREP_REVISION}* |
74 |
+ sst-rsync? ( sys-process/lsof ) |
75 |
+ sst-xtrabackup? ( net-misc/socat[ssl] ) |
76 |
+ ) |
77 |
+ perl? ( !dev-db/mytop |
78 |
+ virtual/perl-Getopt-Long |
79 |
+ dev-perl/TermReadKey |
80 |
+ virtual/perl-Term-ANSIColor |
81 |
+ virtual/perl-Time-HiRes ) |
82 |
+" |
83 |
+# xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed |
84 |
+PDEPEND="galera? ( sst-xtrabackup? ( >=dev-db/xtrabackup-bin-2.2.4 ) )" |
85 |
+ |
86 |
+MULTILIB_WRAPPED_HEADERS+=( /usr/include/mysql/mysql_version.h ) |
87 |
+ |
88 |
+src_configure(){ |
89 |
+ # bug 508724 mariadb cannot use ld.gold |
90 |
+ tc-ld-disable-gold |
91 |
+ local MYSQL_CMAKE_NATIVE_DEFINES=" |
92 |
+ -DWITH_JEMALLOC=$(usex jemalloc system) |
93 |
+ -DWITH_PCRE=system |
94 |
+ " |
95 |
+ if use server ; then |
96 |
+ # Federated{,X} must be treated special otherwise they will not be built as plugins |
97 |
+ if ! use extraengine ; then |
98 |
+ MYSQL_CMAKE_NATIVE_DEFINES+=" |
99 |
+ -DPLUGIN_FEDERATED=NO |
100 |
+ -DPLUGIN_FEDERATEDX=NO" |
101 |
+ fi |
102 |
+ |
103 |
+ MYSQL_CMAKE_NATIVE_DEFINES+=" |
104 |
+ -DPLUGIN_OQGRAPH=$(usex oqgraph YES NO) |
105 |
+ -DPLUGIN_SPHINX=$(usex sphinx YES NO) |
106 |
+ -DPLUGIN_TOKUDB=$(usex tokudb YES NO) |
107 |
+ -DPLUGIN_AUTH_PAM=$(usex pam YES NO) |
108 |
+ -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) |
109 |
+ -DPLUGIN_CASSANDRA=NO |
110 |
+ -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) |
111 |
+ -DPLUGIN_SPIDER=$(usex extraengine YES NO) |
112 |
+ -DPLUGIN_CONNECT=$(usex extraengine YES NO) |
113 |
+ -DCONNECT_WITH_MYSQL=1 |
114 |
+ -DCONNECT_WITH_LIBXML2=$(usex xml) |
115 |
+ -DCONNECT_WITH_ODBC=$(usex odbc) |
116 |
+ -DWITH_WSREP=$(usex galera) |
117 |
+ -DWITH_INNODB_LZ4=$(usex innodb-lz4) |
118 |
+ -DWITH_INNODB_LZO=$(usex innodb-lzo) |
119 |
+ -DWITH_INNODB_SNAPPY=$(usex innodb-snappy) |
120 |
+ " |
121 |
+ |
122 |
+ use mroonga || MYSQL_CMAKE_NATIVE_DEFINES+="-DWITHOUT_MROONGA=1" |
123 |
+ fi |
124 |
+ mysql-multilib-r1_src_configure |
125 |
+} |
126 |
+ |
127 |
+# Official test instructions: |
128 |
+# USE='embedded extraengine perl server openssl static-libs' \ |
129 |
+# FEATURES='test userpriv -usersandbox' \ |
130 |
+# ebuild mariadb-X.X.XX.ebuild \ |
131 |
+# digest clean package |
132 |
+multilib_src_test() { |
133 |
+ |
134 |
+ if ! multilib_is_native_abi ; then |
135 |
+ einfo "Server tests not available on non-native abi". |
136 |
+ return 0; |
137 |
+ fi |
138 |
+ |
139 |
+ local TESTDIR="${BUILD_DIR}/mysql-test" |
140 |
+ local retstatus_unit |
141 |
+ local retstatus_tests |
142 |
+ |
143 |
+ if use server ; then |
144 |
+ |
145 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
146 |
+ # localhost. Also causes weird failures. |
147 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
148 |
+ |
149 |
+ if [[ $UID -eq 0 ]]; then |
150 |
+ die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
151 |
+ fi |
152 |
+ has usersandbox $FEATURES && eerror "Some tests may fail with FEATURES=usersandbox" |
153 |
+ |
154 |
+ einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" |
155 |
+ addpredict /this-dir-does-not-exist/t9.MYI |
156 |
+ |
157 |
+ # Run CTest (test-units) |
158 |
+ cmake-utils_src_test |
159 |
+ retstatus_unit=$? |
160 |
+ [[ $retstatus_unit -eq 0 ]] || eerror "test-unit failed" |
161 |
+ |
162 |
+ # Create a symlink to provided binaries so the tests can find them when client-libs is off |
163 |
+ if ! use client-libs ; then |
164 |
+ ln -srf /usr/bin/my_print_defaults "${BUILD_DIR}/client/my_print_defaults" || die |
165 |
+ ln -srf /usr/bin/perror "${BUILD_DIR}/client/perror" || die |
166 |
+ mysql-multilib-r1_disable_test main.perror "String mismatch due to not building local perror" |
167 |
+ fi |
168 |
+ |
169 |
+ # Ensure that parallel runs don't die |
170 |
+ export MTR_BUILD_THREAD="$((${RANDOM} % 100))" |
171 |
+ # Enable parallel testing, auto will try to detect number of cores |
172 |
+ # You may set this by hand. |
173 |
+ # The default maximum is 8 unless MTR_MAX_PARALLEL is increased |
174 |
+ export MTR_PARALLEL="${MTR_PARALLEL:-auto}" |
175 |
+ |
176 |
+ # create directories because mysqladmin might run out of order |
177 |
+ mkdir -p "${T}"/var-tests{,/log} |
178 |
+ |
179 |
+ # These are failing in MariaDB 10.0 for now and are believed to be |
180 |
+ # false positives: |
181 |
+ # |
182 |
+ # main.information_schema, binlog.binlog_statement_insert_delayed, |
183 |
+ # main.mysqld--help, funcs_1.is_triggers, funcs_1.is_tables_mysql, |
184 |
+ # funcs_1.is_columns_mysql main.bootstrap |
185 |
+ # fails due to USE=-latin1 / utf8 default |
186 |
+ # |
187 |
+ # main.mysql_client_test, main.mysql_client_test_nonblock |
188 |
+ # main.mysql_client_test_comp: |
189 |
+ # segfaults at random under Portage only, suspect resource limits. |
190 |
+ # |
191 |
+ # plugins.cracklib_password_check |
192 |
+ # Can randomly fail due to cracklib return message |
193 |
+ |
194 |
+ for t in main.mysql_client_test main.mysql_client_test_nonblock \ |
195 |
+ main.mysql_client_test_comp main.bootstrap \ |
196 |
+ binlog.binlog_statement_insert_delayed main.information_schema \ |
197 |
+ main.mysqld--help plugins.cracklib_password_check \ |
198 |
+ funcs_1.is_triggers funcs_1.is_tables_mysql funcs_1.is_columns_mysql ; do |
199 |
+ mysql-multilib_disable_test "$t" "False positives in Gentoo" |
200 |
+ done |
201 |
+ |
202 |
+ # Run mysql tests |
203 |
+ pushd "${TESTDIR}" || die |
204 |
+ |
205 |
+ # run mysql-test tests |
206 |
+ perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder |
207 |
+ |
208 |
+ retstatus_tests=$? |
209 |
+ [[ $retstatus_tests -eq 0 ]] || eerror "tests failed" |
210 |
+ has usersandbox $FEATURES && eerror "Some tests may fail with FEATURES=usersandbox" |
211 |
+ |
212 |
+ popd || die |
213 |
+ |
214 |
+ # Cleanup is important for these testcases. |
215 |
+ pkill -9 -f "${S}/ndb" 2>/dev/null |
216 |
+ pkill -9 -f "${S}/sql" 2>/dev/null |
217 |
+ |
218 |
+ failures="" |
219 |
+ [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" |
220 |
+ [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" |
221 |
+ has usersandbox $FEATURES && eerror "Some tests may fail with FEATURES=usersandbox" |
222 |
+ |
223 |
+ [[ -z "$failures" ]] || die "Test failures: $failures" |
224 |
+ einfo "Tests successfully completed" |
225 |
+ |
226 |
+ else |
227 |
+ einfo "Skipping server tests due to minimal build." |
228 |
+ fi |
229 |
+} |
230 |
|
231 |
diff --git a/dev-db/percona-server/percona-server-5.6.26.74.0-r1.ebuild b/dev-db/percona-server/percona-server-5.6.26.74.0-r1.ebuild |
232 |
new file mode 100644 |
233 |
index 0000000..4df5953 |
234 |
--- /dev/null |
235 |
+++ b/dev-db/percona-server/percona-server-5.6.26.74.0-r1.ebuild |
236 |
@@ -0,0 +1,173 @@ |
237 |
+# Copyright 1999-2015 Gentoo Foundation |
238 |
+# Distributed under the terms of the GNU General Public License v2 |
239 |
+# $Id$ |
240 |
+ |
241 |
+EAPI="5" |
242 |
+MY_EXTRAS_VER="20150717-1707Z" |
243 |
+SUBSLOT="18" |
244 |
+PYTHON_COMPAT=( python2_7 ) |
245 |
+inherit toolchain-funcs python-any-r1 mysql-multilib-r1 |
246 |
+ |
247 |
+IUSE="pam tokudb tokudb-backup-plugin" |
248 |
+ |
249 |
+# REMEMBER: also update eclass/mysql*.eclass before committing! |
250 |
+KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd ~x86-linux" |
251 |
+HOMEPAGE="http://www.percona.com/software/percona-server" |
252 |
+DESCRIPTION="An enhanced, drop-in replacement for MySQL from the Percona team" |
253 |
+ |
254 |
+# When MY_EXTRAS is bumped, the index should be revised to exclude these. |
255 |
+EPATCH_EXCLUDE='' |
256 |
+ |
257 |
+COMMON_DEPEND="server? ( pam? ( virtual/pam:0= ) ) |
258 |
+ tokudb? ( app-arch/snappy ) |
259 |
+ tokudb-backup-plugin? ( dev-util/valgrind ) |
260 |
+ " |
261 |
+ |
262 |
+DEPEND="${COMMON_DEPEND} |
263 |
+ || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) |
264 |
+ test? ( $(python_gen_any_dep 'dev-python/mysql-python[${PYTHON_USEDEP}]') )" |
265 |
+RDEPEND="${COMMON_DEPEND}" |
266 |
+ |
267 |
+REQUIRED_USE="tokudb? ( jemalloc ) tokudb-backup-plugin? ( tokudb )" |
268 |
+ |
269 |
+# Please do not add a naive src_unpack to this ebuild |
270 |
+# If you want to add a single patch, copy the ebuild to an overlay |
271 |
+# and create your own mysql-extras tarball, looking at 000_index.txt |
272 |
+ |
273 |
+python_check_deps() { |
274 |
+ has_version "dev-python/mysql-python[${PYTHON_USEDEP}]" |
275 |
+} |
276 |
+ |
277 |
+src_configure() { |
278 |
+ local MYSQL_CMAKE_NATIVE_DEFINES="-DWITH_PAM=$(usex pam)" |
279 |
+ if use tokudb ; then |
280 |
+ # TokuDB Backup plugin requires valgrind unconditionally |
281 |
+ MYSQL_CMAKE_NATIVE_DEFINES+=" |
282 |
+ $(mysql-cmake_use_plugin tokudb TOKUDB) |
283 |
+ $(usex tokudb-backup-plugin '' -DTOKUDB_BACKUP_DISABLED=1) |
284 |
+ " |
285 |
+ fi |
286 |
+} |
287 |
+ |
288 |
+# Official test instructions: |
289 |
+# USE='extraengine perl openssl static-libs' \ |
290 |
+# FEATURES='test userpriv -usersandbox' \ |
291 |
+# ebuild percona-server-X.X.XX.ebuild \ |
292 |
+# digest clean package |
293 |
+multilib_src_test() { |
294 |
+ |
295 |
+ if ! multilib_is_native_abi ; then |
296 |
+ einfo "Server tests not available on non-native abi". |
297 |
+ return 0; |
298 |
+ fi |
299 |
+ |
300 |
+ local TESTDIR="${CMAKE_BUILD_DIR}/mysql-test" |
301 |
+ local retstatus_unit |
302 |
+ local retstatus_tests |
303 |
+ |
304 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
305 |
+ # localhost. Also causes weird failures. |
306 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
307 |
+ |
308 |
+ if use server ; then |
309 |
+ |
310 |
+ if [[ $UID -eq 0 ]]; then |
311 |
+ die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
312 |
+ fi |
313 |
+ has usersandbox $FEATURES && eerror "Some tests may fail with FEATURES=usersandbox" |
314 |
+ |
315 |
+ einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" |
316 |
+ addpredict /this-dir-does-not-exist/t9.MYI |
317 |
+ |
318 |
+ # Run CTest (test-units) |
319 |
+ cmake-utils_src_test |
320 |
+ retstatus_unit=$? |
321 |
+ [[ $retstatus_unit -eq 0 ]] || eerror "test-unit failed" |
322 |
+ |
323 |
+ # Ensure that parallel runs don't die |
324 |
+ export MTR_BUILD_THREAD="$((${RANDOM} % 100))" |
325 |
+ # Enable parallel testing, auto will try to detect number of cores |
326 |
+ # You may set this by hand. |
327 |
+ # The default maximum is 8 unless MTR_MAX_PARALLEL is increased |
328 |
+ export MTR_PARALLEL="${MTR_PARALLEL:-auto}" |
329 |
+ |
330 |
+ # create directories because mysqladmin might right out of order |
331 |
+ mkdir -p "${T}"/var-tests{,/log} |
332 |
+ |
333 |
+ # Create a symlink to provided binaries so the tests can find them when client-libs is off |
334 |
+ if ! use client-libs ; then |
335 |
+ ln -srf /usr/bin/my_print_defaults "${BUILD_DIR}/client/my_print_defaults" || die |
336 |
+ ln -srf /usr/bin/perror "${BUILD_DIR}/client/perror" || die |
337 |
+ mysql-multilib_disable_test main.perror "String mismatch due to not building local perror" |
338 |
+ fi |
339 |
+ |
340 |
+ # These are failing in Percona 5.6 for now and are believed to be |
341 |
+ # false positives: |
342 |
+ # |
343 |
+ # main.information_schema, binlog.binlog_statement_insert_delayed, |
344 |
+ # main.mysqld--help-notwin, binlog.binlog_mysqlbinlog_filter |
345 |
+ # perfschema.binlog_edge_mix, perfschema.binlog_edge_stmt |
346 |
+ # funcs_1.is_columns_mysql funcs_1.is_tables_mysql funcs_1.is_triggers |
347 |
+ # engines/funcs.db_alter_character_set engines/funcs.db_alter_character_set_collate |
348 |
+ # engines/funcs.db_alter_collate_ascii engines/funcs.db_alter_collate_utf8 |
349 |
+ # engines/funcs.db_create_character_set engines/funcs.db_create_character_set_collate |
350 |
+ # fails due to USE=-latin1 / utf8 default |
351 |
+ # |
352 |
+ # main.mysql_client_test: |
353 |
+ # segfaults at random under Portage only, suspect resource limits. |
354 |
+ # |
355 |
+ # main.percona_bug1289599 |
356 |
+ # Looks to be a syntax error in the test file itself |
357 |
+ # |
358 |
+ # main.variables main.myisam main.merge_recover |
359 |
+ # fails due to ulimit not able to open enough files (needs 5000) |
360 |
+ # |
361 |
+ # main.mysqlhotcopy_archive main.mysqlhotcopy_myisam |
362 |
+ # Called with bad parameters should be reported upstream |
363 |
+ # |
364 |
+ |
365 |
+ for t in main.mysql_client_test \ |
366 |
+ binlog.binlog_statement_insert_delayed main.information_schema \ |
367 |
+ main.mysqld--help-notwin binlog.binlog_mysqlbinlog_filter \ |
368 |
+ perfschema.binlog_edge_mix perfschema.binlog_edge_stmt \ |
369 |
+ funcs_1.is_columns_mysql funcs_1.is_tables_mysql funcs_1.is_triggers \ |
370 |
+ main.variables main.myisam main.merge_recover \ |
371 |
+ engines/funcs.db_alter_character_set engines/funcs.db_alter_character_set_collate \ |
372 |
+ engines/funcs.db_alter_collate_ascii engines/funcs.db_alter_collate_utf8 \ |
373 |
+ engines/funcs.db_create_character_set engines/funcs.db_create_character_set_collate \ |
374 |
+ main.percona_bug1289599 main.mysqlhotcopy_archive main.mysqlhotcopy_myisam ; do |
375 |
+ mysql-multilib_disable_test "$t" "False positives in Gentoo" |
376 |
+ done |
377 |
+ |
378 |
+ # Run mysql tests |
379 |
+ pushd "${TESTDIR}" |
380 |
+ |
381 |
+ # Set file limits higher so tests run |
382 |
+ ulimit -n 3000 |
383 |
+ python_setup |
384 |
+ # run mysql-test tests |
385 |
+ perl mysql-test-run.pl --force --vardir="${T}/var-tests" \ |
386 |
+ --testcase-timeout=30 --reorder |
387 |
+ retstatus_tests=$? |
388 |
+ [[ $retstatus_tests -eq 0 ]] || eerror "tests failed" |
389 |
+ has usersandbox $FEATURES && eerror "Some tests may fail with FEATURES=usersandbox" |
390 |
+ |
391 |
+ popd |
392 |
+ |
393 |
+ # Cleanup is important for these testcases. |
394 |
+ pkill -9 -f "${S}/ndb" 2>/dev/null |
395 |
+ pkill -9 -f "${S}/sql" 2>/dev/null |
396 |
+ |
397 |
+ failures="" |
398 |
+ [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" |
399 |
+ [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" |
400 |
+ has usersandbox $FEATURES && eerror "Some tests may fail with FEATURES=usersandbox" |
401 |
+ |
402 |
+ [[ -z "$failures" ]] || die "Test failures: $failures" |
403 |
+ einfo "Tests successfully completed" |
404 |
+ |
405 |
+ else |
406 |
+ |
407 |
+ einfo "Skipping server tests due to minimal build." |
408 |
+ fi |
409 |
+} |
410 |
|
411 |
diff --git a/eclass/mysql-multilib-r1.eclass b/eclass/mysql-multilib-r1.eclass |
412 |
new file mode 100644 |
413 |
index 0000000..5969d6b |
414 |
--- /dev/null |
415 |
+++ b/eclass/mysql-multilib-r1.eclass |
416 |
@@ -0,0 +1,1043 @@ |
417 |
+# Copyright 1999-2015 Gentoo Foundation |
418 |
+# Distributed under the terms of the GNU General Public License v2 |
419 |
+# $Id$ |
420 |
+ |
421 |
+# @ECLASS: mysql-multilib.eclass |
422 |
+# @MAINTAINER: |
423 |
+# Maintainers: |
424 |
+# - MySQL Team <mysql-bugs@g.o> |
425 |
+# - Robin H. Johnson <robbat2@g.o> |
426 |
+# - Jorge Manuel B. S. Vicetto <jmbsvicetto@g.o> |
427 |
+# - Brian Evans <grknight@g.o> |
428 |
+# @BLURB: This eclass provides common functions for mysql ebuilds |
429 |
+# @DESCRIPTION: |
430 |
+# The mysql-multilib-r1.eclass is the base eclass to build the mysql and |
431 |
+# alternative projects (mariadb and percona) ebuilds. |
432 |
+# Provider and version specific settings will be included in each ebuild. |
433 |
+# It provides the src_unpack, src_prepare, src_configure, src_compile, |
434 |
+# src_install, pkg_preinst, pkg_postinst, pkg_config and pkg_postrm |
435 |
+# phase hooks. |
436 |
+ |
437 |
+MYSQL_EXTRAS="" |
438 |
+ |
439 |
+# @ECLASS-VARIABLE: MYSQL_EXTRAS_VER |
440 |
+# @DESCRIPTION: |
441 |
+# The version of the MYSQL_EXTRAS repo to use to build mysql |
442 |
+# Use "none" to disable it's use |
443 |
+[[ ${MY_EXTRAS_VER} == "live" ]] && MYSQL_EXTRAS="git-r3" |
444 |
+ |
445 |
+inherit eutils systemd flag-o-matic ${MYSQL_EXTRAS} mysql_fx versionator \ |
446 |
+ multilib prefix toolchain-funcs user cmake-utils multilib-minimal |
447 |
+ |
448 |
+# |
449 |
+# Supported EAPI versions and export functions |
450 |
+# |
451 |
+ |
452 |
+case "${EAPI:-0}" in |
453 |
+ 5) ;; |
454 |
+ *) die "Unsupported EAPI: ${EAPI}" ;; |
455 |
+esac |
456 |
+ |
457 |
+EXPORT_FUNCTIONS pkg_pretend pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_preinst pkg_postinst pkg_config |
458 |
+ |
459 |
+# |
460 |
+# VARIABLES: |
461 |
+# |
462 |
+ |
463 |
+# Shorten the path because the socket path length must be shorter than 107 chars |
464 |
+# and we will run a mysql server during test phase |
465 |
+S="${WORKDIR}/mysql" |
466 |
+ |
467 |
+[[ ${MY_EXTRAS_VER} == "latest" ]] && MY_EXTRAS_VER="20090228-0714Z" |
468 |
+if [[ ${MY_EXTRAS_VER} == "live" ]]; then |
469 |
+ EGIT_REPO_URI="git://anongit.gentoo.org/proj/mysql-extras.git" |
470 |
+ EGIT_CHECKOUT_DIR=${WORKDIR}/mysql-extras |
471 |
+ EGIT_CLONE_TYPE=shallow |
472 |
+fi |
473 |
+ |
474 |
+# @ECLASS-VARIABLE: MYSQL_PV_MAJOR |
475 |
+# @DESCRIPTION: |
476 |
+# Upstream MySQL considers the first two parts of the version number to be the |
477 |
+# major version. Upgrades that change major version should always run |
478 |
+# mysql_upgrade. |
479 |
+if [[ -z ${MYSQL_PV_MAJOR} ]] ; then MYSQL_PV_MAJOR="$(get_version_component_range 1-2 ${PV})" ; fi |
480 |
+ |
481 |
+# @ECLASS-VARIABLE: MYSQL_VERSION_ID |
482 |
+# @DESCRIPTION: |
483 |
+# MYSQL_VERSION_ID will be: |
484 |
+# major * 10e6 + minor * 10e4 + micro * 10e2 + gentoo revision number, all [0..99] |
485 |
+# This is an important part, because many of the choices the MySQL ebuild will do |
486 |
+# depend on this variable. |
487 |
+# In particular, the code below transforms a $PVR like "5.0.18-r3" in "5001803" |
488 |
+# We also strip off upstream's trailing letter that they use to respin tarballs |
489 |
+MYSQL_VERSION_ID="" |
490 |
+tpv="${PV%[a-z]}" |
491 |
+tpv=( ${tpv//[-._]/ } ) ; tpv[3]="${PVR:${#PV}}" ; tpv[3]="${tpv[3]##*-r}" |
492 |
+for vatom in 0 1 2 3 ; do |
493 |
+ # pad to length 2 |
494 |
+ tpv[${vatom}]="00${tpv[${vatom}]}" |
495 |
+ MYSQL_VERSION_ID="${MYSQL_VERSION_ID}${tpv[${vatom}]:0-2}" |
496 |
+done |
497 |
+# strip leading "0" (otherwise it's considered an octal number by BASH) |
498 |
+MYSQL_VERSION_ID=${MYSQL_VERSION_ID##"0"} |
499 |
+ |
500 |
+# This eclass should only be used with at least mysql-5.5.35 |
501 |
+mysql_version_is_at_least "5.5.35" || die "This eclass should only be used with >=mysql-5.5.35" |
502 |
+ |
503 |
+# Work out the default SERVER_URI correctly |
504 |
+if [[ -z ${SERVER_URI} ]]; then |
505 |
+ if [[ ${PN} == "mariadb" ]]; then |
506 |
+ # Beginning with 5.5, MariaDB stopped putting beta, alpha or rc on their tarball names |
507 |
+ MARIA_FULL_PV=$(get_version_component_range 1-3) |
508 |
+ MARIA_FULL_P="${PN}-${MARIA_FULL_PV}" |
509 |
+ SERVER_URI="https://downloads.mariadb.org/interstitial/${MARIA_FULL_P}/source/${MARIA_FULL_P}.tar.gz" |
510 |
+ elif [[ ${PN} == "percona-server" ]]; then |
511 |
+ PERCONA_PN="Percona-Server" |
512 |
+ MIRROR_PV=$(get_version_component_range 1-2 ${PV}) |
513 |
+ MY_PV=$(get_version_component_range 1-3 ${PV}) |
514 |
+ PERCONA_RELEASE=$(get_version_component_range 4-5 ${PV}) |
515 |
+ PERCONA_RC=$(get_version_component_range 6 ${PV}) |
516 |
+ SERVER_URI="http://www.percona.com/redir/downloads/${PERCONA_PN}-${MIRROR_PV}/${PERCONA_PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}/source/tarball/${PN}-${MY_PV}-${PERCONA_RC}${PERCONA_RELEASE}.tar.gz" |
517 |
+ else |
518 |
+ if [[ "${PN}" == "mysql-cluster" ]] ; then |
519 |
+ URI_DIR="MySQL-Cluster" |
520 |
+ URI_FILE="mysql-cluster-gpl" |
521 |
+ else |
522 |
+ URI_DIR="MySQL" |
523 |
+ URI_FILE="mysql" |
524 |
+ fi |
525 |
+ [[ -z ${MY_PV} ]] && MY_PV="${PV//_/-}" |
526 |
+ URI_A="${URI_FILE}-${MY_PV}.tar.gz" |
527 |
+ MIRROR_PV=$(get_version_component_range 1-2 ${PV}) |
528 |
+ # Recently upstream switched to an archive site, and not on mirrors |
529 |
+ SERVER_URI="http://downloads.mysql.com/archives/${URI_FILE}-${MIRROR_PV}/${URI_A}" |
530 |
+ fi |
531 |
+fi |
532 |
+ |
533 |
+# Define correct SRC_URIs |
534 |
+SRC_URI="${SERVER_URI}" |
535 |
+ |
536 |
+# Gentoo patches to MySQL |
537 |
+if [[ ${MY_EXTRAS_VER} != "live" && ${MY_EXTRAS_VER} != "none" ]]; then |
538 |
+ SRC_URI="${SRC_URI} |
539 |
+ mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 |
540 |
+ https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 |
541 |
+ https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 |
542 |
+ https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" |
543 |
+fi |
544 |
+ |
545 |
+DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" |
546 |
+HOMEPAGE="http://www.mysql.com/" |
547 |
+LICENSE="GPL-2" |
548 |
+SLOT="0/${SUBSLOT:-0}" |
549 |
+ |
550 |
+IUSE="debug embedded extraengine jemalloc latin1 libressl +openssl |
551 |
+ +perl profiling selinux +server systemtap static static-libs tcmalloc test yassl" |
552 |
+ |
553 |
+REQUIRED_USE="^^ ( yassl openssl libressl )" |
554 |
+ |
555 |
+# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests |
556 |
+RESTRICT="libressl? ( test )" |
557 |
+ |
558 |
+REQUIRED_USE="!server? ( !extraengine !embedded ) |
559 |
+ ?? ( tcmalloc jemalloc ) |
560 |
+ static? ( !libressl !openssl yassl )" |
561 |
+ |
562 |
+# |
563 |
+# DEPENDENCIES: |
564 |
+# |
565 |
+ |
566 |
+# Be warned, *DEPEND are version-dependant |
567 |
+# These are used for both runtime and compiletime |
568 |
+# MULTILIB_USEDEP only set for libraries used by the client library |
569 |
+DEPEND=" |
570 |
+ kernel_linux? ( |
571 |
+ sys-process/procps:0= |
572 |
+ dev-libs/libaio:0= |
573 |
+ ) |
574 |
+ >=sys-apps/sed-4 |
575 |
+ >=sys-apps/texinfo-4.7-r1 |
576 |
+ !dev-db/mariadb-native-client[mysqlcompat] |
577 |
+ jemalloc? ( dev-libs/jemalloc:0= ) |
578 |
+ tcmalloc? ( dev-util/google-perftools:0= ) |
579 |
+ systemtap? ( >=dev-util/systemtap-1.3:0= ) |
580 |
+ openssl? ( >=dev-libs/openssl-1.0.0:0=[${MULTILIB_USEDEP},static-libs?] ) |
581 |
+ libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP},static-libs?] ) |
582 |
+ >=sys-libs/zlib-1.2.3:0=[${MULTILIB_USEDEP},static-libs?] |
583 |
+ sys-libs/ncurses:0= |
584 |
+" |
585 |
+ |
586 |
+# prefix: first need to implement something for #196294 |
587 |
+RDEPEND="${DEPEND} |
588 |
+ selinux? ( sec-policy/selinux-mysql ) |
589 |
+ abi_x86_32? ( !app-emulation/emul-linux-x86-db[-abi_x86_32(-)] ) |
590 |
+" |
591 |
+ |
592 |
+# Having different flavours at the same time is not a good idea |
593 |
+for i in "mysql" "mariadb" "mariadb-galera" "percona-server" "mysql-cluster" ; do |
594 |
+ [[ ${i} == ${PN} ]] || |
595 |
+ RDEPEND="${RDEPEND} !dev-db/${i}" |
596 |
+done |
597 |
+ |
598 |
+RDEPEND="${RDEPEND} |
599 |
+ server? ( !prefix? ( dev-db/mysql-init-scripts ) ) |
600 |
+ !<virtual/mysql-5.6-r4" |
601 |
+ |
602 |
+# compile-time-only |
603 |
+# ncurses only needs multilib for compile time due to a binary that will be not installed |
604 |
+DEPEND="${DEPEND} |
605 |
+ virtual/yacc |
606 |
+ static? ( sys-libs/ncurses[static-libs] ) |
607 |
+" |
608 |
+ |
609 |
+# For other stuff to bring us in |
610 |
+# dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
611 |
+PDEPEND="${PDEPEND} perl? ( >=dev-perl/DBD-mysql-2.9004 ) |
612 |
+ ~virtual/mysql-${MYSQL_PV_MAJOR}" |
613 |
+ |
614 |
+# my_config.h includes ABI specific data |
615 |
+MULTILIB_WRAPPED_HEADERS=( /usr/include/mysql/my_config.h /usr/include/mysql/private/embedded_priv.h ) |
616 |
+ |
617 |
+# |
618 |
+# EBUILD FUNCTIONS |
619 |
+# |
620 |
+ |
621 |
+# @FUNCTION: mysql-multilib-r1_pkg_pretend |
622 |
+# @DESCRIPTION: |
623 |
+# Perform some basic tests and tasks during pkg_pretend phase: |
624 |
+mysql-multilib-r1_pkg_pretend() { |
625 |
+ if [[ ${MERGE_TYPE} != binary ]] ; then |
626 |
+ local GCC_MAJOR_SET=$(gcc-major-version) |
627 |
+ local GCC_MINOR_SET=$(gcc-minor-version) |
628 |
+ if use_if_iuse tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ |
629 |
+ ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then |
630 |
+ eerror "${PN} with tokudb needs to be built with gcc-4.7 or later." |
631 |
+ eerror "Please use gcc-config to switch to gcc-4.7 or later version." |
632 |
+ die |
633 |
+ fi |
634 |
+ # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on |
635 |
+ # non x86{,_64} arches |
636 |
+ if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \ |
637 |
+ ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then |
638 |
+ eerror "${PN} needs to be built with gcc-4.7 or later." |
639 |
+ eerror "Please use gcc-config to switch to gcc-4.7 or later version." |
640 |
+ die |
641 |
+ fi |
642 |
+ fi |
643 |
+} |
644 |
+ |
645 |
+# @FUNCTION: mysql-multilib-r1_pkg_setup |
646 |
+# @DESCRIPTION: |
647 |
+# Perform some basic tests and tasks during pkg_setup phase: |
648 |
+# die if FEATURES="test", USE="server" and not using FEATURES="userpriv" |
649 |
+# create new user and group for mysql |
650 |
+# warn about deprecated features |
651 |
+mysql-multilib-r1_pkg_setup() { |
652 |
+ |
653 |
+ if has test ${FEATURES} && \ |
654 |
+ use server && ! has userpriv ${FEATURES} ; then |
655 |
+ eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
656 |
+ fi |
657 |
+ |
658 |
+ # This should come after all of the die statements |
659 |
+ enewgroup mysql 60 || die "problem adding 'mysql' group" |
660 |
+ enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" |
661 |
+} |
662 |
+ |
663 |
+# @FUNCTION: mysql-multilib-r1_src_unpack |
664 |
+# @DESCRIPTION: |
665 |
+# Unpack the source code |
666 |
+mysql-multilib-r1_src_unpack() { |
667 |
+ |
668 |
+ # Initialize the proper variables first |
669 |
+ mysql_init_vars |
670 |
+ |
671 |
+ unpack ${A} |
672 |
+ # Grab the patches |
673 |
+ [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack |
674 |
+ |
675 |
+ mv -f "${WORKDIR}/${MY_SOURCEDIR}" "${S}" |
676 |
+} |
677 |
+ |
678 |
+# @FUNCTION: mysql-multilib-r1_src_prepare |
679 |
+# @DESCRIPTION: |
680 |
+# Apply patches to the source code and remove unneeded bundled libs. |
681 |
+mysql-multilib-r1_src_prepare() { |
682 |
+ |
683 |
+ debug-print-function ${FUNCNAME} "$@" |
684 |
+ |
685 |
+ cd "${S}" |
686 |
+ |
687 |
+ if [[ ${MY_EXTRAS_VER} != none ]]; then |
688 |
+ |
689 |
+ # Apply the patches for this MySQL version |
690 |
+ EPATCH_SUFFIX="patch" |
691 |
+ mkdir -p "${EPATCH_SOURCE}" || die "Unable to create epatch directory" |
692 |
+ # Clean out old items |
693 |
+ rm -f "${EPATCH_SOURCE}"/* |
694 |
+ # Now link in right patches |
695 |
+ mysql_mv_patches |
696 |
+ # And apply |
697 |
+ epatch |
698 |
+ fi |
699 |
+ |
700 |
+ # last -fPIC fixup, per bug #305873 |
701 |
+ i="${S}"/storage/innodb_plugin/plug.in |
702 |
+ if [[ -f ${i} ]] ; then sed -i -e '/CFLAGS/s,-prefer-non-pic,,g' "${i}" || die ; fi |
703 |
+ |
704 |
+ rm -f "scripts/mysqlbug" |
705 |
+ if use jemalloc && [[ ${PN} != "mariadb" ]] ; then |
706 |
+ echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die |
707 |
+ fi |
708 |
+ |
709 |
+ if use tcmalloc; then |
710 |
+ echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" |
711 |
+ fi |
712 |
+ |
713 |
+ if in_iuse tokudb ; then |
714 |
+ # Don't build bundled xz-utils |
715 |
+ if [[ -d "${S}/storage/tokudb/ft-index" ]] ; then |
716 |
+ rm -f "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die |
717 |
+ touch "${S}/storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake" || die |
718 |
+ sed -i 's/ build_lzma//' "${S}/storage/tokudb/ft-index/ft/CMakeLists.txt" || die |
719 |
+ elif [[ -d "${S}/storage/tokudb/PerconaFT" ]] ; then |
720 |
+ rm "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die |
721 |
+ touch "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die |
722 |
+ sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die |
723 |
+ sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die |
724 |
+ fi |
725 |
+ |
726 |
+ if [[ -d "${S}/plugin/tokudb-backup-plugin" ]] && ! use tokudb-backup-plugin ; then |
727 |
+ rm -r "${S}/plugin/tokudb-backup-plugin/Percona-TokuBackup" || die |
728 |
+ fi |
729 |
+ fi |
730 |
+ |
731 |
+ # Remove the bundled groonga if it exists |
732 |
+ # There is no CMake flag, it simply checks for existance |
733 |
+ if [[ -d "${S}"/storage/mroonga/vendor/groonga ]] ; then |
734 |
+ rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" |
735 |
+ fi |
736 |
+ |
737 |
+ epatch_user |
738 |
+} |
739 |
+ |
740 |
+# @FUNCTION: mysql-multilib-r1_src_configure |
741 |
+# @DESCRIPTION: |
742 |
+# Configure mysql to build the code for Gentoo respecting the use flags. |
743 |
+mysql-multilib-r1_src_configure() { |
744 |
+ # Bug #114895, bug #110149 |
745 |
+ filter-flags "-O" "-O[01]" |
746 |
+ |
747 |
+ CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing" |
748 |
+ CXXFLAGS="${CXXFLAGS} -felide-constructors" |
749 |
+ # Causes linkage failures. Upstream bug #59607 removes it |
750 |
+ if ! mysql_version_is_at_least "5.6" ; then |
751 |
+ CXXFLAGS="${CXXFLAGS} -fno-implicit-templates" |
752 |
+ fi |
753 |
+ # As of 5.7, exceptions are used! |
754 |
+ if [[ ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.6.26" ; then |
755 |
+ CXXFLAGS="${CXXFLAGS} -fno-rtti" |
756 |
+ elif ! mysql_version_is_at_least "5.7" ; then |
757 |
+ CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti" |
758 |
+ fi |
759 |
+ export CXXFLAGS |
760 |
+ |
761 |
+ # bug #283926, with GCC4.4, this is required to get correct behavior. |
762 |
+ append-flags -fno-strict-aliasing |
763 |
+ |
764 |
+ multilib-minimal_src_configure |
765 |
+} |
766 |
+ |
767 |
+multilib_src_configure() { |
768 |
+ debug-print-function ${FUNCNAME} "$@" |
769 |
+ |
770 |
+ CMAKE_BUILD_TYPE="RelWithDebInfo" |
771 |
+ |
772 |
+ # debug hack wrt #497532 |
773 |
+ mycmakeargs=( |
774 |
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
775 |
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
776 |
+ -DCMAKE_INSTALL_PREFIX=${EPREFIX}/usr |
777 |
+ -DMYSQL_DATADIR=${EPREFIX}/var/lib/mysql |
778 |
+ -DSYSCONFDIR=${EPREFIX}/etc/mysql |
779 |
+ -DINSTALL_BINDIR=bin |
780 |
+ -DINSTALL_DOCDIR=share/doc/${PF} |
781 |
+ -DINSTALL_DOCREADMEDIR=share/doc/${PF} |
782 |
+ -DINSTALL_INCLUDEDIR=include/mysql |
783 |
+ -DINSTALL_INFODIR=share/info |
784 |
+ -DINSTALL_LIBDIR=$(get_libdir) |
785 |
+ -DINSTALL_ELIBDIR=$(get_libdir)/mysql |
786 |
+ -DINSTALL_MANDIR=share/man |
787 |
+ -DINSTALL_MYSQLDATADIR=${EPREFIX}/var/lib/mysql |
788 |
+ -DINSTALL_MYSQLSHAREDIR=share/mysql |
789 |
+ -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test |
790 |
+ -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin |
791 |
+ -DINSTALL_SBINDIR=sbin |
792 |
+ -DINSTALL_SCRIPTDIR=share/mysql/scripts |
793 |
+ -DINSTALL_SQLBENCHDIR=share/mysql |
794 |
+ -DINSTALL_SUPPORTFILESDIR=${EPREFIX}/usr/share/mysql |
795 |
+ -DWITH_COMMENT="Gentoo Linux ${PF}" |
796 |
+ -DWITH_UNIT_TESTS=$(usex test) |
797 |
+ -DWITH_LIBEDIT=0 |
798 |
+ -DWITH_ZLIB=system |
799 |
+ -DWITHOUT_LIBWRAP=1 |
800 |
+ -DENABLED_LOCAL_INFILE=1 |
801 |
+ -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock |
802 |
+ -DINSTALL_UNIX_ADDRDIR=${EPREFIX}/var/run/mysqld/mysqld.sock |
803 |
+ -DWITH_DEFAULT_COMPILER_OPTIONS=0 |
804 |
+ -DWITH_DEFAULT_FEATURE_SET=0 |
805 |
+ -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_unitdir)" |
806 |
+ ) |
807 |
+ |
808 |
+ if in_iuse systemd ; then |
809 |
+ mycmakeargs+=( -DWITH_SYSTEMD=$(usex systemd) ) |
810 |
+ fi |
811 |
+ |
812 |
+ if use openssl || use libressl ; then |
813 |
+ mycmakeargs+=( -DWITH_SSL=system ) |
814 |
+ else |
815 |
+ mycmakeargs+=( -DWITH_SSL=bundled ) |
816 |
+ fi |
817 |
+ |
818 |
+ if ! multilib_is_native_abi ; then |
819 |
+ mycmakeargs+=( -DWITHOUT_TOOLS=1 ) |
820 |
+ fi |
821 |
+ |
822 |
+ if in_iuse bindist ; then |
823 |
+ # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION |
824 |
+ if multilib_is_native_abi; then |
825 |
+ mycmakeargs+=( |
826 |
+ -DWITH_READLINE=$(usex bindist 1 0) |
827 |
+ -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) |
828 |
+ ) |
829 |
+ else |
830 |
+ mycmakeargs+=( |
831 |
+ -DWITH_READLINE=1 |
832 |
+ -DNOT_FOR_DISTRIBUTION=0 |
833 |
+ ) |
834 |
+ fi |
835 |
+ fi |
836 |
+ |
837 |
+ ### TODO: make this system but issues with UTF-8 prevent it |
838 |
+ mycmakeargs+=( -DWITH_EDITLINE=bundled ) |
839 |
+ |
840 |
+ if multilib_is_native_abi && use server ; then |
841 |
+ if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then |
842 |
+ ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" |
843 |
+ ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." |
844 |
+ ewarn "You MUST file bugs without these variables set." |
845 |
+ |
846 |
+ mycmakeargs+=( |
847 |
+ -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} |
848 |
+ -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} |
849 |
+ ) |
850 |
+ |
851 |
+ elif ! use latin1 ; then |
852 |
+ mycmakeargs+=( |
853 |
+ -DDEFAULT_CHARSET=utf8 |
854 |
+ -DDEFAULT_COLLATION=utf8_general_ci |
855 |
+ ) |
856 |
+ else |
857 |
+ mycmakeargs+=( |
858 |
+ -DDEFAULT_CHARSET=latin1 |
859 |
+ -DDEFAULT_COLLATION=latin1_swedish_ci |
860 |
+ ) |
861 |
+ fi |
862 |
+ mycmakeargs+=( |
863 |
+ -DEXTRA_CHARSETS=all |
864 |
+ -DMYSQL_USER=mysql |
865 |
+ -DMYSQL_UNIX_ADDR=${EPREFIX}/var/run/mysqld/mysqld.sock |
866 |
+ -DDISABLE_SHARED=$(usex static YES NO) |
867 |
+ -DWITH_DEBUG=$(usex debug) |
868 |
+ -DWITH_EMBEDDED_SERVER=$(usex embedded) |
869 |
+ -DWITH_PROFILING=$(usex profiling) |
870 |
+ ) |
871 |
+ |
872 |
+ if use static; then |
873 |
+ mycmakeargs+=( -DWITH_PIC=1 ) |
874 |
+ fi |
875 |
+ |
876 |
+ if use jemalloc || use tcmalloc ; then |
877 |
+ mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) |
878 |
+ fi |
879 |
+ |
880 |
+ # Storage engines |
881 |
+ mycmakeargs+=( |
882 |
+ -DWITH_ARCHIVE_STORAGE_ENGINE=1 |
883 |
+ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 |
884 |
+ -DWITH_CSV_STORAGE_ENGINE=1 |
885 |
+ -DWITH_HEAP_STORAGE_ENGINE=1 |
886 |
+ -DWITH_INNOBASE_STORAGE_ENGINE=1 |
887 |
+ -DWITH_MYISAMMRG_STORAGE_ENGINE=1 |
888 |
+ -DWITH_MYISAM_STORAGE_ENGINE=1 |
889 |
+ -DWITH_PARTITION_STORAGE_ENGINE=1 |
890 |
+ ) |
891 |
+ |
892 |
+ mycmakeargs+=( -DWITH_FEDERATED_STORAGE_ENGINE=$(usex extraengine) ) |
893 |
+ else |
894 |
+ mycmakeargs+=( |
895 |
+ -DWITHOUT_SERVER=1 |
896 |
+ -DWITHOUT_EMBEDDED_SERVER=1 |
897 |
+ -DEXTRA_CHARSETS=none |
898 |
+ -DINSTALL_SQLBENCHDIR= |
899 |
+ ) |
900 |
+ fi |
901 |
+ |
902 |
+ # systemtap only works on native ABI bug 530132 |
903 |
+ if multilib_is_native_abi; then |
904 |
+ mycmakeargs+=( -DENABLE_DTRACE=$(usex systemtap) ) |
905 |
+ [[ ${MYSQL_CMAKE_NATIVE_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_NATIVE_DEFINES} ) |
906 |
+ else |
907 |
+ mycmakeargs+=( -DENABLE_DTRACE=0 ) |
908 |
+ [[ ${MYSQL_CMAKE_NONNATIVE_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_NONNATIVE_DEFINES} ) |
909 |
+ fi |
910 |
+ |
911 |
+ [[ ${MYSQL_CMAKE_EXTRA_DEFINES} ]] && mycmakeargs+=( ${MYSQL_CMAKE_EXTRA_DEFINES} ) |
912 |
+ |
913 |
+ cmake-utils_src_configure |
914 |
+} |
915 |
+ |
916 |
+mysql-multilib-r1_src_compile() { |
917 |
+ local _cmake_args=( "${@}" ) |
918 |
+ |
919 |
+ multilib-minimal_src_compile |
920 |
+} |
921 |
+ |
922 |
+multilib_src_compile() { |
923 |
+ |
924 |
+ cmake-utils_src_compile "${_cmake_args[@]}" |
925 |
+} |
926 |
+ |
927 |
+ |
928 |
+# @FUNCTION: mysql-multilib_src_install |
929 |
+# @DESCRIPTION: |
930 |
+# Install mysql. |
931 |
+mysql-multilib-r1_src_install() { |
932 |
+ # wrap the config script |
933 |
+ MULTILIB_CHOST_TOOLS=( /usr/bin/mysql_config ) |
934 |
+ |
935 |
+ multilib-minimal_src_install |
936 |
+} |
937 |
+ |
938 |
+multilib_src_install() { |
939 |
+ debug-print-function ${FUNCNAME} "$@" |
940 |
+ |
941 |
+ if multilib_is_native_abi; then |
942 |
+ # Make sure the vars are correctly initialized |
943 |
+ mysql_init_vars |
944 |
+ |
945 |
+ cmake-utils_src_install |
946 |
+ |
947 |
+ # Convenience links |
948 |
+ einfo "Making Convenience links for mysqlcheck multi-call binary" |
949 |
+ dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlanalyze" |
950 |
+ dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqlrepair" |
951 |
+ dosym "/usr/bin/mysqlcheck" "/usr/bin/mysqloptimize" |
952 |
+ |
953 |
+ # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir |
954 |
+ if [[ -d "${ED}/usr/data" ]] ; then |
955 |
+ rm -Rf "${ED}/usr/data" || die |
956 |
+ fi |
957 |
+ |
958 |
+ # Unless they explicitly specific USE=test, then do not install the |
959 |
+ # testsuite. It DOES have a use to be installed, esp. when you want to do a |
960 |
+ # validation of your database configuration after tuning it. |
961 |
+ if ! use test ; then |
962 |
+ rm -rf "${D}"/${MY_SHAREDSTATEDIR}/mysql-test |
963 |
+ fi |
964 |
+ |
965 |
+ # Configuration stuff |
966 |
+ case ${MYSQL_PV_MAJOR} in |
967 |
+ 5.5) mysql_mycnf_version="5.5" ;; |
968 |
+ 5.[6-9]|6*|7*|8*|9*|10*) mysql_mycnf_version="5.6" ;; |
969 |
+ esac |
970 |
+ einfo "Building default my.cnf (${mysql_mycnf_version})" |
971 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}" |
972 |
+ [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf |
973 |
+ mycnf_src="my.cnf-${mysql_mycnf_version}" |
974 |
+ sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ |
975 |
+ "${FILESDIR}/${mycnf_src}" \ |
976 |
+ > "${TMPDIR}/my.cnf.ok" || die |
977 |
+ use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR}/my.cnf.ok" |
978 |
+ if use latin1 ; then |
979 |
+ sed -i \ |
980 |
+ -e "/character-set/s|utf8|latin1|g" \ |
981 |
+ "${TMPDIR}/my.cnf.ok" || die |
982 |
+ fi |
983 |
+ eprefixify "${TMPDIR}/my.cnf.ok" |
984 |
+ newins "${TMPDIR}/my.cnf.ok" my.cnf |
985 |
+ |
986 |
+ if use server ; then |
987 |
+ einfo "Creating initial directories" |
988 |
+ # Empty directories ... |
989 |
+ diropts "-m0750" |
990 |
+ if [[ ${PREVIOUS_DATADIR} != "yes" ]] ; then |
991 |
+ dodir "${MY_DATADIR#${EPREFIX}}" |
992 |
+ keepdir "${MY_DATADIR#${EPREFIX}}" |
993 |
+ chown -R mysql:mysql "${D}/${MY_DATADIR}" |
994 |
+ fi |
995 |
+ |
996 |
+ diropts "-m0755" |
997 |
+ for folder in "${MY_LOGDIR#${EPREFIX}}" ; do |
998 |
+ dodir "${folder}" |
999 |
+ keepdir "${folder}" |
1000 |
+ chown -R mysql:mysql "${ED}/${folder}" |
1001 |
+ done |
1002 |
+ |
1003 |
+ einfo "Including support files and sample configurations" |
1004 |
+ docinto "support-files" |
1005 |
+ for script in \ |
1006 |
+ "${S}"/support-files/my-*.cnf.sh \ |
1007 |
+ "${S}"/support-files/magic \ |
1008 |
+ "${S}"/support-files/ndb-config-2-node.ini.sh |
1009 |
+ do |
1010 |
+ [[ -f $script ]] && dodoc "${script}" |
1011 |
+ done |
1012 |
+ |
1013 |
+ docinto "scripts" |
1014 |
+ for script in "${S}"/scripts/mysql* ; do |
1015 |
+ [[ ( -f $script ) && ( ${script%.sh} == ${script} ) ]] && dodoc "${script}" |
1016 |
+ done |
1017 |
+ fi |
1018 |
+ |
1019 |
+ #Remove mytop if perl is not selected |
1020 |
+ [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" |
1021 |
+ |
1022 |
+ # Percona has decided to rename libmysqlclient to libperconaserverclient |
1023 |
+ # Use a symlink to preserve linkages for those who don't use mysql_config |
1024 |
+ local suffix |
1025 |
+ for suffix in ".so" "_r.so" ".a" "_r.a" ; do |
1026 |
+ if [[ -e "${ED}/usr/$(get_libdir)/libperconaserverclient${suffix}" ]] ; then |
1027 |
+ dosym libperconaserverclient${suffix} /usr/$(get_libdir)/libmysqlclient${suffix} |
1028 |
+ fi |
1029 |
+ done |
1030 |
+ else |
1031 |
+ cmake-utils_src_install |
1032 |
+ if [[ "${PN}" == "mariadb" ]] && use server ; then |
1033 |
+ insinto /usr/include/mysql/private |
1034 |
+ doins "${S}"/sql/*.h |
1035 |
+ fi |
1036 |
+ fi |
1037 |
+} |
1038 |
+ |
1039 |
+# @FUNCTION: mysql-multilib_pkg_preinst |
1040 |
+# @DESCRIPTION: |
1041 |
+mysql-multilib-r1_pkg_preinst() { |
1042 |
+ debug-print-function ${FUNCNAME} "$@" |
1043 |
+ |
1044 |
+ # Here we need to see if the implementation switched client libraries |
1045 |
+ # We check if this is a new instance of the package and a client library already exists |
1046 |
+ local SHOW_ABI_MESSAGE |
1047 |
+ if [[ -z ${REPLACING_VERSIONS} && -e "${EROOT}usr/$(get_libdir)/libmysqlclient.so" ]] ; then |
1048 |
+ elog "Due to ABI changes when switching between different client libraries," |
1049 |
+ elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." |
1050 |
+ elog "Please run: revdep-rebuild --library libmysqlclient.so.${SUBSLOT:-18}" |
1051 |
+ ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" |
1052 |
+ fi |
1053 |
+} |
1054 |
+ |
1055 |
+# @FUNCTION: mysql-multilib-r1_pkg_postinst |
1056 |
+# @DESCRIPTION: |
1057 |
+# Run post-installation tasks: |
1058 |
+# create the dir for logfiles if non-existant |
1059 |
+# touch the logfiles and secure them |
1060 |
+# install scripts |
1061 |
+# issue required steps for optional features |
1062 |
+# issue deprecation warnings |
1063 |
+mysql-multilib-r1_pkg_postinst() { |
1064 |
+ debug-print-function ${FUNCNAME} "$@" |
1065 |
+ |
1066 |
+ # Make sure the vars are correctly initialized |
1067 |
+ mysql_init_vars |
1068 |
+ |
1069 |
+ # Check FEATURES="collision-protect" before removing this |
1070 |
+ [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" |
1071 |
+ |
1072 |
+ # Secure the logfiles |
1073 |
+ touch "${ROOT}${MY_LOGDIR}"/mysql.{log,err} |
1074 |
+ chown mysql:mysql "${ROOT}${MY_LOGDIR}"/mysql* |
1075 |
+ chmod 0660 "${ROOT}${MY_LOGDIR}"/mysql* |
1076 |
+ |
1077 |
+ # Minimal builds don't have the MySQL server |
1078 |
+ if use server ; then |
1079 |
+ docinto "support-files" |
1080 |
+ for script in \ |
1081 |
+ support-files/my-*.cnf \ |
1082 |
+ support-files/magic \ |
1083 |
+ support-files/ndb-config-2-node.ini |
1084 |
+ do |
1085 |
+ [[ -f "${script}" ]] \ |
1086 |
+ && dodoc "${script}" |
1087 |
+ done |
1088 |
+ |
1089 |
+ docinto "scripts" |
1090 |
+ for script in scripts/mysql* ; do |
1091 |
+ if [[ -f "${script}" && "${script%.sh}" == "${script}" ]]; then |
1092 |
+ dodoc "${script}" |
1093 |
+ fi |
1094 |
+ done |
1095 |
+ |
1096 |
+ if use_if_iuse pam ; then |
1097 |
+ einfo |
1098 |
+ elog "This install includes the PAM authentication plugin." |
1099 |
+ elog "To activate and configure the PAM plugin, please read:" |
1100 |
+ if [[ ${PN} == "mariadb" ]] ; then |
1101 |
+ elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" |
1102 |
+ elif [[ ${PN} == "percona-server" ]] ; then |
1103 |
+ elog "https://www.percona.com/doc/percona-server/5.6/management/pam_plugin.html" |
1104 |
+ fi |
1105 |
+ einfo |
1106 |
+ fi |
1107 |
+ |
1108 |
+ if [[ -z "${REPLACING_VERSIONS}" ]] ; then |
1109 |
+ einfo |
1110 |
+ elog "You might want to run:" |
1111 |
+ elog "\"emerge --config =${CATEGORY}/${PF}\"" |
1112 |
+ elog "if this is a new install." |
1113 |
+ elog |
1114 |
+ elog "If you are switching server implentations, you should run the" |
1115 |
+ elog "mysql_upgrade tool." |
1116 |
+ einfo |
1117 |
+ else |
1118 |
+ einfo |
1119 |
+ elog "If you are upgrading major versions, you should run the" |
1120 |
+ elog "mysql_upgrade tool." |
1121 |
+ einfo |
1122 |
+ fi |
1123 |
+ |
1124 |
+ if use_if_iuse galera ; then |
1125 |
+ einfo |
1126 |
+ elog "Be sure to edit the my.cnf file to activate your cluster settings." |
1127 |
+ elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" |
1128 |
+ elog "The first time the cluster is activated, you should add" |
1129 |
+ elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." |
1130 |
+ elog "This option should then be removed for subsequent starts." |
1131 |
+ einfo |
1132 |
+ fi |
1133 |
+ fi |
1134 |
+} |
1135 |
+ |
1136 |
+# @FUNCTION: mysql-multilib-r1_getopt |
1137 |
+# @DESCRIPTION: |
1138 |
+# Use my_print_defaults to extract specific config options |
1139 |
+mysql-multilib-r1_getopt() { |
1140 |
+ local mypd="${EROOT}"/usr/bin/my_print_defaults |
1141 |
+ section="$1" |
1142 |
+ flag="--${2}=" |
1143 |
+ "${mypd}" $section | sed -n "/^${flag}/p" |
1144 |
+} |
1145 |
+ |
1146 |
+# @FUNCTION: mysql-multilib-r1_getoptval |
1147 |
+# @DESCRIPTION: |
1148 |
+# Use my_print_defaults to extract specific config options |
1149 |
+mysql-multilib-r1_getoptval() { |
1150 |
+ local mypd="${EROOT}"/usr/bin/my_print_defaults |
1151 |
+ local section="$1" |
1152 |
+ local flag="--${2}=" |
1153 |
+ local extra_options="${3}" |
1154 |
+ "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" |
1155 |
+} |
1156 |
+ |
1157 |
+# @FUNCTION: mysql-multilib_pkg_config |
1158 |
+# @DESCRIPTION: |
1159 |
+# Configure mysql environment. |
1160 |
+mysql-multilib-r1_pkg_config() { |
1161 |
+ |
1162 |
+ debug-print-function ${FUNCNAME} "$@" |
1163 |
+ |
1164 |
+ local old_MY_DATADIR="${MY_DATADIR}" |
1165 |
+ local old_HOME="${HOME}" |
1166 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
1167 |
+ export HOME=${EPREFIX}/root |
1168 |
+ |
1169 |
+ # Make sure the vars are correctly initialized |
1170 |
+ mysql_init_vars |
1171 |
+ |
1172 |
+ [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" |
1173 |
+ if ! built_with_use ${CATEGORY}/${PN} server ; then |
1174 |
+ die "Minimal builds do NOT include the MySQL server" |
1175 |
+ fi |
1176 |
+ |
1177 |
+ if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then |
1178 |
+ local MY_DATADIR_s="${ROOT}/${MY_DATADIR}" |
1179 |
+ MY_DATADIR_s="${MY_DATADIR_s%%/}" |
1180 |
+ local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}" |
1181 |
+ old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" |
1182 |
+ |
1183 |
+ if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then |
1184 |
+ if [[ -d "${MY_DATADIR_s}" ]]; then |
1185 |
+ ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" |
1186 |
+ ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" |
1187 |
+ else |
1188 |
+ elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" |
1189 |
+ mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ |
1190 |
+ || die "Moving MY_DATADIR failed" |
1191 |
+ fi |
1192 |
+ else |
1193 |
+ ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" |
1194 |
+ if [[ -d "${MY_DATADIR_s}" ]]; then |
1195 |
+ ewarn "Attempting to use ${MY_DATADIR_s}" |
1196 |
+ else |
1197 |
+ eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" |
1198 |
+ die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" |
1199 |
+ fi |
1200 |
+ fi |
1201 |
+ fi |
1202 |
+ |
1203 |
+ local pwd1="a" |
1204 |
+ local pwd2="b" |
1205 |
+ local maxtry=15 |
1206 |
+ |
1207 |
+ if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
1208 |
+ MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password)" |
1209 |
+ # Sometimes --show is required to display passwords in some implementations of my_print_defaults |
1210 |
+ if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then |
1211 |
+ MYSQL_ROOT_PASSWORD="$(mysql-multilib-r1_getoptval 'client mysql' password --show)" |
1212 |
+ fi |
1213 |
+ fi |
1214 |
+ MYSQL_TMPDIR="$(mysql-multilib-r1_getoptval mysqld tmpdir)" |
1215 |
+ # These are dir+prefix |
1216 |
+ MYSQL_RELAY_LOG="$(mysql-multilib-r1_getoptval mysqld relay-log)" |
1217 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
1218 |
+ MYSQL_LOG_BIN="$(mysql-multilib-r1_getoptval mysqld log-bin)" |
1219 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
1220 |
+ |
1221 |
+ if [[ ! -d "${ROOT}"/$MYSQL_TMPDIR ]]; then |
1222 |
+ einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" |
1223 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_TMPDIR |
1224 |
+ fi |
1225 |
+ if [[ ! -d "${ROOT}"/$MYSQL_LOG_BIN ]]; then |
1226 |
+ einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" |
1227 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_LOG_BIN |
1228 |
+ fi |
1229 |
+ if [[ ! -d "${EROOT}"/$MYSQL_RELAY_LOG ]]; then |
1230 |
+ einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" |
1231 |
+ install -d -m 770 -o mysql -g mysql "${EROOT}"/$MYSQL_RELAY_LOG |
1232 |
+ fi |
1233 |
+ |
1234 |
+ if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then |
1235 |
+ ewarn "You have already a MySQL database in place." |
1236 |
+ ewarn "(${ROOT}/${MY_DATADIR}/*)" |
1237 |
+ ewarn "Please rename or delete it if you wish to replace it." |
1238 |
+ die "MySQL database already exists!" |
1239 |
+ fi |
1240 |
+ |
1241 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
1242 |
+ # localhost. Also causes weird failures. |
1243 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
1244 |
+ |
1245 |
+ if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then |
1246 |
+ |
1247 |
+ einfo "Please provide a password for the mysql 'root' user now" |
1248 |
+ einfo "or through the ${HOME}/.my.cnf file." |
1249 |
+ ewarn "Avoid [\"'\\_%] characters in the password" |
1250 |
+ read -rsp " >" pwd1 ; echo |
1251 |
+ |
1252 |
+ einfo "Retype the password" |
1253 |
+ read -rsp " >" pwd2 ; echo |
1254 |
+ |
1255 |
+ if [[ "x$pwd1" != "x$pwd2" ]] ; then |
1256 |
+ die "Passwords are not the same" |
1257 |
+ fi |
1258 |
+ MYSQL_ROOT_PASSWORD="${pwd1}" |
1259 |
+ unset pwd1 pwd2 |
1260 |
+ fi |
1261 |
+ |
1262 |
+ local options |
1263 |
+ local sqltmp="$(emktemp)" |
1264 |
+ |
1265 |
+ # Fix bug 446200. Don't reference host my.cnf, needs to come first, |
1266 |
+ # see http://bugs.mysql.com/bug.php?id=31312 |
1267 |
+ use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" |
1268 |
+ |
1269 |
+ local help_tables="${ROOT}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" |
1270 |
+ [[ -r "${help_tables}" ]] \ |
1271 |
+ && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ |
1272 |
+ || touch "${TMPDIR}/fill_help_tables.sql" |
1273 |
+ help_tables="${TMPDIR}/fill_help_tables.sql" |
1274 |
+ |
1275 |
+ # Figure out which options we need to disable to do the setup |
1276 |
+ local helpfile="${TMPDIR}/mysqld-help" |
1277 |
+ ${EROOT}/usr/sbin/mysqld --verbose --help >"${helpfile}" 2>/dev/null |
1278 |
+ for opt in grant-tables host-cache name-resolve networking slave-start \ |
1279 |
+ federated ssl log-bin relay-log slow-query-log external-locking \ |
1280 |
+ ndbcluster log-slave-updates \ |
1281 |
+ ; do |
1282 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
1283 |
+ egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" |
1284 |
+ done |
1285 |
+ # But some options changed names |
1286 |
+ egrep -sq external-locking "${helpfile}" && \ |
1287 |
+ options="${options/skip-locking/skip-external-locking}" |
1288 |
+ |
1289 |
+ use prefix || options="${options} --user=mysql" |
1290 |
+ |
1291 |
+ einfo "Creating the mysql database and setting proper permissions on it ..." |
1292 |
+ |
1293 |
+ # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it |
1294 |
+ PID_DIR="${EROOT}/var/run/mysqld" |
1295 |
+ if [[ ! -d "${PID_DIR}" ]]; then |
1296 |
+ mkdir -p "${PID_DIR}" || die "Could not create pid directory" |
1297 |
+ chown mysql:mysql "${PID_DIR}" || die "Could not set ownership on pid directory" |
1298 |
+ chmod 755 "${PID_DIR}" || die "Could not set permissions on pid directory" |
1299 |
+ fi |
1300 |
+ |
1301 |
+ pushd "${TMPDIR}" &>/dev/null |
1302 |
+ |
1303 |
+ # Filling timezones, see |
1304 |
+ # http://dev.mysql.com/doc/mysql/en/time-zone-support.html |
1305 |
+ "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" > "${sqltmp}" 2>/dev/null |
1306 |
+ |
1307 |
+ local cmd |
1308 |
+ local initialize_options |
1309 |
+ if [[ ${PN} == "mysql" || ${PN} == "percona-server" ]] && mysql_version_is_at_least "5.7.6" ; then |
1310 |
+ # --initialize-insecure will not set root password |
1311 |
+ # --initialize would set a random one in the log which we don't need as we set it ourselves |
1312 |
+ cmd="${EROOT}usr/sbin/mysqld" |
1313 |
+ initialize_options="--initialize-insecure '--init-file=${sqltmp}'" |
1314 |
+ sqltmp="" # the initialize will take care of it |
1315 |
+ else |
1316 |
+ cmd="${EROOT}usr/share/mysql/scripts/mysql_install_db" |
1317 |
+ [[ -f "${cmd}" ]] || cmd="${EROOT}usr/bin/mysql_install_db" |
1318 |
+ if [[ -r "${help_tables}" ]] ; then |
1319 |
+ cat "${help_tables}" >> "${sqltmp}" |
1320 |
+ fi |
1321 |
+ fi |
1322 |
+ cmd="'$cmd' '--basedir=${EPREFIX}/usr' ${options} '--datadir=${ROOT}/${MY_DATADIR}' '--tmpdir=${ROOT}/${MYSQL_TMPDIR}' ${initialize_options}" |
1323 |
+ einfo "Command: $cmd" |
1324 |
+ eval $cmd \ |
1325 |
+ >"${TMPDIR}"/mysql_install_db.log 2>&1 |
1326 |
+ if [ $? -ne 0 ]; then |
1327 |
+ grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 |
1328 |
+ die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" |
1329 |
+ fi |
1330 |
+ popd &>/dev/null |
1331 |
+ [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ |
1332 |
+ || die "MySQL databases not installed" |
1333 |
+ chown -R mysql:mysql "${ROOT}/${MY_DATADIR}" 2>/dev/null |
1334 |
+ chmod 0750 "${ROOT}/${MY_DATADIR}" 2>/dev/null |
1335 |
+ |
1336 |
+ local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock" |
1337 |
+ local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid" |
1338 |
+ local mysqld="${EROOT}/usr/sbin/mysqld \ |
1339 |
+ ${options} \ |
1340 |
+ $(use prefix || echo --user=mysql) \ |
1341 |
+ --log-warnings=0 \ |
1342 |
+ --basedir=${EROOT}/usr \ |
1343 |
+ --datadir=${ROOT}/${MY_DATADIR} \ |
1344 |
+ --max_allowed_packet=8M \ |
1345 |
+ --net_buffer_length=16K \ |
1346 |
+ --default-storage-engine=MyISAM \ |
1347 |
+ --socket=${socket} \ |
1348 |
+ --pid-file=${pidfile} |
1349 |
+ --tmpdir=${ROOT}/${MYSQL_TMPDIR}" |
1350 |
+ #einfo "About to start mysqld: ${mysqld}" |
1351 |
+ ebegin "Starting mysqld" |
1352 |
+ einfo "Command ${mysqld}" |
1353 |
+ ${mysqld} & |
1354 |
+ rc=$? |
1355 |
+ while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do |
1356 |
+ maxtry=$((${maxtry}-1)) |
1357 |
+ echo -n "." |
1358 |
+ sleep 1 |
1359 |
+ done |
1360 |
+ eend $rc |
1361 |
+ |
1362 |
+ if ! [[ -S "${socket}" ]]; then |
1363 |
+ die "Completely failed to start up mysqld with: ${mysqld}" |
1364 |
+ fi |
1365 |
+ |
1366 |
+ ebegin "Setting root password" |
1367 |
+ # Do this from memory, as we don't want clear text passwords in temp files |
1368 |
+ local sql="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'" |
1369 |
+ "${EROOT}/usr/bin/mysql" \ |
1370 |
+ --socket=${socket} \ |
1371 |
+ -hlocalhost \ |
1372 |
+ -e "${sql}" |
1373 |
+ eend $? |
1374 |
+ |
1375 |
+ if [[ -n "${sqltmp}" ]] ; then |
1376 |
+ ebegin "Loading \"zoneinfo\", this step may require a few seconds" |
1377 |
+ "${EROOT}/usr/bin/mysql" \ |
1378 |
+ --socket=${socket} \ |
1379 |
+ -hlocalhost \ |
1380 |
+ -uroot \ |
1381 |
+ --password="${MYSQL_ROOT_PASSWORD}" \ |
1382 |
+ mysql < "${sqltmp}" |
1383 |
+ rc=$? |
1384 |
+ eend $? |
1385 |
+ [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!" |
1386 |
+ fi |
1387 |
+ |
1388 |
+ # Stop the server and cleanup |
1389 |
+ einfo "Stopping the server ..." |
1390 |
+ kill $(< "${pidfile}" ) |
1391 |
+ rm -f "${sqltmp}" |
1392 |
+ wait %1 |
1393 |
+ einfo "Done" |
1394 |
+} |
1395 |
+ |
1396 |
+ |
1397 |
+# |
1398 |
+# HELPER FUNCTIONS: |
1399 |
+# |
1400 |
+ |
1401 |
+# @FUNCTION: mysql-multilib-r1_disable_test |
1402 |
+# @DESCRIPTION: |
1403 |
+# Helper function to disable specific tests. |
1404 |
+mysql-multilib-r1_disable_test() { |
1405 |
+ |
1406 |
+ local rawtestname testname testsuite reason mysql_disabled_file mysql_disabled_dir |
1407 |
+ rawtestname="${1}" ; shift |
1408 |
+ reason="${@}" |
1409 |
+ ewarn "test '${rawtestname}' disabled: '${reason}'" |
1410 |
+ |
1411 |
+ testsuite="${rawtestname/.*}" |
1412 |
+ testname="${rawtestname/*.}" |
1413 |
+ for mysql_disabled_file in \ |
1414 |
+ ${S}/mysql-test/disabled.def \ |
1415 |
+ ${S}/mysql-test/t/disabled.def ; do |
1416 |
+ [[ -f ${mysql_disabled_file} ]] && break |
1417 |
+ done |
1418 |
+ #mysql_disabled_file="${S}/mysql-test/t/disabled.def" |
1419 |
+ #einfo "rawtestname=${rawtestname} testname=${testname} testsuite=${testsuite}" |
1420 |
+ echo ${testname} : ${reason} >> "${mysql_disabled_file}" |
1421 |
+ |
1422 |
+ if [[ ( -n ${testsuite} ) && ( ${testsuite} != "main" ) ]]; then |
1423 |
+ for mysql_disabled_file in \ |
1424 |
+ ${S}/mysql-test/suite/${testsuite}/disabled.def \ |
1425 |
+ ${S}/mysql-test/suite/${testsuite}/t/disabled.def \ |
1426 |
+ FAILED ; do |
1427 |
+ [[ -f ${mysql_disabled_file} ]] && break |
1428 |
+ done |
1429 |
+ if [[ ${mysql_disabled_file} != "FAILED" ]]; then |
1430 |
+ echo "${testname} : ${reason}" >> "${mysql_disabled_file}" |
1431 |
+ else |
1432 |
+ for mysql_disabled_dir in \ |
1433 |
+ ${S}/mysql-test/suite/${testsuite} \ |
1434 |
+ ${S}/mysql-test/suite/${testsuite}/t \ |
1435 |
+ FAILED ; do |
1436 |
+ [[ -d ${mysql_disabled_dir} ]] && break |
1437 |
+ done |
1438 |
+ if [[ ${mysql_disabled_dir} != "FAILED" ]]; then |
1439 |
+ echo "${testname} : ${reason}" >> "${mysql_disabled_dir}/disabled.def" |
1440 |
+ else |
1441 |
+ ewarn "Could not find testsuite disabled.def location for ${rawtestname}" |
1442 |
+ fi |
1443 |
+ fi |
1444 |
+ fi |
1445 |
+} |
1446 |
+ |
1447 |
+# @FUNCTION: mysql-cmake_use_plugin |
1448 |
+# @DESCRIPTION: |
1449 |
+# Helper function to enable/disable plugins by use flags |
1450 |
+# cmake-utils_use_with is not enough as some references check WITH_ (0|1) |
1451 |
+# and some check WITHOUT_. Also, this can easily extend to non-storage plugins. |
1452 |
+mysql-cmake_use_plugin() { |
1453 |
+ [[ -z $2 ]] && die "mysql-cmake_use_plugin <USE flag> <flag name>" |
1454 |
+ if use_if_iuse $1 ; then |
1455 |
+ echo "-DWITH_$2=1 -DPLUGIN_$2=YES" |
1456 |
+ else |
1457 |
+ echo "-DWITHOUT_$2=1 -DWITH_$2=0 -DPLUGIN_$2=NO" |
1458 |
+ fi |
1459 |
+} |