Gentoo Archives: gentoo-commits

From: David Seifert <soap@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-db/mysql/
Date: Thu, 03 Mar 2022 21:22:24
Message-Id: 1646342512.34aba362af98cb350efedc53351de2802dc47691.soap@gentoo
1 commit: 34aba362af98cb350efedc53351de2802dc47691
2 Author: David Seifert <soap <AT> gentoo <DOT> org>
3 AuthorDate: Thu Mar 3 21:21:52 2022 +0000
4 Commit: David Seifert <soap <AT> gentoo <DOT> org>
5 CommitDate: Thu Mar 3 21:21:52 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=34aba362
7
8 dev-db/mysql: drop 8.0.22, 8.0.23, 8.0.25, 8.0.25-r1, 8.0.26
9
10 Closes: https://github.com/gentoo/gentoo/pull/24381
11 Bug: https://bugs.gentoo.org/822258
12 Signed-off-by: David Seifert <soap <AT> gentoo.org>
13
14 dev-db/mysql/Manifest | 9 -
15 dev-db/mysql/mysql-8.0.22.ebuild | 1156 ---------------------------------
16 dev-db/mysql/mysql-8.0.23.ebuild | 1158 ---------------------------------
17 dev-db/mysql/mysql-8.0.25-r1.ebuild | 1193 ----------------------------------
18 dev-db/mysql/mysql-8.0.25.ebuild | 1164 ---------------------------------
19 dev-db/mysql/mysql-8.0.26.ebuild | 1227 -----------------------------------
20 6 files changed, 5907 deletions(-)
21
22 diff --git a/dev-db/mysql/Manifest b/dev-db/mysql/Manifest
23 index e922b317d818..4d99d89cbd95 100644
24 --- a/dev-db/mysql/Manifest
25 +++ b/dev-db/mysql/Manifest
26 @@ -4,19 +4,10 @@ DIST mysql-5.7.34-patches-01.tar.xz 6676 BLAKE2B b925880bfbb991fcba81964ff658a2e
27 DIST mysql-5.7.34-patches-02.tar.xz 6408 BLAKE2B fdb36247832b6282af94ce2f61b5dd77f6b45f9efca4b438ecd5fed8d810d9d51547d0ae3de085e7f5dcc8795b4bc4f1210902495b92859e1d5aec3048256ef3 SHA512 f0513eb7f0c9e415aa972a53af668939934ea4f4fa438f468f32a46ccc2aa3b84ba8edd999e4786256ada34851ad64c81e9dd0e36c2a21da641987dfd18635c3
28 DIST mysql-5.7.35-patches-01.tar.xz 6408 BLAKE2B ddead9d6f5570f23433ffaef0188a8e93c0220b3d59ae24b870927e9e5908619f357725c1ab2d16905f39dd9d5f6cd23d3aabf6a1df2abdc865683f603912b8f SHA512 6374536299c691fd12a3f8b7cd27291e6f3b0b6d159284b2866caaed6a7f124439c16e659e6da5aae9e72d613de2a1e1b80066c961e122e90ad644e9a32633cc
29 DIST mysql-5.7.36-patches-01.tar.xz 6396 BLAKE2B ed9783f207d40fc220992c4193bdd8e96523f69414daa756f1f30306c1aedff9e96216ba2294a4c41eefbaf39c8bb37784bf1e7cce656c93f829c9cf0682fa6d SHA512 b0fbd41ebb2d32067e6c81707dffa91fece2d368f4b2fa47951492936509972d425b64d7613748c42b31cf9ba9dab697efeff70debe7268855a90d322d3f3158
30 -DIST mysql-8.0.22-patches-02.tar.xz 7580 BLAKE2B a50704c3c58b1f67ca86edb233544137927b0ae5fdf302687b48f6fd30fbbd26798e8ef8282662586b25a7240b47278b44f944a8ca59f1a198bc228dd74459c9 SHA512 59f864452e9fdebe4d3990eff8b756e9bbfad58da216b74fa8b7e8391cb0d9d543ca2828591b9ed1ee276c1dec9e1851a8c2683507f0a326c85054e31cc3f950
31 -DIST mysql-8.0.23-patches-01.tar.xz 7568 BLAKE2B 222120dcb5556457f382eefbb10f66f46fe1673c64730c8c8a5566942031bc98bab1f1182f747e79e23fccfb6b09197d5c2874aa2087104b6f1eaa25ea9fd60c SHA512 54222c420d57c1b206d920f22738746925ed1e0d78683f01c97cac5bd1d3450f70f784a7f603304b8595fb58120e691f94e28fa1d1884a7cc8bea1d7b177470f
32 -DIST mysql-8.0.25-patches-01.tar.xz 3604 BLAKE2B 09cccab204c30d16bdc374bcd01d4a8e6298955f86f479b8e287aab74fb6bd9857547e360be725dfc66acb56e1bb5665277d340761d0110a8823763ad4d2d1f4 SHA512 6d90a34a20e9cbc7e7a9b5b63a1408f33ac8523f2be6c9ab6d9ad7589c3ded83c87e460d782d4d8c33f11b337151fd8db994099e371260ecf204933e844eb50e
33 -DIST mysql-8.0.25-patches-02.tar.xz 6456 BLAKE2B c9c1020a505ebcee836f8dc3bbe540ff924a0174daf36c37b852df267a81919d37581d1c9be037d52cdcd34c27c5c34d3f0af6160857b22d8ab4d8ece37798e0 SHA512 3c3726b397f3a6fb1d84396bb571b4903a167c9a47273b9d5996949e1d3febc96d3528bfa8dfaeea073a245051ae10c983f2ad258268babc91649563ce3cfc00
34 -DIST mysql-8.0.26-patches-01.tar.xz 6980 BLAKE2B 5fc86125b622ac978dc7ec3d6954a1d366315a57b6f56ca8dade9ad4a255b4b793ad33736404b29ab2db12f726897f014aeec9232dc52954087e7533d0f593d2 SHA512 00e6478716cf857b8ab768ec481dc1e7d809db17a9d899a52822f61dcc18797e87c0eecfafb1bb9065895c1b261c03c87fe0593b59dc86fb40853b0c660c9bfb
35 DIST mysql-8.0.27-patches-02.tar.xz 7204 BLAKE2B 1a3548f8b48b63a1d38cd9826f8ed2daf3d396276e8887e0a02a73fb91e544e1d0f1da9560351f03d3345d2ea5e8f61e5a9df2bce80558143bd3bc2558372232 SHA512 86c660d67d883fb84e6a38c39994bc30669c18b1d5bdedf908f112c7ebb59f0acf23903e6a81f01de1e6862a8cb779c7b537659ff18b090306eacf668dea47f8
36 DIST mysql-boost-5.7.32.tar.gz 52882168 BLAKE2B dd112fa1d8bd29d86fba076675b5b7c9c98b6fb876aed45a00e8a25be716102fc9aa688b7170bef07b1c9f9751737277774d8fb2c64c21e181ecae58f89b4a8a SHA512 33a617d040efd065ea1c2ad84be537f851480abd5cc8a6879b7f170bc4e6db9432bd03f2a6bc680b71f17839c508cab0e7ef1a3aba032197da1b7943c916c77a
37 DIST mysql-boost-5.7.33.tar.gz 52912380 BLAKE2B bca09314ae73932f6095799faa016998e65655cf5ea74d5596dcdc785e77014fe0b29a6c123e8618771f4a20a19978df00f7b79eea329aeb4b536ae71a4bef94 SHA512 1d1e1e5934fb17ff731fea45b88d4af6a394c2fbf0177a87803b18cb0eb4fb8d4939f82fc22b6cbc2af64022a44e206cd23e2e88ce11cc119c3ea22129d54e7a
38 DIST mysql-boost-5.7.34.tar.gz 52891142 BLAKE2B 986fe106d73495ea9acb837f699ef2b1ffd123d9728b61da42f990d670569f1f7c12dc0a8611c3a7b6e3ed7be9fc277e1a977fa6c6d06f7d156a2f492951d9c7 SHA512 4eab7e90477b75643df743d806d5abcfb56572a2aa003a354980287c9148209f4fb7f0158ba969fb0462c32e49fcb4cf2a79f0330ab1bd2b243725dbf6f31d6d
39 DIST mysql-boost-5.7.35.tar.gz 52959014 BLAKE2B 02cbc2201176773516479636ab40828a98bbc6bc1e90060e36d36af5c20a84b4b415d6e467328890ecff044834c81458fff8b717fd8942196dcf35e0ae85f298 SHA512 2469c8e13a236aee327bc0828804ba189e3abf78b6e0b3ef65b2343210f9c0cd5313d18b57ae3b76ca1487dc1d70854c8a12e6da61a6fffbce95854dcc792482
40 DIST mysql-boost-5.7.36.tar.gz 52968383 BLAKE2B 4d5e4fcf8d56f4a1d1d54ee889d432ee3265f55ff9c0ecf6fe216e67790a49ed052b94457680daef4cb42df29f14db7b0e678e0f0443c20b7e2324c772c24313 SHA512 a95580efd5b87776ee7f1aae9b50d50d88c70a48c16e7a2d8c6ada0b1cadc5ec6074a859291a65caa1b50a00e08a9e350df342bb0c6ef74edaf21055331c081b
41 -DIST mysql-boost-8.0.22.tar.gz 285934450 BLAKE2B 1ba0c9bb9a0cb74af4842d3b746f8b690c122cfbf2c6d5201ce95e59a257427a8683dd8d5c2be31dfe9ece4761366c1287fa7b841c45db222725bf76b0639bc6 SHA512 792f2ada93ec67a4679228478c6b798e81d9e9f6d13c7f4977cb7682738a4aae3cb483294edc6b2fde16c3960e51af8786216c063ab500840afd39a609e4b612
42 -DIST mysql-boost-8.0.23.tar.gz 291039175 BLAKE2B 3a7d3e05c774085d6078d0d3effd58d2df47521615356a2aa5efc2ea2ef8457e19ad57a054926ccff0a4752ca71d0464daa7fe9a3ac6c1b1d3bd86a9a82dfc58 SHA512 b8c2e2ac772b7b730f8b3bac7a5afb205da173b3639500606e7d1fac74832a0134027951855a2dc81af015e6158c924927ad63b9e1f2e7c823d45d4c4961c3f8
43 -DIST mysql-boost-8.0.25.tar.gz 290265324 BLAKE2B 5393a2a2525a886d9ece19777deae01e6c0b24b9ff5a0a5ffb9075740ed912d0df59a165b6ec9ceb60c7c28f3062cda5cceb4da3a8280f42549984c846f1ce5c SHA512 af653ccff66a9d87221b46ad4f7bcc629700549f758998b9a7fb22e4573b9495a28624e031f016f9ad8fe0dfcf481b82f1ffe224aa48c2d45531570026b26081
44 -DIST mysql-boost-8.0.26.tar.gz 291285918 BLAKE2B 6198ca8982a8c9df7e6ee4df5e2c1e0d64d2eb4d83cb7265317b58d55f6787c3240c8e40d196f2326ff3d66926ad7dab0705edd92e5a82881ce6ddb7f0c510b9 SHA512 63d47cb52407a816dc9f4330b99924624dfee46e57e7fdce19eff32909dd9e23251e2439d1807b002a1661b547173222c77465a3ca4dbb312414a84927809cfc
45 DIST mysql-boost-8.0.27.tar.gz 292184025 BLAKE2B 177209f3c62b0326ca9d021c751a701dec84c1b15c946ab0a68b1b4cf0620468eb3a1df77a918284007a0fde1aaa6a9767d0baed57936612813ef583df51c35e SHA512 6ef2426c0bee46bdf8e2fa5cb159d5ae19f0bed4f7c9bea9b33e0dd922b568c3c68ca063dcbcd7ea6904aaea31877c10064ea10b4bc63fb40d9f31778e3a7891
46
47 diff --git a/dev-db/mysql/mysql-8.0.22.ebuild b/dev-db/mysql/mysql-8.0.22.ebuild
48 deleted file mode 100644
49 index 7ba23d865dfb..000000000000
50 --- a/dev-db/mysql/mysql-8.0.22.ebuild
51 +++ /dev/null
52 @@ -1,1156 +0,0 @@
53 -# Copyright 1999-2021 Gentoo Authors
54 -# Distributed under the terms of the GNU General Public License v2
55 -
56 -EAPI="7"
57 -
58 -CMAKE_MAKEFILE_GENERATOR=emake
59 -
60 -inherit check-reqs cmake flag-o-matic linux-info \
61 - multiprocessing prefix toolchain-funcs
62 -
63 -MY_PV="${PV//_pre*}"
64 -MY_P="${PN}-${MY_PV}"
65 -
66 -# Patch version
67 -PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-8.0.22-patches-02.tar.xz"
68 -
69 -SRC_URI="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${MY_PV}.tar.gz
70 - https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${MY_PV}.tar.gz
71 - http://downloads.mysql.com/archives/MySQL-8.0/${PN}-boost-${MY_PV}.tar.gz
72 - ${PATCH_SET}"
73 -
74 -HOMEPAGE="https://www.mysql.com/"
75 -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
76 -LICENSE="GPL-2"
77 -SLOT="8.0"
78 -IUSE="cjk cracklib debug jemalloc latin1 numa +perl profiling
79 - router selinux +server tcmalloc test"
80 -
81 -RESTRICT="!test? ( test )"
82 -
83 -REQUIRED_USE="?? ( tcmalloc jemalloc )
84 - cjk? ( server )
85 - jemalloc? ( server )
86 - numa? ( server )
87 - profiling? ( server )
88 - router? ( server )
89 - tcmalloc? ( server )"
90 -
91 -# -ppc, -riscv for bug #761715
92 -KEYWORDS="amd64 arm arm64 ~hppa ~ia64 ~mips -ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris"
93 -
94 -# Shorten the path because the socket path length must be shorter than 107 chars
95 -# and we will run a mysql server during test phase
96 -S="${WORKDIR}/mysql"
97 -
98 -# Be warned, *DEPEND are version-dependant
99 -# These are used for both runtime and compiletime
100 -COMMON_DEPEND="
101 - >=app-arch/lz4-0_p131:=
102 - app-arch/zstd:=
103 - sys-libs/ncurses:0=
104 - >=sys-libs/zlib-1.2.3:0=
105 - >=dev-libs/openssl-1.0.0:0=
106 - server? (
107 - dev-libs/icu:=
108 - dev-libs/libevent:=[ssl,threads]
109 - >=dev-libs/protobuf-3.8:=
110 - net-libs/libtirpc:=
111 - cjk? ( app-text/mecab:= )
112 - jemalloc? ( dev-libs/jemalloc:0= )
113 - kernel_linux? (
114 - dev-libs/libaio:0=
115 - sys-process/procps:0=
116 - )
117 - numa? ( sys-process/numactl )
118 - tcmalloc? ( dev-util/google-perftools:0= )
119 - )
120 -"
121 -DEPEND="${COMMON_DEPEND}
122 - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
123 - virtual/yacc
124 - server? ( net-libs/rpcsvc-proto )
125 - test? (
126 - acct-group/mysql acct-user/mysql
127 - dev-perl/JSON
128 - )
129 -"
130 -RDEPEND="${COMMON_DEPEND}
131 - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
132 - !dev-db/mysql:0
133 - !dev-db/mysql:5.7
134 - selinux? ( sec-policy/selinux-mysql )
135 - !prefix? (
136 - acct-group/mysql acct-user/mysql
137 - dev-db/mysql-init-scripts
138 - )
139 -"
140 -# For other stuff to bring us in
141 -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
142 -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
143 -
144 -mysql_init_vars() {
145 - : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
146 - : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
147 - : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
148 - : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
149 - MY_DATADIR="${MY_LOCALSTATEDIR}"
150 -
151 - export MY_SHAREDSTATEDIR MY_SYSCONFDIR
152 - export MY_LOCALSTATEDIR MY_LOGDIR
153 - export MY_DATADIR
154 -}
155 -
156 -pkg_pretend() {
157 - if [[ ${MERGE_TYPE} != binary ]] ; then
158 - if use server ; then
159 - CHECKREQS_DISK_BUILD="2G"
160 -
161 - if has test $FEATURES ; then
162 - CHECKREQS_DISK_BUILD="9G"
163 - fi
164 -
165 - check-reqs_pkg_pretend
166 - fi
167 - fi
168 -}
169 -
170 -pkg_setup() {
171 - if [[ ${MERGE_TYPE} != binary ]] ; then
172 - CHECKREQS_DISK_BUILD="2G"
173 -
174 - if has test ${FEATURES} ; then
175 - CHECKREQS_DISK_BUILD="9G"
176 -
177 - # Bug #213475 - MySQL _will_ object strenuously if your machine is named
178 - # localhost. Also causes weird failures.
179 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
180 -
181 - if ! has userpriv ${FEATURES} ; then
182 - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
183 - fi
184 -
185 - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null)
186 - [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \
187 - && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!"
188 -
189 - if use latin1 ; then
190 - # Upstream only supports tests with default charset
191 - die "Testing with USE=latin1 is not supported."
192 - fi
193 - fi
194 -
195 - if use kernel_linux ; then
196 - if use numa ; then
197 - linux-info_get_any_version
198 -
199 - local CONFIG_CHECK="~NUMA"
200 -
201 - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
202 - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
203 -
204 - check_extra_config
205 - fi
206 - fi
207 -
208 - use server && check-reqs_pkg_setup
209 - fi
210 -}
211 -
212 -src_unpack() {
213 - unpack ${A}
214 -
215 - mv -f "${WORKDIR}/${MY_P}" "${S}" || die
216 -}
217 -
218 -src_prepare() {
219 - eapply "${WORKDIR}"/mysql-patches
220 -
221 - # Avoid rpm call which would trigger sandbox, #692368
222 - sed -i \
223 - -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \
224 - CMakeLists.txt || die
225 -
226 - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
227 - if [[ -d "${S}/support-files/SELinux" ]] ; then
228 - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
229 - fi
230 -
231 - # Remove man pages for client-lib tools we don't install
232 - rm \
233 - man/my_print_defaults.1 \
234 - man/perror.1 \
235 - man/zlib_decompress.1 \
236 - || die
237 -
238 - cmake_src_prepare
239 -}
240 -
241 -src_configure() {
242 - # Bug #114895, bug #110149
243 - filter-flags "-O" "-O[01]"
244 -
245 - append-cxxflags -felide-constructors
246 -
247 - # bug #283926, with GCC4.4, this is required to get correct behavior.
248 - append-flags -fno-strict-aliasing
249 -
250 - CMAKE_BUILD_TYPE="RelWithDebInfo"
251 -
252 - # debug hack wrt #497532
253 - mycmakeargs=(
254 - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
255 - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
256 - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
257 - -DSYSCONFDIR="${EPREFIX}/etc/mysql"
258 - -DINSTALL_BINDIR=bin
259 - -DINSTALL_DOCDIR=share/doc/${PF}
260 - -DINSTALL_DOCREADMEDIR=share/doc/${PF}
261 - -DINSTALL_INCLUDEDIR=include/mysql
262 - -DINSTALL_INFODIR=share/info
263 - -DINSTALL_LIBDIR=$(get_libdir)
264 - -DINSTALL_MANDIR=share/man
265 - -DINSTALL_MYSQLSHAREDIR=share/mysql
266 - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
267 - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
268 - -DINSTALL_SBINDIR=sbin
269 - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
270 - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
271 - -DWITH_UNIT_TESTS=$(usex test ON OFF)
272 - # Using bundled editline to get CTRL+C working
273 - -DWITH_EDITLINE=bundled
274 - -DWITH_ZLIB=system
275 - -DWITH_SSL=system
276 - -DWITH_LIBWRAP=0
277 - -DENABLED_LOCAL_INFILE=1
278 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
279 - -DWITH_DEFAULT_COMPILER_OPTIONS=0
280 - # The build forces this to be defined when cross-compiling. We pass it
281 - # all the time for simplicity and to make sure it is actually correct.
282 - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
283 - -DCMAKE_POSITION_INDEPENDENT_CODE=ON
284 - -DWITH_CURL=system
285 - -DWITH_BOOST="${S}/boost"
286 - -DWITH_ROUTER=$(usex router ON OFF)
287 - )
288 -
289 - if is-flagq -fno-lto ; then
290 - einfo "LTO disabled via {C,CXX,F,FC}FLAGS"
291 - mycmakeargs+=( -DWITH_LTO=OFF )
292 - elif is-flagq -flto ; then
293 - einfo "LTO forced via {C,CXX,F,FC}FLAGS"
294 - myconf+=( -DWITH_LTO=ON )
295 - else
296 - # Disable automagic
297 - myconf+=( -DWITH_LTO=OFF )
298 - fi
299 -
300 - if use test ; then
301 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
302 - else
303 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
304 - fi
305 -
306 - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
307 -
308 - mycmakeargs+=(
309 - -DWITH_ICU=system
310 - -DWITH_LZ4=system
311 - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex
312 - -DWITH_RAPIDJSON=bundled
313 - -DWITH_ZSTD=system
314 - )
315 -
316 - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then
317 - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
318 - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
319 - ewarn "You MUST file bugs without these variables set."
320 - ewarn "Tests will probably fail!"
321 -
322 - mycmakeargs+=(
323 - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
324 - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
325 - )
326 - elif use latin1 ; then
327 - mycmakeargs+=(
328 - -DDEFAULT_CHARSET=latin1
329 - -DDEFAULT_COLLATION=latin1_swedish_ci
330 - )
331 - else
332 - mycmakeargs+=(
333 - -DDEFAULT_CHARSET=utf8mb4
334 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
335 - )
336 - fi
337 -
338 - if use server ; then
339 - mycmakeargs+=(
340 - -DWITH_EXTRA_CHARSETS=all
341 - -DWITH_DEBUG=$(usex debug)
342 - -DWITH_MECAB=$(usex cjk system OFF)
343 - -DWITH_LIBEVENT=system
344 - -DWITH_PROTOBUF=system
345 - -DWITH_NUMA=$(usex numa ON OFF)
346 - )
347 -
348 - if use jemalloc ; then
349 - mycmakeargs+=( -DWITH_JEMALLOC=ON )
350 - elif use tcmalloc ; then
351 - mycmakeargs+=( -DWITH_TCMALLOC=ON )
352 - fi
353 -
354 - if use profiling ; then
355 - # Setting to OFF doesn't work: Once set, profiling options will be added
356 - # to `mysqld --help` output via sql/sys_vars.cc causing
357 - # "main.mysqld--help-notwin" test to fail
358 - mycmakeargs+=( -DENABLED_PROFILING=ON )
359 - fi
360 -
361 - # Storage engines
362 - mycmakeargs+=(
363 - -DWITH_EXAMPLE_STORAGE_ENGINE=0
364 - -DWITH_ARCHIVE_STORAGE_ENGINE=1
365 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1
366 - -DWITH_CSV_STORAGE_ENGINE=1
367 - -DWITH_FEDERATED_STORAGE_ENGINE=1
368 - -DWITH_HEAP_STORAGE_ENGINE=1
369 - -DWITH_INNOBASE_STORAGE_ENGINE=1
370 - -DWITH_INNODB_MEMCACHED=0
371 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1
372 - -DWITH_MYISAM_STORAGE_ENGINE=1
373 - )
374 - else
375 - mycmakeargs+=(
376 - -DWITHOUT_SERVER=1
377 - -DWITH_SYSTEMD=no
378 - )
379 - fi
380 -
381 - cmake_src_configure
382 -}
383 -
384 -# Official test instructions:
385 -# ulimit -n 16500 && \
386 -# USE='perl server' \
387 -# FEATURES='test userpriv' \
388 -# ebuild mysql-X.X.XX.ebuild \
389 -# digest clean package
390 -src_test() {
391 - _disable_test() {
392 - local rawtestname bug reason
393 - rawtestname="${1}" ; shift
394 - bug="${1}" ; shift
395 - reason="${@}"
396 - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
397 - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def"
398 - }
399 -
400 - local TESTDIR="${BUILD_DIR}/mysql-test"
401 - local retstatus_unit
402 - local retstatus_tests
403 -
404 - # Run CTest (test-units)
405 - cmake_src_test
406 - retstatus_unit=$?
407 -
408 - # Ensure that parallel runs don't die
409 - export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
410 -
411 - if [[ -z "${MTR_PARALLEL}" ]] ; then
412 - local -x MTR_PARALLEL=$(makeopts_jobs)
413 -
414 - if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
415 - # Running multiple tests in parallel usually require higher ulimit
416 - # and fs.aio-max-nr setting. In addition, tests like main.multi_update
417 - # are known to hit timeout when system is busy.
418 - # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
419 - # using "auto".
420 - local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
421 - info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
422 - einfo "${info_msg}"
423 - unset info_msg
424 - MTR_PARALLEL=4
425 - fi
426 - else
427 - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
428 - fi
429 -
430 - # create directories because mysqladmin might run out of order
431 - mkdir -p "${T}"/var-tests{,/log} || die
432 -
433 - # Run mysql tests
434 - pushd "${TESTDIR}" &>/dev/null || die
435 -
436 - touch "${T}/disabled.def"
437 -
438 - local -a disabled_tests
439 - disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" )
440 - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" )
441 - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" )
442 - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" )
443 - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" )
444 - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" )
445 - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" )
446 - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" )
447 - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" )
448 - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" )
449 - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" )
450 - disabled_tests+=( "main.mysql_load_data_local_dir;0;Known test failure - no upstream bug yet" )
451 - disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
452 - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
453 - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
454 - disabled_tests+=( "main.with_recursive;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
455 - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" )
456 - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Known failure - no upstream bug yet" )
457 - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware")
458 - disabled_tests+=( "x.connection;0;Known failure - no upstream bug yet" )
459 - disabled_tests+=( "main.mysqlpump_basic_lz4;0;Extra tool output causes false positive" )
460 - disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" )
461 - disabled_tests+=( "x.message_protobuf_nested;0;False positive caused by protobuff-3.11+" )
462 -
463 - if ! hash zip 1>/dev/null 2>&1 ; then
464 - # no need to force dep app-arch/zip for one test
465 - disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" )
466 - disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" )
467 - fi
468 -
469 - local test_infos_str test_infos_arr
470 - for test_infos_str in "${disabled_tests[@]}" ; do
471 - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
472 -
473 - if [[ ${#test_infos_arr[@]} != 3 ]] ; then
474 - die "Invalid test data set, not matching format: ${test_infos_str}"
475 - fi
476 -
477 - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
478 - done
479 - unset test_infos_str test_infos_arr
480 -
481 - # Try to increase file limits to increase test coverage
482 - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
483 - # Upper limit comes from parts.partition_* tests
484 - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
485 -
486 - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
487 - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
488 - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
489 -
490 - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
491 - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
492 - else
493 - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
494 - fi
495 - else
496 - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
497 - fi
498 - else
499 - einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
500 - fi
501 -
502 - # run mysql-test tests
503 - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
504 - retstatus_tests=$?
505 -
506 - popd &>/dev/null || die
507 -
508 - # Cleanup is important for these testcases.
509 - pkill -9 -f "${S}/ndb" 2>/dev/null
510 - pkill -9 -f "${S}/sql" 2>/dev/null
511 -
512 - local failures=""
513 - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
514 - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
515 -
516 - [[ -z "$failures" ]] || die "Test failures: $failures"
517 - einfo "Tests successfully completed"
518 -}
519 -
520 -src_install() {
521 - cmake_src_install
522 -
523 - # Make sure the vars are correctly initialized
524 - mysql_init_vars
525 -
526 - # Convenience links
527 - einfo "Making Convenience links for mysqlcheck multi-call binary"
528 - dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
529 - dosym "mysqlcheck" "/usr/bin/mysqlrepair"
530 - dosym "mysqlcheck" "/usr/bin/mysqloptimize"
531 -
532 - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
533 - if [[ -d "${ED}/usr/data" ]] ; then
534 - rm -Rf "${ED}/usr/data" || die
535 - fi
536 -
537 - # Unless they explicitly specific USE=test, then do not install the
538 - # testsuite. It DOES have a use to be installed, esp. when you want to do a
539 - # validation of your database configuration after tuning it.
540 - if ! use test ; then
541 - rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test"
542 - fi
543 -
544 - # Configuration stuff
545 - einfo "Building default configuration ..."
546 - insinto "${MY_SYSCONFDIR#${EPREFIX}}"
547 - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
548 - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
549 - eprefixify "${TMPDIR}/my.cnf"
550 - doins "${TMPDIR}/my.cnf"
551 - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
552 - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
553 - eprefixify "${TMPDIR}/50-distro-client.cnf"
554 - doins "${TMPDIR}/50-distro-client.cnf"
555 -
556 - mycnf_src="my.cnf-8.0.distro-server"
557 - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
558 - "${FILESDIR}/${mycnf_src}" \
559 - > "${TMPDIR}/my.cnf.ok" || die
560 -
561 - if use prefix ; then
562 - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
563 - "${TMPDIR}/my.cnf.ok" || die
564 - fi
565 -
566 - if use latin1 ; then
567 - sed -i \
568 - -e "/character-set/s|utf8mb4|latin1|g" \
569 - "${TMPDIR}/my.cnf.ok" || die
570 - fi
571 -
572 - eprefixify "${TMPDIR}/my.cnf.ok"
573 -
574 - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
575 -
576 - #Remove mytop if perl is not selected
577 - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
578 -
579 - if use router ; then
580 - rm -rf \
581 - "${ED}/usr/LICENSE.router" \
582 - "${ED}/usr/README.router" \
583 - "${ED}/usr/run" \
584 - "${ED}/usr/var" \
585 - || die
586 - fi
587 -
588 - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
589 - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
590 -}
591 -
592 -pkg_postinst() {
593 - # Make sure the vars are correctly initialized
594 - mysql_init_vars
595 -
596 - # Create log directory securely if it does not exist
597 - # NOTE: $MY_LOGDIR contains $EPREFIX by default
598 - [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}"
599 -
600 - # Note about configuration change
601 - einfo
602 - elog "This version of ${PN} reorganizes the configuration from a single my.cnf"
603 - elog "to several files in /etc/mysql/mysql.d."
604 - elog "Please backup any changes you made to /etc/mysql/my.cnf"
605 - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension."
606 - elog "You may have as many files as needed and they are read alphabetically."
607 - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
608 - einfo
609 -
610 - if [[ -z "${REPLACING_VERSIONS}" ]] ; then
611 - einfo
612 - elog "You might want to run:"
613 - elog " \"emerge --config =${CATEGORY}/${PF}\""
614 - elog "if this is a new install."
615 - einfo
616 - else
617 - einfo
618 - elog "Upgrade process for ${PN}-8.x has changed. Please read"
619 - elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html"
620 - einfo
621 - fi
622 -}
623 -
624 -pkg_config() {
625 - _getoptval() {
626 - local section="$1"
627 - local flag="--${2}="
628 - local extra_options="${3}"
629 - local cmd=(
630 - "${my_print_defaults_binary}"
631 - "${extra_options}"
632 - "${section}"
633 - )
634 - local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") )
635 -
636 - if [[ ${#results[@]} -gt 0 ]] ; then
637 - # When option is set multiple times only return last value
638 - echo "${results[-1]}"
639 - fi
640 - }
641 -
642 - _mktemp_dry() {
643 - # emktemp has no --dry-run option
644 - local template="${1}"
645 -
646 - if [[ -z "${template}" ]] ; then
647 - if [[ -z "${T}" ]] ; then
648 - template="/tmp/XXXXXXX"
649 - else
650 - template="${T}/XXXXXXX"
651 - fi
652 - fi
653 -
654 - local template_wo_X=${template//X/}
655 - local n_X
656 - let n_X=${#template}-${#template_wo_X}
657 - if [[ ${n_X} -lt 3 ]] ; then
658 - echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2
659 - return
660 - fi
661 -
662 - local attempts=0
663 - local character tmpfile
664 - while [[ true ]] ; do
665 - let attempts=attempts+1
666 -
667 - new_file=
668 - while read -n1 character ; do
669 - if [[ "${character}" == "X" ]] ; then
670 - tmpfile+="${RANDOM:0:1}"
671 - else
672 - tmpfile+="${character}"
673 - fi
674 - done < <(echo -n "${template}")
675 -
676 - if [[ ! -f "${tmpfile}" ]]
677 - then
678 - echo "${tmpfile}"
679 - return
680 - fi
681 -
682 - if [[ ${attempts} -ge 100 ]] ; then
683 - echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2
684 - return
685 - fi
686 - done
687 - }
688 -
689 - local mysqld_binary="${EROOT}/usr/sbin/mysqld"
690 - if [[ ! -x "${mysqld_binary}" ]] ; then
691 - die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
692 - fi
693 -
694 - local mysql_binary="${EROOT}/usr/bin/mysql"
695 - if [[ ! -x "${mysql_binary}" ]] ; then
696 - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
697 - fi
698 -
699 - local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults"
700 - if [[ ! -x "${my_print_defaults_binary}" ]] ; then
701 - die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!"
702 - fi
703 -
704 - if [[ -z "${MYSQL_USER}" ]] ; then
705 - MYSQL_USER=mysql
706 - if use prefix ; then
707 - MYSQL_USER=$(id -u -n 2>/dev/null)
708 - if [[ -z "${MYSQL_USER}" ]] ; then
709 - die "Failed to determine current username!"
710 - fi
711 - fi
712 - fi
713 -
714 - if [[ -z "${MYSQL_GROUP}" ]] ; then
715 - MYSQL_GROUP=mysql
716 - if use prefix ; then
717 - MYSQL_GROUP=$(id -g -n 2>/dev/null)
718 - if [[ -z "${MYSQL_GROUP}" ]] ; then
719 - die "Failed to determine current user groupname!"
720 - fi
721 - fi
722 - fi
723 -
724 - # my_print_defaults needs to read stuff in $HOME/.my.cnf
725 - local -x HOME="${EROOT}/root"
726 -
727 - # Make sure the vars are correctly initialized
728 - mysql_init_vars
729 -
730 - # Read currently set data directory
731 - MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
732 -
733 - # Bug #213475 - MySQL _will_ object strenously if your machine is named
734 - # localhost. Also causes weird failures.
735 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
736 -
737 - if [[ -z "${MY_DATADIR}" ]] ; then
738 - die "Sorry, unable to find MY_DATADIR!"
739 - elif [[ -d "${MY_DATADIR}/mysql" ]] ; then
740 - ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!"
741 - ewarn "Please rename or delete its content if you wish to initialize a new data directory."
742 - die "${PN} data directory at '${MY_DATADIR}' looks already initialized!"
743 - fi
744 -
745 - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
746 - MYSQL_TMPDIR=${MYSQL_TMPDIR%/}
747 - # These are dir+prefix
748 - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
749 - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
750 - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
751 - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
752 -
753 - # Create missing directories.
754 - # Always check if mysql user can write to directory even if we just
755 - # created directory because a parent directory might be not
756 - # accessible for that user.
757 - PID_DIR="${EROOT}/run/mysqld"
758 - if [[ ! -d "${PID_DIR}" ]] ; then
759 - einfo "Creating ${PN} PID directory '${PID_DIR}' ..."
760 - install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \
761 - || die "Failed to create PID directory '${PID_DIR}'!"
762 - fi
763 -
764 - local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")"
765 - [[ -z "${_pid_dir_testfile}" ]] \
766 - && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
767 -
768 - if use prefix ; then
769 - touch "${_pid_dir_testfile}" &>/dev/null
770 - else
771 - su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null
772 - fi
773 -
774 - if [[ $? -ne 0 ]] ; then
775 - die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!"
776 - else
777 - rm "${_pid_dir_testfile}" || die
778 - unset _pid_dir_testfile
779 - fi
780 -
781 - if [[ ! -d "${MY_DATADIR}" ]] ; then
782 - einfo "Creating ${PN} data directory '${MY_DATADIR}' ..."
783 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \
784 - || die "Failed to create ${PN} data directory '${MY_DATADIR}'!"
785 - fi
786 -
787 - local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")"
788 - [[ -z "${_my_datadir_testfile}" ]] \
789 - && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
790 -
791 - if use prefix ; then
792 - touch "${_my_datadir_testfile}" &>/dev/null
793 - else
794 - su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null
795 - fi
796 -
797 - if [[ $? -ne 0 ]] ; then
798 - die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!"
799 - else
800 - rm "${_my_datadir_testfile}" || die
801 - unset _my_datadir_testfile
802 - fi
803 -
804 - if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then
805 - einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..."
806 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \
807 - || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!"
808 - fi
809 -
810 - if [[ -z "${MYSQL_TMPDIR}" ]] ; then
811 - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")"
812 - [[ -z "${MYSQL_TMPDIR}" ]] \
813 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!"
814 -
815 - mkdir "${MYSQL_TMPDIR}" || die
816 - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die
817 - fi
818 -
819 - # Now we need to test MYSQL_TMPDIR...
820 - local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")"
821 - [[ -z "${_my_tmpdir_testfile}" ]] \
822 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
823 -
824 - if use prefix ; then
825 - touch "${_my_tmpdir_testfile}" &>/dev/null
826 - else
827 - su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null
828 - fi
829 -
830 - if [[ $? -ne 0 ]] ; then
831 - die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!"
832 - else
833 - rm "${_my_tmpdir_testfile}" || die
834 - unset _my_tmpdir_testfile
835 - fi
836 -
837 - if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then
838 - einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..."
839 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \
840 - || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'"
841 - fi
842 -
843 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
844 - local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")"
845 - [[ -z "${_my_logbin_testfile}" ]] \
846 - && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!"
847 -
848 - if use prefix ; then
849 - touch "${_my_logbin_testfile}" &>/dev/null
850 - else
851 - su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null
852 - fi
853 -
854 - if [[ $? -ne 0 ]] ; then
855 - die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!"
856 - else
857 - rm "${_my_logbin_testfile}" || die
858 - unset _my_logbin_testfile
859 - fi
860 - fi
861 -
862 - if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then
863 - einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..."
864 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \
865 - || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!"
866 - fi
867 -
868 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
869 - local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")"
870 - [[ -z "${_my_relaylog_testfile}" ]] \
871 - && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!"
872 -
873 - if use prefix ; then
874 - touch "${_my_relaylog_testfile}" &>/dev/null
875 - else
876 - su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null
877 - fi
878 -
879 - if [[ $? -ne 0 ]] ; then
880 - die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!"
881 - else
882 - rm "${_my_relaylog_testfile}" || die
883 - unset _my_relaylog_testfile
884 - fi
885 - fi
886 -
887 - local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")"
888 - if [[ -z "${mysql_install_log}" ]] ; then
889 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!"
890 - else
891 - # make sure file is writable for MYSQL_USER...
892 - touch "${mysql_install_log}" || die
893 - chown ${MYSQL_USER} "${mysql_install_log}" || die
894 - fi
895 -
896 - local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")"
897 - if [[ -z "${mysqld_logfile}" ]] ; then
898 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!"
899 - else
900 - # make sure file is writable for MYSQL_USER...
901 - touch "${mysqld_logfile}" || die
902 - chown ${MYSQL_USER} "${mysqld_logfile}" || die
903 - fi
904 -
905 - echo ""
906 - einfo "Detected settings:"
907 - einfo "=================="
908 - einfo "MySQL User:\t\t\t\t${MYSQL_USER}"
909 - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}"
910 - einfo "MySQL DATA directory:\t\t${MY_DATADIR}"
911 - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}"
912 -
913 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
914 - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}"
915 - fi
916 -
917 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
918 - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}"
919 - fi
920 -
921 - einfo "PID DIR:\t\t\t\t${PID_DIR}"
922 - einfo "Install db log:\t\t\t${mysql_install_log}"
923 - einfo "Install server log:\t\t\t${mysqld_logfile}"
924 -
925 - local -a config_files
926 -
927 - local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf"
928 - if [[ -f "${config_file}" ]] ; then
929 - config_files+=( "${config_file}" )
930 - else
931 - ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..."
932 - fi
933 -
934 - config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf"
935 - if [[ -f "${config_file}" ]] ; then
936 - config_files+=( "${config_file}" )
937 - else
938 - ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..."
939 - fi
940 -
941 - if [[ ${#config_files[@]} -gt 0 ]] ; then
942 - if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then
943 - local user_answer
944 -
945 - echo
946 - einfo "Please select default authentication plugin (enter number or plugin name):"
947 - einfo "1) caching_sha2_password [MySQL 8.0 default]"
948 - einfo "2) mysql_native_password [MySQL 5.7 default]"
949 - einfo
950 - einfo "For details see:"
951 - einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password"
952 - read -p " >" user_answer
953 - echo
954 -
955 - case "${user_answer}" in
956 - 1|caching_sha2_password)
957 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password
958 - ;;
959 - 2|mysql_native_password)
960 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password
961 - ;;
962 - '')
963 - die "No authentication plugin selected!"
964 - ;;
965 - *)
966 - die "Authentication plugin '${user_answer}' is unknown/unsupported!"
967 - ;;
968 - esac
969 -
970 - echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}"
971 -
972 - unset user_answer
973 - fi
974 -
975 - local cfg_option cfg_option_tabs cfg_section
976 - for config_file in "${config_files[@]}" ; do
977 - cfg_option="default-authentication-plugin"
978 - cfg_section="mysqld"
979 - cfg_option_tabs="\t\t"
980 - if [[ "${config_file}" == *client.cnf ]] ; then
981 - cfg_option="default-auth"
982 - cfg_section="client"
983 - cfg_option_tabs="\t\t\t\t"
984 - fi
985 -
986 - if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then
987 - einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
988 - sed -i \
989 - -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \
990 - "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!"
991 - else
992 - einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
993 - sed -i \
994 - -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \
995 - "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!"
996 - fi
997 - done
998 - unset cfg_option cfg_option_tabs cfg_section
999 - fi
1000 - unset config_files config_file
1001 -
1002 - echo
1003 -
1004 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
1005 - local tmp_mysqld_password_source=
1006 -
1007 - for tmp_mysqld_password_source in mysql client ; do
1008 - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
1009 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
1010 - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
1011 - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
1012 - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
1013 - MYSQL_ROOT_PASSWORD=
1014 - continue
1015 - fi
1016 -
1017 - einfo "Found password in '${tmp_mysqld_password_source}' section!"
1018 - break
1019 - fi
1020 - done
1021 -
1022 - # Sometimes --show is required to display passwords in some implementations of my_print_defaults
1023 - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
1024 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
1025 - fi
1026 -
1027 - unset tmp_mysqld_password_source
1028 - fi
1029 -
1030 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
1031 - local pwd1="a"
1032 - local pwd2="b"
1033 -
1034 - echo
1035 - einfo "No password for mysql 'root' user was specified via environment"
1036 - einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config"
1037 - einfo "file like '${HOME}/.my.cnf'."
1038 - einfo "To continue please provide a password for the mysql 'root' user"
1039 - einfo "now on console:"
1040 - ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!"
1041 - read -rsp " >" pwd1 ; echo
1042 -
1043 - einfo "Retype the password"
1044 - read -rsp " >" pwd2 ; echo
1045 -
1046 - if [[ "x$pwd1" != "x$pwd2" ]] ; then
1047 - die "Passwords are not the same!"
1048 - fi
1049 -
1050 - MYSQL_ROOT_PASSWORD="${pwd1}"
1051 - unset pwd1 pwd2
1052 -
1053 - echo
1054 - fi
1055 -
1056 - local -a mysqld_options
1057 -
1058 - # Fix bug 446200. Don't reference host my.cnf, needs to come first,
1059 - # see http://bugs.mysql.com/bug.php?id=31312
1060 - use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" )
1061 -
1062 - # Figure out which options we need to disable to do the setup
1063 - local helpfile="${TMPDIR}/mysqld-help"
1064 - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
1065 -
1066 - local opt optexp optfull
1067 - for opt in host-cache name-resolve networking slave-start \
1068 - federated ssl log-bin relay-log slow-query-log external-locking \
1069 - log-slave-updates \
1070 - ; do
1071 - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
1072 - egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" )
1073 - done
1074 -
1075 - # Prepare timezones, see
1076 - # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
1077 - local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")"
1078 - [[ -z "${tz_sql}" ]] \
1079 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!"
1080 -
1081 - echo "USE mysql;" >"${tz_sql}"
1082 - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null
1083 - if [[ $? -ne 0 ]] ; then
1084 - die "mysql_tzinfo_to_sql failed!"
1085 - fi
1086 -
1087 - # --initialize-insecure will not set root password
1088 - # --initialize would set a random one in the log which we don't need as we set it ourselves
1089 - local cmd=(
1090 - "${mysqld_binary}"
1091 - "${mysqld_options[@]}"
1092 - "--initialize-insecure"
1093 - "--init-file='${tz_sql}'"
1094 - "--basedir='${EROOT}/usr'"
1095 - "--datadir='${MY_DATADIR}'"
1096 - "--tmpdir='${MYSQL_TMPDIR}'"
1097 - "--log-error='${mysql_install_log}'"
1098 - "--user=${MYSQL_USER}"
1099 - )
1100 -
1101 - einfo "Initializing ${PN} data directory: ${cmd[@]}"
1102 - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1
1103 -
1104 - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then
1105 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2
1106 - die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!"
1107 - fi
1108 -
1109 - rm "${tz_sql}" || die
1110 -
1111 - local x=${RANDOM}
1112 - local socket="${EROOT}${PID_DIR}/mysqld${x}.sock"
1113 - local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid"
1114 - unset x
1115 -
1116 - cmd=(
1117 - "${mysqld_binary}"
1118 - "${mysqld_options[@]}"
1119 - "--basedir='${EROOT}/usr'"
1120 - "--datadir='${MY_DATADIR}'"
1121 - "--tmpdir='${MYSQL_TMPDIR}'"
1122 - --max_allowed_packet=8M
1123 - --net_buffer_length=16K
1124 - "--socket='${socket}'"
1125 - "--pid-file='${pidfile}'"
1126 - "--log-error='${mysqld_logfile}'"
1127 - "--user=${MYSQL_USER}"
1128 - )
1129 -
1130 - einfo "Starting mysqld to finalize initialization: ${cmd[@]}"
1131 - eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 &
1132 -
1133 - echo -n "Waiting for mysqld to accept connections "
1134 - local maxtry=15
1135 - while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
1136 - maxtry=$((${maxtry}-1))
1137 - echo -n "."
1138 - sleep 1
1139 - done
1140 -
1141 - if [[ -S "${socket}" ]] ; then
1142 - # Even with a socket we don't know if mysqld will abort
1143 - # start due to an error so just wait a little bit more...
1144 - maxtry=5
1145 - while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
1146 - maxtry=$((${maxtry}-1))
1147 - echo -n "."
1148 - sleep 1
1149 - done
1150 - fi
1151 -
1152 - echo
1153 -
1154 - if [[ ! -S "${socket}" ]] ; then
1155 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2
1156 - die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!"
1157 - fi
1158 -
1159 - local mysql_logfile="${TMPDIR}/set_root_pw.log"
1160 - touch "${mysql_logfile}" || die
1161 -
1162 - ebegin "Setting root password"
1163 - # Do this from memory, as we don't want clear text passwords in temp files
1164 - local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'"
1165 - cmd=(
1166 - "${mysql_binary}"
1167 - --no-defaults
1168 - "--socket='${socket}'"
1169 - -hlocalhost
1170 - "-e \"${sql}\""
1171 - )
1172 - eval "${cmd[@]}" >"${mysql_logfile}" 2>&1
1173 - local rc=$?
1174 - eend ${rc}
1175 -
1176 - if [[ ${rc} -ne 0 ]] ; then
1177 - # Poor man's solution which tries to avoid having password
1178 - # in log. NOTE: sed can fail if user didn't follow advice
1179 - # and included character which will require escaping...
1180 - sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null
1181 -
1182 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}"
1183 - die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!"
1184 - fi
1185 -
1186 - # Stop the server
1187 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
1188 - echo -n "Stopping the server "
1189 - pkill -F "${pidfile}" &>/dev/null
1190 -
1191 - maxtry=10
1192 - while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do
1193 - maxtry=$((${maxtry}-1))
1194 - echo -n "."
1195 - sleep 1
1196 - done
1197 -
1198 - echo
1199 -
1200 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
1201 - # We somehow failed to stop server.
1202 - # However, not a fatal error. Just warn the user.
1203 - ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!"
1204 - fi
1205 - fi
1206 -
1207 - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!"
1208 -}
1209
1210 diff --git a/dev-db/mysql/mysql-8.0.23.ebuild b/dev-db/mysql/mysql-8.0.23.ebuild
1211 deleted file mode 100644
1212 index 2ad3f320946d..000000000000
1213 --- a/dev-db/mysql/mysql-8.0.23.ebuild
1214 +++ /dev/null
1215 @@ -1,1158 +0,0 @@
1216 -# Copyright 1999-2021 Gentoo Authors
1217 -# Distributed under the terms of the GNU General Public License v2
1218 -
1219 -EAPI="7"
1220 -
1221 -CMAKE_MAKEFILE_GENERATOR=emake
1222 -
1223 -inherit check-reqs cmake flag-o-matic linux-info \
1224 - multiprocessing prefix toolchain-funcs
1225 -
1226 -MY_PV="${PV//_pre*}"
1227 -MY_P="${PN}-${MY_PV}"
1228 -
1229 -# Patch version
1230 -PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-8.0.23-patches-01.tar.xz"
1231 -
1232 -SRC_URI="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${MY_PV}.tar.gz
1233 - https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${MY_PV}.tar.gz
1234 - http://downloads.mysql.com/archives/MySQL-8.0/${PN}-boost-${MY_PV}.tar.gz
1235 - ${PATCH_SET}"
1236 -
1237 -HOMEPAGE="https://www.mysql.com/"
1238 -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
1239 -LICENSE="GPL-2"
1240 -SLOT="8.0"
1241 -IUSE="cjk cracklib debug jemalloc latin1 numa +perl profiling
1242 - router selinux +server tcmalloc test"
1243 -
1244 -RESTRICT="!test? ( test )"
1245 -
1246 -REQUIRED_USE="?? ( tcmalloc jemalloc )
1247 - cjk? ( server )
1248 - jemalloc? ( server )
1249 - numa? ( server )
1250 - profiling? ( server )
1251 - router? ( server )
1252 - tcmalloc? ( server )"
1253 -
1254 -# -ppc, -riscv for bug #761715
1255 -KEYWORDS="amd64 ~arm ~arm64 ~hppa ~ia64 ~mips -ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris"
1256 -
1257 -# Shorten the path because the socket path length must be shorter than 107 chars
1258 -# and we will run a mysql server during test phase
1259 -S="${WORKDIR}/mysql"
1260 -
1261 -# Be warned, *DEPEND are version-dependant
1262 -# These are used for both runtime and compiletime
1263 -COMMON_DEPEND="
1264 - >=app-arch/lz4-0_p131:=
1265 - app-arch/zstd:=
1266 - sys-libs/ncurses:0=
1267 - >=sys-libs/zlib-1.2.3:0=
1268 - >=dev-libs/openssl-1.0.0:0=
1269 - server? (
1270 - dev-libs/icu:=
1271 - dev-libs/libevent:=[ssl,threads]
1272 - >=dev-libs/protobuf-3.8:=
1273 - net-libs/libtirpc:=
1274 - cjk? ( app-text/mecab:= )
1275 - jemalloc? ( dev-libs/jemalloc:0= )
1276 - kernel_linux? (
1277 - dev-libs/libaio:0=
1278 - sys-process/procps:0=
1279 - )
1280 - numa? ( sys-process/numactl )
1281 - tcmalloc? ( dev-util/google-perftools:0= )
1282 - )
1283 -"
1284 -DEPEND="${COMMON_DEPEND}
1285 - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
1286 - virtual/yacc
1287 - server? ( net-libs/rpcsvc-proto )
1288 - test? (
1289 - acct-group/mysql acct-user/mysql
1290 - dev-perl/JSON
1291 - )
1292 -"
1293 -RDEPEND="${COMMON_DEPEND}
1294 - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
1295 - !dev-db/mysql:0
1296 - !dev-db/mysql:5.7
1297 - selinux? ( sec-policy/selinux-mysql )
1298 - !prefix? (
1299 - acct-group/mysql acct-user/mysql
1300 - dev-db/mysql-init-scripts
1301 - )
1302 -"
1303 -# For other stuff to bring us in
1304 -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
1305 -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
1306 -
1307 -mysql_init_vars() {
1308 - : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
1309 - : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
1310 - : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
1311 - : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
1312 - MY_DATADIR="${MY_LOCALSTATEDIR}"
1313 -
1314 - export MY_SHAREDSTATEDIR MY_SYSCONFDIR
1315 - export MY_LOCALSTATEDIR MY_LOGDIR
1316 - export MY_DATADIR
1317 -}
1318 -
1319 -pkg_pretend() {
1320 - if [[ ${MERGE_TYPE} != binary ]] ; then
1321 - if use server ; then
1322 - CHECKREQS_DISK_BUILD="2G"
1323 -
1324 - if has test $FEATURES ; then
1325 - CHECKREQS_DISK_BUILD="9G"
1326 - fi
1327 -
1328 - check-reqs_pkg_pretend
1329 - fi
1330 - fi
1331 -}
1332 -
1333 -pkg_setup() {
1334 - if [[ ${MERGE_TYPE} != binary ]] ; then
1335 - CHECKREQS_DISK_BUILD="2G"
1336 -
1337 - if has test ${FEATURES} ; then
1338 - CHECKREQS_DISK_BUILD="9G"
1339 -
1340 - # Bug #213475 - MySQL _will_ object strenuously if your machine is named
1341 - # localhost. Also causes weird failures.
1342 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1343 -
1344 - if ! has userpriv ${FEATURES} ; then
1345 - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
1346 - fi
1347 -
1348 - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null)
1349 - [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \
1350 - && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!"
1351 -
1352 - if use latin1 ; then
1353 - # Upstream only supports tests with default charset
1354 - die "Testing with USE=latin1 is not supported."
1355 - fi
1356 - fi
1357 -
1358 - if use kernel_linux ; then
1359 - if use numa ; then
1360 - linux-info_get_any_version
1361 -
1362 - local CONFIG_CHECK="~NUMA"
1363 -
1364 - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
1365 - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
1366 -
1367 - check_extra_config
1368 - fi
1369 - fi
1370 -
1371 - use server && check-reqs_pkg_setup
1372 - fi
1373 -}
1374 -
1375 -src_unpack() {
1376 - unpack ${A}
1377 -
1378 - mv -f "${WORKDIR}/${MY_P}" "${S}" || die
1379 -}
1380 -
1381 -src_prepare() {
1382 - eapply "${WORKDIR}"/mysql-patches
1383 -
1384 - # Avoid rpm call which would trigger sandbox, #692368
1385 - sed -i \
1386 - -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \
1387 - CMakeLists.txt || die
1388 -
1389 - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
1390 - if [[ -d "${S}/support-files/SELinux" ]] ; then
1391 - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
1392 - fi
1393 -
1394 - # Remove man pages for client-lib tools we don't install
1395 - rm \
1396 - man/my_print_defaults.1 \
1397 - man/perror.1 \
1398 - man/zlib_decompress.1 \
1399 - || die
1400 -
1401 - cmake_src_prepare
1402 -}
1403 -
1404 -src_configure() {
1405 - # Bug #114895, bug #110149
1406 - filter-flags "-O" "-O[01]"
1407 -
1408 - append-cxxflags -felide-constructors
1409 -
1410 - # bug #283926, with GCC4.4, this is required to get correct behavior.
1411 - append-flags -fno-strict-aliasing
1412 -
1413 - CMAKE_BUILD_TYPE="RelWithDebInfo"
1414 -
1415 - # debug hack wrt #497532
1416 - mycmakeargs=(
1417 - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1418 - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
1419 - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
1420 - -DSYSCONFDIR="${EPREFIX}/etc/mysql"
1421 - -DINSTALL_BINDIR=bin
1422 - -DINSTALL_DOCDIR=share/doc/${PF}
1423 - -DINSTALL_DOCREADMEDIR=share/doc/${PF}
1424 - -DINSTALL_INCLUDEDIR=include/mysql
1425 - -DINSTALL_INFODIR=share/info
1426 - -DINSTALL_LIBDIR=$(get_libdir)
1427 - -DINSTALL_MANDIR=share/man
1428 - -DINSTALL_MYSQLSHAREDIR=share/mysql
1429 - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
1430 - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
1431 - -DINSTALL_SBINDIR=sbin
1432 - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
1433 - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
1434 - -DWITH_UNIT_TESTS=$(usex test ON OFF)
1435 - # Using bundled editline to get CTRL+C working
1436 - -DWITH_EDITLINE=bundled
1437 - -DWITH_ZLIB=system
1438 - -DWITH_SSL=system
1439 - -DWITH_LIBWRAP=0
1440 - -DENABLED_LOCAL_INFILE=1
1441 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
1442 - -DWITH_DEFAULT_COMPILER_OPTIONS=0
1443 - # The build forces this to be defined when cross-compiling. We pass it
1444 - # all the time for simplicity and to make sure it is actually correct.
1445 - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
1446 - -DCMAKE_POSITION_INDEPENDENT_CODE=ON
1447 - -DWITH_CURL=system
1448 - -DWITH_BOOST="${S}/boost"
1449 - -DWITH_ROUTER=$(usex router ON OFF)
1450 - )
1451 -
1452 - if is-flagq -fno-lto ; then
1453 - einfo "LTO disabled via {C,CXX,F,FC}FLAGS"
1454 - mycmakeargs+=( -DWITH_LTO=OFF )
1455 - elif is-flagq -flto ; then
1456 - einfo "LTO forced via {C,CXX,F,FC}FLAGS"
1457 - myconf+=( -DWITH_LTO=ON )
1458 - else
1459 - # Disable automagic
1460 - myconf+=( -DWITH_LTO=OFF )
1461 - fi
1462 -
1463 - if use test ; then
1464 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
1465 - else
1466 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
1467 - fi
1468 -
1469 - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
1470 -
1471 - mycmakeargs+=(
1472 - -DWITH_ICU=system
1473 - -DWITH_LZ4=system
1474 - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex
1475 - -DWITH_RAPIDJSON=bundled
1476 - -DWITH_ZSTD=system
1477 - )
1478 -
1479 - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then
1480 - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
1481 - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
1482 - ewarn "You MUST file bugs without these variables set."
1483 - ewarn "Tests will probably fail!"
1484 -
1485 - mycmakeargs+=(
1486 - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
1487 - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
1488 - )
1489 - elif use latin1 ; then
1490 - mycmakeargs+=(
1491 - -DDEFAULT_CHARSET=latin1
1492 - -DDEFAULT_COLLATION=latin1_swedish_ci
1493 - )
1494 - else
1495 - mycmakeargs+=(
1496 - -DDEFAULT_CHARSET=utf8mb4
1497 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
1498 - )
1499 - fi
1500 -
1501 - if use server ; then
1502 - mycmakeargs+=(
1503 - -DWITH_EXTRA_CHARSETS=all
1504 - -DWITH_DEBUG=$(usex debug)
1505 - -DWITH_MECAB=$(usex cjk system OFF)
1506 - -DWITH_LIBEVENT=system
1507 - -DWITH_PROTOBUF=system
1508 - -DWITH_NUMA=$(usex numa ON OFF)
1509 - )
1510 -
1511 - if use jemalloc ; then
1512 - mycmakeargs+=( -DWITH_JEMALLOC=ON )
1513 - elif use tcmalloc ; then
1514 - mycmakeargs+=( -DWITH_TCMALLOC=ON )
1515 - fi
1516 -
1517 - if use profiling ; then
1518 - # Setting to OFF doesn't work: Once set, profiling options will be added
1519 - # to `mysqld --help` output via sql/sys_vars.cc causing
1520 - # "main.mysqld--help-notwin" test to fail
1521 - mycmakeargs+=( -DENABLED_PROFILING=ON )
1522 - fi
1523 -
1524 - # Storage engines
1525 - mycmakeargs+=(
1526 - -DWITH_EXAMPLE_STORAGE_ENGINE=0
1527 - -DWITH_ARCHIVE_STORAGE_ENGINE=1
1528 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1
1529 - -DWITH_CSV_STORAGE_ENGINE=1
1530 - -DWITH_FEDERATED_STORAGE_ENGINE=1
1531 - -DWITH_HEAP_STORAGE_ENGINE=1
1532 - -DWITH_INNOBASE_STORAGE_ENGINE=1
1533 - -DWITH_INNODB_MEMCACHED=0
1534 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1
1535 - -DWITH_MYISAM_STORAGE_ENGINE=1
1536 - )
1537 - else
1538 - mycmakeargs+=(
1539 - -DWITHOUT_SERVER=1
1540 - -DWITH_SYSTEMD=no
1541 - )
1542 - fi
1543 -
1544 - cmake_src_configure
1545 -}
1546 -
1547 -# Official test instructions:
1548 -# ulimit -n 16500 && \
1549 -# USE='perl server' \
1550 -# FEATURES='test userpriv' \
1551 -# ebuild mysql-X.X.XX.ebuild \
1552 -# digest clean package
1553 -src_test() {
1554 - _disable_test() {
1555 - local rawtestname bug reason
1556 - rawtestname="${1}" ; shift
1557 - bug="${1}" ; shift
1558 - reason="${@}"
1559 - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
1560 - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def"
1561 - }
1562 -
1563 - local TESTDIR="${BUILD_DIR}/mysql-test"
1564 - local retstatus_unit
1565 - local retstatus_tests
1566 -
1567 - # Run CTest (test-units)
1568 - cmake_src_test
1569 - retstatus_unit=$?
1570 -
1571 - # Ensure that parallel runs don't die
1572 - export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
1573 -
1574 - if [[ -z "${MTR_PARALLEL}" ]] ; then
1575 - local -x MTR_PARALLEL=$(makeopts_jobs)
1576 -
1577 - if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
1578 - # Running multiple tests in parallel usually require higher ulimit
1579 - # and fs.aio-max-nr setting. In addition, tests like main.multi_update
1580 - # are known to hit timeout when system is busy.
1581 - # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
1582 - # using "auto".
1583 - local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
1584 - info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
1585 - einfo "${info_msg}"
1586 - unset info_msg
1587 - MTR_PARALLEL=4
1588 - fi
1589 - else
1590 - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
1591 - fi
1592 -
1593 - # create directories because mysqladmin might run out of order
1594 - mkdir -p "${T}"/var-tests{,/log} || die
1595 -
1596 - # Run mysql tests
1597 - pushd "${TESTDIR}" &>/dev/null || die
1598 -
1599 - touch "${T}/disabled.def"
1600 -
1601 - local -a disabled_tests
1602 - disabled_tests+=( "auth_sec.atomic_rename_user;0;Depends on user running test" )
1603 - disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" )
1604 - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" )
1605 - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" )
1606 - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" )
1607 - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" )
1608 - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" )
1609 - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" )
1610 - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" )
1611 - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" )
1612 - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" )
1613 - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" )
1614 - disabled_tests+=( "main.cast;0;Needs update for 2021" )
1615 - disabled_tests+=( "main.mysql_load_data_local_dir;0;Known test failure - no upstream bug yet" )
1616 - disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
1617 - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
1618 - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
1619 - disabled_tests+=( "main.with_recursive;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
1620 - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" )
1621 - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Known failure - no upstream bug yet" )
1622 - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware")
1623 - disabled_tests+=( "x.connection;0;Known failure - no upstream bug yet" )
1624 - disabled_tests+=( "main.mysqlpump_basic_lz4;0;Extra tool output causes false positive" )
1625 - disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" )
1626 - disabled_tests+=( "x.message_protobuf_nested;0;False positive caused by protobuff-3.11+" )
1627 -
1628 - if ! hash zip 1>/dev/null 2>&1 ; then
1629 - # no need to force dep app-arch/zip for one test
1630 - disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" )
1631 - disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" )
1632 - fi
1633 -
1634 - local test_infos_str test_infos_arr
1635 - for test_infos_str in "${disabled_tests[@]}" ; do
1636 - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
1637 -
1638 - if [[ ${#test_infos_arr[@]} != 3 ]] ; then
1639 - die "Invalid test data set, not matching format: ${test_infos_str}"
1640 - fi
1641 -
1642 - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
1643 - done
1644 - unset test_infos_str test_infos_arr
1645 -
1646 - # Try to increase file limits to increase test coverage
1647 - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
1648 - # Upper limit comes from parts.partition_* tests
1649 - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
1650 -
1651 - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
1652 - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
1653 - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
1654 -
1655 - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
1656 - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
1657 - else
1658 - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
1659 - fi
1660 - else
1661 - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
1662 - fi
1663 - else
1664 - einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
1665 - fi
1666 -
1667 - # run mysql-test tests
1668 - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
1669 - retstatus_tests=$?
1670 -
1671 - popd &>/dev/null || die
1672 -
1673 - # Cleanup is important for these testcases.
1674 - pkill -9 -f "${S}/ndb" 2>/dev/null
1675 - pkill -9 -f "${S}/sql" 2>/dev/null
1676 -
1677 - local failures=""
1678 - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
1679 - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
1680 -
1681 - [[ -z "$failures" ]] || die "Test failures: $failures"
1682 - einfo "Tests successfully completed"
1683 -}
1684 -
1685 -src_install() {
1686 - cmake_src_install
1687 -
1688 - # Make sure the vars are correctly initialized
1689 - mysql_init_vars
1690 -
1691 - # Convenience links
1692 - einfo "Making Convenience links for mysqlcheck multi-call binary"
1693 - dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
1694 - dosym "mysqlcheck" "/usr/bin/mysqlrepair"
1695 - dosym "mysqlcheck" "/usr/bin/mysqloptimize"
1696 -
1697 - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
1698 - if [[ -d "${ED}/usr/data" ]] ; then
1699 - rm -Rf "${ED}/usr/data" || die
1700 - fi
1701 -
1702 - # Unless they explicitly specific USE=test, then do not install the
1703 - # testsuite. It DOES have a use to be installed, esp. when you want to do a
1704 - # validation of your database configuration after tuning it.
1705 - if ! use test ; then
1706 - rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test"
1707 - fi
1708 -
1709 - # Configuration stuff
1710 - einfo "Building default configuration ..."
1711 - insinto "${MY_SYSCONFDIR#${EPREFIX}}"
1712 - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
1713 - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
1714 - eprefixify "${TMPDIR}/my.cnf"
1715 - doins "${TMPDIR}/my.cnf"
1716 - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
1717 - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
1718 - eprefixify "${TMPDIR}/50-distro-client.cnf"
1719 - doins "${TMPDIR}/50-distro-client.cnf"
1720 -
1721 - mycnf_src="my.cnf-8.0.distro-server"
1722 - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
1723 - "${FILESDIR}/${mycnf_src}" \
1724 - > "${TMPDIR}/my.cnf.ok" || die
1725 -
1726 - if use prefix ; then
1727 - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
1728 - "${TMPDIR}/my.cnf.ok" || die
1729 - fi
1730 -
1731 - if use latin1 ; then
1732 - sed -i \
1733 - -e "/character-set/s|utf8mb4|latin1|g" \
1734 - "${TMPDIR}/my.cnf.ok" || die
1735 - fi
1736 -
1737 - eprefixify "${TMPDIR}/my.cnf.ok"
1738 -
1739 - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
1740 -
1741 - #Remove mytop if perl is not selected
1742 - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
1743 -
1744 - if use router ; then
1745 - rm -rf \
1746 - "${ED}/usr/LICENSE.router" \
1747 - "${ED}/usr/README.router" \
1748 - "${ED}/usr/run" \
1749 - "${ED}/usr/var" \
1750 - || die
1751 - fi
1752 -
1753 - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
1754 - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
1755 -}
1756 -
1757 -pkg_postinst() {
1758 - # Make sure the vars are correctly initialized
1759 - mysql_init_vars
1760 -
1761 - # Create log directory securely if it does not exist
1762 - # NOTE: $MY_LOGDIR contains $EPREFIX by default
1763 - [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}"
1764 -
1765 - # Note about configuration change
1766 - einfo
1767 - elog "This version of ${PN} reorganizes the configuration from a single my.cnf"
1768 - elog "to several files in /etc/mysql/mysql.d."
1769 - elog "Please backup any changes you made to /etc/mysql/my.cnf"
1770 - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension."
1771 - elog "You may have as many files as needed and they are read alphabetically."
1772 - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
1773 - einfo
1774 -
1775 - if [[ -z "${REPLACING_VERSIONS}" ]] ; then
1776 - einfo
1777 - elog "You might want to run:"
1778 - elog " \"emerge --config =${CATEGORY}/${PF}\""
1779 - elog "if this is a new install."
1780 - einfo
1781 - else
1782 - einfo
1783 - elog "Upgrade process for ${PN}-8.x has changed. Please read"
1784 - elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html"
1785 - einfo
1786 - fi
1787 -}
1788 -
1789 -pkg_config() {
1790 - _getoptval() {
1791 - local section="$1"
1792 - local flag="--${2}="
1793 - local extra_options="${3}"
1794 - local cmd=(
1795 - "${my_print_defaults_binary}"
1796 - "${extra_options}"
1797 - "${section}"
1798 - )
1799 - local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") )
1800 -
1801 - if [[ ${#results[@]} -gt 0 ]] ; then
1802 - # When option is set multiple times only return last value
1803 - echo "${results[-1]}"
1804 - fi
1805 - }
1806 -
1807 - _mktemp_dry() {
1808 - # emktemp has no --dry-run option
1809 - local template="${1}"
1810 -
1811 - if [[ -z "${template}" ]] ; then
1812 - if [[ -z "${T}" ]] ; then
1813 - template="/tmp/XXXXXXX"
1814 - else
1815 - template="${T}/XXXXXXX"
1816 - fi
1817 - fi
1818 -
1819 - local template_wo_X=${template//X/}
1820 - local n_X
1821 - let n_X=${#template}-${#template_wo_X}
1822 - if [[ ${n_X} -lt 3 ]] ; then
1823 - echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2
1824 - return
1825 - fi
1826 -
1827 - local attempts=0
1828 - local character tmpfile
1829 - while [[ true ]] ; do
1830 - let attempts=attempts+1
1831 -
1832 - new_file=
1833 - while read -n1 character ; do
1834 - if [[ "${character}" == "X" ]] ; then
1835 - tmpfile+="${RANDOM:0:1}"
1836 - else
1837 - tmpfile+="${character}"
1838 - fi
1839 - done < <(echo -n "${template}")
1840 -
1841 - if [[ ! -f "${tmpfile}" ]]
1842 - then
1843 - echo "${tmpfile}"
1844 - return
1845 - fi
1846 -
1847 - if [[ ${attempts} -ge 100 ]] ; then
1848 - echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2
1849 - return
1850 - fi
1851 - done
1852 - }
1853 -
1854 - local mysqld_binary="${EROOT}/usr/sbin/mysqld"
1855 - if [[ ! -x "${mysqld_binary}" ]] ; then
1856 - die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
1857 - fi
1858 -
1859 - local mysql_binary="${EROOT}/usr/bin/mysql"
1860 - if [[ ! -x "${mysql_binary}" ]] ; then
1861 - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
1862 - fi
1863 -
1864 - local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults"
1865 - if [[ ! -x "${my_print_defaults_binary}" ]] ; then
1866 - die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!"
1867 - fi
1868 -
1869 - if [[ -z "${MYSQL_USER}" ]] ; then
1870 - MYSQL_USER=mysql
1871 - if use prefix ; then
1872 - MYSQL_USER=$(id -u -n 2>/dev/null)
1873 - if [[ -z "${MYSQL_USER}" ]] ; then
1874 - die "Failed to determine current username!"
1875 - fi
1876 - fi
1877 - fi
1878 -
1879 - if [[ -z "${MYSQL_GROUP}" ]] ; then
1880 - MYSQL_GROUP=mysql
1881 - if use prefix ; then
1882 - MYSQL_GROUP=$(id -g -n 2>/dev/null)
1883 - if [[ -z "${MYSQL_GROUP}" ]] ; then
1884 - die "Failed to determine current user groupname!"
1885 - fi
1886 - fi
1887 - fi
1888 -
1889 - # my_print_defaults needs to read stuff in $HOME/.my.cnf
1890 - local -x HOME="${EROOT}/root"
1891 -
1892 - # Make sure the vars are correctly initialized
1893 - mysql_init_vars
1894 -
1895 - # Read currently set data directory
1896 - MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
1897 -
1898 - # Bug #213475 - MySQL _will_ object strenously if your machine is named
1899 - # localhost. Also causes weird failures.
1900 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
1901 -
1902 - if [[ -z "${MY_DATADIR}" ]] ; then
1903 - die "Sorry, unable to find MY_DATADIR!"
1904 - elif [[ -d "${MY_DATADIR}/mysql" ]] ; then
1905 - ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!"
1906 - ewarn "Please rename or delete its content if you wish to initialize a new data directory."
1907 - die "${PN} data directory at '${MY_DATADIR}' looks already initialized!"
1908 - fi
1909 -
1910 - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
1911 - MYSQL_TMPDIR=${MYSQL_TMPDIR%/}
1912 - # These are dir+prefix
1913 - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
1914 - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
1915 - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
1916 - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
1917 -
1918 - # Create missing directories.
1919 - # Always check if mysql user can write to directory even if we just
1920 - # created directory because a parent directory might be not
1921 - # accessible for that user.
1922 - PID_DIR="${EROOT}/run/mysqld"
1923 - if [[ ! -d "${PID_DIR}" ]] ; then
1924 - einfo "Creating ${PN} PID directory '${PID_DIR}' ..."
1925 - install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \
1926 - || die "Failed to create PID directory '${PID_DIR}'!"
1927 - fi
1928 -
1929 - local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")"
1930 - [[ -z "${_pid_dir_testfile}" ]] \
1931 - && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
1932 -
1933 - if use prefix ; then
1934 - touch "${_pid_dir_testfile}" &>/dev/null
1935 - else
1936 - su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null
1937 - fi
1938 -
1939 - if [[ $? -ne 0 ]] ; then
1940 - die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!"
1941 - else
1942 - rm "${_pid_dir_testfile}" || die
1943 - unset _pid_dir_testfile
1944 - fi
1945 -
1946 - if [[ ! -d "${MY_DATADIR}" ]] ; then
1947 - einfo "Creating ${PN} data directory '${MY_DATADIR}' ..."
1948 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \
1949 - || die "Failed to create ${PN} data directory '${MY_DATADIR}'!"
1950 - fi
1951 -
1952 - local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")"
1953 - [[ -z "${_my_datadir_testfile}" ]] \
1954 - && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
1955 -
1956 - if use prefix ; then
1957 - touch "${_my_datadir_testfile}" &>/dev/null
1958 - else
1959 - su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null
1960 - fi
1961 -
1962 - if [[ $? -ne 0 ]] ; then
1963 - die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!"
1964 - else
1965 - rm "${_my_datadir_testfile}" || die
1966 - unset _my_datadir_testfile
1967 - fi
1968 -
1969 - if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then
1970 - einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..."
1971 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \
1972 - || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!"
1973 - fi
1974 -
1975 - if [[ -z "${MYSQL_TMPDIR}" ]] ; then
1976 - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")"
1977 - [[ -z "${MYSQL_TMPDIR}" ]] \
1978 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!"
1979 -
1980 - mkdir "${MYSQL_TMPDIR}" || die
1981 - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die
1982 - fi
1983 -
1984 - # Now we need to test MYSQL_TMPDIR...
1985 - local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")"
1986 - [[ -z "${_my_tmpdir_testfile}" ]] \
1987 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
1988 -
1989 - if use prefix ; then
1990 - touch "${_my_tmpdir_testfile}" &>/dev/null
1991 - else
1992 - su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null
1993 - fi
1994 -
1995 - if [[ $? -ne 0 ]] ; then
1996 - die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!"
1997 - else
1998 - rm "${_my_tmpdir_testfile}" || die
1999 - unset _my_tmpdir_testfile
2000 - fi
2001 -
2002 - if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then
2003 - einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..."
2004 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \
2005 - || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'"
2006 - fi
2007 -
2008 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
2009 - local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")"
2010 - [[ -z "${_my_logbin_testfile}" ]] \
2011 - && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!"
2012 -
2013 - if use prefix ; then
2014 - touch "${_my_logbin_testfile}" &>/dev/null
2015 - else
2016 - su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null
2017 - fi
2018 -
2019 - if [[ $? -ne 0 ]] ; then
2020 - die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!"
2021 - else
2022 - rm "${_my_logbin_testfile}" || die
2023 - unset _my_logbin_testfile
2024 - fi
2025 - fi
2026 -
2027 - if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then
2028 - einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..."
2029 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \
2030 - || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!"
2031 - fi
2032 -
2033 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
2034 - local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")"
2035 - [[ -z "${_my_relaylog_testfile}" ]] \
2036 - && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!"
2037 -
2038 - if use prefix ; then
2039 - touch "${_my_relaylog_testfile}" &>/dev/null
2040 - else
2041 - su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null
2042 - fi
2043 -
2044 - if [[ $? -ne 0 ]] ; then
2045 - die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!"
2046 - else
2047 - rm "${_my_relaylog_testfile}" || die
2048 - unset _my_relaylog_testfile
2049 - fi
2050 - fi
2051 -
2052 - local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")"
2053 - if [[ -z "${mysql_install_log}" ]] ; then
2054 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!"
2055 - else
2056 - # make sure file is writable for MYSQL_USER...
2057 - touch "${mysql_install_log}" || die
2058 - chown ${MYSQL_USER} "${mysql_install_log}" || die
2059 - fi
2060 -
2061 - local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")"
2062 - if [[ -z "${mysqld_logfile}" ]] ; then
2063 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!"
2064 - else
2065 - # make sure file is writable for MYSQL_USER...
2066 - touch "${mysqld_logfile}" || die
2067 - chown ${MYSQL_USER} "${mysqld_logfile}" || die
2068 - fi
2069 -
2070 - echo ""
2071 - einfo "Detected settings:"
2072 - einfo "=================="
2073 - einfo "MySQL User:\t\t\t\t${MYSQL_USER}"
2074 - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}"
2075 - einfo "MySQL DATA directory:\t\t${MY_DATADIR}"
2076 - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}"
2077 -
2078 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
2079 - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}"
2080 - fi
2081 -
2082 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
2083 - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}"
2084 - fi
2085 -
2086 - einfo "PID DIR:\t\t\t\t${PID_DIR}"
2087 - einfo "Install db log:\t\t\t${mysql_install_log}"
2088 - einfo "Install server log:\t\t\t${mysqld_logfile}"
2089 -
2090 - local -a config_files
2091 -
2092 - local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf"
2093 - if [[ -f "${config_file}" ]] ; then
2094 - config_files+=( "${config_file}" )
2095 - else
2096 - ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..."
2097 - fi
2098 -
2099 - config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf"
2100 - if [[ -f "${config_file}" ]] ; then
2101 - config_files+=( "${config_file}" )
2102 - else
2103 - ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..."
2104 - fi
2105 -
2106 - if [[ ${#config_files[@]} -gt 0 ]] ; then
2107 - if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then
2108 - local user_answer
2109 -
2110 - echo
2111 - einfo "Please select default authentication plugin (enter number or plugin name):"
2112 - einfo "1) caching_sha2_password [MySQL 8.0 default]"
2113 - einfo "2) mysql_native_password [MySQL 5.7 default]"
2114 - einfo
2115 - einfo "For details see:"
2116 - einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password"
2117 - read -p " >" user_answer
2118 - echo
2119 -
2120 - case "${user_answer}" in
2121 - 1|caching_sha2_password)
2122 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password
2123 - ;;
2124 - 2|mysql_native_password)
2125 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password
2126 - ;;
2127 - '')
2128 - die "No authentication plugin selected!"
2129 - ;;
2130 - *)
2131 - die "Authentication plugin '${user_answer}' is unknown/unsupported!"
2132 - ;;
2133 - esac
2134 -
2135 - echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}"
2136 -
2137 - unset user_answer
2138 - fi
2139 -
2140 - local cfg_option cfg_option_tabs cfg_section
2141 - for config_file in "${config_files[@]}" ; do
2142 - cfg_option="default-authentication-plugin"
2143 - cfg_section="mysqld"
2144 - cfg_option_tabs="\t\t"
2145 - if [[ "${config_file}" == *client.cnf ]] ; then
2146 - cfg_option="default-auth"
2147 - cfg_section="client"
2148 - cfg_option_tabs="\t\t\t\t"
2149 - fi
2150 -
2151 - if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then
2152 - einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
2153 - sed -i \
2154 - -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \
2155 - "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!"
2156 - else
2157 - einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
2158 - sed -i \
2159 - -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \
2160 - "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!"
2161 - fi
2162 - done
2163 - unset cfg_option cfg_option_tabs cfg_section
2164 - fi
2165 - unset config_files config_file
2166 -
2167 - echo
2168 -
2169 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
2170 - local tmp_mysqld_password_source=
2171 -
2172 - for tmp_mysqld_password_source in mysql client ; do
2173 - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
2174 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
2175 - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
2176 - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
2177 - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
2178 - MYSQL_ROOT_PASSWORD=
2179 - continue
2180 - fi
2181 -
2182 - einfo "Found password in '${tmp_mysqld_password_source}' section!"
2183 - break
2184 - fi
2185 - done
2186 -
2187 - # Sometimes --show is required to display passwords in some implementations of my_print_defaults
2188 - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
2189 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
2190 - fi
2191 -
2192 - unset tmp_mysqld_password_source
2193 - fi
2194 -
2195 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
2196 - local pwd1="a"
2197 - local pwd2="b"
2198 -
2199 - echo
2200 - einfo "No password for mysql 'root' user was specified via environment"
2201 - einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config"
2202 - einfo "file like '${HOME}/.my.cnf'."
2203 - einfo "To continue please provide a password for the mysql 'root' user"
2204 - einfo "now on console:"
2205 - ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!"
2206 - read -rsp " >" pwd1 ; echo
2207 -
2208 - einfo "Retype the password"
2209 - read -rsp " >" pwd2 ; echo
2210 -
2211 - if [[ "x$pwd1" != "x$pwd2" ]] ; then
2212 - die "Passwords are not the same!"
2213 - fi
2214 -
2215 - MYSQL_ROOT_PASSWORD="${pwd1}"
2216 - unset pwd1 pwd2
2217 -
2218 - echo
2219 - fi
2220 -
2221 - local -a mysqld_options
2222 -
2223 - # Fix bug 446200. Don't reference host my.cnf, needs to come first,
2224 - # see http://bugs.mysql.com/bug.php?id=31312
2225 - use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" )
2226 -
2227 - # Figure out which options we need to disable to do the setup
2228 - local helpfile="${TMPDIR}/mysqld-help"
2229 - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
2230 -
2231 - local opt optexp optfull
2232 - for opt in host-cache name-resolve networking slave-start \
2233 - federated ssl log-bin relay-log slow-query-log external-locking \
2234 - log-slave-updates \
2235 - ; do
2236 - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
2237 - egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" )
2238 - done
2239 -
2240 - # Prepare timezones, see
2241 - # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
2242 - local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")"
2243 - [[ -z "${tz_sql}" ]] \
2244 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!"
2245 -
2246 - echo "USE mysql;" >"${tz_sql}"
2247 - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null
2248 - if [[ $? -ne 0 ]] ; then
2249 - die "mysql_tzinfo_to_sql failed!"
2250 - fi
2251 -
2252 - # --initialize-insecure will not set root password
2253 - # --initialize would set a random one in the log which we don't need as we set it ourselves
2254 - local cmd=(
2255 - "${mysqld_binary}"
2256 - "${mysqld_options[@]}"
2257 - "--initialize-insecure"
2258 - "--init-file='${tz_sql}'"
2259 - "--basedir='${EROOT}/usr'"
2260 - "--datadir='${MY_DATADIR}'"
2261 - "--tmpdir='${MYSQL_TMPDIR}'"
2262 - "--log-error='${mysql_install_log}'"
2263 - "--user=${MYSQL_USER}"
2264 - )
2265 -
2266 - einfo "Initializing ${PN} data directory: ${cmd[@]}"
2267 - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1
2268 -
2269 - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then
2270 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2
2271 - die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!"
2272 - fi
2273 -
2274 - rm "${tz_sql}" || die
2275 -
2276 - local x=${RANDOM}
2277 - local socket="${EROOT}${PID_DIR}/mysqld${x}.sock"
2278 - local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid"
2279 - unset x
2280 -
2281 - cmd=(
2282 - "${mysqld_binary}"
2283 - "${mysqld_options[@]}"
2284 - "--basedir='${EROOT}/usr'"
2285 - "--datadir='${MY_DATADIR}'"
2286 - "--tmpdir='${MYSQL_TMPDIR}'"
2287 - --max_allowed_packet=8M
2288 - --net_buffer_length=16K
2289 - "--socket='${socket}'"
2290 - "--pid-file='${pidfile}'"
2291 - "--log-error='${mysqld_logfile}'"
2292 - "--user=${MYSQL_USER}"
2293 - )
2294 -
2295 - einfo "Starting mysqld to finalize initialization: ${cmd[@]}"
2296 - eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 &
2297 -
2298 - echo -n "Waiting for mysqld to accept connections "
2299 - local maxtry=15
2300 - while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
2301 - maxtry=$((${maxtry}-1))
2302 - echo -n "."
2303 - sleep 1
2304 - done
2305 -
2306 - if [[ -S "${socket}" ]] ; then
2307 - # Even with a socket we don't know if mysqld will abort
2308 - # start due to an error so just wait a little bit more...
2309 - maxtry=5
2310 - while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
2311 - maxtry=$((${maxtry}-1))
2312 - echo -n "."
2313 - sleep 1
2314 - done
2315 - fi
2316 -
2317 - echo
2318 -
2319 - if [[ ! -S "${socket}" ]] ; then
2320 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2
2321 - die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!"
2322 - fi
2323 -
2324 - local mysql_logfile="${TMPDIR}/set_root_pw.log"
2325 - touch "${mysql_logfile}" || die
2326 -
2327 - ebegin "Setting root password"
2328 - # Do this from memory, as we don't want clear text passwords in temp files
2329 - local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'"
2330 - cmd=(
2331 - "${mysql_binary}"
2332 - --no-defaults
2333 - "--socket='${socket}'"
2334 - -hlocalhost
2335 - "-e \"${sql}\""
2336 - )
2337 - eval "${cmd[@]}" >"${mysql_logfile}" 2>&1
2338 - local rc=$?
2339 - eend ${rc}
2340 -
2341 - if [[ ${rc} -ne 0 ]] ; then
2342 - # Poor man's solution which tries to avoid having password
2343 - # in log. NOTE: sed can fail if user didn't follow advice
2344 - # and included character which will require escaping...
2345 - sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null
2346 -
2347 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}"
2348 - die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!"
2349 - fi
2350 -
2351 - # Stop the server
2352 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
2353 - echo -n "Stopping the server "
2354 - pkill -F "${pidfile}" &>/dev/null
2355 -
2356 - maxtry=10
2357 - while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do
2358 - maxtry=$((${maxtry}-1))
2359 - echo -n "."
2360 - sleep 1
2361 - done
2362 -
2363 - echo
2364 -
2365 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
2366 - # We somehow failed to stop server.
2367 - # However, not a fatal error. Just warn the user.
2368 - ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!"
2369 - fi
2370 - fi
2371 -
2372 - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!"
2373 -}
2374
2375 diff --git a/dev-db/mysql/mysql-8.0.25-r1.ebuild b/dev-db/mysql/mysql-8.0.25-r1.ebuild
2376 deleted file mode 100644
2377 index 9a4e4b01dc9a..000000000000
2378 --- a/dev-db/mysql/mysql-8.0.25-r1.ebuild
2379 +++ /dev/null
2380 @@ -1,1193 +0,0 @@
2381 -# Copyright 1999-2021 Gentoo Authors
2382 -# Distributed under the terms of the GNU General Public License v2
2383 -
2384 -EAPI="7"
2385 -
2386 -CMAKE_MAKEFILE_GENERATOR=emake
2387 -
2388 -inherit check-reqs cmake flag-o-matic linux-info \
2389 - multiprocessing prefix toolchain-funcs
2390 -
2391 -MY_PV="${PV//_pre*}"
2392 -MY_P="${PN}-${MY_PV}"
2393 -
2394 -# Patch version
2395 -PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-8.0.25-patches-02.tar.xz"
2396 -
2397 -SRC_URI="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${MY_PV}.tar.gz
2398 - https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${MY_PV}.tar.gz
2399 - http://downloads.mysql.com/archives/MySQL-8.0/${PN}-boost-${MY_PV}.tar.gz
2400 - ${PATCH_SET}"
2401 -
2402 -HOMEPAGE="https://www.mysql.com/"
2403 -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
2404 -LICENSE="GPL-2"
2405 -SLOT="8.0"
2406 -IUSE="cjk cracklib debug jemalloc latin1 numa +perl profiling
2407 - router selinux +server tcmalloc test"
2408 -
2409 -RESTRICT="!test? ( test )"
2410 -
2411 -REQUIRED_USE="?? ( tcmalloc jemalloc )
2412 - cjk? ( server )
2413 - jemalloc? ( server )
2414 - numa? ( server )
2415 - profiling? ( server )
2416 - router? ( server )
2417 - tcmalloc? ( server )"
2418 -
2419 -# -ppc, -riscv for bug #761715
2420 -KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips -ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris"
2421 -
2422 -# Shorten the path because the socket path length must be shorter than 107 chars
2423 -# and we will run a mysql server during test phase
2424 -S="${WORKDIR}/mysql"
2425 -
2426 -# Be warned, *DEPEND are version-dependant
2427 -# These are used for both runtime and compiletime
2428 -COMMON_DEPEND="
2429 - >=app-arch/lz4-0_p131:=
2430 - app-arch/zstd:=
2431 - sys-libs/ncurses:0=
2432 - >=sys-libs/zlib-1.2.3:0=
2433 - >=dev-libs/openssl-1.0.0:0=
2434 - server? (
2435 - dev-libs/icu:=
2436 - dev-libs/libevent:=[ssl,threads]
2437 - >=dev-libs/protobuf-3.8:=
2438 - net-libs/libtirpc:=
2439 - cjk? ( app-text/mecab:= )
2440 - jemalloc? ( dev-libs/jemalloc:0= )
2441 - kernel_linux? (
2442 - dev-libs/libaio:0=
2443 - sys-process/procps:0=
2444 - )
2445 - numa? ( sys-process/numactl )
2446 - tcmalloc? ( dev-util/google-perftools:0= )
2447 - )
2448 -"
2449 -
2450 -DEPEND="
2451 - ${COMMON_DEPEND}
2452 - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
2453 - virtual/yacc
2454 - server? ( net-libs/rpcsvc-proto )
2455 - test? (
2456 - acct-group/mysql acct-user/mysql
2457 - dev-perl/JSON
2458 - )
2459 -"
2460 -
2461 -RDEPEND="
2462 - ${COMMON_DEPEND}
2463 - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
2464 - !dev-db/mysql:0
2465 - !dev-db/mysql:5.7
2466 - selinux? ( sec-policy/selinux-mysql )
2467 - !prefix? (
2468 - acct-group/mysql acct-user/mysql
2469 - dev-db/mysql-init-scripts
2470 - )
2471 -"
2472 -
2473 -# For other stuff to bring us in
2474 -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
2475 -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
2476 -
2477 -mysql_init_vars() {
2478 - : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
2479 - : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
2480 - : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
2481 - : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
2482 - MY_DATADIR="${MY_LOCALSTATEDIR}"
2483 -
2484 - export MY_SHAREDSTATEDIR MY_SYSCONFDIR
2485 - export MY_LOCALSTATEDIR MY_LOGDIR
2486 - export MY_DATADIR
2487 -}
2488 -
2489 -pkg_pretend() {
2490 - if [[ ${MERGE_TYPE} != binary ]] ; then
2491 - if use server ; then
2492 - CHECKREQS_DISK_BUILD="2G"
2493 -
2494 - if has test $FEATURES ; then
2495 - CHECKREQS_DISK_BUILD="9G"
2496 - fi
2497 -
2498 - check-reqs_pkg_pretend
2499 - fi
2500 - fi
2501 -}
2502 -
2503 -pkg_setup() {
2504 - if [[ ${MERGE_TYPE} != binary ]] ; then
2505 - CHECKREQS_DISK_BUILD="2G"
2506 -
2507 - if has test ${FEATURES} ; then
2508 - CHECKREQS_DISK_BUILD="9G"
2509 -
2510 - # Bug #213475 - MySQL _will_ object strenuously if your machine is named
2511 - # localhost. Also causes weird failures.
2512 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
2513 -
2514 - if ! has userpriv ${FEATURES} ; then
2515 - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
2516 - fi
2517 -
2518 - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null)
2519 - [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \
2520 - && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!"
2521 -
2522 - if use latin1 ; then
2523 - # Upstream only supports tests with default charset
2524 - die "Testing with USE=latin1 is not supported."
2525 - fi
2526 - fi
2527 -
2528 - if use kernel_linux ; then
2529 - if use numa ; then
2530 - linux-info_get_any_version
2531 -
2532 - local CONFIG_CHECK="~NUMA"
2533 -
2534 - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
2535 - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
2536 -
2537 - check_extra_config
2538 - fi
2539 - fi
2540 -
2541 - use server && check-reqs_pkg_setup
2542 - fi
2543 -}
2544 -
2545 -src_unpack() {
2546 - unpack ${A}
2547 -
2548 - mv -f "${WORKDIR}/${MY_P}" "${S}" || die
2549 -}
2550 -
2551 -src_prepare() {
2552 - eapply "${WORKDIR}"/mysql-patches
2553 -
2554 - # Avoid rpm call which would trigger sandbox, #692368
2555 - sed -i \
2556 - -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \
2557 - CMakeLists.txt || die
2558 -
2559 - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
2560 - if [[ -d "${S}/support-files/SELinux" ]] ; then
2561 - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
2562 - fi
2563 -
2564 - # Remove man pages for client-lib tools we don't install
2565 - rm \
2566 - man/my_print_defaults.1 \
2567 - man/perror.1 \
2568 - man/zlib_decompress.1 \
2569 - || die
2570 -
2571 - cmake_src_prepare
2572 -}
2573 -
2574 -src_configure() {
2575 - # Bug #114895, bug #110149
2576 - filter-flags "-O" "-O[01]"
2577 -
2578 - append-cxxflags -felide-constructors
2579 -
2580 - # code is not C++17 ready, bug #786402
2581 - append-cxxflags -std=c++14
2582 -
2583 - # bug #283926, with GCC4.4, this is required to get correct behavior.
2584 - append-flags -fno-strict-aliasing
2585 -
2586 - CMAKE_BUILD_TYPE="RelWithDebInfo"
2587 -
2588 - # debug hack wrt #497532
2589 - mycmakeargs=(
2590 - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
2591 - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
2592 - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
2593 - -DSYSCONFDIR="${EPREFIX}/etc/mysql"
2594 - -DINSTALL_BINDIR=bin
2595 - -DINSTALL_DOCDIR=share/doc/${PF}
2596 - -DINSTALL_DOCREADMEDIR=share/doc/${PF}
2597 - -DINSTALL_INCLUDEDIR=include/mysql
2598 - -DINSTALL_INFODIR=share/info
2599 - -DINSTALL_LIBDIR=$(get_libdir)
2600 - -DINSTALL_MANDIR=share/man
2601 - -DINSTALL_MYSQLSHAREDIR=share/mysql
2602 - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
2603 - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
2604 - -DINSTALL_SBINDIR=sbin
2605 - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
2606 - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
2607 - -DWITH_UNIT_TESTS=$(usex test ON OFF)
2608 - # Using bundled editline to get CTRL+C working
2609 - -DWITH_EDITLINE=bundled
2610 - -DWITH_ZLIB=system
2611 - -DWITH_SSL=system
2612 - -DWITH_LIBWRAP=0
2613 - -DENABLED_LOCAL_INFILE=1
2614 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
2615 - -DWITH_DEFAULT_COMPILER_OPTIONS=0
2616 - # The build forces this to be defined when cross-compiling. We pass it
2617 - # all the time for simplicity and to make sure it is actually correct.
2618 - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
2619 - -DCMAKE_POSITION_INDEPENDENT_CODE=ON
2620 - -DWITH_CURL=system
2621 - -DWITH_BOOST="${S}/boost"
2622 - -DWITH_ROUTER=$(usex router ON OFF)
2623 - )
2624 -
2625 - if is-flagq -fno-lto ; then
2626 - einfo "LTO disabled via {C,CXX,F,FC}FLAGS"
2627 - mycmakeargs+=( -DWITH_LTO=OFF )
2628 - elif is-flagq -flto ; then
2629 - einfo "LTO forced via {C,CXX,F,FC}FLAGS"
2630 - myconf+=( -DWITH_LTO=ON )
2631 - else
2632 - # Disable automagic
2633 - myconf+=( -DWITH_LTO=OFF )
2634 - fi
2635 -
2636 - if use test ; then
2637 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
2638 - else
2639 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
2640 - fi
2641 -
2642 - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
2643 -
2644 - mycmakeargs+=(
2645 - -DWITH_ICU=system
2646 - -DWITH_LZ4=system
2647 - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex
2648 - -DWITH_RAPIDJSON=bundled
2649 - -DWITH_ZSTD=system
2650 - )
2651 -
2652 - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then
2653 - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
2654 - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
2655 - ewarn "You MUST file bugs without these variables set."
2656 - ewarn "Tests will probably fail!"
2657 -
2658 - mycmakeargs+=(
2659 - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
2660 - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
2661 - )
2662 - elif use latin1 ; then
2663 - mycmakeargs+=(
2664 - -DDEFAULT_CHARSET=latin1
2665 - -DDEFAULT_COLLATION=latin1_swedish_ci
2666 - )
2667 - else
2668 - mycmakeargs+=(
2669 - -DDEFAULT_CHARSET=utf8mb4
2670 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
2671 - )
2672 - fi
2673 -
2674 - if use server ; then
2675 - mycmakeargs+=(
2676 - -DWITH_EXTRA_CHARSETS=all
2677 - -DWITH_DEBUG=$(usex debug)
2678 - -DWITH_MECAB=$(usex cjk system OFF)
2679 - -DWITH_LIBEVENT=system
2680 - -DWITH_PROTOBUF=system
2681 - -DWITH_NUMA=$(usex numa ON OFF)
2682 - )
2683 -
2684 - if use jemalloc ; then
2685 - mycmakeargs+=( -DWITH_JEMALLOC=ON )
2686 - elif use tcmalloc ; then
2687 - mycmakeargs+=( -DWITH_TCMALLOC=ON )
2688 - fi
2689 -
2690 - if use profiling ; then
2691 - # Setting to OFF doesn't work: Once set, profiling options will be added
2692 - # to `mysqld --help` output via sql/sys_vars.cc causing
2693 - # "main.mysqld--help-notwin" test to fail
2694 - mycmakeargs+=( -DENABLED_PROFILING=ON )
2695 - fi
2696 -
2697 - # Storage engines
2698 - mycmakeargs+=(
2699 - -DWITH_EXAMPLE_STORAGE_ENGINE=0
2700 - -DWITH_ARCHIVE_STORAGE_ENGINE=1
2701 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1
2702 - -DWITH_CSV_STORAGE_ENGINE=1
2703 - -DWITH_FEDERATED_STORAGE_ENGINE=1
2704 - -DWITH_HEAP_STORAGE_ENGINE=1
2705 - -DWITH_INNOBASE_STORAGE_ENGINE=1
2706 - -DWITH_INNODB_MEMCACHED=0
2707 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1
2708 - -DWITH_MYISAM_STORAGE_ENGINE=1
2709 - )
2710 - else
2711 - mycmakeargs+=(
2712 - -DWITHOUT_SERVER=1
2713 - -DWITH_SYSTEMD=no
2714 - )
2715 - fi
2716 -
2717 - cmake_src_configure
2718 -}
2719 -
2720 -# Official test instructions:
2721 -# ulimit -n 16500 && \
2722 -# USE='perl server' \
2723 -# FEATURES='test userpriv' \
2724 -# ebuild mysql-X.X.XX.ebuild \
2725 -# digest clean package
2726 -src_test() {
2727 - _disable_test() {
2728 - local rawtestname bug reason
2729 - rawtestname="${1}" ; shift
2730 - bug="${1}" ; shift
2731 - reason="${@}"
2732 - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
2733 - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def"
2734 - }
2735 -
2736 - local TESTDIR="${BUILD_DIR}/mysql-test"
2737 - local retstatus_unit
2738 - local retstatus_tests
2739 -
2740 - # Run CTest (test-units)
2741 - cmake_src_test
2742 - retstatus_unit=$?
2743 -
2744 - # Ensure that parallel runs don't die
2745 - export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
2746 -
2747 - if [[ -z "${MTR_PARALLEL}" ]] ; then
2748 - local -x MTR_PARALLEL=$(makeopts_jobs)
2749 -
2750 - if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
2751 - # Running multiple tests in parallel usually require higher ulimit
2752 - # and fs.aio-max-nr setting. In addition, tests like main.multi_update
2753 - # are known to hit timeout when system is busy.
2754 - # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
2755 - # using "auto".
2756 - local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
2757 - info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
2758 - einfo "${info_msg}"
2759 - unset info_msg
2760 - MTR_PARALLEL=4
2761 - fi
2762 - else
2763 - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
2764 - fi
2765 -
2766 - # >=dev-libs/openssl-3 defaults to security level 1 which disallow
2767 - # TLSv1/1.1 but tests will require TLSv1/1.1.
2768 - einfo "Set OpenSSL configuration for test suite ..."
2769 - cat > "${T}/openssl_tlsv1.cnf" <<- EOF || die
2770 - openssl_conf = default_conf
2771 -
2772 - [default_conf]
2773 - ssl_conf = ssl_sect
2774 -
2775 - [ssl_sect]
2776 - system_default = system_default_sect
2777 -
2778 - [system_default_sect]
2779 - CipherString = DEFAULT@SECLEVEL=0
2780 - EOF
2781 -
2782 - local -x OPENSSL_CONF="${T}/openssl_tlsv1.cnf"
2783 -
2784 - # create directories because mysqladmin might run out of order
2785 - mkdir -p "${T}"/var-tests{,/log} || die
2786 -
2787 - # Run mysql tests
2788 - pushd "${TESTDIR}" &>/dev/null || die
2789 -
2790 - touch "${T}/disabled.def"
2791 -
2792 - local -a disabled_tests
2793 - disabled_tests+=( "auth_sec.atomic_rename_user;103512;Depends on user running test" )
2794 - disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" )
2795 - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" )
2796 - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" )
2797 - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" )
2798 - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" )
2799 - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" )
2800 - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" )
2801 - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" )
2802 - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" )
2803 - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" )
2804 - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" )
2805 - disabled_tests+=( "main.explain_tree;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
2806 - disabled_tests+=( "main.derived_limit;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
2807 - disabled_tests+=( "main.mysql_load_data_local_dir;0;Known test failure - no upstream bug yet" )
2808 - disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
2809 - disabled_tests+=( "main.subquery_sj_mat_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
2810 - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
2811 - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
2812 - disabled_tests+=( "main.with_recursive;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
2813 - disabled_tests+=( "perfschema.statement_digest_query_sample;0;Test will fail on slow hardware")
2814 - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" )
2815 - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Known failure - no upstream bug yet" )
2816 - disabled_tests+=( "rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch;0;Unstable test" )
2817 - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware")
2818 - disabled_tests+=( "x.connection;0;Known failure - no upstream bug yet" )
2819 - disabled_tests+=( "main.mysqlpump_basic_lz4;0;Extra tool output causes false positive" )
2820 - disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" )
2821 - disabled_tests+=( "x.message_protobuf_nested;0;False positive caused by protobuff-3.11+" )
2822 -
2823 - if ! hash zip 1>/dev/null 2>&1 ; then
2824 - # no need to force dep app-arch/zip for one test
2825 - disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" )
2826 - disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" )
2827 - fi
2828 -
2829 - if has_version ">=dev-libs/openssl-3" ; then
2830 - # no need to force dep app-arch/zip for one test
2831 - disabled_tests+=( "x.connection_tls_version;0;Not compatible with OpenSSL 3.x error messages" )
2832 - fi
2833 -
2834 - local test_infos_str test_infos_arr
2835 - for test_infos_str in "${disabled_tests[@]}" ; do
2836 - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
2837 -
2838 - if [[ ${#test_infos_arr[@]} != 3 ]] ; then
2839 - die "Invalid test data set, not matching format: ${test_infos_str}"
2840 - fi
2841 -
2842 - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
2843 - done
2844 - unset test_infos_str test_infos_arr
2845 -
2846 - # Try to increase file limits to increase test coverage
2847 - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
2848 - # Upper limit comes from parts.partition_* tests
2849 - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
2850 -
2851 - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
2852 - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
2853 - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
2854 -
2855 - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
2856 - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
2857 - else
2858 - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
2859 - fi
2860 - else
2861 - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
2862 - fi
2863 - else
2864 - einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
2865 - fi
2866 -
2867 - # run mysql-test tests
2868 - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
2869 - retstatus_tests=$?
2870 -
2871 - popd &>/dev/null || die
2872 -
2873 - # Cleanup is important for these testcases.
2874 - pkill -9 -f "${S}/ndb" 2>/dev/null
2875 - pkill -9 -f "${S}/sql" 2>/dev/null
2876 -
2877 - local failures=""
2878 - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
2879 - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
2880 -
2881 - [[ -z "$failures" ]] || die "Test failures: $failures"
2882 - einfo "Tests successfully completed"
2883 -}
2884 -
2885 -src_install() {
2886 - cmake_src_install
2887 -
2888 - # Make sure the vars are correctly initialized
2889 - mysql_init_vars
2890 -
2891 - # Convenience links
2892 - einfo "Making Convenience links for mysqlcheck multi-call binary"
2893 - dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
2894 - dosym "mysqlcheck" "/usr/bin/mysqlrepair"
2895 - dosym "mysqlcheck" "/usr/bin/mysqloptimize"
2896 -
2897 - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
2898 - if [[ -d "${ED}/usr/data" ]] ; then
2899 - rm -Rf "${ED}/usr/data" || die
2900 - fi
2901 -
2902 - # Unless they explicitly specific USE=test, then do not install the
2903 - # testsuite. It DOES have a use to be installed, esp. when you want to do a
2904 - # validation of your database configuration after tuning it.
2905 - if ! use test ; then
2906 - rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test"
2907 - fi
2908 -
2909 - # Configuration stuff
2910 - einfo "Building default configuration ..."
2911 - insinto "${MY_SYSCONFDIR#${EPREFIX}}"
2912 - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
2913 - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
2914 - eprefixify "${TMPDIR}/my.cnf"
2915 - doins "${TMPDIR}/my.cnf"
2916 - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
2917 - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
2918 - eprefixify "${TMPDIR}/50-distro-client.cnf"
2919 - doins "${TMPDIR}/50-distro-client.cnf"
2920 -
2921 - mycnf_src="my.cnf-8.0.distro-server"
2922 - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
2923 - "${FILESDIR}/${mycnf_src}" \
2924 - > "${TMPDIR}/my.cnf.ok" || die
2925 -
2926 - if use prefix ; then
2927 - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
2928 - "${TMPDIR}/my.cnf.ok" || die
2929 - fi
2930 -
2931 - if use latin1 ; then
2932 - sed -i \
2933 - -e "/character-set/s|utf8mb4|latin1|g" \
2934 - "${TMPDIR}/my.cnf.ok" || die
2935 - fi
2936 -
2937 - eprefixify "${TMPDIR}/my.cnf.ok"
2938 -
2939 - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
2940 -
2941 - #Remove mytop if perl is not selected
2942 - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
2943 -
2944 - if use router ; then
2945 - rm -rf \
2946 - "${ED}/usr/LICENSE.router" \
2947 - "${ED}/usr/README.router" \
2948 - "${ED}/usr/run" \
2949 - "${ED}/usr/var" \
2950 - || die
2951 - fi
2952 -
2953 - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
2954 - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
2955 -}
2956 -
2957 -pkg_postinst() {
2958 - # Make sure the vars are correctly initialized
2959 - mysql_init_vars
2960 -
2961 - # Create log directory securely if it does not exist
2962 - # NOTE: $MY_LOGDIR contains $EPREFIX by default
2963 - [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}"
2964 -
2965 - # Note about configuration change
2966 - einfo
2967 - elog "This version of ${PN} reorganizes the configuration from a single my.cnf"
2968 - elog "to several files in /etc/mysql/mysql.d."
2969 - elog "Please backup any changes you made to /etc/mysql/my.cnf"
2970 - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension."
2971 - elog "You may have as many files as needed and they are read alphabetically."
2972 - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
2973 - einfo
2974 -
2975 - if [[ -z "${REPLACING_VERSIONS}" ]] ; then
2976 - einfo
2977 - elog "You might want to run:"
2978 - elog " \"emerge --config =${CATEGORY}/${PF}\""
2979 - elog "if this is a new install."
2980 - einfo
2981 - else
2982 - einfo
2983 - elog "Upgrade process for ${PN}-8.x has changed. Please read"
2984 - elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html"
2985 - einfo
2986 - fi
2987 -}
2988 -
2989 -pkg_config() {
2990 - _getoptval() {
2991 - local section="$1"
2992 - local flag="--${2}="
2993 - local extra_options="${3}"
2994 - local cmd=(
2995 - "${my_print_defaults_binary}"
2996 - "${extra_options}"
2997 - "${section}"
2998 - )
2999 - local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") )
3000 -
3001 - if [[ ${#results[@]} -gt 0 ]] ; then
3002 - # When option is set multiple times only return last value
3003 - echo "${results[-1]}"
3004 - fi
3005 - }
3006 -
3007 - _mktemp_dry() {
3008 - # emktemp has no --dry-run option
3009 - local template="${1}"
3010 -
3011 - if [[ -z "${template}" ]] ; then
3012 - if [[ -z "${T}" ]] ; then
3013 - template="/tmp/XXXXXXX"
3014 - else
3015 - template="${T}/XXXXXXX"
3016 - fi
3017 - fi
3018 -
3019 - local template_wo_X=${template//X/}
3020 - local n_X
3021 - let n_X=${#template}-${#template_wo_X}
3022 - if [[ ${n_X} -lt 3 ]] ; then
3023 - echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2
3024 - return
3025 - fi
3026 -
3027 - local attempts=0
3028 - local character tmpfile
3029 - while [[ true ]] ; do
3030 - let attempts=attempts+1
3031 -
3032 - new_file=
3033 - while read -n1 character ; do
3034 - if [[ "${character}" == "X" ]] ; then
3035 - tmpfile+="${RANDOM:0:1}"
3036 - else
3037 - tmpfile+="${character}"
3038 - fi
3039 - done < <(echo -n "${template}")
3040 -
3041 - if [[ ! -f "${tmpfile}" ]]
3042 - then
3043 - echo "${tmpfile}"
3044 - return
3045 - fi
3046 -
3047 - if [[ ${attempts} -ge 100 ]] ; then
3048 - echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2
3049 - return
3050 - fi
3051 - done
3052 - }
3053 -
3054 - local mysqld_binary="${EROOT}/usr/sbin/mysqld"
3055 - if [[ ! -x "${mysqld_binary}" ]] ; then
3056 - die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
3057 - fi
3058 -
3059 - local mysql_binary="${EROOT}/usr/bin/mysql"
3060 - if [[ ! -x "${mysql_binary}" ]] ; then
3061 - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
3062 - fi
3063 -
3064 - local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults"
3065 - if [[ ! -x "${my_print_defaults_binary}" ]] ; then
3066 - die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!"
3067 - fi
3068 -
3069 - if [[ -z "${MYSQL_USER}" ]] ; then
3070 - MYSQL_USER=mysql
3071 - if use prefix ; then
3072 - MYSQL_USER=$(id -u -n 2>/dev/null)
3073 - if [[ -z "${MYSQL_USER}" ]] ; then
3074 - die "Failed to determine current username!"
3075 - fi
3076 - fi
3077 - fi
3078 -
3079 - if [[ -z "${MYSQL_GROUP}" ]] ; then
3080 - MYSQL_GROUP=mysql
3081 - if use prefix ; then
3082 - MYSQL_GROUP=$(id -g -n 2>/dev/null)
3083 - if [[ -z "${MYSQL_GROUP}" ]] ; then
3084 - die "Failed to determine current user groupname!"
3085 - fi
3086 - fi
3087 - fi
3088 -
3089 - # my_print_defaults needs to read stuff in $HOME/.my.cnf
3090 - local -x HOME="${EROOT}/root"
3091 -
3092 - # Make sure the vars are correctly initialized
3093 - mysql_init_vars
3094 -
3095 - # Read currently set data directory
3096 - MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
3097 -
3098 - # Bug #213475 - MySQL _will_ object strenously if your machine is named
3099 - # localhost. Also causes weird failures.
3100 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
3101 -
3102 - if [[ -z "${MY_DATADIR}" ]] ; then
3103 - die "Sorry, unable to find MY_DATADIR!"
3104 - elif [[ -d "${MY_DATADIR}/mysql" ]] ; then
3105 - ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!"
3106 - ewarn "Please rename or delete its content if you wish to initialize a new data directory."
3107 - die "${PN} data directory at '${MY_DATADIR}' looks already initialized!"
3108 - fi
3109 -
3110 - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
3111 - MYSQL_TMPDIR=${MYSQL_TMPDIR%/}
3112 - # These are dir+prefix
3113 - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
3114 - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
3115 - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
3116 - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
3117 -
3118 - # Create missing directories.
3119 - # Always check if mysql user can write to directory even if we just
3120 - # created directory because a parent directory might be not
3121 - # accessible for that user.
3122 - PID_DIR="${EROOT}/run/mysqld"
3123 - if [[ ! -d "${PID_DIR}" ]] ; then
3124 - einfo "Creating ${PN} PID directory '${PID_DIR}' ..."
3125 - install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \
3126 - || die "Failed to create PID directory '${PID_DIR}'!"
3127 - fi
3128 -
3129 - local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")"
3130 - [[ -z "${_pid_dir_testfile}" ]] \
3131 - && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
3132 -
3133 - if use prefix ; then
3134 - touch "${_pid_dir_testfile}" &>/dev/null
3135 - else
3136 - su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null
3137 - fi
3138 -
3139 - if [[ $? -ne 0 ]] ; then
3140 - die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!"
3141 - else
3142 - rm "${_pid_dir_testfile}" || die
3143 - unset _pid_dir_testfile
3144 - fi
3145 -
3146 - if [[ ! -d "${MY_DATADIR}" ]] ; then
3147 - einfo "Creating ${PN} data directory '${MY_DATADIR}' ..."
3148 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \
3149 - || die "Failed to create ${PN} data directory '${MY_DATADIR}'!"
3150 - fi
3151 -
3152 - local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")"
3153 - [[ -z "${_my_datadir_testfile}" ]] \
3154 - && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
3155 -
3156 - if use prefix ; then
3157 - touch "${_my_datadir_testfile}" &>/dev/null
3158 - else
3159 - su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null
3160 - fi
3161 -
3162 - if [[ $? -ne 0 ]] ; then
3163 - die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!"
3164 - else
3165 - rm "${_my_datadir_testfile}" || die
3166 - unset _my_datadir_testfile
3167 - fi
3168 -
3169 - if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then
3170 - einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..."
3171 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \
3172 - || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!"
3173 - fi
3174 -
3175 - if [[ -z "${MYSQL_TMPDIR}" ]] ; then
3176 - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")"
3177 - [[ -z "${MYSQL_TMPDIR}" ]] \
3178 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!"
3179 -
3180 - mkdir "${MYSQL_TMPDIR}" || die
3181 - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die
3182 - fi
3183 -
3184 - # Now we need to test MYSQL_TMPDIR...
3185 - local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")"
3186 - [[ -z "${_my_tmpdir_testfile}" ]] \
3187 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
3188 -
3189 - if use prefix ; then
3190 - touch "${_my_tmpdir_testfile}" &>/dev/null
3191 - else
3192 - su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null
3193 - fi
3194 -
3195 - if [[ $? -ne 0 ]] ; then
3196 - die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!"
3197 - else
3198 - rm "${_my_tmpdir_testfile}" || die
3199 - unset _my_tmpdir_testfile
3200 - fi
3201 -
3202 - if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then
3203 - einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..."
3204 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \
3205 - || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'"
3206 - fi
3207 -
3208 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
3209 - local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")"
3210 - [[ -z "${_my_logbin_testfile}" ]] \
3211 - && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!"
3212 -
3213 - if use prefix ; then
3214 - touch "${_my_logbin_testfile}" &>/dev/null
3215 - else
3216 - su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null
3217 - fi
3218 -
3219 - if [[ $? -ne 0 ]] ; then
3220 - die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!"
3221 - else
3222 - rm "${_my_logbin_testfile}" || die
3223 - unset _my_logbin_testfile
3224 - fi
3225 - fi
3226 -
3227 - if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then
3228 - einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..."
3229 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \
3230 - || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!"
3231 - fi
3232 -
3233 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
3234 - local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")"
3235 - [[ -z "${_my_relaylog_testfile}" ]] \
3236 - && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!"
3237 -
3238 - if use prefix ; then
3239 - touch "${_my_relaylog_testfile}" &>/dev/null
3240 - else
3241 - su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null
3242 - fi
3243 -
3244 - if [[ $? -ne 0 ]] ; then
3245 - die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!"
3246 - else
3247 - rm "${_my_relaylog_testfile}" || die
3248 - unset _my_relaylog_testfile
3249 - fi
3250 - fi
3251 -
3252 - local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")"
3253 - if [[ -z "${mysql_install_log}" ]] ; then
3254 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!"
3255 - else
3256 - # make sure file is writable for MYSQL_USER...
3257 - touch "${mysql_install_log}" || die
3258 - chown ${MYSQL_USER} "${mysql_install_log}" || die
3259 - fi
3260 -
3261 - local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")"
3262 - if [[ -z "${mysqld_logfile}" ]] ; then
3263 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!"
3264 - else
3265 - # make sure file is writable for MYSQL_USER...
3266 - touch "${mysqld_logfile}" || die
3267 - chown ${MYSQL_USER} "${mysqld_logfile}" || die
3268 - fi
3269 -
3270 - echo ""
3271 - einfo "Detected settings:"
3272 - einfo "=================="
3273 - einfo "MySQL User:\t\t\t\t${MYSQL_USER}"
3274 - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}"
3275 - einfo "MySQL DATA directory:\t\t${MY_DATADIR}"
3276 - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}"
3277 -
3278 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
3279 - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}"
3280 - fi
3281 -
3282 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
3283 - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}"
3284 - fi
3285 -
3286 - einfo "PID DIR:\t\t\t\t${PID_DIR}"
3287 - einfo "Install db log:\t\t\t${mysql_install_log}"
3288 - einfo "Install server log:\t\t\t${mysqld_logfile}"
3289 -
3290 - local -a config_files
3291 -
3292 - local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf"
3293 - if [[ -f "${config_file}" ]] ; then
3294 - config_files+=( "${config_file}" )
3295 - else
3296 - ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..."
3297 - fi
3298 -
3299 - config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf"
3300 - if [[ -f "${config_file}" ]] ; then
3301 - config_files+=( "${config_file}" )
3302 - else
3303 - ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..."
3304 - fi
3305 -
3306 - if [[ ${#config_files[@]} -gt 0 ]] ; then
3307 - if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then
3308 - local user_answer
3309 -
3310 - echo
3311 - einfo "Please select default authentication plugin (enter number or plugin name):"
3312 - einfo "1) caching_sha2_password [MySQL 8.0 default]"
3313 - einfo "2) mysql_native_password [MySQL 5.7 default]"
3314 - einfo
3315 - einfo "For details see:"
3316 - einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password"
3317 - read -p " >" user_answer
3318 - echo
3319 -
3320 - case "${user_answer}" in
3321 - 1|caching_sha2_password)
3322 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password
3323 - ;;
3324 - 2|mysql_native_password)
3325 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password
3326 - ;;
3327 - '')
3328 - die "No authentication plugin selected!"
3329 - ;;
3330 - *)
3331 - die "Authentication plugin '${user_answer}' is unknown/unsupported!"
3332 - ;;
3333 - esac
3334 -
3335 - echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}"
3336 -
3337 - unset user_answer
3338 - fi
3339 -
3340 - local cfg_option cfg_option_tabs cfg_section
3341 - for config_file in "${config_files[@]}" ; do
3342 - cfg_option="default-authentication-plugin"
3343 - cfg_section="mysqld"
3344 - cfg_option_tabs="\t\t"
3345 - if [[ "${config_file}" == *client.cnf ]] ; then
3346 - cfg_option="default-auth"
3347 - cfg_section="client"
3348 - cfg_option_tabs="\t\t\t\t"
3349 - fi
3350 -
3351 - if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then
3352 - einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
3353 - sed -i \
3354 - -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \
3355 - "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!"
3356 - else
3357 - einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
3358 - sed -i \
3359 - -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \
3360 - "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!"
3361 - fi
3362 - done
3363 - unset cfg_option cfg_option_tabs cfg_section
3364 - fi
3365 - unset config_files config_file
3366 -
3367 - echo
3368 -
3369 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
3370 - local tmp_mysqld_password_source=
3371 -
3372 - for tmp_mysqld_password_source in mysql client ; do
3373 - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
3374 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
3375 - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
3376 - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
3377 - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
3378 - MYSQL_ROOT_PASSWORD=
3379 - continue
3380 - fi
3381 -
3382 - einfo "Found password in '${tmp_mysqld_password_source}' section!"
3383 - break
3384 - fi
3385 - done
3386 -
3387 - # Sometimes --show is required to display passwords in some implementations of my_print_defaults
3388 - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
3389 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
3390 - fi
3391 -
3392 - unset tmp_mysqld_password_source
3393 - fi
3394 -
3395 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
3396 - local pwd1="a"
3397 - local pwd2="b"
3398 -
3399 - echo
3400 - einfo "No password for mysql 'root' user was specified via environment"
3401 - einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config"
3402 - einfo "file like '${HOME}/.my.cnf'."
3403 - einfo "To continue please provide a password for the mysql 'root' user"
3404 - einfo "now on console:"
3405 - ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!"
3406 - read -rsp " >" pwd1 ; echo
3407 -
3408 - einfo "Retype the password"
3409 - read -rsp " >" pwd2 ; echo
3410 -
3411 - if [[ "x$pwd1" != "x$pwd2" ]] ; then
3412 - die "Passwords are not the same!"
3413 - fi
3414 -
3415 - MYSQL_ROOT_PASSWORD="${pwd1}"
3416 - unset pwd1 pwd2
3417 -
3418 - echo
3419 - fi
3420 -
3421 - local -a mysqld_options
3422 -
3423 - # Fix bug 446200. Don't reference host my.cnf, needs to come first,
3424 - # see http://bugs.mysql.com/bug.php?id=31312
3425 - use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" )
3426 -
3427 - # Figure out which options we need to disable to do the setup
3428 - local helpfile="${TMPDIR}/mysqld-help"
3429 - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
3430 -
3431 - local opt optexp optfull
3432 - for opt in host-cache name-resolve networking slave-start \
3433 - federated ssl log-bin relay-log slow-query-log external-locking \
3434 - log-slave-updates \
3435 - ; do
3436 - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
3437 - egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" )
3438 - done
3439 -
3440 - # Prepare timezones, see
3441 - # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
3442 - local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")"
3443 - [[ -z "${tz_sql}" ]] \
3444 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!"
3445 -
3446 - echo "USE mysql;" >"${tz_sql}"
3447 - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null
3448 - if [[ $? -ne 0 ]] ; then
3449 - die "mysql_tzinfo_to_sql failed!"
3450 - fi
3451 -
3452 - # --initialize-insecure will not set root password
3453 - # --initialize would set a random one in the log which we don't need as we set it ourselves
3454 - local cmd=(
3455 - "${mysqld_binary}"
3456 - "${mysqld_options[@]}"
3457 - "--initialize-insecure"
3458 - "--init-file='${tz_sql}'"
3459 - "--basedir='${EROOT}/usr'"
3460 - "--datadir='${MY_DATADIR}'"
3461 - "--tmpdir='${MYSQL_TMPDIR}'"
3462 - "--log-error='${mysql_install_log}'"
3463 - "--user=${MYSQL_USER}"
3464 - )
3465 -
3466 - einfo "Initializing ${PN} data directory: ${cmd[@]}"
3467 - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1
3468 -
3469 - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then
3470 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2
3471 - die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!"
3472 - fi
3473 -
3474 - rm "${tz_sql}" || die
3475 -
3476 - local x=${RANDOM}
3477 - local socket="${EROOT}${PID_DIR}/mysqld${x}.sock"
3478 - local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid"
3479 - unset x
3480 -
3481 - cmd=(
3482 - "${mysqld_binary}"
3483 - "${mysqld_options[@]}"
3484 - "--basedir='${EROOT}/usr'"
3485 - "--datadir='${MY_DATADIR}'"
3486 - "--tmpdir='${MYSQL_TMPDIR}'"
3487 - --max_allowed_packet=8M
3488 - --net_buffer_length=16K
3489 - "--socket='${socket}'"
3490 - "--pid-file='${pidfile}'"
3491 - "--log-error='${mysqld_logfile}'"
3492 - "--user=${MYSQL_USER}"
3493 - )
3494 -
3495 - einfo "Starting mysqld to finalize initialization: ${cmd[@]}"
3496 - eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 &
3497 -
3498 - echo -n "Waiting for mysqld to accept connections "
3499 - local maxtry=15
3500 - while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
3501 - maxtry=$((${maxtry}-1))
3502 - echo -n "."
3503 - sleep 1
3504 - done
3505 -
3506 - if [[ -S "${socket}" ]] ; then
3507 - # Even with a socket we don't know if mysqld will abort
3508 - # start due to an error so just wait a little bit more...
3509 - maxtry=5
3510 - while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
3511 - maxtry=$((${maxtry}-1))
3512 - echo -n "."
3513 - sleep 1
3514 - done
3515 - fi
3516 -
3517 - echo
3518 -
3519 - if [[ ! -S "${socket}" ]] ; then
3520 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2
3521 - die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!"
3522 - fi
3523 -
3524 - local mysql_logfile="${TMPDIR}/set_root_pw.log"
3525 - touch "${mysql_logfile}" || die
3526 -
3527 - ebegin "Setting root password"
3528 - # Do this from memory, as we don't want clear text passwords in temp files
3529 - local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'"
3530 - cmd=(
3531 - "${mysql_binary}"
3532 - --no-defaults
3533 - "--socket='${socket}'"
3534 - -hlocalhost
3535 - "-e \"${sql}\""
3536 - )
3537 - eval "${cmd[@]}" >"${mysql_logfile}" 2>&1
3538 - local rc=$?
3539 - eend ${rc}
3540 -
3541 - if [[ ${rc} -ne 0 ]] ; then
3542 - # Poor man's solution which tries to avoid having password
3543 - # in log. NOTE: sed can fail if user didn't follow advice
3544 - # and included character which will require escaping...
3545 - sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null
3546 -
3547 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}"
3548 - die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!"
3549 - fi
3550 -
3551 - # Stop the server
3552 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
3553 - echo -n "Stopping the server "
3554 - pkill -F "${pidfile}" &>/dev/null
3555 -
3556 - maxtry=10
3557 - while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do
3558 - maxtry=$((${maxtry}-1))
3559 - echo -n "."
3560 - sleep 1
3561 - done
3562 -
3563 - echo
3564 -
3565 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
3566 - # We somehow failed to stop server.
3567 - # However, not a fatal error. Just warn the user.
3568 - ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!"
3569 - fi
3570 - fi
3571 -
3572 - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!"
3573 -}
3574
3575 diff --git a/dev-db/mysql/mysql-8.0.25.ebuild b/dev-db/mysql/mysql-8.0.25.ebuild
3576 deleted file mode 100644
3577 index 57a120868df3..000000000000
3578 --- a/dev-db/mysql/mysql-8.0.25.ebuild
3579 +++ /dev/null
3580 @@ -1,1164 +0,0 @@
3581 -# Copyright 1999-2021 Gentoo Authors
3582 -# Distributed under the terms of the GNU General Public License v2
3583 -
3584 -EAPI="7"
3585 -
3586 -CMAKE_MAKEFILE_GENERATOR=emake
3587 -
3588 -inherit check-reqs cmake flag-o-matic linux-info \
3589 - multiprocessing prefix toolchain-funcs
3590 -
3591 -MY_PV="${PV//_pre*}"
3592 -MY_P="${PN}-${MY_PV}"
3593 -
3594 -# Patch version
3595 -PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-8.0.25-patches-01.tar.xz"
3596 -
3597 -SRC_URI="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${MY_PV}.tar.gz
3598 - https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${MY_PV}.tar.gz
3599 - http://downloads.mysql.com/archives/MySQL-8.0/${PN}-boost-${MY_PV}.tar.gz
3600 - ${PATCH_SET}"
3601 -
3602 -HOMEPAGE="https://www.mysql.com/"
3603 -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
3604 -LICENSE="GPL-2"
3605 -SLOT="8.0"
3606 -IUSE="cjk cracklib debug jemalloc latin1 numa +perl profiling
3607 - router selinux +server tcmalloc test"
3608 -
3609 -RESTRICT="!test? ( test )"
3610 -
3611 -REQUIRED_USE="?? ( tcmalloc jemalloc )
3612 - cjk? ( server )
3613 - jemalloc? ( server )
3614 - numa? ( server )
3615 - profiling? ( server )
3616 - router? ( server )
3617 - tcmalloc? ( server )"
3618 -
3619 -# -ppc, -riscv for bug #761715
3620 -KEYWORDS="amd64 arm arm64 ~hppa ~ia64 ~mips -ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris"
3621 -
3622 -# Shorten the path because the socket path length must be shorter than 107 chars
3623 -# and we will run a mysql server during test phase
3624 -S="${WORKDIR}/mysql"
3625 -
3626 -# Be warned, *DEPEND are version-dependant
3627 -# These are used for both runtime and compiletime
3628 -COMMON_DEPEND="
3629 - >=app-arch/lz4-0_p131:=
3630 - app-arch/zstd:=
3631 - sys-libs/ncurses:0=
3632 - >=sys-libs/zlib-1.2.3:0=
3633 - >=dev-libs/openssl-1.0.0:0=
3634 - server? (
3635 - dev-libs/icu:=
3636 - dev-libs/libevent:=[ssl,threads]
3637 - >=dev-libs/protobuf-3.8:=
3638 - net-libs/libtirpc:=
3639 - cjk? ( app-text/mecab:= )
3640 - jemalloc? ( dev-libs/jemalloc:0= )
3641 - kernel_linux? (
3642 - dev-libs/libaio:0=
3643 - sys-process/procps:0=
3644 - )
3645 - numa? ( sys-process/numactl )
3646 - tcmalloc? ( dev-util/google-perftools:0= )
3647 - )
3648 -"
3649 -DEPEND="${COMMON_DEPEND}
3650 - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
3651 - virtual/yacc
3652 - server? ( net-libs/rpcsvc-proto )
3653 - test? (
3654 - acct-group/mysql acct-user/mysql
3655 - dev-perl/JSON
3656 - )
3657 -"
3658 -RDEPEND="${COMMON_DEPEND}
3659 - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
3660 - !dev-db/mysql:0
3661 - !dev-db/mysql:5.7
3662 - selinux? ( sec-policy/selinux-mysql )
3663 - !prefix? (
3664 - acct-group/mysql acct-user/mysql
3665 - dev-db/mysql-init-scripts
3666 - )
3667 -"
3668 -# For other stuff to bring us in
3669 -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
3670 -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
3671 -
3672 -mysql_init_vars() {
3673 - : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
3674 - : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
3675 - : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
3676 - : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
3677 - MY_DATADIR="${MY_LOCALSTATEDIR}"
3678 -
3679 - export MY_SHAREDSTATEDIR MY_SYSCONFDIR
3680 - export MY_LOCALSTATEDIR MY_LOGDIR
3681 - export MY_DATADIR
3682 -}
3683 -
3684 -pkg_pretend() {
3685 - if [[ ${MERGE_TYPE} != binary ]] ; then
3686 - if use server ; then
3687 - CHECKREQS_DISK_BUILD="2G"
3688 -
3689 - if has test $FEATURES ; then
3690 - CHECKREQS_DISK_BUILD="9G"
3691 - fi
3692 -
3693 - check-reqs_pkg_pretend
3694 - fi
3695 - fi
3696 -}
3697 -
3698 -pkg_setup() {
3699 - if [[ ${MERGE_TYPE} != binary ]] ; then
3700 - CHECKREQS_DISK_BUILD="2G"
3701 -
3702 - if has test ${FEATURES} ; then
3703 - CHECKREQS_DISK_BUILD="9G"
3704 -
3705 - # Bug #213475 - MySQL _will_ object strenuously if your machine is named
3706 - # localhost. Also causes weird failures.
3707 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
3708 -
3709 - if ! has userpriv ${FEATURES} ; then
3710 - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
3711 - fi
3712 -
3713 - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null)
3714 - [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \
3715 - && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!"
3716 -
3717 - if use latin1 ; then
3718 - # Upstream only supports tests with default charset
3719 - die "Testing with USE=latin1 is not supported."
3720 - fi
3721 - fi
3722 -
3723 - if use kernel_linux ; then
3724 - if use numa ; then
3725 - linux-info_get_any_version
3726 -
3727 - local CONFIG_CHECK="~NUMA"
3728 -
3729 - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
3730 - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
3731 -
3732 - check_extra_config
3733 - fi
3734 - fi
3735 -
3736 - use server && check-reqs_pkg_setup
3737 - fi
3738 -}
3739 -
3740 -src_unpack() {
3741 - unpack ${A}
3742 -
3743 - mv -f "${WORKDIR}/${MY_P}" "${S}" || die
3744 -}
3745 -
3746 -src_prepare() {
3747 - eapply "${WORKDIR}"/mysql-patches
3748 -
3749 - # Avoid rpm call which would trigger sandbox, #692368
3750 - sed -i \
3751 - -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \
3752 - CMakeLists.txt || die
3753 -
3754 - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
3755 - if [[ -d "${S}/support-files/SELinux" ]] ; then
3756 - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
3757 - fi
3758 -
3759 - # Remove man pages for client-lib tools we don't install
3760 - rm \
3761 - man/my_print_defaults.1 \
3762 - man/perror.1 \
3763 - man/zlib_decompress.1 \
3764 - || die
3765 -
3766 - cmake_src_prepare
3767 -}
3768 -
3769 -src_configure() {
3770 - # Bug #114895, bug #110149
3771 - filter-flags "-O" "-O[01]"
3772 -
3773 - append-cxxflags -felide-constructors
3774 -
3775 - # code is not C++17 ready, bug #786402
3776 - append-cxxflags -std=c++14
3777 -
3778 - # bug #283926, with GCC4.4, this is required to get correct behavior.
3779 - append-flags -fno-strict-aliasing
3780 -
3781 - CMAKE_BUILD_TYPE="RelWithDebInfo"
3782 -
3783 - # debug hack wrt #497532
3784 - mycmakeargs=(
3785 - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
3786 - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
3787 - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
3788 - -DSYSCONFDIR="${EPREFIX}/etc/mysql"
3789 - -DINSTALL_BINDIR=bin
3790 - -DINSTALL_DOCDIR=share/doc/${PF}
3791 - -DINSTALL_DOCREADMEDIR=share/doc/${PF}
3792 - -DINSTALL_INCLUDEDIR=include/mysql
3793 - -DINSTALL_INFODIR=share/info
3794 - -DINSTALL_LIBDIR=$(get_libdir)
3795 - -DINSTALL_MANDIR=share/man
3796 - -DINSTALL_MYSQLSHAREDIR=share/mysql
3797 - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
3798 - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
3799 - -DINSTALL_SBINDIR=sbin
3800 - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
3801 - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
3802 - -DWITH_UNIT_TESTS=$(usex test ON OFF)
3803 - # Using bundled editline to get CTRL+C working
3804 - -DWITH_EDITLINE=bundled
3805 - -DWITH_ZLIB=system
3806 - -DWITH_SSL=system
3807 - -DWITH_LIBWRAP=0
3808 - -DENABLED_LOCAL_INFILE=1
3809 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
3810 - -DWITH_DEFAULT_COMPILER_OPTIONS=0
3811 - # The build forces this to be defined when cross-compiling. We pass it
3812 - # all the time for simplicity and to make sure it is actually correct.
3813 - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
3814 - -DCMAKE_POSITION_INDEPENDENT_CODE=ON
3815 - -DWITH_CURL=system
3816 - -DWITH_BOOST="${S}/boost"
3817 - -DWITH_ROUTER=$(usex router ON OFF)
3818 - )
3819 -
3820 - if is-flagq -fno-lto ; then
3821 - einfo "LTO disabled via {C,CXX,F,FC}FLAGS"
3822 - mycmakeargs+=( -DWITH_LTO=OFF )
3823 - elif is-flagq -flto ; then
3824 - einfo "LTO forced via {C,CXX,F,FC}FLAGS"
3825 - myconf+=( -DWITH_LTO=ON )
3826 - else
3827 - # Disable automagic
3828 - myconf+=( -DWITH_LTO=OFF )
3829 - fi
3830 -
3831 - if use test ; then
3832 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
3833 - else
3834 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
3835 - fi
3836 -
3837 - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
3838 -
3839 - mycmakeargs+=(
3840 - -DWITH_ICU=system
3841 - -DWITH_LZ4=system
3842 - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex
3843 - -DWITH_RAPIDJSON=bundled
3844 - -DWITH_ZSTD=system
3845 - )
3846 -
3847 - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then
3848 - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
3849 - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
3850 - ewarn "You MUST file bugs without these variables set."
3851 - ewarn "Tests will probably fail!"
3852 -
3853 - mycmakeargs+=(
3854 - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
3855 - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
3856 - )
3857 - elif use latin1 ; then
3858 - mycmakeargs+=(
3859 - -DDEFAULT_CHARSET=latin1
3860 - -DDEFAULT_COLLATION=latin1_swedish_ci
3861 - )
3862 - else
3863 - mycmakeargs+=(
3864 - -DDEFAULT_CHARSET=utf8mb4
3865 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
3866 - )
3867 - fi
3868 -
3869 - if use server ; then
3870 - mycmakeargs+=(
3871 - -DWITH_EXTRA_CHARSETS=all
3872 - -DWITH_DEBUG=$(usex debug)
3873 - -DWITH_MECAB=$(usex cjk system OFF)
3874 - -DWITH_LIBEVENT=system
3875 - -DWITH_PROTOBUF=system
3876 - -DWITH_NUMA=$(usex numa ON OFF)
3877 - )
3878 -
3879 - if use jemalloc ; then
3880 - mycmakeargs+=( -DWITH_JEMALLOC=ON )
3881 - elif use tcmalloc ; then
3882 - mycmakeargs+=( -DWITH_TCMALLOC=ON )
3883 - fi
3884 -
3885 - if use profiling ; then
3886 - # Setting to OFF doesn't work: Once set, profiling options will be added
3887 - # to `mysqld --help` output via sql/sys_vars.cc causing
3888 - # "main.mysqld--help-notwin" test to fail
3889 - mycmakeargs+=( -DENABLED_PROFILING=ON )
3890 - fi
3891 -
3892 - # Storage engines
3893 - mycmakeargs+=(
3894 - -DWITH_EXAMPLE_STORAGE_ENGINE=0
3895 - -DWITH_ARCHIVE_STORAGE_ENGINE=1
3896 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1
3897 - -DWITH_CSV_STORAGE_ENGINE=1
3898 - -DWITH_FEDERATED_STORAGE_ENGINE=1
3899 - -DWITH_HEAP_STORAGE_ENGINE=1
3900 - -DWITH_INNOBASE_STORAGE_ENGINE=1
3901 - -DWITH_INNODB_MEMCACHED=0
3902 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1
3903 - -DWITH_MYISAM_STORAGE_ENGINE=1
3904 - )
3905 - else
3906 - mycmakeargs+=(
3907 - -DWITHOUT_SERVER=1
3908 - -DWITH_SYSTEMD=no
3909 - )
3910 - fi
3911 -
3912 - cmake_src_configure
3913 -}
3914 -
3915 -# Official test instructions:
3916 -# ulimit -n 16500 && \
3917 -# USE='perl server' \
3918 -# FEATURES='test userpriv' \
3919 -# ebuild mysql-X.X.XX.ebuild \
3920 -# digest clean package
3921 -src_test() {
3922 - _disable_test() {
3923 - local rawtestname bug reason
3924 - rawtestname="${1}" ; shift
3925 - bug="${1}" ; shift
3926 - reason="${@}"
3927 - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
3928 - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def"
3929 - }
3930 -
3931 - local TESTDIR="${BUILD_DIR}/mysql-test"
3932 - local retstatus_unit
3933 - local retstatus_tests
3934 -
3935 - # Run CTest (test-units)
3936 - cmake_src_test
3937 - retstatus_unit=$?
3938 -
3939 - # Ensure that parallel runs don't die
3940 - export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
3941 -
3942 - if [[ -z "${MTR_PARALLEL}" ]] ; then
3943 - local -x MTR_PARALLEL=$(makeopts_jobs)
3944 -
3945 - if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
3946 - # Running multiple tests in parallel usually require higher ulimit
3947 - # and fs.aio-max-nr setting. In addition, tests like main.multi_update
3948 - # are known to hit timeout when system is busy.
3949 - # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
3950 - # using "auto".
3951 - local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
3952 - info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
3953 - einfo "${info_msg}"
3954 - unset info_msg
3955 - MTR_PARALLEL=4
3956 - fi
3957 - else
3958 - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
3959 - fi
3960 -
3961 - # create directories because mysqladmin might run out of order
3962 - mkdir -p "${T}"/var-tests{,/log} || die
3963 -
3964 - # Run mysql tests
3965 - pushd "${TESTDIR}" &>/dev/null || die
3966 -
3967 - touch "${T}/disabled.def"
3968 -
3969 - local -a disabled_tests
3970 - disabled_tests+=( "auth_sec.atomic_rename_user;103512;Depends on user running test" )
3971 - disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" )
3972 - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" )
3973 - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" )
3974 - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" )
3975 - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" )
3976 - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" )
3977 - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" )
3978 - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" )
3979 - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" )
3980 - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" )
3981 - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" )
3982 - disabled_tests+=( "main.explain_tree;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
3983 - disabled_tests+=( "main.derived_limit;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
3984 - disabled_tests+=( "main.mysql_load_data_local_dir;0;Known test failure - no upstream bug yet" )
3985 - disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
3986 - disabled_tests+=( "main.subquery_sj_mat_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
3987 - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
3988 - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
3989 - disabled_tests+=( "main.with_recursive;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
3990 - disabled_tests+=( "perfschema.statement_digest_query_sample;0;Test will fail on slow hardware")
3991 - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" )
3992 - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Known failure - no upstream bug yet" )
3993 - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware")
3994 - disabled_tests+=( "x.connection;0;Known failure - no upstream bug yet" )
3995 - disabled_tests+=( "main.mysqlpump_basic_lz4;0;Extra tool output causes false positive" )
3996 - disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" )
3997 - disabled_tests+=( "x.message_protobuf_nested;0;False positive caused by protobuff-3.11+" )
3998 -
3999 - if ! hash zip 1>/dev/null 2>&1 ; then
4000 - # no need to force dep app-arch/zip for one test
4001 - disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" )
4002 - disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" )
4003 - fi
4004 -
4005 - local test_infos_str test_infos_arr
4006 - for test_infos_str in "${disabled_tests[@]}" ; do
4007 - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
4008 -
4009 - if [[ ${#test_infos_arr[@]} != 3 ]] ; then
4010 - die "Invalid test data set, not matching format: ${test_infos_str}"
4011 - fi
4012 -
4013 - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
4014 - done
4015 - unset test_infos_str test_infos_arr
4016 -
4017 - # Try to increase file limits to increase test coverage
4018 - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
4019 - # Upper limit comes from parts.partition_* tests
4020 - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
4021 -
4022 - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
4023 - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
4024 - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
4025 -
4026 - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
4027 - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
4028 - else
4029 - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
4030 - fi
4031 - else
4032 - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
4033 - fi
4034 - else
4035 - einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
4036 - fi
4037 -
4038 - # run mysql-test tests
4039 - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
4040 - retstatus_tests=$?
4041 -
4042 - popd &>/dev/null || die
4043 -
4044 - # Cleanup is important for these testcases.
4045 - pkill -9 -f "${S}/ndb" 2>/dev/null
4046 - pkill -9 -f "${S}/sql" 2>/dev/null
4047 -
4048 - local failures=""
4049 - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
4050 - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
4051 -
4052 - [[ -z "$failures" ]] || die "Test failures: $failures"
4053 - einfo "Tests successfully completed"
4054 -}
4055 -
4056 -src_install() {
4057 - cmake_src_install
4058 -
4059 - # Make sure the vars are correctly initialized
4060 - mysql_init_vars
4061 -
4062 - # Convenience links
4063 - einfo "Making Convenience links for mysqlcheck multi-call binary"
4064 - dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
4065 - dosym "mysqlcheck" "/usr/bin/mysqlrepair"
4066 - dosym "mysqlcheck" "/usr/bin/mysqloptimize"
4067 -
4068 - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
4069 - if [[ -d "${ED}/usr/data" ]] ; then
4070 - rm -Rf "${ED}/usr/data" || die
4071 - fi
4072 -
4073 - # Unless they explicitly specific USE=test, then do not install the
4074 - # testsuite. It DOES have a use to be installed, esp. when you want to do a
4075 - # validation of your database configuration after tuning it.
4076 - if ! use test ; then
4077 - rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test"
4078 - fi
4079 -
4080 - # Configuration stuff
4081 - einfo "Building default configuration ..."
4082 - insinto "${MY_SYSCONFDIR#${EPREFIX}}"
4083 - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
4084 - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
4085 - eprefixify "${TMPDIR}/my.cnf"
4086 - doins "${TMPDIR}/my.cnf"
4087 - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
4088 - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
4089 - eprefixify "${TMPDIR}/50-distro-client.cnf"
4090 - doins "${TMPDIR}/50-distro-client.cnf"
4091 -
4092 - mycnf_src="my.cnf-8.0.distro-server"
4093 - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
4094 - "${FILESDIR}/${mycnf_src}" \
4095 - > "${TMPDIR}/my.cnf.ok" || die
4096 -
4097 - if use prefix ; then
4098 - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
4099 - "${TMPDIR}/my.cnf.ok" || die
4100 - fi
4101 -
4102 - if use latin1 ; then
4103 - sed -i \
4104 - -e "/character-set/s|utf8mb4|latin1|g" \
4105 - "${TMPDIR}/my.cnf.ok" || die
4106 - fi
4107 -
4108 - eprefixify "${TMPDIR}/my.cnf.ok"
4109 -
4110 - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
4111 -
4112 - #Remove mytop if perl is not selected
4113 - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
4114 -
4115 - if use router ; then
4116 - rm -rf \
4117 - "${ED}/usr/LICENSE.router" \
4118 - "${ED}/usr/README.router" \
4119 - "${ED}/usr/run" \
4120 - "${ED}/usr/var" \
4121 - || die
4122 - fi
4123 -
4124 - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
4125 - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
4126 -}
4127 -
4128 -pkg_postinst() {
4129 - # Make sure the vars are correctly initialized
4130 - mysql_init_vars
4131 -
4132 - # Create log directory securely if it does not exist
4133 - # NOTE: $MY_LOGDIR contains $EPREFIX by default
4134 - [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}"
4135 -
4136 - # Note about configuration change
4137 - einfo
4138 - elog "This version of ${PN} reorganizes the configuration from a single my.cnf"
4139 - elog "to several files in /etc/mysql/mysql.d."
4140 - elog "Please backup any changes you made to /etc/mysql/my.cnf"
4141 - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension."
4142 - elog "You may have as many files as needed and they are read alphabetically."
4143 - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
4144 - einfo
4145 -
4146 - if [[ -z "${REPLACING_VERSIONS}" ]] ; then
4147 - einfo
4148 - elog "You might want to run:"
4149 - elog " \"emerge --config =${CATEGORY}/${PF}\""
4150 - elog "if this is a new install."
4151 - einfo
4152 - else
4153 - einfo
4154 - elog "Upgrade process for ${PN}-8.x has changed. Please read"
4155 - elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html"
4156 - einfo
4157 - fi
4158 -}
4159 -
4160 -pkg_config() {
4161 - _getoptval() {
4162 - local section="$1"
4163 - local flag="--${2}="
4164 - local extra_options="${3}"
4165 - local cmd=(
4166 - "${my_print_defaults_binary}"
4167 - "${extra_options}"
4168 - "${section}"
4169 - )
4170 - local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") )
4171 -
4172 - if [[ ${#results[@]} -gt 0 ]] ; then
4173 - # When option is set multiple times only return last value
4174 - echo "${results[-1]}"
4175 - fi
4176 - }
4177 -
4178 - _mktemp_dry() {
4179 - # emktemp has no --dry-run option
4180 - local template="${1}"
4181 -
4182 - if [[ -z "${template}" ]] ; then
4183 - if [[ -z "${T}" ]] ; then
4184 - template="/tmp/XXXXXXX"
4185 - else
4186 - template="${T}/XXXXXXX"
4187 - fi
4188 - fi
4189 -
4190 - local template_wo_X=${template//X/}
4191 - local n_X
4192 - let n_X=${#template}-${#template_wo_X}
4193 - if [[ ${n_X} -lt 3 ]] ; then
4194 - echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2
4195 - return
4196 - fi
4197 -
4198 - local attempts=0
4199 - local character tmpfile
4200 - while [[ true ]] ; do
4201 - let attempts=attempts+1
4202 -
4203 - new_file=
4204 - while read -n1 character ; do
4205 - if [[ "${character}" == "X" ]] ; then
4206 - tmpfile+="${RANDOM:0:1}"
4207 - else
4208 - tmpfile+="${character}"
4209 - fi
4210 - done < <(echo -n "${template}")
4211 -
4212 - if [[ ! -f "${tmpfile}" ]]
4213 - then
4214 - echo "${tmpfile}"
4215 - return
4216 - fi
4217 -
4218 - if [[ ${attempts} -ge 100 ]] ; then
4219 - echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2
4220 - return
4221 - fi
4222 - done
4223 - }
4224 -
4225 - local mysqld_binary="${EROOT}/usr/sbin/mysqld"
4226 - if [[ ! -x "${mysqld_binary}" ]] ; then
4227 - die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
4228 - fi
4229 -
4230 - local mysql_binary="${EROOT}/usr/bin/mysql"
4231 - if [[ ! -x "${mysql_binary}" ]] ; then
4232 - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
4233 - fi
4234 -
4235 - local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults"
4236 - if [[ ! -x "${my_print_defaults_binary}" ]] ; then
4237 - die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!"
4238 - fi
4239 -
4240 - if [[ -z "${MYSQL_USER}" ]] ; then
4241 - MYSQL_USER=mysql
4242 - if use prefix ; then
4243 - MYSQL_USER=$(id -u -n 2>/dev/null)
4244 - if [[ -z "${MYSQL_USER}" ]] ; then
4245 - die "Failed to determine current username!"
4246 - fi
4247 - fi
4248 - fi
4249 -
4250 - if [[ -z "${MYSQL_GROUP}" ]] ; then
4251 - MYSQL_GROUP=mysql
4252 - if use prefix ; then
4253 - MYSQL_GROUP=$(id -g -n 2>/dev/null)
4254 - if [[ -z "${MYSQL_GROUP}" ]] ; then
4255 - die "Failed to determine current user groupname!"
4256 - fi
4257 - fi
4258 - fi
4259 -
4260 - # my_print_defaults needs to read stuff in $HOME/.my.cnf
4261 - local -x HOME="${EROOT}/root"
4262 -
4263 - # Make sure the vars are correctly initialized
4264 - mysql_init_vars
4265 -
4266 - # Read currently set data directory
4267 - MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
4268 -
4269 - # Bug #213475 - MySQL _will_ object strenously if your machine is named
4270 - # localhost. Also causes weird failures.
4271 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
4272 -
4273 - if [[ -z "${MY_DATADIR}" ]] ; then
4274 - die "Sorry, unable to find MY_DATADIR!"
4275 - elif [[ -d "${MY_DATADIR}/mysql" ]] ; then
4276 - ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!"
4277 - ewarn "Please rename or delete its content if you wish to initialize a new data directory."
4278 - die "${PN} data directory at '${MY_DATADIR}' looks already initialized!"
4279 - fi
4280 -
4281 - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
4282 - MYSQL_TMPDIR=${MYSQL_TMPDIR%/}
4283 - # These are dir+prefix
4284 - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
4285 - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
4286 - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
4287 - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
4288 -
4289 - # Create missing directories.
4290 - # Always check if mysql user can write to directory even if we just
4291 - # created directory because a parent directory might be not
4292 - # accessible for that user.
4293 - PID_DIR="${EROOT}/run/mysqld"
4294 - if [[ ! -d "${PID_DIR}" ]] ; then
4295 - einfo "Creating ${PN} PID directory '${PID_DIR}' ..."
4296 - install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \
4297 - || die "Failed to create PID directory '${PID_DIR}'!"
4298 - fi
4299 -
4300 - local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")"
4301 - [[ -z "${_pid_dir_testfile}" ]] \
4302 - && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
4303 -
4304 - if use prefix ; then
4305 - touch "${_pid_dir_testfile}" &>/dev/null
4306 - else
4307 - su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null
4308 - fi
4309 -
4310 - if [[ $? -ne 0 ]] ; then
4311 - die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!"
4312 - else
4313 - rm "${_pid_dir_testfile}" || die
4314 - unset _pid_dir_testfile
4315 - fi
4316 -
4317 - if [[ ! -d "${MY_DATADIR}" ]] ; then
4318 - einfo "Creating ${PN} data directory '${MY_DATADIR}' ..."
4319 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \
4320 - || die "Failed to create ${PN} data directory '${MY_DATADIR}'!"
4321 - fi
4322 -
4323 - local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")"
4324 - [[ -z "${_my_datadir_testfile}" ]] \
4325 - && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
4326 -
4327 - if use prefix ; then
4328 - touch "${_my_datadir_testfile}" &>/dev/null
4329 - else
4330 - su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null
4331 - fi
4332 -
4333 - if [[ $? -ne 0 ]] ; then
4334 - die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!"
4335 - else
4336 - rm "${_my_datadir_testfile}" || die
4337 - unset _my_datadir_testfile
4338 - fi
4339 -
4340 - if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then
4341 - einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..."
4342 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \
4343 - || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!"
4344 - fi
4345 -
4346 - if [[ -z "${MYSQL_TMPDIR}" ]] ; then
4347 - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")"
4348 - [[ -z "${MYSQL_TMPDIR}" ]] \
4349 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!"
4350 -
4351 - mkdir "${MYSQL_TMPDIR}" || die
4352 - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die
4353 - fi
4354 -
4355 - # Now we need to test MYSQL_TMPDIR...
4356 - local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")"
4357 - [[ -z "${_my_tmpdir_testfile}" ]] \
4358 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
4359 -
4360 - if use prefix ; then
4361 - touch "${_my_tmpdir_testfile}" &>/dev/null
4362 - else
4363 - su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null
4364 - fi
4365 -
4366 - if [[ $? -ne 0 ]] ; then
4367 - die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!"
4368 - else
4369 - rm "${_my_tmpdir_testfile}" || die
4370 - unset _my_tmpdir_testfile
4371 - fi
4372 -
4373 - if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then
4374 - einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..."
4375 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \
4376 - || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'"
4377 - fi
4378 -
4379 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
4380 - local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")"
4381 - [[ -z "${_my_logbin_testfile}" ]] \
4382 - && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!"
4383 -
4384 - if use prefix ; then
4385 - touch "${_my_logbin_testfile}" &>/dev/null
4386 - else
4387 - su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null
4388 - fi
4389 -
4390 - if [[ $? -ne 0 ]] ; then
4391 - die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!"
4392 - else
4393 - rm "${_my_logbin_testfile}" || die
4394 - unset _my_logbin_testfile
4395 - fi
4396 - fi
4397 -
4398 - if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then
4399 - einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..."
4400 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \
4401 - || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!"
4402 - fi
4403 -
4404 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
4405 - local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")"
4406 - [[ -z "${_my_relaylog_testfile}" ]] \
4407 - && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!"
4408 -
4409 - if use prefix ; then
4410 - touch "${_my_relaylog_testfile}" &>/dev/null
4411 - else
4412 - su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null
4413 - fi
4414 -
4415 - if [[ $? -ne 0 ]] ; then
4416 - die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!"
4417 - else
4418 - rm "${_my_relaylog_testfile}" || die
4419 - unset _my_relaylog_testfile
4420 - fi
4421 - fi
4422 -
4423 - local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")"
4424 - if [[ -z "${mysql_install_log}" ]] ; then
4425 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!"
4426 - else
4427 - # make sure file is writable for MYSQL_USER...
4428 - touch "${mysql_install_log}" || die
4429 - chown ${MYSQL_USER} "${mysql_install_log}" || die
4430 - fi
4431 -
4432 - local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")"
4433 - if [[ -z "${mysqld_logfile}" ]] ; then
4434 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!"
4435 - else
4436 - # make sure file is writable for MYSQL_USER...
4437 - touch "${mysqld_logfile}" || die
4438 - chown ${MYSQL_USER} "${mysqld_logfile}" || die
4439 - fi
4440 -
4441 - echo ""
4442 - einfo "Detected settings:"
4443 - einfo "=================="
4444 - einfo "MySQL User:\t\t\t\t${MYSQL_USER}"
4445 - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}"
4446 - einfo "MySQL DATA directory:\t\t${MY_DATADIR}"
4447 - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}"
4448 -
4449 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
4450 - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}"
4451 - fi
4452 -
4453 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
4454 - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}"
4455 - fi
4456 -
4457 - einfo "PID DIR:\t\t\t\t${PID_DIR}"
4458 - einfo "Install db log:\t\t\t${mysql_install_log}"
4459 - einfo "Install server log:\t\t\t${mysqld_logfile}"
4460 -
4461 - local -a config_files
4462 -
4463 - local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf"
4464 - if [[ -f "${config_file}" ]] ; then
4465 - config_files+=( "${config_file}" )
4466 - else
4467 - ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..."
4468 - fi
4469 -
4470 - config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf"
4471 - if [[ -f "${config_file}" ]] ; then
4472 - config_files+=( "${config_file}" )
4473 - else
4474 - ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..."
4475 - fi
4476 -
4477 - if [[ ${#config_files[@]} -gt 0 ]] ; then
4478 - if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then
4479 - local user_answer
4480 -
4481 - echo
4482 - einfo "Please select default authentication plugin (enter number or plugin name):"
4483 - einfo "1) caching_sha2_password [MySQL 8.0 default]"
4484 - einfo "2) mysql_native_password [MySQL 5.7 default]"
4485 - einfo
4486 - einfo "For details see:"
4487 - einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password"
4488 - read -p " >" user_answer
4489 - echo
4490 -
4491 - case "${user_answer}" in
4492 - 1|caching_sha2_password)
4493 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password
4494 - ;;
4495 - 2|mysql_native_password)
4496 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password
4497 - ;;
4498 - '')
4499 - die "No authentication plugin selected!"
4500 - ;;
4501 - *)
4502 - die "Authentication plugin '${user_answer}' is unknown/unsupported!"
4503 - ;;
4504 - esac
4505 -
4506 - echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}"
4507 -
4508 - unset user_answer
4509 - fi
4510 -
4511 - local cfg_option cfg_option_tabs cfg_section
4512 - for config_file in "${config_files[@]}" ; do
4513 - cfg_option="default-authentication-plugin"
4514 - cfg_section="mysqld"
4515 - cfg_option_tabs="\t\t"
4516 - if [[ "${config_file}" == *client.cnf ]] ; then
4517 - cfg_option="default-auth"
4518 - cfg_section="client"
4519 - cfg_option_tabs="\t\t\t\t"
4520 - fi
4521 -
4522 - if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then
4523 - einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
4524 - sed -i \
4525 - -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \
4526 - "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!"
4527 - else
4528 - einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
4529 - sed -i \
4530 - -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \
4531 - "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!"
4532 - fi
4533 - done
4534 - unset cfg_option cfg_option_tabs cfg_section
4535 - fi
4536 - unset config_files config_file
4537 -
4538 - echo
4539 -
4540 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
4541 - local tmp_mysqld_password_source=
4542 -
4543 - for tmp_mysqld_password_source in mysql client ; do
4544 - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
4545 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
4546 - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
4547 - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
4548 - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
4549 - MYSQL_ROOT_PASSWORD=
4550 - continue
4551 - fi
4552 -
4553 - einfo "Found password in '${tmp_mysqld_password_source}' section!"
4554 - break
4555 - fi
4556 - done
4557 -
4558 - # Sometimes --show is required to display passwords in some implementations of my_print_defaults
4559 - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
4560 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
4561 - fi
4562 -
4563 - unset tmp_mysqld_password_source
4564 - fi
4565 -
4566 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
4567 - local pwd1="a"
4568 - local pwd2="b"
4569 -
4570 - echo
4571 - einfo "No password for mysql 'root' user was specified via environment"
4572 - einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config"
4573 - einfo "file like '${HOME}/.my.cnf'."
4574 - einfo "To continue please provide a password for the mysql 'root' user"
4575 - einfo "now on console:"
4576 - ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!"
4577 - read -rsp " >" pwd1 ; echo
4578 -
4579 - einfo "Retype the password"
4580 - read -rsp " >" pwd2 ; echo
4581 -
4582 - if [[ "x$pwd1" != "x$pwd2" ]] ; then
4583 - die "Passwords are not the same!"
4584 - fi
4585 -
4586 - MYSQL_ROOT_PASSWORD="${pwd1}"
4587 - unset pwd1 pwd2
4588 -
4589 - echo
4590 - fi
4591 -
4592 - local -a mysqld_options
4593 -
4594 - # Fix bug 446200. Don't reference host my.cnf, needs to come first,
4595 - # see http://bugs.mysql.com/bug.php?id=31312
4596 - use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" )
4597 -
4598 - # Figure out which options we need to disable to do the setup
4599 - local helpfile="${TMPDIR}/mysqld-help"
4600 - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
4601 -
4602 - local opt optexp optfull
4603 - for opt in host-cache name-resolve networking slave-start \
4604 - federated ssl log-bin relay-log slow-query-log external-locking \
4605 - log-slave-updates \
4606 - ; do
4607 - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
4608 - egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" )
4609 - done
4610 -
4611 - # Prepare timezones, see
4612 - # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
4613 - local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")"
4614 - [[ -z "${tz_sql}" ]] \
4615 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!"
4616 -
4617 - echo "USE mysql;" >"${tz_sql}"
4618 - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null
4619 - if [[ $? -ne 0 ]] ; then
4620 - die "mysql_tzinfo_to_sql failed!"
4621 - fi
4622 -
4623 - # --initialize-insecure will not set root password
4624 - # --initialize would set a random one in the log which we don't need as we set it ourselves
4625 - local cmd=(
4626 - "${mysqld_binary}"
4627 - "${mysqld_options[@]}"
4628 - "--initialize-insecure"
4629 - "--init-file='${tz_sql}'"
4630 - "--basedir='${EROOT}/usr'"
4631 - "--datadir='${MY_DATADIR}'"
4632 - "--tmpdir='${MYSQL_TMPDIR}'"
4633 - "--log-error='${mysql_install_log}'"
4634 - "--user=${MYSQL_USER}"
4635 - )
4636 -
4637 - einfo "Initializing ${PN} data directory: ${cmd[@]}"
4638 - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1
4639 -
4640 - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then
4641 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2
4642 - die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!"
4643 - fi
4644 -
4645 - rm "${tz_sql}" || die
4646 -
4647 - local x=${RANDOM}
4648 - local socket="${EROOT}${PID_DIR}/mysqld${x}.sock"
4649 - local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid"
4650 - unset x
4651 -
4652 - cmd=(
4653 - "${mysqld_binary}"
4654 - "${mysqld_options[@]}"
4655 - "--basedir='${EROOT}/usr'"
4656 - "--datadir='${MY_DATADIR}'"
4657 - "--tmpdir='${MYSQL_TMPDIR}'"
4658 - --max_allowed_packet=8M
4659 - --net_buffer_length=16K
4660 - "--socket='${socket}'"
4661 - "--pid-file='${pidfile}'"
4662 - "--log-error='${mysqld_logfile}'"
4663 - "--user=${MYSQL_USER}"
4664 - )
4665 -
4666 - einfo "Starting mysqld to finalize initialization: ${cmd[@]}"
4667 - eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 &
4668 -
4669 - echo -n "Waiting for mysqld to accept connections "
4670 - local maxtry=15
4671 - while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
4672 - maxtry=$((${maxtry}-1))
4673 - echo -n "."
4674 - sleep 1
4675 - done
4676 -
4677 - if [[ -S "${socket}" ]] ; then
4678 - # Even with a socket we don't know if mysqld will abort
4679 - # start due to an error so just wait a little bit more...
4680 - maxtry=5
4681 - while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
4682 - maxtry=$((${maxtry}-1))
4683 - echo -n "."
4684 - sleep 1
4685 - done
4686 - fi
4687 -
4688 - echo
4689 -
4690 - if [[ ! -S "${socket}" ]] ; then
4691 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2
4692 - die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!"
4693 - fi
4694 -
4695 - local mysql_logfile="${TMPDIR}/set_root_pw.log"
4696 - touch "${mysql_logfile}" || die
4697 -
4698 - ebegin "Setting root password"
4699 - # Do this from memory, as we don't want clear text passwords in temp files
4700 - local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'"
4701 - cmd=(
4702 - "${mysql_binary}"
4703 - --no-defaults
4704 - "--socket='${socket}'"
4705 - -hlocalhost
4706 - "-e \"${sql}\""
4707 - )
4708 - eval "${cmd[@]}" >"${mysql_logfile}" 2>&1
4709 - local rc=$?
4710 - eend ${rc}
4711 -
4712 - if [[ ${rc} -ne 0 ]] ; then
4713 - # Poor man's solution which tries to avoid having password
4714 - # in log. NOTE: sed can fail if user didn't follow advice
4715 - # and included character which will require escaping...
4716 - sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null
4717 -
4718 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}"
4719 - die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!"
4720 - fi
4721 -
4722 - # Stop the server
4723 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
4724 - echo -n "Stopping the server "
4725 - pkill -F "${pidfile}" &>/dev/null
4726 -
4727 - maxtry=10
4728 - while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do
4729 - maxtry=$((${maxtry}-1))
4730 - echo -n "."
4731 - sleep 1
4732 - done
4733 -
4734 - echo
4735 -
4736 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
4737 - # We somehow failed to stop server.
4738 - # However, not a fatal error. Just warn the user.
4739 - ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!"
4740 - fi
4741 - fi
4742 -
4743 - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!"
4744 -}
4745
4746 diff --git a/dev-db/mysql/mysql-8.0.26.ebuild b/dev-db/mysql/mysql-8.0.26.ebuild
4747 deleted file mode 100644
4748 index 7667bc29e608..000000000000
4749 --- a/dev-db/mysql/mysql-8.0.26.ebuild
4750 +++ /dev/null
4751 @@ -1,1227 +0,0 @@
4752 -# Copyright 1999-2021 Gentoo Authors
4753 -# Distributed under the terms of the GNU General Public License v2
4754 -
4755 -EAPI="7"
4756 -
4757 -CMAKE_MAKEFILE_GENERATOR=emake
4758 -
4759 -inherit check-reqs cmake flag-o-matic linux-info \
4760 - multiprocessing prefix toolchain-funcs
4761 -
4762 -MY_PV="${PV//_pre*}"
4763 -MY_P="${PN}-${MY_PV}"
4764 -
4765 -# Patch version
4766 -PATCH_SET="https://dev.gentoo.org/~whissi/dist/mysql/${PN}-8.0.26-patches-01.tar.xz"
4767 -
4768 -SRC_URI="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${MY_PV}.tar.gz
4769 - https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${MY_PV}.tar.gz
4770 - http://downloads.mysql.com/archives/MySQL-8.0/${PN}-boost-${MY_PV}.tar.gz
4771 - ${PATCH_SET}"
4772 -
4773 -HOMEPAGE="https://www.mysql.com/"
4774 -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server"
4775 -LICENSE="GPL-2"
4776 -SLOT="8.0"
4777 -IUSE="cjk cracklib debug jemalloc latin1 numa +perl profiling
4778 - router selinux +server tcmalloc test"
4779 -
4780 -RESTRICT="!test? ( test )"
4781 -
4782 -REQUIRED_USE="?? ( tcmalloc jemalloc )
4783 - cjk? ( server )
4784 - jemalloc? ( server )
4785 - numa? ( server )
4786 - profiling? ( server )
4787 - router? ( server )
4788 - tcmalloc? ( server )"
4789 -
4790 -# -ppc, -riscv for bug #761715
4791 -KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips -ppc ~ppc64 -riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris ~x86-solaris"
4792 -
4793 -# Shorten the path because the socket path length must be shorter than 107 chars
4794 -# and we will run a mysql server during test phase
4795 -S="${WORKDIR}/mysql"
4796 -
4797 -# Be warned, *DEPEND are version-dependant
4798 -# These are used for both runtime and compiletime
4799 -COMMON_DEPEND="
4800 - >=app-arch/lz4-0_p131:=
4801 - app-arch/zstd:=
4802 - sys-libs/ncurses:0=
4803 - >=sys-libs/zlib-1.2.3:0=
4804 - >=dev-libs/openssl-1.0.0:0=
4805 - server? (
4806 - dev-libs/icu:=
4807 - dev-libs/libevent:=[ssl,threads]
4808 - >=dev-libs/protobuf-3.8:=
4809 - net-libs/libtirpc:=
4810 - cjk? ( app-text/mecab:= )
4811 - jemalloc? ( dev-libs/jemalloc:0= )
4812 - kernel_linux? (
4813 - dev-libs/libaio:0=
4814 - sys-process/procps:0=
4815 - )
4816 - numa? ( sys-process/numactl )
4817 - tcmalloc? ( dev-util/google-perftools:0= )
4818 - )
4819 -"
4820 -
4821 -DEPEND="
4822 - ${COMMON_DEPEND}
4823 - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 )
4824 - virtual/yacc
4825 - server? ( net-libs/rpcsvc-proto )
4826 - test? (
4827 - acct-group/mysql acct-user/mysql
4828 - dev-perl/JSON
4829 - )
4830 -"
4831 -
4832 -RDEPEND="
4833 - ${COMMON_DEPEND}
4834 - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster
4835 - !dev-db/mysql:0
4836 - !dev-db/mysql:5.7
4837 - selinux? ( sec-policy/selinux-mysql )
4838 - !prefix? (
4839 - acct-group/mysql acct-user/mysql
4840 - dev-db/mysql-init-scripts
4841 - )
4842 -"
4843 -
4844 -# For other stuff to bring us in
4845 -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL
4846 -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )"
4847 -
4848 -mysql_init_vars() {
4849 - : ${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"}
4850 - : ${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"}
4851 - : ${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"}
4852 - : ${MY_LOGDIR="${EPREFIX}/var/log/mysql"}
4853 - MY_DATADIR="${MY_LOCALSTATEDIR}"
4854 -
4855 - export MY_SHAREDSTATEDIR MY_SYSCONFDIR
4856 - export MY_LOCALSTATEDIR MY_LOGDIR
4857 - export MY_DATADIR
4858 -}
4859 -
4860 -pkg_pretend() {
4861 - if [[ ${MERGE_TYPE} != binary ]] ; then
4862 - if use server ; then
4863 - CHECKREQS_DISK_BUILD="2G"
4864 -
4865 - if has test $FEATURES ; then
4866 - CHECKREQS_DISK_BUILD="9G"
4867 - fi
4868 -
4869 - check-reqs_pkg_pretend
4870 - fi
4871 - fi
4872 -}
4873 -
4874 -pkg_setup() {
4875 - if [[ ${MERGE_TYPE} != binary ]] ; then
4876 - CHECKREQS_DISK_BUILD="2G"
4877 -
4878 - if has test ${FEATURES} ; then
4879 - CHECKREQS_DISK_BUILD="9G"
4880 -
4881 - # Bug #213475 - MySQL _will_ object strenuously if your machine is named
4882 - # localhost. Also causes weird failures.
4883 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
4884 -
4885 - if ! has userpriv ${FEATURES} ; then
4886 - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root."
4887 - fi
4888 -
4889 - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null)
4890 - [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \
4891 - && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!"
4892 -
4893 - if use latin1 ; then
4894 - # Upstream only supports tests with default charset
4895 - die "Testing with USE=latin1 is not supported."
4896 - fi
4897 - fi
4898 -
4899 - if use kernel_linux ; then
4900 - if use numa ; then
4901 - linux-info_get_any_version
4902 -
4903 - local CONFIG_CHECK="~NUMA"
4904 -
4905 - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;"
4906 - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support"
4907 -
4908 - check_extra_config
4909 - fi
4910 - fi
4911 -
4912 - use server && check-reqs_pkg_setup
4913 - fi
4914 -}
4915 -
4916 -src_unpack() {
4917 - unpack ${A}
4918 -
4919 - mv -f "${WORKDIR}/${MY_P}" "${S}" || die
4920 -}
4921 -
4922 -src_prepare() {
4923 - eapply "${WORKDIR}"/mysql-patches
4924 -
4925 - # Avoid rpm call which would trigger sandbox, #692368
4926 - sed -i \
4927 - -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \
4928 - CMakeLists.txt || die
4929 -
4930 - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux
4931 - if [[ -d "${S}/support-files/SELinux" ]] ; then
4932 - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die
4933 - fi
4934 -
4935 - # Remove man pages for client-lib tools we don't install
4936 - rm \
4937 - man/my_print_defaults.1 \
4938 - man/perror.1 \
4939 - man/zlib_decompress.1 \
4940 - || die
4941 -
4942 - cmake_src_prepare
4943 -}
4944 -
4945 -src_configure() {
4946 - # Bug #114895, bug #110149
4947 - filter-flags "-O" "-O[01]"
4948 -
4949 - append-cxxflags -felide-constructors
4950 -
4951 - # code is not C++17 ready, bug #786402
4952 - append-cxxflags -std=c++14
4953 -
4954 - # bug #283926, with GCC4.4, this is required to get correct behavior.
4955 - append-flags -fno-strict-aliasing
4956 -
4957 - CMAKE_BUILD_TYPE="RelWithDebInfo"
4958 -
4959 - # debug hack wrt #497532
4960 - mycmakeargs=(
4961 - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
4962 - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')"
4963 - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql"
4964 - -DSYSCONFDIR="${EPREFIX}/etc/mysql"
4965 - -DINSTALL_BINDIR=bin
4966 - -DINSTALL_DOCDIR=share/doc/${PF}
4967 - -DINSTALL_DOCREADMEDIR=share/doc/${PF}
4968 - -DINSTALL_INCLUDEDIR=include/mysql
4969 - -DINSTALL_INFODIR=share/info
4970 - -DINSTALL_LIBDIR=$(get_libdir)
4971 - -DINSTALL_MANDIR=share/man
4972 - -DINSTALL_MYSQLSHAREDIR=share/mysql
4973 - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin
4974 - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql"
4975 - -DINSTALL_SBINDIR=sbin
4976 - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql"
4977 - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}"
4978 - -DWITH_UNIT_TESTS=$(usex test ON OFF)
4979 - # Using bundled editline to get CTRL+C working
4980 - -DWITH_EDITLINE=bundled
4981 - -DWITH_ZLIB=system
4982 - -DWITH_SSL=system
4983 - -DWITH_LIBWRAP=0
4984 - -DENABLED_LOCAL_INFILE=1
4985 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock"
4986 - -DWITH_DEFAULT_COMPILER_OPTIONS=0
4987 - # The build forces this to be defined when cross-compiling. We pass it
4988 - # all the time for simplicity and to make sure it is actually correct.
4989 - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1)
4990 - -DCMAKE_POSITION_INDEPENDENT_CODE=ON
4991 - -DWITH_CURL=system
4992 - -DWITH_BOOST="${S}/boost"
4993 - -DWITH_ROUTER=$(usex router ON OFF)
4994 - )
4995 -
4996 - if is-flagq -fno-lto ; then
4997 - einfo "LTO disabled via {C,CXX,F,FC}FLAGS"
4998 - mycmakeargs+=( -DWITH_LTO=OFF )
4999 - elif is-flagq -flto ; then
5000 - einfo "LTO forced via {C,CXX,F,FC}FLAGS"
5001 - myconf+=( -DWITH_LTO=ON )
5002 - else
5003 - # Disable automagic
5004 - myconf+=( -DWITH_LTO=OFF )
5005 - fi
5006 -
5007 - if use test ; then
5008 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test )
5009 - else
5010 - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' )
5011 - fi
5012 -
5013 - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES )
5014 -
5015 - mycmakeargs+=(
5016 - -DWITH_ICU=system
5017 - -DWITH_LZ4=system
5018 - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex
5019 - -DWITH_RAPIDJSON=bundled
5020 - -DWITH_ZSTD=system
5021 - )
5022 -
5023 - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then
5024 - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}"
5025 - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}."
5026 - ewarn "You MUST file bugs without these variables set."
5027 - ewarn "Tests will probably fail!"
5028 -
5029 - mycmakeargs+=(
5030 - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET}
5031 - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION}
5032 - )
5033 - elif use latin1 ; then
5034 - mycmakeargs+=(
5035 - -DDEFAULT_CHARSET=latin1
5036 - -DDEFAULT_COLLATION=latin1_swedish_ci
5037 - )
5038 - else
5039 - mycmakeargs+=(
5040 - -DDEFAULT_CHARSET=utf8mb4
5041 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci
5042 - )
5043 - fi
5044 -
5045 - if use server ; then
5046 - mycmakeargs+=(
5047 - -DWITH_EXTRA_CHARSETS=all
5048 - -DWITH_DEBUG=$(usex debug)
5049 - -DWITH_MECAB=$(usex cjk system OFF)
5050 - -DWITH_LIBEVENT=system
5051 - -DWITH_PROTOBUF=system
5052 - -DWITH_NUMA=$(usex numa ON OFF)
5053 - )
5054 -
5055 - if use jemalloc ; then
5056 - mycmakeargs+=( -DWITH_JEMALLOC=ON )
5057 - elif use tcmalloc ; then
5058 - mycmakeargs+=( -DWITH_TCMALLOC=ON )
5059 - fi
5060 -
5061 - if use profiling ; then
5062 - # Setting to OFF doesn't work: Once set, profiling options will be added
5063 - # to `mysqld --help` output via sql/sys_vars.cc causing
5064 - # "main.mysqld--help-notwin" test to fail
5065 - mycmakeargs+=( -DENABLED_PROFILING=ON )
5066 - fi
5067 -
5068 - # Storage engines
5069 - mycmakeargs+=(
5070 - -DWITH_EXAMPLE_STORAGE_ENGINE=0
5071 - -DWITH_ARCHIVE_STORAGE_ENGINE=1
5072 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1
5073 - -DWITH_CSV_STORAGE_ENGINE=1
5074 - -DWITH_FEDERATED_STORAGE_ENGINE=1
5075 - -DWITH_HEAP_STORAGE_ENGINE=1
5076 - -DWITH_INNOBASE_STORAGE_ENGINE=1
5077 - -DWITH_INNODB_MEMCACHED=0
5078 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1
5079 - -DWITH_MYISAM_STORAGE_ENGINE=1
5080 - )
5081 - else
5082 - mycmakeargs+=(
5083 - -DWITHOUT_SERVER=1
5084 - -DWITH_SYSTEMD=no
5085 - )
5086 - fi
5087 -
5088 - cmake_src_configure
5089 -}
5090 -
5091 -# Official test instructions:
5092 -# ulimit -n 16500 && \
5093 -# USE='perl server' \
5094 -# FEATURES='test userpriv' \
5095 -# ebuild mysql-X.X.XX.ebuild \
5096 -# digest clean package
5097 -src_test() {
5098 - _disable_test() {
5099 - local rawtestname bug reason
5100 - rawtestname="${1}" ; shift
5101 - bug="${1}" ; shift
5102 - reason="${@}"
5103 - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})"
5104 - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def"
5105 - }
5106 -
5107 - local TESTDIR="${BUILD_DIR}/mysql-test"
5108 - local retstatus_unit
5109 - local retstatus_tests
5110 -
5111 - # Run CTest (test-units)
5112 - cmake_src_test
5113 - retstatus_unit=$?
5114 -
5115 - # Ensure that parallel runs don't die
5116 - export MTR_BUILD_THREAD="$((${RANDOM} % 100))"
5117 -
5118 - if [[ -z "${MTR_PARALLEL}" ]] ; then
5119 - local -x MTR_PARALLEL=$(makeopts_jobs)
5120 -
5121 - if [[ ${MTR_PARALLEL} -gt 4 ]] ; then
5122 - # Running multiple tests in parallel usually require higher ulimit
5123 - # and fs.aio-max-nr setting. In addition, tests like main.multi_update
5124 - # are known to hit timeout when system is busy.
5125 - # To avoid test failure we will limit MTR_PARALLEL to 4 instead of
5126 - # using "auto".
5127 - local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})"
5128 - info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!"
5129 - einfo "${info_msg}"
5130 - unset info_msg
5131 - MTR_PARALLEL=4
5132 - fi
5133 - else
5134 - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'"
5135 - fi
5136 -
5137 - # create directories because mysqladmin might run out of order
5138 - mkdir -p "${T}"/var-tests{,/log} || die
5139 -
5140 - # Run mysql tests
5141 - pushd "${TESTDIR}" &>/dev/null || die
5142 -
5143 - touch "${T}/disabled.def"
5144 -
5145 - local -a disabled_tests
5146 - disabled_tests+=( "auth_sec.atomic_rename_user;103512;Depends on user running test" )
5147 - disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges" )
5148 - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)" )
5149 - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)" )
5150 - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)" )
5151 - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)" )
5152 - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)" )
5153 - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)" )
5154 - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)" )
5155 - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)" )
5156 - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)" )
5157 - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)" )
5158 - disabled_tests+=( "innodb.alter_kill;0;Known test failure -- no upstream bug yet" )
5159 - disabled_tests+=( "main.derived_limit;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5160 - disabled_tests+=( "main.explain_tree;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5161 - disabled_tests+=( "main.gis-precise;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5162 - disabled_tests+=( "main.mysql_load_data_local_dir;0;Known test failure -- no upstream bug yet" )
5163 - disabled_tests+=( "main.select_icp_mrr;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5164 - disabled_tests+=( "main.subquery_bugs;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5165 - disabled_tests+=( "main.subquery_sj_dupsweed;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5166 - disabled_tests+=( "main.subquery_sj_dupsweed_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5167 - disabled_tests+=( "main.subquery_sj_dupsweed_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5168 - disabled_tests+=( "main.subquery_sj_firstmatch;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5169 - disabled_tests+=( "main.subquery_sj_firstmatch_bka;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5170 - disabled_tests+=( "main.subquery_sj_firstmatch_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5171 - disabled_tests+=( "main.subquery_sj_mat_bka_nobnl;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5172 - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5173 - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5174 - disabled_tests+=( "main.with_recursive;0;Known rounding error with latest AMD processors -- no upstream bug yet" )
5175 - disabled_tests+=( "perfschema.statement_digest_query_sample;0;Test will fail on slow hardware")
5176 - disabled_tests+=( "rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch;0;Unstable test" )
5177 - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" )
5178 - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Known failure - no upstream bug yet" )
5179 - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware")
5180 - disabled_tests+=( "x.connection;0;Known failure - no upstream bug yet" )
5181 - disabled_tests+=( "x.message_compressed_payload;0;False positive caused by protobuff-3.11+" )
5182 - disabled_tests+=( "x.message_protobuf_nested;0;False positive caused by protobuff-3.11+" )
5183 -
5184 - if ! hash zip 1>/dev/null 2>&1 ; then
5185 - # no need to force dep app-arch/zip for one test
5186 - disabled_tests+=( "innodb.discarded_partition_create;0;Requires app-arch/zip" )
5187 - disabled_tests+=( "innodb.partition_upgrade_create;0;Requires app-arch/zip" )
5188 - fi
5189 -
5190 - if has_version ">=dev-libs/openssl-3" ; then
5191 - # >=dev-libs/openssl-3 defaults to security level 1 which disallow
5192 - # TLSv1/1.1 but tests will require TLSv1/1.1.
5193 - einfo "Set OpenSSL configuration for test suite ..."
5194 - cat > "${T}/openssl_tlsv1.cnf" <<- EOF || die
5195 - openssl_conf = default_conf
5196 -
5197 - [ req ]
5198 - default_bits = 2048
5199 - default_keyfile = privkey.pem
5200 - distinguished_name = req_distinguished_name
5201 -
5202 - [ req_distinguished_name ]
5203 - countryName = Country Name (2 letter code)
5204 - countryName_default = AU
5205 - countryName_min = 2
5206 - countryName_max = 2
5207 -
5208 - stateOrProvinceName = State or Province Name (full name)
5209 - stateOrProvinceName_default = Some-State
5210 -
5211 - localityName = Locality Name (eg, city)
5212 -
5213 - 0.organizationName = Organization Name (eg, company)
5214 - 0.organizationName_default = Internet Widgits Pty Ltd
5215 -
5216 - organizationalUnitName = Organizational Unit Name (eg, section)
5217 -
5218 - commonName = Common Name (e.g. server FQDN or YOUR name)
5219 - commonName_max = 64
5220 -
5221 - emailAddress = Email Address
5222 - emailAddress_max = 64
5223 -
5224 - [default_conf]
5225 - ssl_conf = ssl_sect
5226 -
5227 - [ssl_sect]
5228 - system_default = system_default_sect
5229 -
5230 - [system_default_sect]
5231 - CipherString = DEFAULT@SECLEVEL=0
5232 - EOF
5233 -
5234 - local -x OPENSSL_CONF="${T}/openssl_tlsv1.cnf"
5235 -
5236 - disabled_tests+=( "x.connection_tls_version;0;Not compatible with OpenSSL 3.x error messages" )
5237 - fi
5238 -
5239 - local test_infos_str test_infos_arr
5240 - for test_infos_str in "${disabled_tests[@]}" ; do
5241 - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}"
5242 -
5243 - if [[ ${#test_infos_arr[@]} != 3 ]] ; then
5244 - die "Invalid test data set, not matching format: ${test_infos_str}"
5245 - fi
5246 -
5247 - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}"
5248 - done
5249 - unset test_infos_str test_infos_arr
5250 -
5251 - # Try to increase file limits to increase test coverage
5252 - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then
5253 - # Upper limit comes from parts.partition_* tests
5254 - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager."
5255 -
5256 - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then
5257 - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)'
5258 - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager."
5259 -
5260 - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then
5261 - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager."
5262 - else
5263 - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)."
5264 - fi
5265 - else
5266 - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)."
5267 - fi
5268 - else
5269 - einfo "Will run test suite with open file limit set to 16500 (best test coverage)."
5270 - fi
5271 -
5272 - # run mysql-test tests
5273 - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def"
5274 - retstatus_tests=$?
5275 -
5276 - popd &>/dev/null || die
5277 -
5278 - # Cleanup is important for these testcases.
5279 - pkill -9 -f "${S}/ndb" 2>/dev/null
5280 - pkill -9 -f "${S}/sql" 2>/dev/null
5281 -
5282 - local failures=""
5283 - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit"
5284 - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests"
5285 -
5286 - [[ -z "$failures" ]] || die "Test failures: $failures"
5287 - einfo "Tests successfully completed"
5288 -}
5289 -
5290 -src_install() {
5291 - cmake_src_install
5292 -
5293 - # Make sure the vars are correctly initialized
5294 - mysql_init_vars
5295 -
5296 - # Convenience links
5297 - einfo "Making Convenience links for mysqlcheck multi-call binary"
5298 - dosym "mysqlcheck" "/usr/bin/mysqlanalyze"
5299 - dosym "mysqlcheck" "/usr/bin/mysqlrepair"
5300 - dosym "mysqlcheck" "/usr/bin/mysqloptimize"
5301 -
5302 - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir
5303 - if [[ -d "${ED}/usr/data" ]] ; then
5304 - rm -Rf "${ED}/usr/data" || die
5305 - fi
5306 -
5307 - # Unless they explicitly specific USE=test, then do not install the
5308 - # testsuite. It DOES have a use to be installed, esp. when you want to do a
5309 - # validation of your database configuration after tuning it.
5310 - if ! use test ; then
5311 - rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test"
5312 - fi
5313 -
5314 - # Configuration stuff
5315 - einfo "Building default configuration ..."
5316 - insinto "${MY_SYSCONFDIR#${EPREFIX}}"
5317 - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf
5318 - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die
5319 - eprefixify "${TMPDIR}/my.cnf"
5320 - doins "${TMPDIR}/my.cnf"
5321 - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d"
5322 - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die
5323 - eprefixify "${TMPDIR}/50-distro-client.cnf"
5324 - doins "${TMPDIR}/50-distro-client.cnf"
5325 -
5326 - mycnf_src="my.cnf-8.0.distro-server"
5327 - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \
5328 - "${FILESDIR}/${mycnf_src}" \
5329 - > "${TMPDIR}/my.cnf.ok" || die
5330 -
5331 - if use prefix ; then
5332 - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \
5333 - "${TMPDIR}/my.cnf.ok" || die
5334 - fi
5335 -
5336 - if use latin1 ; then
5337 - sed -i \
5338 - -e "/character-set/s|utf8mb4|latin1|g" \
5339 - "${TMPDIR}/my.cnf.ok" || die
5340 - fi
5341 -
5342 - eprefixify "${TMPDIR}/my.cnf.ok"
5343 -
5344 - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf
5345 -
5346 - #Remove mytop if perl is not selected
5347 - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop"
5348 -
5349 - if use router ; then
5350 - rm -rf \
5351 - "${ED}/usr/LICENSE.router" \
5352 - "${ED}/usr/README.router" \
5353 - "${ED}/usr/run" \
5354 - "${ED}/usr/var" \
5355 - || die
5356 - fi
5357 -
5358 - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them.
5359 - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die
5360 -}
5361 -
5362 -pkg_postinst() {
5363 - # Make sure the vars are correctly initialized
5364 - mysql_init_vars
5365 -
5366 - # Create log directory securely if it does not exist
5367 - # NOTE: $MY_LOGDIR contains $EPREFIX by default
5368 - [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}"
5369 -
5370 - # Note about configuration change
5371 - einfo
5372 - elog "This version of ${PN} reorganizes the configuration from a single my.cnf"
5373 - elog "to several files in /etc/mysql/mysql.d."
5374 - elog "Please backup any changes you made to /etc/mysql/my.cnf"
5375 - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension."
5376 - elog "You may have as many files as needed and they are read alphabetically."
5377 - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]."
5378 - einfo
5379 -
5380 - if [[ -z "${REPLACING_VERSIONS}" ]] ; then
5381 - einfo
5382 - elog "You might want to run:"
5383 - elog " \"emerge --config =${CATEGORY}/${PF}\""
5384 - elog "if this is a new install."
5385 - einfo
5386 - else
5387 - einfo
5388 - elog "Upgrade process for ${PN}-8.x has changed. Please read"
5389 - elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html"
5390 - einfo
5391 - fi
5392 -}
5393 -
5394 -pkg_config() {
5395 - _getoptval() {
5396 - local section="$1"
5397 - local flag="--${2}="
5398 - local extra_options="${3}"
5399 - local cmd=(
5400 - "${my_print_defaults_binary}"
5401 - "${extra_options}"
5402 - "${section}"
5403 - )
5404 - local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") )
5405 -
5406 - if [[ ${#results[@]} -gt 0 ]] ; then
5407 - # When option is set multiple times only return last value
5408 - echo "${results[-1]}"
5409 - fi
5410 - }
5411 -
5412 - _mktemp_dry() {
5413 - # emktemp has no --dry-run option
5414 - local template="${1}"
5415 -
5416 - if [[ -z "${template}" ]] ; then
5417 - if [[ -z "${T}" ]] ; then
5418 - template="/tmp/XXXXXXX"
5419 - else
5420 - template="${T}/XXXXXXX"
5421 - fi
5422 - fi
5423 -
5424 - local template_wo_X=${template//X/}
5425 - local n_X
5426 - let n_X=${#template}-${#template_wo_X}
5427 - if [[ ${n_X} -lt 3 ]] ; then
5428 - echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2
5429 - return
5430 - fi
5431 -
5432 - local attempts=0
5433 - local character tmpfile
5434 - while [[ true ]] ; do
5435 - let attempts=attempts+1
5436 -
5437 - new_file=
5438 - while read -n1 character ; do
5439 - if [[ "${character}" == "X" ]] ; then
5440 - tmpfile+="${RANDOM:0:1}"
5441 - else
5442 - tmpfile+="${character}"
5443 - fi
5444 - done < <(echo -n "${template}")
5445 -
5446 - if [[ ! -f "${tmpfile}" ]]
5447 - then
5448 - echo "${tmpfile}"
5449 - return
5450 - fi
5451 -
5452 - if [[ ${attempts} -ge 100 ]] ; then
5453 - echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2
5454 - return
5455 - fi
5456 - done
5457 - }
5458 -
5459 - local mysqld_binary="${EROOT}/usr/sbin/mysqld"
5460 - if [[ ! -x "${mysqld_binary}" ]] ; then
5461 - die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
5462 - fi
5463 -
5464 - local mysql_binary="${EROOT}/usr/bin/mysql"
5465 - if [[ ! -x "${mysql_binary}" ]] ; then
5466 - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!"
5467 - fi
5468 -
5469 - local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults"
5470 - if [[ ! -x "${my_print_defaults_binary}" ]] ; then
5471 - die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!"
5472 - fi
5473 -
5474 - if [[ -z "${MYSQL_USER}" ]] ; then
5475 - MYSQL_USER=mysql
5476 - if use prefix ; then
5477 - MYSQL_USER=$(id -u -n 2>/dev/null)
5478 - if [[ -z "${MYSQL_USER}" ]] ; then
5479 - die "Failed to determine current username!"
5480 - fi
5481 - fi
5482 - fi
5483 -
5484 - if [[ -z "${MYSQL_GROUP}" ]] ; then
5485 - MYSQL_GROUP=mysql
5486 - if use prefix ; then
5487 - MYSQL_GROUP=$(id -g -n 2>/dev/null)
5488 - if [[ -z "${MYSQL_GROUP}" ]] ; then
5489 - die "Failed to determine current user groupname!"
5490 - fi
5491 - fi
5492 - fi
5493 -
5494 - # my_print_defaults needs to read stuff in $HOME/.my.cnf
5495 - local -x HOME="${EROOT}/root"
5496 -
5497 - # Make sure the vars are correctly initialized
5498 - mysql_init_vars
5499 -
5500 - # Read currently set data directory
5501 - MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
5502 -
5503 - # Bug #213475 - MySQL _will_ object strenously if your machine is named
5504 - # localhost. Also causes weird failures.
5505 - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost"
5506 -
5507 - if [[ -z "${MY_DATADIR}" ]] ; then
5508 - die "Sorry, unable to find MY_DATADIR!"
5509 - elif [[ -d "${MY_DATADIR}/mysql" ]] ; then
5510 - ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!"
5511 - ewarn "Please rename or delete its content if you wish to initialize a new data directory."
5512 - die "${PN} data directory at '${MY_DATADIR}' looks already initialized!"
5513 - fi
5514 -
5515 - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
5516 - MYSQL_TMPDIR=${MYSQL_TMPDIR%/}
5517 - # These are dir+prefix
5518 - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
5519 - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*}
5520 - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")"
5521 - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*}
5522 -
5523 - # Create missing directories.
5524 - # Always check if mysql user can write to directory even if we just
5525 - # created directory because a parent directory might be not
5526 - # accessible for that user.
5527 - PID_DIR="${EROOT}/run/mysqld"
5528 - if [[ ! -d "${PID_DIR}" ]] ; then
5529 - einfo "Creating ${PN} PID directory '${PID_DIR}' ..."
5530 - install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \
5531 - || die "Failed to create PID directory '${PID_DIR}'!"
5532 - fi
5533 -
5534 - local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")"
5535 - [[ -z "${_pid_dir_testfile}" ]] \
5536 - && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
5537 -
5538 - if use prefix ; then
5539 - touch "${_pid_dir_testfile}" &>/dev/null
5540 - else
5541 - su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null
5542 - fi
5543 -
5544 - if [[ $? -ne 0 ]] ; then
5545 - die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!"
5546 - else
5547 - rm "${_pid_dir_testfile}" || die
5548 - unset _pid_dir_testfile
5549 - fi
5550 -
5551 - if [[ ! -d "${MY_DATADIR}" ]] ; then
5552 - einfo "Creating ${PN} data directory '${MY_DATADIR}' ..."
5553 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \
5554 - || die "Failed to create ${PN} data directory '${MY_DATADIR}'!"
5555 - fi
5556 -
5557 - local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")"
5558 - [[ -z "${_my_datadir_testfile}" ]] \
5559 - && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
5560 -
5561 - if use prefix ; then
5562 - touch "${_my_datadir_testfile}" &>/dev/null
5563 - else
5564 - su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null
5565 - fi
5566 -
5567 - if [[ $? -ne 0 ]] ; then
5568 - die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!"
5569 - else
5570 - rm "${_my_datadir_testfile}" || die
5571 - unset _my_datadir_testfile
5572 - fi
5573 -
5574 - if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then
5575 - einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..."
5576 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \
5577 - || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!"
5578 - fi
5579 -
5580 - if [[ -z "${MYSQL_TMPDIR}" ]] ; then
5581 - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")"
5582 - [[ -z "${MYSQL_TMPDIR}" ]] \
5583 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!"
5584 -
5585 - mkdir "${MYSQL_TMPDIR}" || die
5586 - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die
5587 - fi
5588 -
5589 - # Now we need to test MYSQL_TMPDIR...
5590 - local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")"
5591 - [[ -z "${_my_tmpdir_testfile}" ]] \
5592 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!"
5593 -
5594 - if use prefix ; then
5595 - touch "${_my_tmpdir_testfile}" &>/dev/null
5596 - else
5597 - su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null
5598 - fi
5599 -
5600 - if [[ $? -ne 0 ]] ; then
5601 - die "${MYSQL_USER} user cannot write into tmpdir '${MYSQL_TMPDIR}'!"
5602 - else
5603 - rm "${_my_tmpdir_testfile}" || die
5604 - unset _my_tmpdir_testfile
5605 - fi
5606 -
5607 - if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then
5608 - einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..."
5609 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \
5610 - || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'"
5611 - fi
5612 -
5613 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
5614 - local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")"
5615 - [[ -z "${_my_logbin_testfile}" ]] \
5616 - && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!"
5617 -
5618 - if use prefix ; then
5619 - touch "${_my_logbin_testfile}" &>/dev/null
5620 - else
5621 - su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null
5622 - fi
5623 -
5624 - if [[ $? -ne 0 ]] ; then
5625 - die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!"
5626 - else
5627 - rm "${_my_logbin_testfile}" || die
5628 - unset _my_logbin_testfile
5629 - fi
5630 - fi
5631 -
5632 - if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then
5633 - einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..."
5634 - install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \
5635 - || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!"
5636 - fi
5637 -
5638 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
5639 - local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")"
5640 - [[ -z "${_my_relaylog_testfile}" ]] \
5641 - && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!"
5642 -
5643 - if use prefix ; then
5644 - touch "${_my_relaylog_testfile}" &>/dev/null
5645 - else
5646 - su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null
5647 - fi
5648 -
5649 - if [[ $? -ne 0 ]] ; then
5650 - die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!"
5651 - else
5652 - rm "${_my_relaylog_testfile}" || die
5653 - unset _my_relaylog_testfile
5654 - fi
5655 - fi
5656 -
5657 - local mysql_install_log="$(_mktemp_dry "${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log")"
5658 - if [[ -z "${mysql_install_log}" ]] ; then
5659 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_db.XXXXXXXXX.log' failed!"
5660 - else
5661 - # make sure file is writable for MYSQL_USER...
5662 - touch "${mysql_install_log}" || die
5663 - chown ${MYSQL_USER} "${mysql_install_log}" || die
5664 - fi
5665 -
5666 - local mysqld_logfile="$(_mktemp_dry "${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log")"
5667 - if [[ -z "${mysqld_logfile}" ]] ; then
5668 - die "_mktemp_dry() for '${MYSQL_TMPDIR}/install_mysqld.XXXXXXXXX.log' failed!"
5669 - else
5670 - # make sure file is writable for MYSQL_USER...
5671 - touch "${mysqld_logfile}" || die
5672 - chown ${MYSQL_USER} "${mysqld_logfile}" || die
5673 - fi
5674 -
5675 - echo ""
5676 - einfo "Detected settings:"
5677 - einfo "=================="
5678 - einfo "MySQL User:\t\t\t\t${MYSQL_USER}"
5679 - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}"
5680 - einfo "MySQL DATA directory:\t\t${MY_DATADIR}"
5681 - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}"
5682 -
5683 - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then
5684 - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}"
5685 - fi
5686 -
5687 - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then
5688 - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}"
5689 - fi
5690 -
5691 - einfo "PID DIR:\t\t\t\t${PID_DIR}"
5692 - einfo "Install db log:\t\t\t${mysql_install_log}"
5693 - einfo "Install server log:\t\t\t${mysqld_logfile}"
5694 -
5695 - local -a config_files
5696 -
5697 - local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf"
5698 - if [[ -f "${config_file}" ]] ; then
5699 - config_files+=( "${config_file}" )
5700 - else
5701 - ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..."
5702 - fi
5703 -
5704 - config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf"
5705 - if [[ -f "${config_file}" ]] ; then
5706 - config_files+=( "${config_file}" )
5707 - else
5708 - ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..."
5709 - fi
5710 -
5711 - if [[ ${#config_files[@]} -gt 0 ]] ; then
5712 - if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then
5713 - local user_answer
5714 -
5715 - echo
5716 - einfo "Please select default authentication plugin (enter number or plugin name):"
5717 - einfo "1) caching_sha2_password [MySQL 8.0 default]"
5718 - einfo "2) mysql_native_password [MySQL 5.7 default]"
5719 - einfo
5720 - einfo "For details see:"
5721 - einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password"
5722 - read -p " >" user_answer
5723 - echo
5724 -
5725 - case "${user_answer}" in
5726 - 1|caching_sha2_password)
5727 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password
5728 - ;;
5729 - 2|mysql_native_password)
5730 - MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password
5731 - ;;
5732 - '')
5733 - die "No authentication plugin selected!"
5734 - ;;
5735 - *)
5736 - die "Authentication plugin '${user_answer}' is unknown/unsupported!"
5737 - ;;
5738 - esac
5739 -
5740 - echo "Selected authentication plugin: ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" >> "${mysql_install_log}"
5741 -
5742 - unset user_answer
5743 - fi
5744 -
5745 - local cfg_option cfg_option_tabs cfg_section
5746 - for config_file in "${config_files[@]}" ; do
5747 - cfg_option="default-authentication-plugin"
5748 - cfg_section="mysqld"
5749 - cfg_option_tabs="\t\t"
5750 - if [[ "${config_file}" == *client.cnf ]] ; then
5751 - cfg_option="default-auth"
5752 - cfg_section="client"
5753 - cfg_option_tabs="\t\t\t\t"
5754 - fi
5755 -
5756 - if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then
5757 - einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
5758 - sed -i \
5759 - -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \
5760 - "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!"
5761 - else
5762 - einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..."
5763 - sed -i \
5764 - -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \
5765 - "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!"
5766 - fi
5767 - done
5768 - unset cfg_option cfg_option_tabs cfg_section
5769 - fi
5770 - unset config_files config_file
5771 -
5772 - echo
5773 -
5774 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
5775 - local tmp_mysqld_password_source=
5776 -
5777 - for tmp_mysqld_password_source in mysql client ; do
5778 - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..."
5779 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)"
5780 - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then
5781 - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then
5782 - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!"
5783 - MYSQL_ROOT_PASSWORD=
5784 - continue
5785 - fi
5786 -
5787 - einfo "Found password in '${tmp_mysqld_password_source}' section!"
5788 - break
5789 - fi
5790 - done
5791 -
5792 - # Sometimes --show is required to display passwords in some implementations of my_print_defaults
5793 - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then
5794 - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)"
5795 - fi
5796 -
5797 - unset tmp_mysqld_password_source
5798 - fi
5799 -
5800 - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then
5801 - local pwd1="a"
5802 - local pwd2="b"
5803 -
5804 - echo
5805 - einfo "No password for mysql 'root' user was specified via environment"
5806 - einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config"
5807 - einfo "file like '${HOME}/.my.cnf'."
5808 - einfo "To continue please provide a password for the mysql 'root' user"
5809 - einfo "now on console:"
5810 - ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!"
5811 - read -rsp " >" pwd1 ; echo
5812 -
5813 - einfo "Retype the password"
5814 - read -rsp " >" pwd2 ; echo
5815 -
5816 - if [[ "x$pwd1" != "x$pwd2" ]] ; then
5817 - die "Passwords are not the same!"
5818 - fi
5819 -
5820 - MYSQL_ROOT_PASSWORD="${pwd1}"
5821 - unset pwd1 pwd2
5822 -
5823 - echo
5824 - fi
5825 -
5826 - local -a mysqld_options
5827 -
5828 - # Fix bug 446200. Don't reference host my.cnf, needs to come first,
5829 - # see http://bugs.mysql.com/bug.php?id=31312
5830 - use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" )
5831 -
5832 - # Figure out which options we need to disable to do the setup
5833 - local helpfile="${TMPDIR}/mysqld-help"
5834 - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null
5835 -
5836 - local opt optexp optfull
5837 - for opt in host-cache name-resolve networking slave-start \
5838 - federated ssl log-bin relay-log slow-query-log external-locking \
5839 - log-slave-updates \
5840 - ; do
5841 - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}"
5842 - egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" )
5843 - done
5844 -
5845 - # Prepare timezones, see
5846 - # https://dev.mysql.com/doc/mysql/en/time-zone-support.html
5847 - local tz_sql="$(_mktemp_dry "${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql")"
5848 - [[ -z "${tz_sql}" ]] \
5849 - && die "_mktemp_dry() for '${MYSQL_TMPDIR}/tz.XXXXXXXXX.sql' failed!"
5850 -
5851 - echo "USE mysql;" >"${tz_sql}"
5852 - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null
5853 - if [[ $? -ne 0 ]] ; then
5854 - die "mysql_tzinfo_to_sql failed!"
5855 - fi
5856 -
5857 - # --initialize-insecure will not set root password
5858 - # --initialize would set a random one in the log which we don't need as we set it ourselves
5859 - local cmd=(
5860 - "${mysqld_binary}"
5861 - "${mysqld_options[@]}"
5862 - "--initialize-insecure"
5863 - "--init-file='${tz_sql}'"
5864 - "--basedir='${EROOT}/usr'"
5865 - "--datadir='${MY_DATADIR}'"
5866 - "--tmpdir='${MYSQL_TMPDIR}'"
5867 - "--log-error='${mysql_install_log}'"
5868 - "--user=${MYSQL_USER}"
5869 - )
5870 -
5871 - einfo "Initializing ${PN} data directory: ${cmd[@]}"
5872 - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1
5873 -
5874 - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then
5875 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2
5876 - die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!"
5877 - fi
5878 -
5879 - rm "${tz_sql}" || die
5880 -
5881 - local x=${RANDOM}
5882 - local socket="${EROOT}${PID_DIR}/mysqld${x}.sock"
5883 - local pidfile="${EROOT}${PID_DIR}/mysqld${x}.pid"
5884 - unset x
5885 -
5886 - cmd=(
5887 - "${mysqld_binary}"
5888 - "${mysqld_options[@]}"
5889 - "--basedir='${EROOT}/usr'"
5890 - "--datadir='${MY_DATADIR}'"
5891 - "--tmpdir='${MYSQL_TMPDIR}'"
5892 - --max_allowed_packet=8M
5893 - --net_buffer_length=16K
5894 - "--socket='${socket}'"
5895 - "--pid-file='${pidfile}'"
5896 - "--log-error='${mysqld_logfile}'"
5897 - "--user=${MYSQL_USER}"
5898 - )
5899 -
5900 - einfo "Starting mysqld to finalize initialization: ${cmd[@]}"
5901 - eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 &
5902 -
5903 - echo -n "Waiting for mysqld to accept connections "
5904 - local maxtry=15
5905 - while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
5906 - maxtry=$((${maxtry}-1))
5907 - echo -n "."
5908 - sleep 1
5909 - done
5910 -
5911 - if [[ -S "${socket}" ]] ; then
5912 - # Even with a socket we don't know if mysqld will abort
5913 - # start due to an error so just wait a little bit more...
5914 - maxtry=5
5915 - while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do
5916 - maxtry=$((${maxtry}-1))
5917 - echo -n "."
5918 - sleep 1
5919 - done
5920 - fi
5921 -
5922 - echo
5923 -
5924 - if [[ ! -S "${socket}" ]] ; then
5925 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2
5926 - die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!"
5927 - fi
5928 -
5929 - local mysql_logfile="${TMPDIR}/set_root_pw.log"
5930 - touch "${mysql_logfile}" || die
5931 -
5932 - ebegin "Setting root password"
5933 - # Do this from memory, as we don't want clear text passwords in temp files
5934 - local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'"
5935 - cmd=(
5936 - "${mysql_binary}"
5937 - --no-defaults
5938 - "--socket='${socket}'"
5939 - -hlocalhost
5940 - "-e \"${sql}\""
5941 - )
5942 - eval "${cmd[@]}" >"${mysql_logfile}" 2>&1
5943 - local rc=$?
5944 - eend ${rc}
5945 -
5946 - if [[ ${rc} -ne 0 ]] ; then
5947 - # Poor man's solution which tries to avoid having password
5948 - # in log. NOTE: sed can fail if user didn't follow advice
5949 - # and included character which will require escaping...
5950 - sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null
5951 -
5952 - grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}"
5953 - die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!"
5954 - fi
5955 -
5956 - # Stop the server
5957 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
5958 - echo -n "Stopping the server "
5959 - pkill -F "${pidfile}" &>/dev/null
5960 -
5961 - maxtry=10
5962 - while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do
5963 - maxtry=$((${maxtry}-1))
5964 - echo -n "."
5965 - sleep 1
5966 - done
5967 -
5968 - echo
5969 -
5970 - if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then
5971 - # We somehow failed to stop server.
5972 - # However, not a fatal error. Just warn the user.
5973 - ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!"
5974 - fi
5975 - fi
5976 -
5977 - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!"
5978 -}