1 |
commit: e5ac359b6a7722e6165639e4acd89cf38e0c4194 |
2 |
Author: Tomáš Mózes <hydrapolic <AT> gmail <DOT> com> |
3 |
AuthorDate: Tue May 31 18:49:34 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue May 31 22:10:24 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e5ac359b |
7 |
|
8 |
dev-db/mariadb: bump to 10.4.25 |
9 |
|
10 |
Bug: https://bugs.gentoo.org/832490 |
11 |
Signed-off-by: Tomáš Mózes <hydrapolic <AT> gmail.com> |
12 |
Closes: https://github.com/gentoo/gentoo/pull/25704 |
13 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
14 |
|
15 |
dev-db/mariadb/Manifest | 2 + |
16 |
dev-db/mariadb/mariadb-10.4.25.ebuild | 1305 +++++++++++++++++++++++++++++++++ |
17 |
2 files changed, 1307 insertions(+) |
18 |
|
19 |
diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest |
20 |
index 2ad9594c1305..11929214d262 100644 |
21 |
--- a/dev-db/mariadb/Manifest |
22 |
+++ b/dev-db/mariadb/Manifest |
23 |
@@ -10,6 +10,8 @@ DIST mariadb-10.3.34.tar.gz 73455446 BLAKE2B 7737c6f01cb1c9b38d51f9dd390898d8351 |
24 |
DIST mariadb-10.3.35.tar.gz 73496487 BLAKE2B 3ab05276fc22098be11ce8e2f5c9323c05c28b7617b31655506fe97131cccebe70a525dda0856b05c8196fabf50243865adf91ed6914ca750bbdf27c915767e8 SHA512 9355de944eccef4e0bc01b19ffc3c0c72cf88befae7385c6f0ee1ea47dbd98d23f6bb46af9c140acc48d9d9613552870684bc0b7ca1f3cff1dc09c1a2c801573 |
25 |
DIST mariadb-10.4.22-patches-01.tar.xz 4388 BLAKE2B 0e615ddc4db93daa1f4ef1d8755b97502bb19b0ece0fc0d6d8620cb69a7db2df81ef5a06fc0a6b0f7b61fdb5431f919da99afa8068b064d905cdeaa95df807f0 SHA512 7bfff381b7fd19d12f64caaaa7d598ee476e286def9be9acd6f808784ecd47e715f222bd07fd05cd24b3342053f46c22d03041413a6a55b7194d1a5c66b0c03a |
26 |
DIST mariadb-10.4.22.tar.gz 84916052 BLAKE2B f5f7623101cfac6b209a95de20ee737ce0afa574766340471a30ddb81abacaf2acf3809d54ecb62f9377f924b11fac04faa770802c2bdc8dc10e3286b1c8e648 SHA512 e505a56346cfcaf5b8fba80abad6b2ce819dd410f6e6f36e290ad4127aaa9fb580264c28068f9f9e04c3a2fcccd101ef73d2bf5944aedde6b2d4369163fb9248 |
27 |
+DIST mariadb-10.4.25-patches-01.tar.xz 4496 BLAKE2B f710bed49c53bda4cd1bfc8cc8bbde8588a5600a25aba62f90be61e78879729b6b34ec18bfc0729f8330b9fc9858079e2d924c2b72080b86c73b85a9294f2894 SHA512 5545b6fa879ba99c38b52b5c4e1347efea0f1fd098c8593388a6e9c11ae7ffbca5ebe69a3c418420f49a0a7671bf26102dd2dc024fd60e8f9072ae920a16cb58 |
28 |
+DIST mariadb-10.4.25.tar.gz 88680777 BLAKE2B 993ed640ad579c2726ae241165d024a87fff580a4461fedee7c41a2bd70d668ed56b31219032096b4bd264543d6a93457947422b8a1384d3d3b94e7ca2f6ecb4 SHA512 27ad62985e19c877623d1512adcbec44e714ca50da9d303eab12bc2ad67dcae45d48a1aa010ad554341c46a1c5db7ee26c14570b9fa55fb71caf9979dd12671e |
29 |
DIST mariadb-10.5.13-patches-01.tar.xz 5012 BLAKE2B 34a5af415737f71750a8fa47de4f2119e31723686f000a7f99f9892a0a12fbd2be3c7bb635197b131691d73ae663e34c1b010b154d62e1ea16535265f96200f1 SHA512 71e7940558fa863835ef86f04c48c4a1ca927dee0d9ae94fcb32facde857dfef1757ae96b5a738653c341fa19a67916b0b3a03ce473020edd5c8b52ccedc0bea |
30 |
DIST mariadb-10.5.13.tar.gz 102047279 BLAKE2B be91ebbd05b72d8046eaea73075510e160d7985b2766f64a1cdd3e5bbad1f4eebe9f371caf070a0e9fab605a90588539a4011ea4b2e4243ea4fd8f299ee836fd SHA512 5d5ac04a3c8099a982cacb98dd4c162966fc7957e11c28e8b5645e49ffcf0513b9c8956f43d215c37e5eaa34aa8db6c71cfe993c89d62cab123021ee83169e7f |
31 |
DIST mariadb-10.5.15-patches-01.tar.xz 5116 BLAKE2B 57759c61e672668be8ed991ca023007a4e0c10b2352cc621e88b825097cfde3eb83078804af7afaaa0c6f47900c34046773141a9e3dc3c220b33ecc16435784d SHA512 e3d21b3499ec9f6b5fd32978a6a779ecaca671cccadf241700207a1a3822a6b05ba2e13e1a6cb20e4d5fe4e6db6e5f46e9af650c736bdc3e3de9a4d8bad7ce19 |
32 |
|
33 |
diff --git a/dev-db/mariadb/mariadb-10.4.25.ebuild b/dev-db/mariadb/mariadb-10.4.25.ebuild |
34 |
new file mode 100644 |
35 |
index 000000000000..e128e00ce2f5 |
36 |
--- /dev/null |
37 |
+++ b/dev-db/mariadb/mariadb-10.4.25.ebuild |
38 |
@@ -0,0 +1,1305 @@ |
39 |
+# Copyright 1999-2022 Gentoo Authors |
40 |
+# Distributed under the terms of the GNU General Public License v2 |
41 |
+ |
42 |
+EAPI="7" |
43 |
+SUBSLOT="18" |
44 |
+ |
45 |
+JAVA_PKG_OPT_USE="jdbc" |
46 |
+ |
47 |
+inherit eutils systemd flag-o-matic prefix toolchain-funcs \ |
48 |
+ multiprocessing java-pkg-opt-2 cmake |
49 |
+ |
50 |
+# Patch version |
51 |
+PATCH_SET="https://github.com/hydrapolic/gentoo-dist/raw/master/mariadb/mariadb-10.4.25-patches-01.tar.xz" |
52 |
+ |
53 |
+SRC_URI="mirror://mariadb/${PN}-${PV}/source/${P}.tar.gz |
54 |
+ ${PATCH_SET}" |
55 |
+ |
56 |
+HOMEPAGE="https://mariadb.org/" |
57 |
+DESCRIPTION="An enhanced, drop-in replacement for MySQL" |
58 |
+LICENSE="GPL-2 LGPL-2.1+" |
59 |
+SLOT="$(ver_cut 1-2)/${SUBSLOT:-0}" |
60 |
+IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 |
61 |
+ innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga |
62 |
+ numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx |
63 |
+ sst-rsync sst-mariabackup static systemd systemtap tcmalloc |
64 |
+ test tokudb xml yassl" |
65 |
+ |
66 |
+RESTRICT="!bindist? ( bindist ) !test? ( test )" |
67 |
+ |
68 |
+REQUIRED_USE="jdbc? ( extraengine server !static ) |
69 |
+ server? ( tokudb? ( jemalloc !tcmalloc ) ) |
70 |
+ ?? ( tcmalloc jemalloc ) |
71 |
+ static? ( yassl !pam )" |
72 |
+ |
73 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" |
74 |
+ |
75 |
+# Shorten the path because the socket path length must be shorter than 107 chars |
76 |
+# and we will run a mysql server during test phase |
77 |
+S="${WORKDIR}/mysql" |
78 |
+ |
79 |
+# Be warned, *DEPEND are version-dependant |
80 |
+# These are used for both runtime and compiletime |
81 |
+COMMON_DEPEND=" |
82 |
+ kernel_linux? ( |
83 |
+ sys-process/procps:0= |
84 |
+ dev-libs/libaio:0= |
85 |
+ ) |
86 |
+ >=sys-apps/sed-4 |
87 |
+ >=sys-apps/texinfo-4.7-r1 |
88 |
+ jemalloc? ( dev-libs/jemalloc:0= ) |
89 |
+ tcmalloc? ( dev-util/google-perftools:0= ) |
90 |
+ systemtap? ( >=dev-util/systemtap-1.3:0= ) |
91 |
+ >=sys-libs/zlib-1.2.3:0= |
92 |
+ kerberos? ( virtual/krb5 ) |
93 |
+ yassl? ( net-libs/gnutls:0= ) |
94 |
+ !yassl? ( |
95 |
+ >=dev-libs/openssl-1.0.0:0= |
96 |
+ ) |
97 |
+ sys-libs/ncurses:0= |
98 |
+ !bindist? ( |
99 |
+ sys-libs/binutils-libs:0= |
100 |
+ >=sys-libs/readline-4.1:0= |
101 |
+ ) |
102 |
+ server? ( |
103 |
+ backup? ( app-arch/libarchive:0= ) |
104 |
+ cracklib? ( sys-libs/cracklib:0= ) |
105 |
+ extraengine? ( |
106 |
+ odbc? ( dev-db/unixODBC:0= ) |
107 |
+ xml? ( dev-libs/libxml2:2= ) |
108 |
+ ) |
109 |
+ innodb-lz4? ( app-arch/lz4 ) |
110 |
+ innodb-lzo? ( dev-libs/lzo ) |
111 |
+ innodb-snappy? ( app-arch/snappy ) |
112 |
+ mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) |
113 |
+ numa? ( sys-process/numactl ) |
114 |
+ oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) |
115 |
+ pam? ( sys-libs/pam:0= ) |
116 |
+ systemd? ( sys-apps/systemd:= ) |
117 |
+ tokudb? ( app-arch/snappy ) |
118 |
+ ) |
119 |
+ >=dev-libs/libpcre-8.41-r1:3= |
120 |
+ virtual/libcrypt:= |
121 |
+" |
122 |
+BDEPEND="virtual/yacc" |
123 |
+DEPEND="static? ( sys-libs/ncurses[static-libs] ) |
124 |
+ server? ( |
125 |
+ extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) |
126 |
+ test? ( acct-group/mysql acct-user/mysql ) |
127 |
+ ) |
128 |
+ ${COMMON_DEPEND}" |
129 |
+RDEPEND="selinux? ( sec-policy/selinux-mysql ) |
130 |
+ !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster |
131 |
+ !dev-db/mariadb:0 |
132 |
+ !dev-db/mariadb:5.5 |
133 |
+ !dev-db/mariadb:10.1 |
134 |
+ !dev-db/mariadb:10.2 |
135 |
+ !dev-db/mariadb:10.3 |
136 |
+ !dev-db/mariadb:10.5 |
137 |
+ !dev-db/mariadb:10.6 |
138 |
+ !dev-db/mariadb:10.7 |
139 |
+ !dev-db/mariadb:10.8 |
140 |
+ !<virtual/mysql-5.6-r11 |
141 |
+ !<virtual/libmysqlclient-18-r1 |
142 |
+ ${COMMON_DEPEND} |
143 |
+ server? ( |
144 |
+ galera? ( |
145 |
+ sys-apps/iproute2 |
146 |
+ =sys-cluster/galera-26* |
147 |
+ sst-rsync? ( sys-process/lsof ) |
148 |
+ sst-mariabackup? ( net-misc/socat[ssl] ) |
149 |
+ ) |
150 |
+ !prefix? ( dev-db/mysql-init-scripts acct-group/mysql acct-user/mysql ) |
151 |
+ extraengine? ( jdbc? ( >=virtual/jre-1.8 ) ) |
152 |
+ ) |
153 |
+" |
154 |
+# For other stuff to bring us in |
155 |
+# dev-perl/DBD-mysql is needed by some scripts installed by MySQL |
156 |
+PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" |
157 |
+ |
158 |
+mysql_init_vars() { |
159 |
+ MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} |
160 |
+ MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"} |
161 |
+ MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"} |
162 |
+ MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"} |
163 |
+ |
164 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
165 |
+ MY_DATADIR="" |
166 |
+ if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then |
167 |
+ MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \ |
168 |
+ | sed -ne '/datadir/s|^--datadir=||p' \ |
169 |
+ | tail -n1) |
170 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
171 |
+ MY_DATADIR=$(grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ |
172 |
+ | sed -e 's/.*=\s*//' \ |
173 |
+ | tail -n1) |
174 |
+ fi |
175 |
+ fi |
176 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
177 |
+ MY_DATADIR="${MY_LOCALSTATEDIR}" |
178 |
+ einfo "Using default MY_DATADIR" |
179 |
+ fi |
180 |
+ elog "MySQL MY_DATADIR is ${MY_DATADIR}" |
181 |
+ |
182 |
+ if [[ -z "${PREVIOUS_DATADIR}" ]] ; then |
183 |
+ if [[ -e "${MY_DATADIR}" ]] ; then |
184 |
+ # If you get this and you're wondering about it, see bug #207636 |
185 |
+ elog "MySQL datadir found in ${MY_DATADIR}" |
186 |
+ elog "A new one will not be created." |
187 |
+ PREVIOUS_DATADIR="yes" |
188 |
+ else |
189 |
+ PREVIOUS_DATADIR="no" |
190 |
+ fi |
191 |
+ export PREVIOUS_DATADIR |
192 |
+ fi |
193 |
+ else |
194 |
+ if [[ ${EBUILD_PHASE} == "config" ]]; then |
195 |
+ local new_MY_DATADIR |
196 |
+ new_MY_DATADIR=$(my_print_defaults mysqld 2>/dev/null \ |
197 |
+ | sed -ne '/datadir/s|^--datadir=||p' \ |
198 |
+ | tail -n1) |
199 |
+ |
200 |
+ if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then |
201 |
+ ewarn "MySQL MY_DATADIR has changed" |
202 |
+ ewarn "from ${MY_DATADIR}" |
203 |
+ ewarn "to ${new_MY_DATADIR}" |
204 |
+ MY_DATADIR="${new_MY_DATADIR}" |
205 |
+ fi |
206 |
+ fi |
207 |
+ fi |
208 |
+ |
209 |
+ export MY_SHAREDSTATEDIR MY_SYSCONFDIR |
210 |
+ export MY_LOCALSTATEDIR MY_LOGDIR |
211 |
+ export MY_DATADIR |
212 |
+} |
213 |
+ |
214 |
+pkg_setup() { |
215 |
+ if [[ ${MERGE_TYPE} != binary ]] ; then |
216 |
+ if has test ${FEATURES} ; then |
217 |
+ # Bug #213475 - MySQL _will_ object strenuously if your machine is named |
218 |
+ # localhost. Also causes weird failures. |
219 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
220 |
+ |
221 |
+ if ! has userpriv ${FEATURES} ; then |
222 |
+ die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." |
223 |
+ fi |
224 |
+ fi |
225 |
+ fi |
226 |
+ |
227 |
+ java-pkg-opt-2_pkg_setup |
228 |
+} |
229 |
+ |
230 |
+src_unpack() { |
231 |
+ unpack ${A} |
232 |
+ |
233 |
+ mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die |
234 |
+} |
235 |
+ |
236 |
+src_prepare() { |
237 |
+ eapply "${WORKDIR}"/mariadb-patches |
238 |
+ |
239 |
+ eapply_user |
240 |
+ |
241 |
+ _disable_plugin() { |
242 |
+ echo > "${S}/plugin/${1}/CMakeLists.txt" || die |
243 |
+ } |
244 |
+ _disable_engine() { |
245 |
+ echo > "${S}/storage/${1}/CMakeLists.txt" || die |
246 |
+ } |
247 |
+ |
248 |
+ if use jemalloc; then |
249 |
+ echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt" |
250 |
+ elif use tcmalloc; then |
251 |
+ echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt" |
252 |
+ fi |
253 |
+ |
254 |
+ # Don't build bundled xz-utils for tokudb |
255 |
+ echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die |
256 |
+ sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die |
257 |
+ sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die |
258 |
+ |
259 |
+ local plugin |
260 |
+ local server_plugins=( handler_socket auth_socket feedback metadata_lock_info |
261 |
+ locale_info qc_info server_audit sql_errlog auth_ed25519 ) |
262 |
+ local test_plugins=( audit_null auth_examples daemon_example fulltext |
263 |
+ debug_key_management example_key_management versioning ) |
264 |
+ if ! use server; then # These plugins are for the server |
265 |
+ for plugin in "${server_plugins[@]}" ; do |
266 |
+ _disable_plugin "${plugin}" |
267 |
+ done |
268 |
+ fi |
269 |
+ |
270 |
+ if ! use test; then # These plugins are only used during testing |
271 |
+ for plugin in "${test_plugins[@]}" ; do |
272 |
+ _disable_plugin "${plugin}" |
273 |
+ done |
274 |
+ _disable_engine test_sql_discovery |
275 |
+ echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die |
276 |
+ fi |
277 |
+ |
278 |
+ _disable_engine example |
279 |
+ |
280 |
+ if ! use oqgraph ; then # avoids extra library checks |
281 |
+ _disable_engine oqgraph |
282 |
+ fi |
283 |
+ |
284 |
+ if use mroonga ; then |
285 |
+ # Remove the bundled groonga |
286 |
+ # There is no CMake flag, it simply checks for existance |
287 |
+ rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" |
288 |
+ else |
289 |
+ _disable_engine mroonga |
290 |
+ fi |
291 |
+ |
292 |
+ # Fix static bindings in galera replication |
293 |
+ sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ |
294 |
+ "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die |
295 |
+ sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ |
296 |
+ "${S}"/wsrep-lib/src/CMakeLists.txt || die |
297 |
+ |
298 |
+ # Fix galera_recovery.sh script |
299 |
+ sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ |
300 |
+ scripts/galera_recovery.sh || die |
301 |
+ |
302 |
+ sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ |
303 |
+ "${S}"/scripts/mysql_install_db.sh || die |
304 |
+ |
305 |
+ cmake_src_prepare |
306 |
+ java-pkg-opt-2_src_prepare |
307 |
+} |
308 |
+ |
309 |
+src_configure() { |
310 |
+ # bug 508724 mariadb cannot use ld.gold |
311 |
+ tc-ld-disable-gold |
312 |
+ # Bug #114895, bug #110149 |
313 |
+ filter-flags "-O" "-O[01]" |
314 |
+ |
315 |
+ # It fails on alpha without this |
316 |
+ use alpha && append-ldflags "-Wl,--no-relax" |
317 |
+ |
318 |
+ append-cxxflags -felide-constructors |
319 |
+ |
320 |
+ # bug #283926, with GCC4.4, this is required to get correct behavior. |
321 |
+ append-flags -fno-strict-aliasing |
322 |
+ |
323 |
+ CMAKE_BUILD_TYPE="RelWithDebInfo" |
324 |
+ |
325 |
+ # debug hack wrt #497532 |
326 |
+ mycmakeargs=( |
327 |
+ -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
328 |
+ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" |
329 |
+ -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" |
330 |
+ -DSYSCONFDIR="${EPREFIX}/etc/mysql" |
331 |
+ -DINSTALL_BINDIR=bin |
332 |
+ -DINSTALL_DOCDIR=share/doc/${PF} |
333 |
+ -DINSTALL_DOCREADMEDIR=share/doc/${PF} |
334 |
+ -DINSTALL_INCLUDEDIR=include/mysql |
335 |
+ -DINSTALL_INFODIR=share/info |
336 |
+ -DINSTALL_LIBDIR=$(get_libdir) |
337 |
+ -DINSTALL_MANDIR=share/man |
338 |
+ -DINSTALL_MYSQLSHAREDIR=share/mariadb |
339 |
+ -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin |
340 |
+ -DINSTALL_SCRIPTDIR=bin |
341 |
+ -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" |
342 |
+ -DINSTALL_SBINDIR=sbin |
343 |
+ -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" |
344 |
+ -DWITH_COMMENT="Gentoo Linux ${PF}" |
345 |
+ -DWITH_UNIT_TESTS=$(usex test ON OFF) |
346 |
+ -DWITH_LIBEDIT=0 |
347 |
+ -DWITH_ZLIB=system |
348 |
+ -DWITHOUT_LIBWRAP=1 |
349 |
+ -DENABLED_LOCAL_INFILE=1 |
350 |
+ -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" |
351 |
+ -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" |
352 |
+ -DWITH_DEFAULT_COMPILER_OPTIONS=0 |
353 |
+ -DWITH_DEFAULT_FEATURE_SET=0 |
354 |
+ -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" |
355 |
+ # The build forces this to be defined when cross-compiling. We pass it |
356 |
+ # all the time for simplicity and to make sure it is actually correct. |
357 |
+ -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) |
358 |
+ -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" |
359 |
+ -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) |
360 |
+ -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) |
361 |
+ -DCONC_WITH_EXTERNAL_ZLIB=YES |
362 |
+ -DWITH_EXTERNAL_ZLIB=YES |
363 |
+ -DSUFFIX_INSTALL_DIR="" |
364 |
+ -DWITH_UNITTEST=OFF |
365 |
+ -DWITHOUT_CLIENTLIBS=YES |
366 |
+ -DCLIENT_PLUGIN_DIALOG=OFF |
367 |
+ -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF |
368 |
+ -DCLIENT_PLUGIN_CLIENT_ED25519=OFF |
369 |
+ -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC |
370 |
+ -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF |
371 |
+ ) |
372 |
+ if use test ; then |
373 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) |
374 |
+ else |
375 |
+ mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) |
376 |
+ fi |
377 |
+ |
378 |
+ if ! use yassl ; then |
379 |
+ mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) |
380 |
+ else |
381 |
+ mycmakeargs+=( -DWITH_SSL=bundled ) |
382 |
+ fi |
383 |
+ |
384 |
+ # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION |
385 |
+ mycmakeargs+=( |
386 |
+ -DWITH_READLINE=$(usex bindist 1 0) |
387 |
+ -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) |
388 |
+ -DENABLE_DTRACE=$(usex systemtap) |
389 |
+ ) |
390 |
+ |
391 |
+ if use server ; then |
392 |
+ # Connect and Federated{,X} must be treated special |
393 |
+ # otherwise they will not be built as plugins |
394 |
+ if ! use extraengine ; then |
395 |
+ mycmakeargs+=( |
396 |
+ -DPLUGIN_CONNECT=NO |
397 |
+ -DPLUGIN_FEDERATED=NO |
398 |
+ -DPLUGIN_FEDERATEDX=NO |
399 |
+ ) |
400 |
+ fi |
401 |
+ |
402 |
+ mycmakeargs+=( |
403 |
+ -DWITH_PCRE=system |
404 |
+ -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) |
405 |
+ -DPLUGIN_SPHINX=$(usex sphinx YES NO) |
406 |
+ -DPLUGIN_TOKUDB=$(usex tokudb YES NO) |
407 |
+ -DPLUGIN_AUTH_PAM=$(usex pam YES NO) |
408 |
+ -DPLUGIN_AWS_KEY_MANAGEMENT=NO |
409 |
+ -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) |
410 |
+ -DPLUGIN_CASSANDRA=NO |
411 |
+ -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) |
412 |
+ -DPLUGIN_SPIDER=$(usex extraengine YES NO) |
413 |
+ -DCONNECT_WITH_MYSQL=1 |
414 |
+ -DCONNECT_WITH_LIBXML2=$(usex xml) |
415 |
+ -DCONNECT_WITH_ODBC=$(usex odbc) |
416 |
+ -DCONNECT_WITH_JDBC=$(usex jdbc) |
417 |
+ # Build failure and autodep wrt bug 639144 |
418 |
+ -DCONNECT_WITH_MONGO=OFF |
419 |
+ -DWITH_WSREP=$(usex galera) |
420 |
+ -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) |
421 |
+ -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) |
422 |
+ -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) |
423 |
+ -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) |
424 |
+ -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) |
425 |
+ -DWITH_MARIABACKUP=$(usex backup ON OFF) |
426 |
+ -DWITH_LIBARCHIVE=$(usex backup ON OFF) |
427 |
+ -DINSTALL_SQLBENCHDIR="" |
428 |
+ -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) |
429 |
+ # systemd is only linked to for server notification |
430 |
+ -DWITH_SYSTEMD=$(usex systemd yes no) |
431 |
+ -DWITH_NUMA=$(usex numa ON OFF) |
432 |
+ ) |
433 |
+ |
434 |
+ # Workaround for MDEV-14524 |
435 |
+ use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) |
436 |
+ |
437 |
+ if use test ; then |
438 |
+ # This is needed for the new client lib which tests a real, open server |
439 |
+ mycmakeargs+=( -DSKIP_TESTS=ON ) |
440 |
+ fi |
441 |
+ |
442 |
+ if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then |
443 |
+ ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" |
444 |
+ ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." |
445 |
+ ewarn "You MUST file bugs without these variables set." |
446 |
+ |
447 |
+ mycmakeargs+=( |
448 |
+ -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} |
449 |
+ -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} |
450 |
+ ) |
451 |
+ |
452 |
+ elif ! use latin1 ; then |
453 |
+ mycmakeargs+=( |
454 |
+ -DDEFAULT_CHARSET=utf8 |
455 |
+ -DDEFAULT_COLLATION=utf8_general_ci |
456 |
+ ) |
457 |
+ else |
458 |
+ mycmakeargs+=( |
459 |
+ -DDEFAULT_CHARSET=latin1 |
460 |
+ -DDEFAULT_COLLATION=latin1_swedish_ci |
461 |
+ ) |
462 |
+ fi |
463 |
+ mycmakeargs+=( |
464 |
+ -DEXTRA_CHARSETS=all |
465 |
+ -DMYSQL_USER=mysql |
466 |
+ -DDISABLE_SHARED=$(usex static YES NO) |
467 |
+ -DWITH_DEBUG=$(usex debug) |
468 |
+ -DWITH_EMBEDDED_SERVER=OFF |
469 |
+ -DWITH_PROFILING=$(usex profiling) |
470 |
+ ) |
471 |
+ |
472 |
+ if use static; then |
473 |
+ mycmakeargs+=( -DWITH_PIC=1 ) |
474 |
+ fi |
475 |
+ |
476 |
+ if use jemalloc || use tcmalloc ; then |
477 |
+ mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) |
478 |
+ fi |
479 |
+ |
480 |
+ # Storage engines |
481 |
+ mycmakeargs+=( |
482 |
+ -DWITH_ARCHIVE_STORAGE_ENGINE=1 |
483 |
+ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 |
484 |
+ -DWITH_CSV_STORAGE_ENGINE=1 |
485 |
+ -DWITH_HEAP_STORAGE_ENGINE=1 |
486 |
+ -DWITH_INNOBASE_STORAGE_ENGINE=1 |
487 |
+ -DWITH_MYISAMMRG_STORAGE_ENGINE=1 |
488 |
+ -DWITH_MYISAM_STORAGE_ENGINE=1 |
489 |
+ -DWITH_PARTITION_STORAGE_ENGINE=1 |
490 |
+ ) |
491 |
+ else |
492 |
+ mycmakeargs+=( |
493 |
+ -DWITHOUT_SERVER=1 |
494 |
+ -DWITH_EMBEDDED_SERVER=OFF |
495 |
+ -DEXTRA_CHARSETS=none |
496 |
+ -DINSTALL_SQLBENCHDIR= |
497 |
+ -DWITH_SYSTEMD=no |
498 |
+ ) |
499 |
+ fi |
500 |
+ |
501 |
+ cmake_src_configure |
502 |
+} |
503 |
+ |
504 |
+src_compile() { |
505 |
+ cmake_src_compile |
506 |
+} |
507 |
+ |
508 |
+# Official test instructions: |
509 |
+# USE='extraengine perl server xml' \ |
510 |
+# FEATURES='test userpriv' \ |
511 |
+# ebuild mariadb-X.X.XX.ebuild \ |
512 |
+# digest clean package |
513 |
+src_test() { |
514 |
+ _disable_test() { |
515 |
+ local rawtestname bug reason |
516 |
+ rawtestname="${1}" ; shift |
517 |
+ bug="${1}" ; shift |
518 |
+ reason="${@}" |
519 |
+ ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" |
520 |
+ echo "${rawtestname} : BUG#${bug} ${reason}" >> "${T}/disabled.def" |
521 |
+ } |
522 |
+ |
523 |
+ local TESTDIR="${BUILD_DIR}/mysql-test" |
524 |
+ local retstatus_tests |
525 |
+ |
526 |
+ if ! use server ; then |
527 |
+ einfo "Skipping server tests due to minimal build." |
528 |
+ return 0 |
529 |
+ fi |
530 |
+ |
531 |
+ # Ensure that parallel runs don't die |
532 |
+ export MTR_BUILD_THREAD="$((${RANDOM} % 100))" |
533 |
+ |
534 |
+ if [[ -z "${MTR_PARALLEL}" ]] ; then |
535 |
+ local -x MTR_PARALLEL=$(makeopts_jobs) |
536 |
+ |
537 |
+ if [[ ${MTR_PARALLEL} -gt 4 ]] ; then |
538 |
+ # Running multiple tests in parallel usually require higher ulimit |
539 |
+ # and fs.aio-max-nr setting. In addition, tests like main.multi_update |
540 |
+ # are known to hit timeout when system is busy. |
541 |
+ # To avoid test failure we will limit MTR_PARALLEL to 4 instead of |
542 |
+ # using "auto". |
543 |
+ local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" |
544 |
+ info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" |
545 |
+ einfo "${info_msg}" |
546 |
+ unset info_msg |
547 |
+ MTR_PARALLEL=4 |
548 |
+ fi |
549 |
+ else |
550 |
+ einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" |
551 |
+ fi |
552 |
+ |
553 |
+ # Try to increase file limits to increase test coverage |
554 |
+ if ! ulimit -n 16500 1>/dev/null 2>&1 ; then |
555 |
+ # Upper limit comes from parts.partition_* tests |
556 |
+ ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." |
557 |
+ |
558 |
+ if ! ulimit -n 4162 1>/dev/null 2>&1 ; then |
559 |
+ # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' |
560 |
+ ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." |
561 |
+ |
562 |
+ if ! ulimit -n 3000 1>/dev/null 2>&1 ; then |
563 |
+ ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." |
564 |
+ else |
565 |
+ einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." |
566 |
+ fi |
567 |
+ else |
568 |
+ einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." |
569 |
+ fi |
570 |
+ else |
571 |
+ einfo "Will run test suite with open file limit set to 16500 (best test coverage)." |
572 |
+ fi |
573 |
+ |
574 |
+ # create directories because mysqladmin might run out of order |
575 |
+ mkdir -p "${T}"/var-tests{,/log} || die |
576 |
+ |
577 |
+ if [[ ! -f "${S}/mysql-test/unstable-tests" ]] ; then |
578 |
+ touch "${S}"/mysql-test/unstable-tests || die |
579 |
+ fi |
580 |
+ |
581 |
+ cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die |
582 |
+ |
583 |
+ local -a disabled_tests |
584 |
+ disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) |
585 |
+ disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) |
586 |
+ disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) |
587 |
+ disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) |
588 |
+ disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) |
589 |
+ disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) |
590 |
+ disabled_tests+=( "main.selectivity_no_engine;26320;Sporadically failing test" ) |
591 |
+ disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) |
592 |
+ disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) |
593 |
+ disabled_tests+=( "main.upgrade_MDEV-19650;25096;Known to be broken" ) |
594 |
+ disabled_tests+=( "mariabackup.*;0;Broken test suite" ) |
595 |
+ disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) |
596 |
+ disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) |
597 |
+ disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) |
598 |
+ disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) |
599 |
+ disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) |
600 |
+ disabled_tests+=( "sys_vars.wsrep_on_without_provider;25625;Known to be broken" ) |
601 |
+ |
602 |
+ if ! use latin1 ; then |
603 |
+ disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) |
604 |
+ disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) |
605 |
+ disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) |
606 |
+ disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) |
607 |
+ disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) |
608 |
+ fi |
609 |
+ |
610 |
+ local test_infos_str test_infos_arr |
611 |
+ for test_infos_str in "${disabled_tests[@]}" ; do |
612 |
+ IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" |
613 |
+ |
614 |
+ if [[ ${#test_infos_arr[@]} != 3 ]] ; then |
615 |
+ die "Invalid test data set, not matching format: ${test_infos_str}" |
616 |
+ fi |
617 |
+ |
618 |
+ _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" |
619 |
+ done |
620 |
+ unset test_infos_str test_infos_arr |
621 |
+ |
622 |
+ # run mysql-test tests |
623 |
+ pushd "${TESTDIR}" &>/dev/null || die |
624 |
+ perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" |
625 |
+ retstatus_tests=$? |
626 |
+ |
627 |
+ popd &>/dev/null || die |
628 |
+ |
629 |
+ # Cleanup is important for these testcases. |
630 |
+ pkill -9 -f "${S}/ndb" 2>/dev/null |
631 |
+ pkill -9 -f "${S}/sql" 2>/dev/null |
632 |
+ |
633 |
+ local failures="" |
634 |
+ [[ ${retstatus_tests} -eq 0 ]] || failures="${failures} tests" |
635 |
+ |
636 |
+ [[ -z "${failures}" ]] || die "Test failures: ${failures}" |
637 |
+ einfo "Tests successfully completed" |
638 |
+} |
639 |
+ |
640 |
+src_install() { |
641 |
+ cmake_src_install |
642 |
+ |
643 |
+ # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used |
644 |
+ if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then |
645 |
+ rm "${ED}/usr/include/mysql/server/private/config.h" || die |
646 |
+ fi |
647 |
+ |
648 |
+ # Make sure the vars are correctly initialized |
649 |
+ mysql_init_vars |
650 |
+ |
651 |
+ # Convenience links |
652 |
+ einfo "Making Convenience links for mysqlcheck multi-call binary" |
653 |
+ dosym "mysqlcheck" "/usr/bin/mysqlanalyze" |
654 |
+ dosym "mysqlcheck" "/usr/bin/mysqlrepair" |
655 |
+ dosym "mysqlcheck" "/usr/bin/mysqloptimize" |
656 |
+ |
657 |
+ # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir |
658 |
+ if [[ -d "${ED}/usr/data" ]] ; then |
659 |
+ rm -Rf "${ED}/usr/data" || die |
660 |
+ fi |
661 |
+ |
662 |
+ # Unless they explicitly specific USE=test, then do not install the |
663 |
+ # testsuite. It DOES have a use to be installed, esp. when you want to do a |
664 |
+ # validation of your database configuration after tuning it. |
665 |
+ if ! use test ; then |
666 |
+ rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" |
667 |
+ fi |
668 |
+ |
669 |
+ # Configuration stuff |
670 |
+ einfo "Building default configuration ..." |
671 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}" |
672 |
+ [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf |
673 |
+ cp "${FILESDIR}/my.cnf-10.2" "${TMPDIR}/my.cnf" || die |
674 |
+ eprefixify "${TMPDIR}/my.cnf" |
675 |
+ doins "${TMPDIR}/my.cnf" |
676 |
+ insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" |
677 |
+ cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die |
678 |
+ eprefixify "${TMPDIR}/50-distro-client.cnf" |
679 |
+ doins "${TMPDIR}/50-distro-client.cnf" |
680 |
+ |
681 |
+ if use server ; then |
682 |
+ mycnf_src="my.cnf.distro-server" |
683 |
+ sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ |
684 |
+ "${FILESDIR}/${mycnf_src}" \ |
685 |
+ > "${TMPDIR}/my.cnf.ok" || die |
686 |
+ if use prefix ; then |
687 |
+ sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ |
688 |
+ "${TMPDIR}/my.cnf.ok" || die |
689 |
+ fi |
690 |
+ if use latin1 ; then |
691 |
+ sed -i \ |
692 |
+ -e "/character-set/s|utf8|latin1|g" \ |
693 |
+ "${TMPDIR}/my.cnf.ok" || die |
694 |
+ fi |
695 |
+ eprefixify "${TMPDIR}/my.cnf.ok" |
696 |
+ newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf |
697 |
+ |
698 |
+ einfo "Including support files and sample configurations" |
699 |
+ docinto "support-files" |
700 |
+ local script |
701 |
+ for script in \ |
702 |
+ "${S}"/support-files/magic |
703 |
+ do |
704 |
+ [[ -f "$script" ]] && dodoc "${script}" |
705 |
+ done |
706 |
+ |
707 |
+ docinto "scripts" |
708 |
+ for script in "${S}"/scripts/mysql* ; do |
709 |
+ [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}" |
710 |
+ done |
711 |
+ # Manually install supporting files that conflict with other packages |
712 |
+ # but are needed for galera and initial installation |
713 |
+ exeinto /usr/libexec/mariadb |
714 |
+ doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" |
715 |
+ |
716 |
+ if use pam ; then |
717 |
+ keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir |
718 |
+ fi |
719 |
+ fi |
720 |
+ |
721 |
+ # Remove bundled mytop in favor of dev-db/mytop |
722 |
+ local mytop_file |
723 |
+ for mytop_file in \ |
724 |
+ "${ED}/usr/bin/mytop" \ |
725 |
+ "${ED}/usr/share/man/man1/mytop.1" \ |
726 |
+ ; do |
727 |
+ if [[ -e "${mytop_file}" ]] ; then |
728 |
+ rm -v "${mytop_file}" || die |
729 |
+ fi |
730 |
+ done |
731 |
+ |
732 |
+ # Fix a dangling symlink when galera is not built |
733 |
+ if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then |
734 |
+ rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die |
735 |
+ fi |
736 |
+ |
737 |
+ # Remove dangling symlink |
738 |
+ rm "${ED}/usr/$(get_libdir)/libmariadb.a" || die |
739 |
+ |
740 |
+ # Remove broken SST scripts that are incompatible |
741 |
+ local scriptremove |
742 |
+ for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do |
743 |
+ if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then |
744 |
+ rm "${ED}/usr/bin/${scriptremove}" || die |
745 |
+ fi |
746 |
+ done |
747 |
+} |
748 |
+ |
749 |
+pkg_preinst() { |
750 |
+ java-pkg-opt-2_pkg_preinst |
751 |
+} |
752 |
+ |
753 |
+pkg_postinst() { |
754 |
+ # Make sure the vars are correctly initialized |
755 |
+ mysql_init_vars |
756 |
+ |
757 |
+ # Create log directory securely if it does not exist |
758 |
+ [[ -d "${ROOT}/${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}/${MY_LOGDIR}" |
759 |
+ |
760 |
+ if use server ; then |
761 |
+ if use pam; then |
762 |
+ einfo |
763 |
+ elog "This install includes the PAM authentication plugin." |
764 |
+ elog "To activate and configure the PAM plugin, please read:" |
765 |
+ elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" |
766 |
+ einfo |
767 |
+ chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die |
768 |
+ fi |
769 |
+ |
770 |
+ if [[ -z "${REPLACING_VERSIONS}" ]] ; then |
771 |
+ einfo |
772 |
+ elog "You might want to run:" |
773 |
+ elog "\"emerge --config =${CATEGORY}/${PF}\"" |
774 |
+ elog "if this is a new install." |
775 |
+ elog |
776 |
+ elog "If you are switching server implentations, you should run the" |
777 |
+ elog "mysql_upgrade tool." |
778 |
+ einfo |
779 |
+ else |
780 |
+ einfo |
781 |
+ elog "If you are upgrading major versions, you should run the" |
782 |
+ elog "mysql_upgrade tool." |
783 |
+ einfo |
784 |
+ fi |
785 |
+ |
786 |
+ if use galera ; then |
787 |
+ einfo |
788 |
+ elog "Be sure to edit the my.cnf file to activate your cluster settings." |
789 |
+ elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" |
790 |
+ elog "The first time the cluster is activated, you should add" |
791 |
+ elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." |
792 |
+ elog "This option should then be removed for subsequent starts." |
793 |
+ einfo |
794 |
+ if [[ -n "${REPLACING_VERSIONS}" ]] ; then |
795 |
+ local rver |
796 |
+ for rver in ${REPLACING_VERSIONS} ; do |
797 |
+ if ver_test "${rver}" -lt "10.4.0" ; then |
798 |
+ ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." |
799 |
+ ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" |
800 |
+ ewarn "for more information" |
801 |
+ fi |
802 |
+ done |
803 |
+ fi |
804 |
+ fi |
805 |
+ fi |
806 |
+ |
807 |
+ # Note about configuration change |
808 |
+ einfo |
809 |
+ elog "This version of mariadb reorganizes the configuration from a single my.cnf" |
810 |
+ elog "to several files in /etc/mysql/${PN}.d." |
811 |
+ elog "Please backup any changes you made to /etc/mysql/my.cnf" |
812 |
+ elog "and add them as a new file under /etc/mysql/${PN}.d with a .cnf extension." |
813 |
+ elog "You may have as many files as needed and they are read alphabetically." |
814 |
+ elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." |
815 |
+ einfo |
816 |
+} |
817 |
+ |
818 |
+pkg_config() { |
819 |
+ _getoptval() { |
820 |
+ local section="${1}" |
821 |
+ local option="--${2}" |
822 |
+ local extra_options="${3}" |
823 |
+ local cmd=( |
824 |
+ "${my_print_defaults_binary}" |
825 |
+ "${extra_options}" |
826 |
+ "${section}" |
827 |
+ ) |
828 |
+ |
829 |
+ local values=() |
830 |
+ local parameters=( $(eval "${cmd[@]}" 2>/dev/null) ) |
831 |
+ for parameter in "${parameters[@]}" |
832 |
+ do |
833 |
+ # my_print_defaults guarantees output of options, one per line, |
834 |
+ # in the form that they would be specified on the command line. |
835 |
+ # So checking for --option=* should be safe. |
836 |
+ case ${parameter} in |
837 |
+ ${option}=*) |
838 |
+ values+=( "${parameter#*=}" ) |
839 |
+ ;; |
840 |
+ esac |
841 |
+ done |
842 |
+ |
843 |
+ if [[ ${#values[@]} -gt 0 ]] ; then |
844 |
+ # Option could have been set multiple times |
845 |
+ # in which case only the last occurrence |
846 |
+ # contains the current value |
847 |
+ echo "${values[-1]}" |
848 |
+ fi |
849 |
+ } |
850 |
+ |
851 |
+ _mktemp_dry() { |
852 |
+ # emktemp has no --dry-run option |
853 |
+ local template="${1}" |
854 |
+ |
855 |
+ if [[ -z "${template}" ]] ; then |
856 |
+ if [[ -z "${T}" ]] ; then |
857 |
+ template="/tmp/XXXXXXX" |
858 |
+ else |
859 |
+ template="${T}/XXXXXXX" |
860 |
+ fi |
861 |
+ fi |
862 |
+ |
863 |
+ local template_wo_X=${template//X/} |
864 |
+ local n_X |
865 |
+ let n_X=${#template}-${#template_wo_X} |
866 |
+ if [[ ${n_X} -lt 3 ]] ; then |
867 |
+ echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 |
868 |
+ return |
869 |
+ fi |
870 |
+ |
871 |
+ local attempts=0 |
872 |
+ local character tmpfile |
873 |
+ while [[ true ]] ; do |
874 |
+ let attempts=attempts+1 |
875 |
+ |
876 |
+ new_file= |
877 |
+ while read -n1 character ; do |
878 |
+ if [[ "${character}" == "X" ]] ; then |
879 |
+ tmpfile+="${RANDOM:0:1}" |
880 |
+ else |
881 |
+ tmpfile+="${character}" |
882 |
+ fi |
883 |
+ done < <(echo -n "${template}") |
884 |
+ |
885 |
+ if [[ ! -f "${tmpfile}" ]] |
886 |
+ then |
887 |
+ echo "${tmpfile}" |
888 |
+ return |
889 |
+ fi |
890 |
+ |
891 |
+ if [[ ${attempts} -ge 100 ]] ; then |
892 |
+ echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 |
893 |
+ return |
894 |
+ fi |
895 |
+ done |
896 |
+ } |
897 |
+ |
898 |
+ local mysql_binary="${EROOT}/usr/bin/mysql" |
899 |
+ if [[ ! -x "${mysql_binary}" ]] ; then |
900 |
+ die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" |
901 |
+ fi |
902 |
+ |
903 |
+ local mysqld_binary="${EROOT}/usr/sbin/mysqld" |
904 |
+ if [[ ! -x "${mysqld_binary}" ]] ; then |
905 |
+ die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" |
906 |
+ fi |
907 |
+ |
908 |
+ local mysql_install_db_binary="${EROOT}/usr/bin/mysql_install_db" |
909 |
+ if [[ ! -x "${mysql_install_db_binary}" ]] ; then |
910 |
+ die "'${mysql_install_db_binary}' not found! Please re-install ${CATEGORY}/${PN}!" |
911 |
+ fi |
912 |
+ |
913 |
+ local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" |
914 |
+ if [[ ! -x "${my_print_defaults_binary}" ]] ; then |
915 |
+ die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" |
916 |
+ fi |
917 |
+ |
918 |
+ if [[ -z "${MYSQL_USER}" ]] ; then |
919 |
+ MYSQL_USER=mysql |
920 |
+ if use prefix ; then |
921 |
+ MYSQL_USER=$(id -u -n 2>/dev/null) |
922 |
+ if [[ -z "${MYSQL_USER}" ]] ; then |
923 |
+ die "Failed to determine current username!" |
924 |
+ fi |
925 |
+ fi |
926 |
+ fi |
927 |
+ |
928 |
+ if [[ -z "${MYSQL_GROUP}" ]] ; then |
929 |
+ MYSQL_GROUP=mysql |
930 |
+ if use prefix ; then |
931 |
+ MYSQL_GROUP=$(id -g -n 2>/dev/null) |
932 |
+ if [[ -z "${MYSQL_GROUP}" ]] ; then |
933 |
+ die "Failed to determine current user groupname!" |
934 |
+ fi |
935 |
+ fi |
936 |
+ fi |
937 |
+ |
938 |
+ # my_print_defaults needs to read stuff in $HOME/.my.cnf |
939 |
+ local -x HOME="${EROOT}/root" |
940 |
+ |
941 |
+ # Make sure the vars are correctly initialized |
942 |
+ mysql_init_vars |
943 |
+ |
944 |
+ # Read currently set data directory |
945 |
+ MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
946 |
+ |
947 |
+ # Bug #213475 - MySQL _will_ object strenously if your machine is named |
948 |
+ # localhost. Also causes weird failures. |
949 |
+ [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" |
950 |
+ |
951 |
+ if [[ -z "${MY_DATADIR}" ]] ; then |
952 |
+ die "Sorry, unable to find MY_DATADIR!" |
953 |
+ elif [[ -d "${MY_DATADIR}/mysql" ]] ; then |
954 |
+ ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" |
955 |
+ ewarn "Please rename or delete its content if you wish to initialize a new data directory." |
956 |
+ die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" |
957 |
+ fi |
958 |
+ |
959 |
+ MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
960 |
+ MYSQL_TMPDIR=${MYSQL_TMPDIR%/} |
961 |
+ # These are dir+prefix |
962 |
+ MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
963 |
+ MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} |
964 |
+ MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" |
965 |
+ MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} |
966 |
+ |
967 |
+ # Create missing directories. |
968 |
+ # Always check if mysql user can write to directory even if we just |
969 |
+ # created directory because a parent directory might be not |
970 |
+ # accessible for that user. |
971 |
+ PID_DIR="${EROOT}/run/mysqld" |
972 |
+ if [[ ! -d "${PID_DIR}" ]] ; then |
973 |
+ einfo "Creating ${PN} PID directory '${PID_DIR}' ..." |
974 |
+ install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ |
975 |
+ || die "Failed to create PID directory '${PID_DIR}'!" |
976 |
+ fi |
977 |
+ |
978 |
+ local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" |
979 |
+ [[ -z "${_pid_dir_testfile}" ]] \ |
980 |
+ && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
981 |
+ |
982 |
+ if use prefix ; then |
983 |
+ touch "${_pid_dir_testfile}" &>/dev/null |
984 |
+ else |
985 |
+ su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null |
986 |
+ fi |
987 |
+ |
988 |
+ if [[ $? -ne 0 ]] ; then |
989 |
+ die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" |
990 |
+ else |
991 |
+ rm "${_pid_dir_testfile}" || die |
992 |
+ unset _pid_dir_testfile |
993 |
+ fi |
994 |
+ |
995 |
+ if [[ ! -d "${MY_DATADIR}" ]] ; then |
996 |
+ einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." |
997 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ |
998 |
+ || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" |
999 |
+ fi |
1000 |
+ |
1001 |
+ local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" |
1002 |
+ [[ -z "${_my_datadir_testfile}" ]] \ |
1003 |
+ && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
1004 |
+ |
1005 |
+ if use prefix ; then |
1006 |
+ touch "${_my_datadir_testfile}" &>/dev/null |
1007 |
+ else |
1008 |
+ su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null |
1009 |
+ fi |
1010 |
+ |
1011 |
+ if [[ $? -ne 0 ]] ; then |
1012 |
+ die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" |
1013 |
+ else |
1014 |
+ rm "${_my_datadir_testfile}" || die |
1015 |
+ unset _my_datadir_testfile |
1016 |
+ fi |
1017 |
+ |
1018 |
+ if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then |
1019 |
+ einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." |
1020 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ |
1021 |
+ || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" |
1022 |
+ fi |
1023 |
+ |
1024 |
+ if [[ -z "${MYSQL_TMPDIR}" ]] ; then |
1025 |
+ MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" |
1026 |
+ [[ -z "${MYSQL_TMPDIR}" ]] \ |
1027 |
+ && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" |
1028 |
+ |
1029 |
+ mkdir "${MYSQL_TMPDIR}" || die |
1030 |
+ chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die |
1031 |
+ fi |
1032 |
+ |
1033 |
+ # Now we need to test MYSQL_TMPDIR... |
1034 |
+ local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" |
1035 |
+ [[ -z "${_my_tmpdir_testfile}" ]] \ |
1036 |
+ && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" |
1037 |
+ |
1038 |
+ if use prefix ; then |
1039 |
+ touch "${_my_tmpdir_testfile}" &>/dev/null |
1040 |
+ else |
1041 |
+ su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null |
1042 |
+ fi |
1043 |
+ |
1044 |
+ if [[ $? -ne 0 ]] ; then |
1045 |
+ die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!" |
1046 |
+ else |
1047 |
+ rm "${_my_tmpdir_testfile}" || die |
1048 |
+ unset _my_tmpdir_testfile |
1049 |
+ fi |
1050 |
+ |
1051 |
+ if [[ "${MYSQL_LOG_BIN}" == /* && ! -d "${MYSQL_LOG_BIN}" ]] ; then |
1052 |
+ # Only create directory when MYSQL_LOG_BIN is an absolute path |
1053 |
+ einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." |
1054 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ |
1055 |
+ || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" |
1056 |
+ fi |
1057 |
+ |
1058 |
+ if [[ "${MYSQL_LOG_BIN}" == /* ]] ; then |
1059 |
+ # Only test when MYSQL_LOG_BIN is an absolute path |
1060 |
+ local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" |
1061 |
+ [[ -z "${_my_logbin_testfile}" ]] \ |
1062 |
+ && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" |
1063 |
+ |
1064 |
+ if use prefix ; then |
1065 |
+ touch "${_my_logbin_testfile}" &>/dev/null |
1066 |
+ else |
1067 |
+ su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null |
1068 |
+ fi |
1069 |
+ |
1070 |
+ if [[ $? -ne 0 ]] ; then |
1071 |
+ die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" |
1072 |
+ else |
1073 |
+ rm "${_my_logbin_testfile}" || die |
1074 |
+ unset _my_logbin_testfile |
1075 |
+ fi |
1076 |
+ fi |
1077 |
+ |
1078 |
+ if [[ "${MYSQL_RELAY_LOG}" == /* && ! -d "${MYSQL_RELAY_LOG}" ]] ; then |
1079 |
+ # Only create directory when MYSQL_RELAY_LOG is an absolute path |
1080 |
+ einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." |
1081 |
+ install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ |
1082 |
+ || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" |
1083 |
+ fi |
1084 |
+ |
1085 |
+ if [[ "${MYSQL_RELAY_LOG}" == /* ]] ; then |
1086 |
+ # Only test when MYSQL_RELAY_LOG is an absolute path |
1087 |
+ local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" |
1088 |
+ [[ -z "${_my_relaylog_testfile}" ]] \ |
1089 |
+ && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" |
1090 |
+ |
1091 |
+ if use prefix ; then |
1092 |
+ touch "${_my_relaylog_testfile}" &>/dev/null |
1093 |
+ else |
1094 |
+ su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null |
1095 |
+ fi |
1096 |
+ |
1097 |
+ if [[ $? -ne 0 ]] ; then |
1098 |
+ die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" |
1099 |
+ else |
1100 |
+ rm "${_my_relaylog_testfile}" || die |
1101 |
+ unset _my_relaylog_testfile |
1102 |
+ fi |
1103 |
+ fi |
1104 |
+ |
1105 |
+ local SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) |
1106 |
+ [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" |
1107 |
+ |
1108 |
+ # Limit access |
1109 |
+ chmod 0770 "${SETUP_TMPDIR}" || die |
1110 |
+ chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die |
1111 |
+ |
1112 |
+ local mysql_install_log="${SETUP_TMPDIR}/install_db.log" |
1113 |
+ local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" |
1114 |
+ |
1115 |
+ echo "" |
1116 |
+ einfo "Detected settings:" |
1117 |
+ einfo "==================" |
1118 |
+ einfo "MySQL User:\t\t\t\t${MYSQL_USER}" |
1119 |
+ einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" |
1120 |
+ einfo "MySQL DATA directory:\t\t${MY_DATADIR}" |
1121 |
+ einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" |
1122 |
+ |
1123 |
+ if [[ "${MYSQL_LOG_BIN}" == /* ]] ; then |
1124 |
+ # Absolute path for binary log files specified |
1125 |
+ einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" |
1126 |
+ fi |
1127 |
+ |
1128 |
+ if [[ "${MYSQL_RELAY_LOG}" == /* ]] ; then |
1129 |
+ # Absolute path for relay log files specified |
1130 |
+ einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" |
1131 |
+ fi |
1132 |
+ |
1133 |
+ einfo "PID DIR:\t\t\t\t${PID_DIR}" |
1134 |
+ einfo "Install db log:\t\t\t${mysql_install_log}" |
1135 |
+ einfo "Install server log:\t\t\t${mysqld_logfile}" |
1136 |
+ |
1137 |
+ echo |
1138 |
+ |
1139 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
1140 |
+ local tmp_mysqld_password_source= |
1141 |
+ |
1142 |
+ for tmp_mysqld_password_source in mysql client ; do |
1143 |
+ einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." |
1144 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" |
1145 |
+ if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then |
1146 |
+ if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then |
1147 |
+ ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" |
1148 |
+ MYSQL_ROOT_PASSWORD= |
1149 |
+ continue |
1150 |
+ fi |
1151 |
+ |
1152 |
+ einfo "Found password in '${tmp_mysqld_password_source}' section!" |
1153 |
+ break |
1154 |
+ fi |
1155 |
+ done |
1156 |
+ |
1157 |
+ # Sometimes --show is required to display passwords in some implementations of my_print_defaults |
1158 |
+ if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then |
1159 |
+ MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" |
1160 |
+ fi |
1161 |
+ |
1162 |
+ unset tmp_mysqld_password_source |
1163 |
+ fi |
1164 |
+ |
1165 |
+ if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then |
1166 |
+ local pwd1="a" |
1167 |
+ local pwd2="b" |
1168 |
+ |
1169 |
+ echo |
1170 |
+ einfo "No password for mysql 'root' user was specified via environment" |
1171 |
+ einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" |
1172 |
+ einfo "file like '${HOME}/.my.cnf'." |
1173 |
+ einfo "To continue please provide a password for the mysql 'root' user" |
1174 |
+ einfo "now on console:" |
1175 |
+ ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" |
1176 |
+ read -rsp " >" pwd1 ; echo |
1177 |
+ |
1178 |
+ einfo "Retype the password" |
1179 |
+ read -rsp " >" pwd2 ; echo |
1180 |
+ |
1181 |
+ if [[ "x${pwd1}" != "x${pwd2}" ]] ; then |
1182 |
+ die "Passwords are not the same!" |
1183 |
+ fi |
1184 |
+ |
1185 |
+ MYSQL_ROOT_PASSWORD="${pwd1}" |
1186 |
+ unset pwd1 pwd2 |
1187 |
+ |
1188 |
+ echo |
1189 |
+ fi |
1190 |
+ |
1191 |
+ local -a mysqld_options |
1192 |
+ |
1193 |
+ # Fix bug 446200. Don't reference host my.cnf, needs to come first, |
1194 |
+ # see http://bugs.mysql.com/bug.php?id=31312 |
1195 |
+ use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) |
1196 |
+ |
1197 |
+ # Figure out which options we need to disable to do the setup |
1198 |
+ local helpfile="${TMPDIR}/mysqld-help" |
1199 |
+ "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null |
1200 |
+ |
1201 |
+ local opt optexp optfull |
1202 |
+ for opt in host-cache name-resolve networking slave-start \ |
1203 |
+ federated ssl log-bin relay-log slow-query-log external-locking \ |
1204 |
+ log-slave-updates \ |
1205 |
+ ; do |
1206 |
+ optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" |
1207 |
+ grep -E -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) |
1208 |
+ done |
1209 |
+ |
1210 |
+ # Prepare timezones, see |
1211 |
+ # https://dev.mysql.com/doc/mysql/en/time-zone-support.html |
1212 |
+ local tz_sql="${SETUP_TMPDIR}/tz.sql" |
1213 |
+ |
1214 |
+ echo "USE mysql;" >"${tz_sql}" |
1215 |
+ "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null |
1216 |
+ if [[ $? -ne 0 ]] ; then |
1217 |
+ die "mysql_tzinfo_to_sql failed!" |
1218 |
+ fi |
1219 |
+ |
1220 |
+ local cmd=( |
1221 |
+ "${mysql_install_db_binary}" |
1222 |
+ "${mysqld_options[@]}" |
1223 |
+ "--init-file='${tz_sql}'" |
1224 |
+ "--basedir='${EROOT}/usr'" |
1225 |
+ "--datadir='${MY_DATADIR}'" |
1226 |
+ "--tmpdir='${MYSQL_TMPDIR}'" |
1227 |
+ "--log-error='${mysql_install_log}'" |
1228 |
+ "--rpm" |
1229 |
+ "--cross-bootstrap" |
1230 |
+ "--skip-test-db" |
1231 |
+ "--user=${MYSQL_USER}" |
1232 |
+ ) |
1233 |
+ |
1234 |
+ einfo "Initializing ${PN} data directory: ${cmd[@]}" |
1235 |
+ eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 |
1236 |
+ |
1237 |
+ if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; then |
1238 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 |
1239 |
+ die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" |
1240 |
+ fi |
1241 |
+ |
1242 |
+ local x=${RANDOM} |
1243 |
+ local socket="${PID_DIR}/mysqld.${x}.sock" |
1244 |
+ [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" |
1245 |
+ local pidfile="${PID_DIR}/mysqld.${x}.pid" |
1246 |
+ [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" |
1247 |
+ unset x |
1248 |
+ |
1249 |
+ cmd=( |
1250 |
+ "${mysqld_binary}" |
1251 |
+ "${mysqld_options[@]}" |
1252 |
+ "--basedir='${EROOT}/usr'" |
1253 |
+ "--datadir='${MY_DATADIR}'" |
1254 |
+ "--tmpdir='${MYSQL_TMPDIR}'" |
1255 |
+ --max_allowed_packet=8M |
1256 |
+ --net_buffer_length=16K |
1257 |
+ "--socket='${socket}'" |
1258 |
+ "--pid-file='${pidfile}'" |
1259 |
+ "--log-error='${mysqld_logfile}'" |
1260 |
+ "--user=${MYSQL_USER}" |
1261 |
+ ) |
1262 |
+ |
1263 |
+ einfo "Starting mysqld to finalize initialization: ${cmd[@]}" |
1264 |
+ eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & |
1265 |
+ |
1266 |
+ echo -n "Waiting for mysqld to accept connections " |
1267 |
+ local maxtry=15 |
1268 |
+ while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do |
1269 |
+ maxtry=$((${maxtry}-1)) |
1270 |
+ echo -n "." |
1271 |
+ sleep 1 |
1272 |
+ done |
1273 |
+ |
1274 |
+ if [[ -S "${socket}" ]] ; then |
1275 |
+ # Even with a socket we don't know if mysqld will abort |
1276 |
+ # start due to an error so just wait a little bit more... |
1277 |
+ maxtry=5 |
1278 |
+ while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do |
1279 |
+ maxtry=$((${maxtry}-1)) |
1280 |
+ echo -n "." |
1281 |
+ sleep 1 |
1282 |
+ done |
1283 |
+ fi |
1284 |
+ |
1285 |
+ echo |
1286 |
+ |
1287 |
+ if [[ ! -S "${socket}" ]] ; then |
1288 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 |
1289 |
+ die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" |
1290 |
+ fi |
1291 |
+ |
1292 |
+ local mysql_logfile="${SETUP_TMPDIR}/set_root_pw.log" |
1293 |
+ touch "${mysql_logfile}" || die |
1294 |
+ |
1295 |
+ ebegin "Setting root password" |
1296 |
+ # Do this from memory, as we don't want clear text passwords in temp files |
1297 |
+ local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" |
1298 |
+ cmd=( |
1299 |
+ "${mysql_binary}" |
1300 |
+ --no-defaults |
1301 |
+ "--socket='${socket}'" |
1302 |
+ -hlocalhost |
1303 |
+ "-e \"${sql}\"" |
1304 |
+ ) |
1305 |
+ eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 |
1306 |
+ local rc=$? |
1307 |
+ eend ${rc} |
1308 |
+ |
1309 |
+ if [[ ${rc} -ne 0 ]] ; then |
1310 |
+ # Poor man's solution which tries to avoid having password |
1311 |
+ # in log. NOTE: sed can fail if user didn't follow advice |
1312 |
+ # and included character which will require escaping... |
1313 |
+ sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null |
1314 |
+ |
1315 |
+ grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" |
1316 |
+ die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" |
1317 |
+ fi |
1318 |
+ |
1319 |
+ # Stop the server |
1320 |
+ if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then |
1321 |
+ echo -n "Stopping the server " |
1322 |
+ pkill -F "${pidfile}" &>/dev/null |
1323 |
+ |
1324 |
+ maxtry=10 |
1325 |
+ while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do |
1326 |
+ maxtry=$((${maxtry}-1)) |
1327 |
+ echo -n "." |
1328 |
+ sleep 1 |
1329 |
+ done |
1330 |
+ |
1331 |
+ echo |
1332 |
+ |
1333 |
+ if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then |
1334 |
+ # We somehow failed to stop server. |
1335 |
+ # However, not a fatal error. Just warn the user. |
1336 |
+ ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" |
1337 |
+ fi |
1338 |
+ fi |
1339 |
+ |
1340 |
+ rm -r "${SETUP_TMPDIR}" || die |
1341 |
+ |
1342 |
+ einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" |
1343 |
+} |