From fc637fb28da700da71ec2064d65ca5a7a31b9c6c Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 18 Aug 2019 18:16:17 +0100 Subject: gentoo resync : 18.08.2019 --- dev-db/mysql/Manifest | 16 +- dev-db/mysql/files/my.cnf-8.0.distro-client | 4 +- dev-db/mysql/files/my.cnf-8.0.distro-server | 6 +- dev-db/mysql/mysql-5.6.44-r1.ebuild | 838 ++++++++++++++++++++ dev-db/mysql/mysql-5.6.44.ebuild | 800 ------------------- dev-db/mysql/mysql-5.6.45-r1.ebuild | 843 ++++++++++++++++++++ dev-db/mysql/mysql-5.6.45.ebuild | 806 ------------------- dev-db/mysql/mysql-5.7.26.ebuild | 60 +- dev-db/mysql/mysql-5.7.27.ebuild | 61 +- dev-db/mysql/mysql-8.0.17.ebuild | 1104 +++++++++++++++++++++++++++ dev-db/mysql/mysql-8.0.17_pre1.ebuild | 815 -------------------- 11 files changed, 2906 insertions(+), 2447 deletions(-) create mode 100644 dev-db/mysql/mysql-5.6.44-r1.ebuild delete mode 100644 dev-db/mysql/mysql-5.6.44.ebuild create mode 100644 dev-db/mysql/mysql-5.6.45-r1.ebuild delete mode 100644 dev-db/mysql/mysql-5.6.45.ebuild create mode 100644 dev-db/mysql/mysql-8.0.17.ebuild delete mode 100644 dev-db/mysql/mysql-8.0.17_pre1.ebuild (limited to 'dev-db/mysql') diff --git a/dev-db/mysql/Manifest b/dev-db/mysql/Manifest index 8e3f3e66af14..f9d3951bcb9f 100644 --- a/dev-db/mysql/Manifest +++ b/dev-db/mysql/Manifest @@ -1,8 +1,8 @@ AUX my.cnf-5.5 4733 BLAKE2B 89af4a9dbd4828a40aa91b294cef15ec8afbcb614ece424614d0bd2d047273906ccb8e4518a48d530f55e898b6c75403d61aa7a733d5bf50f0f0640c55471505 SHA512 6a5d183f1aeb30d9096838ac010c8f2dc004448924b3606bd03c1a5e0336a20fe5fcef1d2cd772977a167268fcff51a4b663f1f73a37d3066983621a8ca6c004 AUX my.cnf-5.6 4504 BLAKE2B 5d904925d12ad4c3826426e7e7790800028c9adf9b42692adf3260cd8dae910338683fbcd3e5148f113c1ab27481e5ffe61871716a069c50f295cf756b3e685c SHA512 866aa700460c2962bad6294b271efad09ef285dd428ab01551078be9972d2f961fbdf56aef7927439784711022e92a96f2eba30cd297f056f6562e8817c89aae AUX my.cnf-5.7 138 BLAKE2B 71862b4b77334ab74002237453d2c7f6b51cd1ae57dba3b00b19e216d3f10034796de9aa618efb11482cef78b7c7e50393b5f665810d03321b5ca770ac8a6144 SHA512 1d7250689005c948f4a849959baf33f5f0fda099f230611651919ed053fb563daa19d996b7ca6714e224174172fb504f4d7d08e9d449a7e1203e32cf3fdec782 -AUX my.cnf-8.0.distro-client 644 BLAKE2B 6bcc7b7842ed5738cf5b8b71e65f570786a5c30c95083f2d21dc75091d4fca8fd8bbb7a392db71b3e3297c80e1341d67d411c77a16807e14717547f69ac2f3df SHA512 e2d6cd2172bf8195568ea49fb16804dbfd42cfc9c9761a4759873099adbb3781211d01ecac492f58c6a3755d7a4648a4c1fd8e75afc78fa14906b9a26c5a42a4 -AUX my.cnf-8.0.distro-server 981 BLAKE2B e4a347f5597bb15f83b27ae0adbe34a42a296f13c1e3a6607a84ed93cda253962fa4559719efb2a3851762c5735bfd4778adc48b531aee7751503558f3603633 SHA512 a8ff382e0361a93a1f709e47ec1d9c902154ea7b40fbe428066778a2bd0958bd1777a7520d48f6d63ed8b85a958033ae905872ad696f4d441524485e611a6bc4 +AUX my.cnf-8.0.distro-client 749 BLAKE2B b01b39c85430714b5a4bfb9923c9ed1df99cdcef0583b25f28c2ebeee264732f4402198b1918e5ec5b4b1091dbda2d321baf31fe87eae00792b20042260969b3 SHA512 62aa589833126c2b78528e103f2de11ba0e339615cb00170a0f9f53bbb123a4bf99f2041819440297ab6cc34cf57333488e6ae12082fa5dcbe1b0ddef5f6108d +AUX my.cnf-8.0.distro-server 1125 BLAKE2B f4d6941aad1fc29e81e6c805ac42f4c8d3c7bc250990a9c432800dbe25b5c31be08d8e3895666b57f21606ffb69e704c57ed2692fd94696b9d325a4442596587 SHA512 82d35b7bc944e5690e1f2670a3d5674845610c2d11d6d8b1c5784ccb3877c6298de70eced3d7c497c0bcaecfa9e339ac43ce0534a97e7d976e950bb1a7f5c75d AUX my.cnf.distro-client 637 BLAKE2B b0812e0e03aa9a3b2e55e08b933a0b41b6afd95ded61f4d9d7c34a2d3810ec38520abd0d89e1c6565f61d4cd8a36d653f9f3199b3dd6a91345cdb5ff962685d8 SHA512 74bd1d9a58075d0a6195be1f94db310bcbe8da532b03844e6fa1ff84676e84843fc9adf9aed06b7e4db53c9aa24ef0885d96de0ccfe4c6ad98afe4c145d43f4f AUX my.cnf.distro-server 994 BLAKE2B 41dceff58edf748f9f60ac3c0d1682d2fc2f026fc1fd14b4c2dea398814beda3c09aabea04dd3a9e145464524c629e7e69dc257d1245e0a46dd8584b7f685172 SHA512 cf172edc23d3dda49c21af6b8adef8aa13694d8ceecddf1d612d4ae34d00ba53c51ae4ae7ca4d11083eeacb5d862f59a855a9d80e9e448ab8bbf17f42aac2650 DIST mysql-5.5.61.tar.gz 21027098 BLAKE2B b7589f632a211349fc34cec94e333b878e07113969bf5cf6f78cd37435d95b15c03eaf188ed09768033b182de125c9f018a5fe902094f17ab891f94cab9de6dd SHA512 978384915c145ec8f0d85deb764154d8d4a9764f2d342928bda6ad43a00bc110aa888895416d2ba5684a4432e433037990dd3fe8c5caf024faa487bc2e153f49 @@ -24,18 +24,18 @@ DIST mysql-extras-20181111-2314Z.tar.bz2 329013 BLAKE2B fa928b699ef0e6f092e028fc DIST mysql-extras-20190303-1852Z.tar.bz2 331026 BLAKE2B ee033fce8f1b6a58f1f690710fb9709a585cd45564b35e71d4f840a3a7f83a5d80f53c24236c9976319abd89c68c62c74a7111517f1b9721d3cbd0898bf0dd8d SHA512 30361a0b848ed27f9170b1116458a9bc13b1b585c5fa1933c99927541c31e9bda4008b0563f2fc7db286f998089ebebf1fe3f18fce7a45e62acbf769ac62d8c1 DIST mysql-extras-20190524-1046Z.tar.bz2 331517 BLAKE2B e6d48e34b0a7f7176de8740971f8151923beb20a520df73c22d44005059ef6779ad5aa8437e30018b9bbfe1d6d69043cbd8522b6f3662746205193b44372a6b3 SHA512 2f7238578f3aabd1701e1c54da36bc0100c9479871e3c77b22131fd6cde865037307f93b3343ea5e52251c45ef35cdc52cc2dec5a26d44fd41700598282c5c2c DIST mysql-extras-20190604-1109Z.tar.bz2 331780 BLAKE2B 48b6f6ff36818ba3d1d9c0580b0ff5e2343d92a42ee78b6804841d7c4f511adcdc3d5cd0590f769f308ca52e271c07cb34219450f9b86e918ddcd0a4b956e18e SHA512 19a85ba5a4c2de1688f39feb6ce1c1802e4d886436dc02afe1ba508b91365a0ac67d668cf7126588145ee55641992ad71b0d094246a94c89065876b9bb897425 -DIST mysql-extras-20190802-1549Z.tar.bz2 335077 BLAKE2B c4c4e38d30c9e4e02cdbcf4117f020e044374370bf32f6e013aa37ae6794445f3ef12e46abbdb5fefd85a68fe5af6b417363012a64d1fd97d79d478bb4b3749d SHA512 5c19a9ce9fe0d95788cc25fed0c2f987b46fa85accf7440a569066f4ac1b9f8522a0855fa884a128d7ccee17fecc25f4b16a16b3cd962c39f3670819eef2f6dc +DIST mysql-extras-20190817-0024Z.tar.bz2 337793 BLAKE2B dfd51a708654aff5bdbbaf2acad7ef966869a8e3adcba544ee15f217d2ba942827445841e73981bccc6c1f145b6225bfa7245114219f0cf52f0dfb85494a6830 SHA512 c2ff81be1c55636f0a2700033af030149f312f0383217054a4b8c65aef174626299fcb4539eaae967ea7d096a5bb09f5b5122dce344b44b0a135d886ba0fdf28 EBUILD mysql-5.5.61.ebuild 25515 BLAKE2B 2e8a5ff36ec6003ff7e4d746157afe8af9d462537d2808ab6cfe4d469cee1a594df38aafddcb010d0157335b42253f12474614f4eec85729f79d2e05a28cb8b3 SHA512 9ea05d2509c6693d71c5ce048e11393a77cf50570fa19f40500900284b9e5e5d1097de5c82fa518058ea773ac8fd30131a9c153b4effb371f4ce04f454e8867e EBUILD mysql-5.5.62.ebuild 25693 BLAKE2B abb1400994767e1a29259fda70531e27e9160b849a6228802baa440f8a5c8244393cb155ac9985f04353c8b35516e653a563c2eb84b72a714c5ee81d016e5d27 SHA512 759b82802fdeb7840b0da3e4ef1d6e7b1f32d7bd815ba780b11e57143b52bcb7eb483c008d25670f4626968028a46f7080abff247e5d2047f6b500ac67888ad4 EBUILD mysql-5.6.40-r2.ebuild 25714 BLAKE2B c78b1d8b2a77d095302f7e203c3ee6c0c2014770944072b87bd77f97972fcb6db52b05088adacbc821ce2e8f3dbb780bd40d850e381b866458b0d530fd11ea5d SHA512 b6301834c7813714f18f9763922d10e6faa33675705ba479c6d76e3c5673d903b0683f64a8281836bd6be396f398ed1bee14f9e6c8ddfe30b84ad1ac66a8be48 EBUILD mysql-5.6.42.ebuild 25955 BLAKE2B de075ce30850d5f2fe17a5aaf02e5888d62634028a042105ac4bff9a90dbec7803c6b1d348e35267be6b4b12afa8f12f4a02f969c536890bf7970cb4e466907c SHA512 56aa82fe363e091a6db7b307318f14ff93ded6eba2a61142eb3e026205740b02dca8587e23accf2ff757e941b0d4b2a0e7ab386b879d7cee35976facbb7aec94 EBUILD mysql-5.6.43.ebuild 26057 BLAKE2B b6162d04f384dc37aabae472cc3998dea0456d672aa906e778d58637edca29fc11257f1fecbcae36d3c1245467768426284743a2aadaab6723540279c615d11c SHA512 857b83b44f185bb0b811005b0f5ee35eff1a2b4d263b199f8a4955330b7fd73fd2038d565fc6fadd9cc31948f0699db6ebb10e628e93e9b223ab87b5517fe16b -EBUILD mysql-5.6.44.ebuild 26134 BLAKE2B bba7798675d50a5c3830459796fec9b82893efab1945b251b4b4d3177696a66c2ad7356ed777063acb94a04c6711f39223c7d54d4a97a7a478273e4dc053857b SHA512 a701cf6326dc1bf95a7f542de86d647dbc9f2116a2dec79503554b8cef335ab221e2193df501b5869a9c155bef631a6e0010382301e264e80e79515d8f48c7c7 -EBUILD mysql-5.6.45.ebuild 26221 BLAKE2B e8480f719bc168eaf0bc4c6fe41f3415607b0371fc242975c3ebcafa1f05958d8cf67181a7360f94d220528117d8b53af172413d8b5c1c20e9427bb591fdb4a3 SHA512 904c85b11ebf383bd6f30e669604bc555406536b76eb18bcaae75cdc70fee65691499f6ad6e3320a2b997b938a955162fa1ee184850b19af6051607b8643e925 +EBUILD mysql-5.6.44-r1.ebuild 27132 BLAKE2B 6b9c9c6e47a3263e5dc454d486f02fe46fefce8e2e7e20a8ef5476bc6191f1cb57f5928e14ee68b30bed0d73152bdbc03f164ae700e3b76e75bcf6cf289cd7f9 SHA512 f9ca576c2076b34c6548543551a8ef9dee5aacc175cd4928a8ec9dc8180993d68c45824ea72628825a9e463d9d8d00c65482545435ae9f26ff7fbbf355fc9e98 +EBUILD mysql-5.6.45-r1.ebuild 27193 BLAKE2B c25435de96c371988464eac6407419dcd608812c5957569cff72e5c0c205584a0c3d8b2f4a8ad82b716e307dac39c9f3db93f8f3e2109eda82e834a593ff2ca4 SHA512 8bb737d1fb8dc00d732940983ccec3d89d4b0580f5e1ca829ff40467830203a060aa16afa4f10db725659f32e1d2d3724b41e3c41723d82e01d98fb49f4ccc86 EBUILD mysql-5.7.23-r2.ebuild 30078 BLAKE2B 57bf58e862639e651335a10a8c4dfc5f7f0f76bfb0545414d697875906d917131fedd3e9d0e58f57b886d8cae55adbd2a104ee3632d49b4ba0669b93a1a68bff SHA512 dfbb88e79b717ceb615246a806123ee2d30c1632cfb40d0bb9e04a9204565a92afbb2b37245794c15985e99a60d2adc46723b97e455fb85e137079d6192b148c EBUILD mysql-5.7.24.ebuild 30386 BLAKE2B ecf0c03821af6a21467b53a02e6e0a0ae2f7e5d267ff4669266d34cdb9fddb7defbd8a4013dd3a1f8a103c84da4c6eddafae06fc1ebc4bf94c9769e64dbbfc1b SHA512 f8b372573d82b513ea1d82a1e00d728501c483ef949a2411c05ac93a8d2d90162d6992b58d3a101fefcbac541f9f37dcfa2263ac49231839d338af158557153f EBUILD mysql-5.7.25.ebuild 30465 BLAKE2B ec639482f3726ea18994c0e3b88ae991d16eda30c5acf7f6abee4f4301d0ada726494e4ebd2f045291faf967940adc8ef1172a48fb00e10ff69a83f837ac3e73 SHA512 6d45fd341a6f0e71d3546134d4bcfd745c6b488b28e848eb2ee1aaebb96745c797da452250a71c2eba87452e61f5ba017f80b88f4e16e23d076be4a70c6936ed -EBUILD mysql-5.7.26.ebuild 30471 BLAKE2B 783b6bbbe3fbe3067c4255da8180ebee2b5de4c9279d87ddda36dce8d70cc0026abca0634d60a98e3b9b4025c1ffe22bc35117b10891ea4011d286091ee2db78 SHA512 8be36c349123429dadb7593c242835274b881d0172b4796f27aa6476450d3ae865a797918c069a078b88f533b4ff861f7d3c8ba7d79024d87a69a936103f1042 -EBUILD mysql-5.7.27.ebuild 30610 BLAKE2B e7aa49d4def7deea79ba2b9bcd369f346cd3f93db11c84b22775fabdb5cb2551978e73ece4540e2ea227757767898a1c99ee2dfdc4fe3670786de6f0a5ed3d02 SHA512 a8ceee6d478fc6f4f1f00966d97188c0e1b3e0af640578723778468b53ba37cf906e784b21842f7e5fd076b289cd3afca0964e95261935a66d2a1ba8f8ff1080 -EBUILD mysql-8.0.17_pre1.ebuild 27573 BLAKE2B e71ba338797d7132475edc3adcb5700ad8ccd5e3049f52725d38e2448eccd84525cdd31dc9d44a32554856801d3fa4b6ebe2adc3041ae298f6bcc3e2a5d882ec SHA512 a8930d804ae3742ae405c9d5e17d11390ab365742636bcab6e331a7ac5ad1e4fe99b68c30b5a8b04eb99d0c28be08127f81056d96eed7b327ff624fa1aad74a9 +EBUILD mysql-5.7.26.ebuild 31719 BLAKE2B c610c458def0a3ffd1c7b7e4cb2375eeeb50496a38f456916f4c8d95b30b45b8011d6d1806487a5e824bd2ed40d284650bac20e5a4756a569ab71a66bcba6a68 SHA512 4579ab74217d9fb01af95afe9fa725676bab729e772494e45f6efb63f08c4fcf7250f22bb3a680db04ffb81959dd5337ff37d1f7f2d18fa2a0ed24ebf130641e +EBUILD mysql-5.7.27.ebuild 31857 BLAKE2B 5ddae4d74eedc28ebcddc6b293261f7fe33a03c446336a07b88a9d8088dc68f2b149405388869267db1c4f2525618ed4f61e3f15033b09a41201349ad4535549 SHA512 6c2b59adabb4f946bf8661a167059730b59f116935324c7ae7ca6b84c32a21be76472bf7055d296211bffddd02d42b226a3af59baf68465d7b22fc425665ac8c +EBUILD mysql-8.0.17.ebuild 36377 BLAKE2B 0aff546e2e9d25c7b37d1a61d3843592cfef9fbf1d8c6e6fcea52f45a6038fdaa50d7ae22b11246a62622961a87ec20ea1283cb9e0067ee6a0c08b1492ba0f22 SHA512 af768c840fcee4eab5278bd5d7e6401f871ad9defc7fa2b461fc83ea8da4a58799a3822f4d149e96b564aeb7c4e6d61fb1541878332415d39d5892fa916d52d0 MISC metadata.xml 1599 BLAKE2B cad6c530634fbf5923276e0b6e10e54aafca0afb7c4cdbb99ee1e3307e6b0004959eb4c8a35e5542ede6fd7d0c181933293acac0ec562988c3f8c8789546671c SHA512 cd18e4f2569e944648d23a21acf0b89c0c84e2b30a9ca6ad9d2d4f8b38b04fd29cecab598e2a836b99822c0356052fa8ada44c10241fcc03fedc5f0ce21cc36f diff --git a/dev-db/mysql/files/my.cnf-8.0.distro-client b/dev-db/mysql/files/my.cnf-8.0.distro-client index 5325c1a6d8fd..1c2ee7da1d92 100644 --- a/dev-db/mysql/files/my.cnf-8.0.distro-client +++ b/dev-db/mysql/files/my.cnf-8.0.distro-client @@ -1,7 +1,9 @@ -# @GENTOO_PORTAGE_EPREFIX@/etc/mysql/50-distro-client.cnf: The global mysql configuration file. +# @GENTOO_PORTAGE_EPREFIX@/etc/mysql/mysql.d/50-distro-client.cnf: The global mysql configuration file. # The following options will be passed to all MySQL clients [client] +# Should match default server to save a round trip +loose-default-auth = mysql_native_password socket = @GENTOO_PORTAGE_EPREFIX@/var/run/mysqld/mysqld.sock character-sets-dir = @GENTOO_PORTAGE_EPREFIX@/usr/share/mysql/charsets loose-default-character-set = utf8mb4 diff --git a/dev-db/mysql/files/my.cnf-8.0.distro-server b/dev-db/mysql/files/my.cnf-8.0.distro-server index 248c68e393ad..ac087963972e 100644 --- a/dev-db/mysql/files/my.cnf-8.0.distro-server +++ b/dev-db/mysql/files/my.cnf-8.0.distro-server @@ -1,7 +1,9 @@ -# @GENTOO_PORTAGE_EPREFIX@/etc/mysql/50-distro-server.cnf: The global mysql configuration file. +# @GENTOO_PORTAGE_EPREFIX@/etc/mysql/mysql.d/50-distro-server.cnf: The global mysql configuration file. # add a section [mysqld-8.0] for specific configurations [mysqld] +# Using "mysql_native_password" for compatibility with Perl, PHP, Ruby... +loose-default-authentication-plugin = mysql_native_password character-set-server = utf8mb4 user = mysql port = 3306 @@ -24,5 +26,5 @@ log-bin server-id = 1 # point the following paths to different dedicated disks -tmpdir = @GENTOO_PORTAGE_EPREFIX@/tmp/ +#tmpdir = @GENTOO_PORTAGE_EPREFIX@/tmp/ #log-update = @GENTOO_PORTAGE_EPREFIX@/path-to-dedicated-directory/hostname diff --git a/dev-db/mysql/mysql-5.6.44-r1.ebuild b/dev-db/mysql/mysql-5.6.44-r1.ebuild new file mode 100644 index 000000000000..e51ea5affde5 --- /dev/null +++ b/dev-db/mysql/mysql-5.6.44-r1.ebuild @@ -0,0 +1,838 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="6" +MY_EXTRAS_VER="20190817-0024Z" + +CMAKE_MAKEFILE_GENERATOR=emake + +# Keeping eutils in EAPI=6 for emktemp in pkg_config + +inherit eutils flag-o-matic prefix toolchain-funcs \ + user cmake-utils multilib-build + +SRC_URI="http://cdn.mysql.com/Downloads/MySQL-5.6/${P}.tar.gz + https://cdn.mysql.com/archives/mysql-5.6/${P}.tar.gz + http://downloads.mysql.com/archives/MySQL-5.6/${P}.tar.gz" + +# Gentoo patches to MySQL +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then + SRC_URI="${SRC_URI} + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" +fi + +HOMEPAGE="https://www.mysql.com/" +DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" +LICENSE="GPL-2" +SLOT="0/18" +IUSE="client-libs cracklib debug jemalloc latin1 libressl numa +perl profiling selinux + +server static static-libs systemtap tcmalloc test yassl" + +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests +RESTRICT="libressl? ( test )" + +REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )" + +KEYWORDS="~alpha amd64 arm ~hppa ~ia64 ~mips ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" + +# Shorten the path because the socket path length must be shorter than 107 chars +# and we will run a mysql server during test phase +S="${WORKDIR}/mysql" + +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then + inherit git-r3 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git" + EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras" + EGIT_CLONE_TYPE=shallow + MY_PATCH_DIR="${WORKDIR}/mysql-extras" +else + MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" +fi + +PATCHES=( + "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch + "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch + "${MY_PATCH_DIR}"/20006_all_cmake_elib-mysql-5.6.35.patch + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch + "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch + "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch + "${MY_PATCH_DIR}"/20018_all_mysql-5.6.25-without-clientlibs-tools.patch + "${MY_PATCH_DIR}"/20027_all_mysql-5.5-perl5.26-includes.patch + "${MY_PATCH_DIR}"/20028_all_mysql-5.6-gcc7.patch + "${MY_PATCH_DIR}"/20031_all_mysql-5.6-fix-monitor.test.patch + "${MY_PATCH_DIR}"/20036_all_mysql-5.6-fix-rpl_semi_sync_shutdown_hang.test.patch + "${MY_PATCH_DIR}"/20018_all_mysql-5.6.44-fix-libressl-support.patch + "${MY_PATCH_DIR}"/20018_all_mysql-5.6.44-add-openssl-1.1-support.patch +) + +# Be warned, *DEPEND are version-dependant +# These are used for both runtime and compiletime +COMMON_DEPEND=" + kernel_linux? ( + sys-process/procps:0= + dev-libs/libaio:0= + ) + net-misc/curl + >=sys-apps/sed-4 + >=sys-apps/texinfo-4.7-r1 + jemalloc? ( dev-libs/jemalloc:0= ) + tcmalloc? ( dev-util/google-perftools:0= ) + systemtap? ( >=dev-util/systemtap-1.3:0= ) + !yassl? ( + !libressl? ( >=dev-libs/openssl-1.0.0:0= ) + libressl? ( =dev-libs/libressl-2.6.5*:0= ) + ) + >=sys-libs/zlib-1.2.3:0= + sys-libs/ncurses:0= + server? ( + numa? ( sys-process/numactl ) + ) + !client-libs? ( dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] ) +" +DEPEND="virtual/yacc + static? ( sys-libs/ncurses[static-libs] ) + test? ( dev-perl/JSON ) + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c ) + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + server? ( !prefix? ( dev-db/mysql-init-scripts ) ) + ${COMMON_DEPEND} +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" + +pkg_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on + # non x86{,_64} arches + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} needs to be built with gcc-4.7 or later." + eerror "Please use gcc-config to switch to gcc-4.7 or later version." + die + fi + fi + if has test ${FEATURES} && \ + use server && ! has userpriv ${FEATURES} ; then + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + + # This should come after all of the die statements + enewgroup mysql 60 || die "problem adding 'mysql' group" + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" +} + +pkg_preinst() { + # Here we need to see if the implementation switched client libraries + # We check if this is a new instance of the package and a client library already exists + local SHOW_ABI_MESSAGE libpath + if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so" ]] ; then + libpath=$(readlink "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so") + elog "Due to ABI changes when switching between different client libraries," + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." + elog "Please run: revdep-rebuild --library ${libpath}" + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" + fi +} + +pkg_postinst() { + # Make sure the vars are correctly initialized + mysql_init_vars + + # Create log directory securely if it does not exist + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" + + if use server ; then + if [[ -z "${REPLACING_VERSIONS}" ]] ; then + einfo + elog "You might want to run:" + elog "\"emerge --config =${CATEGORY}/${PF}\"" + elog "if this is a new install." + elog + elog "If you are switching server implentations, you should run the" + elog "mysql_upgrade tool." + einfo + else + einfo + elog "If you are upgrading major versions, you should run the" + elog "mysql_upgrade tool." + einfo + fi + fi +} + +src_unpack() { + unpack ${A} + # Grab the patches + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack + + mv -f "${WORKDIR}/${P}" "${S}" || die +} + +src_prepare() { + _disable_engine() { + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die + } + + _disable_plugin() { + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die + } + + if use jemalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + if use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux + if [[ -d "${S}/support-files/SELinux" ]] ; then + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die + fi + + if use libressl ; then + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \ + "${S}/cmake/ssl.cmake" || die + fi + + sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die + + local plugin + local server_plugins=( semisync ) + local test_plugins=( audit_null daemon_example fulltext ) + if ! use server; then # These plugins are for the server + for plugin in "${server_plugins[@]}" ; do + _disable_plugin "${plugin}" + done + fi + + if ! use test; then # These plugins are only used during testing + for plugin in "${test_plugins[@]}" ; do + _disable_plugin "${plugin}" + done + fi + + # Don't build example + _disable_engine example + _disable_engine ndb + _disable_plugin innodb_memcached + + cmake-utils_src_prepare +} + +src_configure(){ + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + append-cxxflags -felide-constructors + + # bug #283926, with GCC4.4, this is required to get correct behavior. + append-flags -fno-strict-aliasing + + CMAKE_BUILD_TYPE="RelWithDebInfo" + + # debug hack wrt #497532 + mycmakeargs=( + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" + -DSYSCONFDIR="${EPREFIX}/etc/mysql" + -DINSTALL_BINDIR=bin + -DINSTALL_DOCDIR=share/doc/${PF} + -DINSTALL_DOCREADMEDIR=share/doc/${PF} + -DINSTALL_INCLUDEDIR=include/mysql + -DINSTALL_INFODIR=share/info + -DINSTALL_LIBDIR=$(get_libdir) + -DINSTALL_MANDIR=share/man + -DINSTALL_MYSQLSHAREDIR=share/mysql + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin + -DINSTALL_SCRIPTDIR=share/mysql/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + ### TODO: make this system but issues with UTF-8 prevent it + -DWITH_EDITLINE=bundled + -DWITH_ZLIB=system + -DWITH_LIBWRAP=0 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + # The build forces this to be defined when cross-compiling. We pass it + # all the time for simplicity and to make sure it is actually correct. + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) + -DWITH_LIBEVENT=NO + -DWITHOUT_CLIENTLIBS=YES + -DENABLE_DTRACE=$(usex systemtap) + -DWITH_SSL=$(usex yassl bundled system) + -DINSTALL_MYSQLTESTDIR=$(usex test 'share/mysql/mysql-test' '') + -DWITHOUT_VALIDATE_PASSWORD=1 + ) + + if use server ; then + + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." + ewarn "You MUST file bugs without these variables set." + + mycmakeargs+=( + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} + ) + + elif ! use latin1 ; then + mycmakeargs+=( + -DDEFAULT_CHARSET=utf8 + -DDEFAULT_COLLATION=utf8_general_ci + ) + else + mycmakeargs+=( + -DDEFAULT_CHARSET=latin1 + -DDEFAULT_COLLATION=latin1_swedish_ci + ) + fi + mycmakeargs+=( + -DWITH_NUMA=$(usex numa ON OFF) + -DEXTRA_CHARSETS=all + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + ) + + if use profiling ; then + # Setting to OFF doesn't work: Once set, profiling options will be added + # to `mysqld --help` output via sql/sys_vars.cc causing + # "main.mysqld--help-notwin" test to fail + mycmakeargs+=( -DENABLED_PROFILING=ON ) + fi + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + # Storage engines + mycmakeargs+=( + -DWITH_ARCHIVE_STORAGE_ENGINE=1 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 + -DWITH_CSV_STORAGE_ENGINE=1 + -DWITH_HEAP_STORAGE_ENGINE=1 + -DWITH_INNOBASE_STORAGE_ENGINE=1 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1 + -DWITH_MYISAM_STORAGE_ENGINE=1 + -DWITH_PARTITION_STORAGE_ENGINE=1 + -DWITH_INNODB_MEMCACHED=0 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + ) + fi + + cmake-utils_src_configure +} + +src_compile() { + cmake-utils_src_compile +} + +src_install() { + cmake-utils_src_install + + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die + # Make sure the vars are correctly initialized + mysql_init_vars + + # Convenience links + einfo "Making Convenience links for mysqlcheck multi-call binary" + dosym "mysqlcheck" "/usr/bin/mysqlanalyze" + dosym "mysqlcheck" "/usr/bin/mysqlrepair" + dosym "mysqlcheck" "/usr/bin/mysqloptimize" + + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir + if [[ -d "${ED}/usr/data" ]] ; then + rm -Rf "${ED}/usr/data" || die + fi + + if [[ -d "${ED%/}/usr/sql-bench" ]] ; then + mv "${ED%/}/usr/sql-bench" "${ED%/}/usr/share/mysql/" || die + fi + + # Unless they explicitly specific USE=test, then do not install the + # testsuite. It DOES have a use to be installed, esp. when you want to do a + # validation of your database configuration after tuning it. + if ! use test ; then + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" + fi + + # Configuration stuff + einfo "Building default configuration ..." + insinto "${MY_SYSCONFDIR#${EPREFIX}}" + [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf + local mycnf_src="my.cnf-5.6" + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ + "${FILESDIR%/}/${mycnf_src}" \ + > "${TMPDIR%/}/my.cnf.ok" || die + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok" + if use latin1 ; then + sed -i \ + -e "/character-set/s|utf8|latin1|g" \ + "${TMPDIR%/}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR%/}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" my.cnf + + if use server ; then + einfo "Including support files and sample configurations" + docinto "support-files" + local script + for script in \ + "${S}"/support-files/magic + do + [[ -f "$script" ]] && dodoc "${script}" + done + + docinto "scripts" + for script in "${S}"/scripts/mysql* ; do + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}" + done + fi + + #Remove mytop if perl is not selected + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" +} + +# Official test instructions: +# USE='perl server static-libs' \ +# FEATURES='test userpriv -usersandbox' \ +# ebuild mysql-X.X.XX.ebuild \ +# digest clean package +src_test() { + + _disable_test() { + local rawtestname reason + rawtestname="${1}" ; shift + reason="${@}" + ewarn "test '${rawtestname}' disabled: '${reason}'" + echo ${rawtestname} : ${reason} >> "${T}/disabled.def" + } + + local TESTDIR="${BUILD_DIR}/mysql-test" + local retstatus_unit + local retstatus_tests + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + # Bug #213475 - MySQL _will_ object strenously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if [[ $UID -eq 0 ]]; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox" + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake-utils_src_test + retstatus_unit=$? + + # Ensure that parallel runs don't die + export MTR_BUILD_THREAD="$((${RANDOM} % 100))" + # Enable parallel testing, auto will try to detect number of cores + # You may set this by hand. + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased + export MTR_PARALLEL="${MTR_PARALLEL:-auto}" + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + # Run mysql tests + pushd "${TESTDIR}" > /dev/null || die + + touch "${T}/disabled.def" + # These are failing in MySQL 5.6 for now and are believed to be + # false positives: + # + local t + + for t in auth_sec.keyring_udf federated.federated_plugin ; do + _disable_test "$t" "False positives in Gentoo" + done + + if ! use latin1 ; then + for t in \ + binlog.binlog_mysqlbinlog_filter \ + binlog.binlog_statement_insert_delayed \ + funcs_1.is_columns_mysql \ + funcs_1.is_tables_mysql \ + funcs_1.is_triggers \ + main.information_schema \ + main.mysql_client_test \ + main.mysqld--help-notwin \ + perfschema.binlog_edge_mix \ + perfschema.binlog_edge_stmt \ + ; do + _disable_test "$t" "Requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" + done + fi + + if has_version '>=dev-libs/openssl-1.1.0' ; then + # Tests are expecting /dev/null || die + + # Cleanup is important for these testcases. + pkill -9 -f "${S}/ndb" 2>/dev/null + pkill -9 -f "${S}/sql" 2>/dev/null + + local failures="" + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" + + [[ -z "$failures" ]] || die "Test failures: $failures" + einfo "Tests successfully completed" +} + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX%/}/usr/share/mysql"} + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX%/}/etc/mysql"} + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX%/}/var/lib/mysql"} + MY_LOGDIR=${MY_LOGDIR="${EPREFIX%/}/var/log/mysql"} + + if [[ -z "${MY_DATADIR}" ]] ; then + MY_DATADIR="" + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ + | sed -ne '/datadir/s|^--datadir=||p' \ + | tail -n1` + if [[ -z "${MY_DATADIR}" ]] ; then + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ + | sed -e 's/.*=\s*//' \ + | tail -n1` + fi + fi + if [[ -z "${MY_DATADIR}" ]] ; then + MY_DATADIR="${MY_LOCALSTATEDIR}" + einfo "Using default MY_DATADIR" + fi + elog "MySQL MY_DATADIR is ${MY_DATADIR}" + + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then + if [[ -e "${MY_DATADIR}" ]] ; then + # If you get this and you're wondering about it, see bug #207636 + elog "MySQL datadir found in ${MY_DATADIR}" + elog "A new one will not be created." + PREVIOUS_DATADIR="yes" + else + PREVIOUS_DATADIR="no" + fi + export PREVIOUS_DATADIR + fi + else + if [[ ${EBUILD_PHASE} == "config" ]]; then + local new_MY_DATADIR + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ + | sed -ne '/datadir/s|^--datadir=||p' \ + | tail -n1` + + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then + ewarn "MySQL MY_DATADIR has changed" + ewarn "from ${MY_DATADIR}" + ewarn "to ${new_MY_DATADIR}" + MY_DATADIR="${new_MY_DATADIR}" + fi + fi + fi + + export MY_SHAREDSTATEDIR MY_SYSCONFDIR + export MY_LOCALSTATEDIR MY_LOGDIR + export MY_DATADIR +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT%/}"/usr/bin/my_print_defaults + local section="$1" + local flag="--${2}=" + local extra_options="${3}" + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" + } + local old_MY_DATADIR="${MY_DATADIR}" + local old_HOME="${HOME}" + # my_print_defaults needs to read stuff in $HOME/.my.cnf + export HOME=${EPREFIX%/}/root + + # Make sure the vars are correctly initialized + mysql_init_vars + + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" + if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then + die "Minimal builds do NOT include the MySQL server" + fi + + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then + local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}" + MY_DATADIR_s="${MY_DATADIR_s%%/}" + local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}" + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" + + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then + if [[ -d "${MY_DATADIR_s}" ]]; then + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" + else + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ + || die "Moving MY_DATADIR failed" + fi + else + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" + if [[ -d "${MY_DATADIR_s}" ]]; then + ewarn "Attempting to use ${MY_DATADIR_s}" + else + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" + fi + fi + fi + + local pwd1="a" + local pwd2="b" + local maxtry=15 + + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then + local tmp_mysqld_password_source= + + for tmp_mysqld_password_source in mysql client; do + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" + MYSQL_ROOT_PASSWORD= + continue + fi + + einfo "Found password in '${tmp_mysqld_password_source}' section!" + break + fi + done + + # Sometimes --show is required to display passwords in some implementations of my_print_defaults + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" + fi + + unset tmp_mysqld_password_source + fi + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]]; then + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN" + fi + if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]]; then + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG" + fi + + if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then + ewarn "You have already a MySQL database in place." + ewarn "(${ROOT%/}/${MY_DATADIR}/*)" + ewarn "Please rename or delete it if you wish to replace it." + die "MySQL database already exists!" + fi + + # Bug #213475 - MySQL _will_ object strenously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then + + einfo "Please provide a password for the mysql 'root' user now" + einfo "or through the ${HOME}/.my.cnf file." + ewarn "Avoid [\"'\\_%] characters in the password" + read -rsp " >" pwd1 ; echo + + einfo "Retype the password" + read -rsp " >" pwd2 ; echo + + if [[ "x$pwd1" != "x$pwd2" ]] ; then + die "Passwords are not the same" + fi + MYSQL_ROOT_PASSWORD="${pwd1}" + unset pwd1 pwd2 + fi + + local options + local sqltmp="$(emktemp)" + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see http://bugs.mysql.com/bug.php?id=31312 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" + + local help_tables="${EROOT%/}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" + [[ -r "${help_tables}" ]] \ + && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ + || touch "${TMPDIR}/fill_help_tables.sql" + help_tables="${TMPDIR}/fill_help_tables.sql" + + # Figure out which options we need to disable to do the setup + local helpfile="${TMPDIR%/}/mysqld-help" + "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null + for opt in host-cache name-resolve networking slave-start \ + federated ssl log-bin relay-log slow-query-log external-locking \ + log-slave-updates \ + ; do + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" + done + + einfo "Creating the mysql database and setting proper permissions on it ..." + + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it + PID_DIR="${EROOT%/}/var/run/mysqld" + if [[ ! -d "${PID_DIR}" ]]; then + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory" + fi + + if [[ ! -d "${MY_DATADIR}" ]]; then + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory" + fi + + pushd "${TMPDIR}" &>/dev/null || die + + # Filling timezones, see + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html + "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null + chown mysql "${sqltmp}" || die + + local cmd=( "${EROOT%/}/usr/share/mysql/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT%/}/usr/bin/mysql_install_db" ) + if [[ -r "${help_tables}" ]] ; then + cat "${help_tables}" >> "${sqltmp}" + fi + cmd+=( "--basedir=${EPREFIX%/}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" ) + einfo "Command: ${cmd[*]}" + su -s /bin/sh -c "${cmd[*]}" mysql \ + >"${TMPDIR%/}"/mysql_install_db.log 2>&1 + if [ $? -ne 0 ]; then + grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2 + die "Failed to initialize mysqld. Please review ${EPREFIX%/}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log" + fi + popd &>/dev/null || die + [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \ + || die "MySQL databases not installed" + + use prefix || options="${options} --user=mysql" + + local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock" + local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid" + local mysqld="${EROOT%/}/usr/sbin/mysqld \ + ${options} \ + $(use prefix || echo --user=mysql) \ + --log-warnings=0 \ + --basedir=${EROOT%/}/usr \ + --datadir=${ROOT%/}/${MY_DATADIR} \ + --max_allowed_packet=8M \ + --net_buffer_length=16K \ + --socket=${socket} \ + --pid-file=${pidfile} \ + --tmpdir=${ROOT}/${MYSQL_TMPDIR}" + #einfo "About to start mysqld: ${mysqld}" + ebegin "Starting mysqld" + einfo "Command ${mysqld}" + ${mysqld} & + rc=$? + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + eend $rc + + if ! [[ -S "${socket}" ]]; then + die "Completely failed to start up mysqld with: ${mysqld}" + fi + + ebegin "Setting root password" + # Do this from memory, as we don't want clear text passwords in temp files + local sql="SET PASSWORD FOR 'root'@'localhost' = PASSWORD('${MYSQL_ROOT_PASSWORD}');" + "${EROOT%/}/usr/bin/mysql" \ + --no-defaults \ + "--socket=${socket}" \ + -hlocalhost \ + -e "${sql}" + eend $? + + if [[ -n "${sqltmp}" ]] ; then + ebegin "Loading \"zoneinfo\", this step may require a few seconds" + "${EROOT%/}/usr/bin/mysql" \ + --socket="${socket}" \ + -hlocalhost \ + -uroot \ + --password="${MYSQL_ROOT_PASSWORD}" \ + mysql < "${sqltmp}" + rc=$? + eend $? + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!" + fi + + # Stop the server and cleanup + einfo "Stopping the server ..." + kill $(< "${pidfile}" ) + rm -f "${sqltmp}" + wait %1 + einfo "Done" +} diff --git a/dev-db/mysql/mysql-5.6.44.ebuild b/dev-db/mysql/mysql-5.6.44.ebuild deleted file mode 100644 index 312951b5e589..000000000000 --- a/dev-db/mysql/mysql-5.6.44.ebuild +++ /dev/null @@ -1,800 +0,0 @@ -# Copyright 1999-2019 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="6" -MY_EXTRAS_VER="20190604-1109Z" - -CMAKE_MAKEFILE_GENERATOR=emake - -# Keeping eutils in EAPI=6 for emktemp in pkg_config - -inherit eutils flag-o-matic prefix toolchain-funcs \ - user cmake-utils multilib-build - -SRC_URI="http://cdn.mysql.com/Downloads/MySQL-5.6/${P}.tar.gz - https://cdn.mysql.com/archives/mysql-5.6/${P}.tar.gz - http://downloads.mysql.com/archives/MySQL-5.6/${P}.tar.gz" - -# Gentoo patches to MySQL -if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then - SRC_URI="${SRC_URI} - mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" -fi - -HOMEPAGE="https://www.mysql.com/" -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" -LICENSE="GPL-2" -SLOT="0/18" -IUSE="client-libs cracklib debug jemalloc latin1 libressl numa +perl profiling selinux - +server static static-libs systemtap tcmalloc test yassl" - -# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests -RESTRICT="libressl? ( test )" - -REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )" - -KEYWORDS="~alpha amd64 arm ~hppa ~ia64 ~mips ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" - -# Shorten the path because the socket path length must be shorter than 107 chars -# and we will run a mysql server during test phase -S="${WORKDIR}/mysql" - -if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then - inherit git-r3 - EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git" - EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras" - EGIT_CLONE_TYPE=shallow - MY_PATCH_DIR="${WORKDIR}/mysql-extras" -else - MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" -fi - -PATCHES=( - "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch - "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch - "${MY_PATCH_DIR}"/20006_all_cmake_elib-mysql-5.6.35.patch - "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch - "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch - "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch - "${MY_PATCH_DIR}"/20018_all_mysql-5.6.25-without-clientlibs-tools.patch - "${MY_PATCH_DIR}"/20027_all_mysql-5.5-perl5.26-includes.patch - "${MY_PATCH_DIR}"/20028_all_mysql-5.6-gcc7.patch - "${MY_PATCH_DIR}"/20031_all_mysql-5.6-fix-monitor.test.patch - "${MY_PATCH_DIR}"/20036_all_mysql-5.6-fix-rpl_semi_sync_shutdown_hang.test.patch - "${MY_PATCH_DIR}"/20018_all_mysql-5.6.44-fix-libressl-support.patch -) - -# Be warned, *DEPEND are version-dependant -# These are used for both runtime and compiletime -COMMON_DEPEND=" - kernel_linux? ( - sys-process/procps:0= - dev-libs/libaio:0= - ) - net-misc/curl - >=sys-apps/sed-4 - >=sys-apps/texinfo-4.7-r1 - jemalloc? ( dev-libs/jemalloc:0= ) - tcmalloc? ( dev-util/google-perftools:0= ) - systemtap? ( >=dev-util/systemtap-1.3:0= ) - !yassl? ( - !libressl? ( =dev-libs/openssl-1.0.2*:0= ) - libressl? ( =dev-libs/libressl-2.6.5*:0= ) - ) - >=sys-libs/zlib-1.2.3:0= - sys-libs/ncurses:0= - server? ( - numa? ( sys-process/numactl ) - ) - !client-libs? ( dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] ) -" -DEPEND="virtual/yacc - static? ( sys-libs/ncurses[static-libs] ) - test? ( dev-perl/JSON ) - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c ) - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - server? ( !prefix? ( dev-db/mysql-init-scripts ) ) - ${COMMON_DEPEND} -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" - -pkg_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on - # non x86{,_64} arches - if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} needs to be built with gcc-4.7 or later." - eerror "Please use gcc-config to switch to gcc-4.7 or later version." - die - fi - fi - if has test ${FEATURES} && \ - use server && ! has userpriv ${FEATURES} ; then - eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - - # This should come after all of the die statements - enewgroup mysql 60 || die "problem adding 'mysql' group" - enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" -} - -pkg_preinst() { - # Here we need to see if the implementation switched client libraries - # We check if this is a new instance of the package and a client library already exists - local SHOW_ABI_MESSAGE libpath - if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so" ]] ; then - libpath=$(readlink "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so") - elog "Due to ABI changes when switching between different client libraries," - elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." - elog "Please run: revdep-rebuild --library ${libpath}" - ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" - fi -} - -pkg_postinst() { - # Make sure the vars are correctly initialized - mysql_init_vars - - # Create log directory securely if it does not exist - [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" - - if use server ; then - if [[ -z "${REPLACING_VERSIONS}" ]] ; then - einfo - elog "You might want to run:" - elog "\"emerge --config =${CATEGORY}/${PF}\"" - elog "if this is a new install." - elog - elog "If you are switching server implentations, you should run the" - elog "mysql_upgrade tool." - einfo - else - einfo - elog "If you are upgrading major versions, you should run the" - elog "mysql_upgrade tool." - einfo - fi - fi -} - -src_unpack() { - unpack ${A} - # Grab the patches - [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack - - mv -f "${WORKDIR}/${P}" "${S}" || die -} - -src_prepare() { - _disable_engine() { - echo > "${S%/}/storage/${1}/CMakeLists.txt" || die - } - - _disable_plugin() { - echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die - } - - if use jemalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - if use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux - if [[ -d "${S}/support-files/SELinux" ]] ; then - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die - fi - - if use libressl ; then - sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \ - "${S}/cmake/ssl.cmake" || die - fi - - sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die - - local plugin - local server_plugins=( semisync ) - local test_plugins=( audit_null daemon_example fulltext ) - if ! use server; then # These plugins are for the server - for plugin in "${server_plugins[@]}" ; do - _disable_plugin "${plugin}" - done - fi - - if ! use test; then # These plugins are only used during testing - for plugin in "${test_plugins[@]}" ; do - _disable_plugin "${plugin}" - done - fi - - # Don't build example - _disable_engine example - _disable_engine ndb - _disable_plugin innodb_memcached - - cmake-utils_src_prepare -} - -src_configure(){ - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - append-cxxflags -felide-constructors - - # bug #283926, with GCC4.4, this is required to get correct behavior. - append-flags -fno-strict-aliasing - - CMAKE_BUILD_TYPE="RelWithDebInfo" - - # debug hack wrt #497532 - mycmakeargs=( - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" - -DSYSCONFDIR="${EPREFIX}/etc/mysql" - -DINSTALL_BINDIR=bin - -DINSTALL_DOCDIR=share/doc/${PF} - -DINSTALL_DOCREADMEDIR=share/doc/${PF} - -DINSTALL_INCLUDEDIR=include/mysql - -DINSTALL_INFODIR=share/info - -DINSTALL_LIBDIR=$(get_libdir) - -DINSTALL_MANDIR=share/man - -DINSTALL_MYSQLSHAREDIR=share/mysql - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin - -DINSTALL_SCRIPTDIR=share/mysql/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - ### TODO: make this system but issues with UTF-8 prevent it - -DWITH_EDITLINE=bundled - -DWITH_ZLIB=system - -DWITH_LIBWRAP=0 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - # The build forces this to be defined when cross-compiling. We pass it - # all the time for simplicity and to make sure it is actually correct. - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) - -DWITH_LIBEVENT=NO - -DWITHOUT_CLIENTLIBS=YES - -DENABLE_DTRACE=$(usex systemtap) - -DWITH_SSL=$(usex yassl bundled system) - -DINSTALL_MYSQLTESTDIR=$(usex test 'share/mysql/mysql-test' '') - -DWITHOUT_VALIDATE_PASSWORD=1 - ) - - if use server ; then - - if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." - ewarn "You MUST file bugs without these variables set." - - mycmakeargs+=( - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} - ) - - elif ! use latin1 ; then - mycmakeargs+=( - -DDEFAULT_CHARSET=utf8 - -DDEFAULT_COLLATION=utf8_general_ci - ) - else - mycmakeargs+=( - -DDEFAULT_CHARSET=latin1 - -DDEFAULT_COLLATION=latin1_swedish_ci - ) - fi - mycmakeargs+=( - -DWITH_NUMA=$(usex numa ON OFF) - -DEXTRA_CHARSETS=all - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - ) - - if use profiling ; then - # Setting to OFF doesn't work: Once set, profiling options will be added - # to `mysqld --help` output via sql/sys_vars.cc causing - # "main.mysqld--help-notwin" test to fail - mycmakeargs+=( -DENABLED_PROFILING=ON ) - fi - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - # Storage engines - mycmakeargs+=( - -DWITH_ARCHIVE_STORAGE_ENGINE=1 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 - -DWITH_CSV_STORAGE_ENGINE=1 - -DWITH_HEAP_STORAGE_ENGINE=1 - -DWITH_INNOBASE_STORAGE_ENGINE=1 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1 - -DWITH_MYISAM_STORAGE_ENGINE=1 - -DWITH_PARTITION_STORAGE_ENGINE=1 - -DWITH_INNODB_MEMCACHED=0 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - ) - fi - - cmake-utils_src_configure -} - -src_compile() { - cmake-utils_src_compile -} - -src_install() { - cmake-utils_src_install - - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die - # Make sure the vars are correctly initialized - mysql_init_vars - - # Convenience links - einfo "Making Convenience links for mysqlcheck multi-call binary" - dosym "mysqlcheck" "/usr/bin/mysqlanalyze" - dosym "mysqlcheck" "/usr/bin/mysqlrepair" - dosym "mysqlcheck" "/usr/bin/mysqloptimize" - - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir - if [[ -d "${ED}/usr/data" ]] ; then - rm -Rf "${ED}/usr/data" || die - fi - - # Unless they explicitly specific USE=test, then do not install the - # testsuite. It DOES have a use to be installed, esp. when you want to do a - # validation of your database configuration after tuning it. - if ! use test ; then - rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" - fi - - # Configuration stuff - einfo "Building default configuration ..." - insinto "${MY_SYSCONFDIR#${EPREFIX}}" - [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf - local mycnf_src="my.cnf-5.6" - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ - "${FILESDIR%/}/${mycnf_src}" \ - > "${TMPDIR%/}/my.cnf.ok" || die - use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok" - if use latin1 ; then - sed -i \ - -e "/character-set/s|utf8|latin1|g" \ - "${TMPDIR%/}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR%/}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" my.cnf - - if use server ; then - einfo "Including support files and sample configurations" - docinto "support-files" - local script - for script in \ - "${S}"/support-files/magic - do - [[ -f "$script" ]] && dodoc "${script}" - done - - docinto "scripts" - for script in "${S}"/scripts/mysql* ; do - [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}" - done - fi - - #Remove mytop if perl is not selected - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" -} - -# Official test instructions: -# USE='perl server static-libs' \ -# FEATURES='test userpriv -usersandbox' \ -# ebuild mysql-X.X.XX.ebuild \ -# digest clean package -src_test() { - - _disable_test() { - local rawtestname reason - rawtestname="${1}" ; shift - reason="${@}" - ewarn "test '${rawtestname}' disabled: '${reason}'" - echo ${rawtestname} : ${reason} >> "${T}/disabled.def" - } - - local TESTDIR="${BUILD_DIR}/mysql-test" - local retstatus_unit - local retstatus_tests - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [[ $UID -eq 0 ]]; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox" - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake-utils_src_test - retstatus_unit=$? - - # Ensure that parallel runs don't die - export MTR_BUILD_THREAD="$((${RANDOM} % 100))" - # Enable parallel testing, auto will try to detect number of cores - # You may set this by hand. - # The default maximum is 8 unless MTR_MAX_PARALLEL is increased - export MTR_PARALLEL="${MTR_PARALLEL:-auto}" - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - # Run mysql tests - pushd "${TESTDIR}" > /dev/null || die - - touch "${T}/disabled.def" - # These are failing in MySQL 5.6 for now and are believed to be - # false positives: - # - local t - - for t in auth_sec.keyring_udf federated.federated_plugin ; do - _disable_test "$t" "False positives in Gentoo" - done - - # Bad test definition - _disable_test main.mysqldump "Test fails after 2018-12-31 with new warnings" - - # run mysql-test tests - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" - retstatus_tests=$? - - popd > /dev/null || die - - # Cleanup is important for these testcases. - pkill -9 -f "${S}/ndb" 2>/dev/null - pkill -9 -f "${S}/sql" 2>/dev/null - - local failures="" - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" - - [[ -z "$failures" ]] || die "Test failures: $failures" - einfo "Tests successfully completed" -} - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX%/}/usr/share/mysql"} - MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX%/}/etc/mysql"} - MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX%/}/var/lib/mysql"} - MY_LOGDIR=${MY_LOGDIR="${EPREFIX%/}/var/log/mysql"} - - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR="" - if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then - MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ - | sed -ne '/datadir/s|^--datadir=||p' \ - | tail -n1` - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ - | sed -e 's/.*=\s*//' \ - | tail -n1` - fi - fi - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR="${MY_LOCALSTATEDIR}" - einfo "Using default MY_DATADIR" - fi - elog "MySQL MY_DATADIR is ${MY_DATADIR}" - - if [[ -z "${PREVIOUS_DATADIR}" ]] ; then - if [[ -e "${MY_DATADIR}" ]] ; then - # If you get this and you're wondering about it, see bug #207636 - elog "MySQL datadir found in ${MY_DATADIR}" - elog "A new one will not be created." - PREVIOUS_DATADIR="yes" - else - PREVIOUS_DATADIR="no" - fi - export PREVIOUS_DATADIR - fi - else - if [[ ${EBUILD_PHASE} == "config" ]]; then - local new_MY_DATADIR - new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ - | sed -ne '/datadir/s|^--datadir=||p' \ - | tail -n1` - - if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then - ewarn "MySQL MY_DATADIR has changed" - ewarn "from ${MY_DATADIR}" - ewarn "to ${new_MY_DATADIR}" - MY_DATADIR="${new_MY_DATADIR}" - fi - fi - fi - - export MY_SHAREDSTATEDIR MY_SYSCONFDIR - export MY_LOCALSTATEDIR MY_LOGDIR - export MY_DATADIR -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT%/}"/usr/bin/my_print_defaults - local section="$1" - local flag="--${2}=" - local extra_options="${3}" - "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" - } - local old_MY_DATADIR="${MY_DATADIR}" - local old_HOME="${HOME}" - # my_print_defaults needs to read stuff in $HOME/.my.cnf - export HOME=${EPREFIX%/}/root - - # Make sure the vars are correctly initialized - mysql_init_vars - - [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" - if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then - die "Minimal builds do NOT include the MySQL server" - fi - - if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then - local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}" - MY_DATADIR_s="${MY_DATADIR_s%%/}" - local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}" - old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" - - if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then - if [[ -d "${MY_DATADIR_s}" ]]; then - ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" - ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" - else - elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" - mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ - || die "Moving MY_DATADIR failed" - fi - else - ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" - if [[ -d "${MY_DATADIR_s}" ]]; then - ewarn "Attempting to use ${MY_DATADIR_s}" - else - eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" - die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" - fi - fi - fi - - local pwd1="a" - local pwd2="b" - local maxtry=15 - - if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then - local tmp_mysqld_password_source= - - for tmp_mysqld_password_source in mysql client; do - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" - MYSQL_ROOT_PASSWORD= - continue - fi - - einfo "Found password in '${tmp_mysqld_password_source}' section!" - break - fi - done - - # Sometimes --show is required to display passwords in some implementations of my_print_defaults - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" - fi - - unset tmp_mysqld_password_source - fi - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]]; then - einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" - install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN" - fi - if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]]; then - einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" - install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG" - fi - - if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then - ewarn "You have already a MySQL database in place." - ewarn "(${ROOT%/}/${MY_DATADIR}/*)" - ewarn "Please rename or delete it if you wish to replace it." - die "MySQL database already exists!" - fi - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then - - einfo "Please provide a password for the mysql 'root' user now" - einfo "or through the ${HOME}/.my.cnf file." - ewarn "Avoid [\"'\\_%] characters in the password" - read -rsp " >" pwd1 ; echo - - einfo "Retype the password" - read -rsp " >" pwd2 ; echo - - if [[ "x$pwd1" != "x$pwd2" ]] ; then - die "Passwords are not the same" - fi - MYSQL_ROOT_PASSWORD="${pwd1}" - unset pwd1 pwd2 - fi - - local options - local sqltmp="$(emktemp)" - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see http://bugs.mysql.com/bug.php?id=31312 - use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" - - local help_tables="${EROOT%/}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" - [[ -r "${help_tables}" ]] \ - && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ - || touch "${TMPDIR}/fill_help_tables.sql" - help_tables="${TMPDIR}/fill_help_tables.sql" - - # Figure out which options we need to disable to do the setup - local helpfile="${TMPDIR%/}/mysqld-help" - "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null - for opt in host-cache name-resolve networking slave-start \ - federated ssl log-bin relay-log slow-query-log external-locking \ - log-slave-updates \ - ; do - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" - egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" - done - - einfo "Creating the mysql database and setting proper permissions on it ..." - - # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it - PID_DIR="${EROOT%/}/var/run/mysqld" - if [[ ! -d "${PID_DIR}" ]]; then - install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory" - fi - - if [[ ! -d "${MY_DATADIR}" ]]; then - install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory" - fi - - pushd "${TMPDIR}" &>/dev/null || die - - # Filling timezones, see - # http://dev.mysql.com/doc/mysql/en/time-zone-support.html - "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null - chown mysql "${sqltmp}" || die - - local cmd=( "${EROOT%/}/usr/share/mysql/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT%/}/usr/bin/mysql_install_db" ) - if [[ -r "${help_tables}" ]] ; then - cat "${help_tables}" >> "${sqltmp}" - fi - cmd+=( "--basedir=${EPREFIX%/}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" ) - einfo "Command: ${cmd[*]}" - su -s /bin/sh -c "${cmd[*]}" mysql \ - >"${TMPDIR%/}"/mysql_install_db.log 2>&1 - if [ $? -ne 0 ]; then - grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2 - die "Failed to initialize mysqld. Please review ${EPREFIX%/}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log" - fi - popd &>/dev/null || die - [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \ - || die "MySQL databases not installed" - - use prefix || options="${options} --user=mysql" - - local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock" - local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid" - local mysqld="${EROOT%/}/usr/sbin/mysqld \ - ${options} \ - $(use prefix || echo --user=mysql) \ - --log-warnings=0 \ - --basedir=${EROOT%/}/usr \ - --datadir=${ROOT%/}/${MY_DATADIR} \ - --max_allowed_packet=8M \ - --net_buffer_length=16K \ - --socket=${socket} \ - --pid-file=${pidfile} \ - --tmpdir=${ROOT}/${MYSQL_TMPDIR}" - #einfo "About to start mysqld: ${mysqld}" - ebegin "Starting mysqld" - einfo "Command ${mysqld}" - ${mysqld} & - rc=$? - while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - eend $rc - - if ! [[ -S "${socket}" ]]; then - die "Completely failed to start up mysqld with: ${mysqld}" - fi - - ebegin "Setting root password" - # Do this from memory, as we don't want clear text passwords in temp files - local sql="SET PASSWORD FOR 'root'@'localhost' = PASSWORD('${MYSQL_ROOT_PASSWORD}');" - "${EROOT%/}/usr/bin/mysql" \ - --no-defaults \ - "--socket=${socket}" \ - -hlocalhost \ - -e "${sql}" - eend $? - - if [[ -n "${sqltmp}" ]] ; then - ebegin "Loading \"zoneinfo\", this step may require a few seconds" - "${EROOT%/}/usr/bin/mysql" \ - --socket="${socket}" \ - -hlocalhost \ - -uroot \ - --password="${MYSQL_ROOT_PASSWORD}" \ - mysql < "${sqltmp}" - rc=$? - eend $? - [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!" - fi - - # Stop the server and cleanup - einfo "Stopping the server ..." - kill $(< "${pidfile}" ) - rm -f "${sqltmp}" - wait %1 - einfo "Done" -} diff --git a/dev-db/mysql/mysql-5.6.45-r1.ebuild b/dev-db/mysql/mysql-5.6.45-r1.ebuild new file mode 100644 index 000000000000..dfea0d2a2a47 --- /dev/null +++ b/dev-db/mysql/mysql-5.6.45-r1.ebuild @@ -0,0 +1,843 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="6" +MY_EXTRAS_VER="20190817-0024Z" + +CMAKE_MAKEFILE_GENERATOR=emake + +# Keeping eutils in EAPI=6 for emktemp in pkg_config + +inherit eutils flag-o-matic prefix toolchain-funcs \ + user cmake-utils multilib-build + +SRC_URI="http://cdn.mysql.com/Downloads/MySQL-5.6/${P}.tar.gz + https://cdn.mysql.com/archives/mysql-5.6/${P}.tar.gz + http://downloads.mysql.com/archives/MySQL-5.6/${P}.tar.gz" + +# Gentoo patches to MySQL +if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then + SRC_URI="${SRC_URI} + mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 + https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" +fi + +HOMEPAGE="https://www.mysql.com/" +DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" +LICENSE="GPL-2" +SLOT="0/18" +IUSE="client-libs cracklib debug jemalloc latin1 libressl numa +perl profiling selinux + +server static static-libs systemtap tcmalloc test yassl" + +# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests +RESTRICT="libressl? ( test )" + +REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )" + +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" + +# Shorten the path because the socket path length must be shorter than 107 chars +# and we will run a mysql server during test phase +S="${WORKDIR}/mysql" + +if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then + inherit git-r3 + EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git" + EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras" + EGIT_CLONE_TYPE=shallow + MY_PATCH_DIR="${WORKDIR}/mysql-extras" +else + MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" +fi + +PATCHES=( + "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch + "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch + "${MY_PATCH_DIR}"/20006_all_cmake_elib-mysql-5.6.35.patch + "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch + "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch + "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch + "${MY_PATCH_DIR}"/20018_all_mysql-5.6.25-without-clientlibs-tools.patch + "${MY_PATCH_DIR}"/20027_all_mysql-5.5-perl5.26-includes.patch + "${MY_PATCH_DIR}"/20031_all_mysql-5.6-fix-monitor.test.patch + "${MY_PATCH_DIR}"/20036_all_mysql-5.6-fix-rpl_semi_sync_shutdown_hang.test.patch + "${MY_PATCH_DIR}"/20018_all_mysql-5.6.44-fix-libressl-support.patch + "${MY_PATCH_DIR}"/20018_all_mysql-5.6.44-add-openssl-1.1-support.patch +) + +# Be warned, *DEPEND are version-dependant +# These are used for both runtime and compiletime +COMMON_DEPEND=" + kernel_linux? ( + sys-process/procps:0= + dev-libs/libaio:0= + ) + net-misc/curl + >=sys-apps/sed-4 + >=sys-apps/texinfo-4.7-r1 + jemalloc? ( dev-libs/jemalloc:0= ) + tcmalloc? ( dev-util/google-perftools:0= ) + systemtap? ( >=dev-util/systemtap-1.3:0= ) + !yassl? ( + !libressl? ( >=dev-libs/openssl-1.0.0:0= ) + libressl? ( =dev-libs/libressl-2.6.5*:0= ) + ) + >=sys-libs/zlib-1.2.3:0= + sys-libs/ncurses:0= + server? ( + numa? ( sys-process/numactl ) + ) + !client-libs? ( dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] ) +" +DEPEND="virtual/yacc + static? ( sys-libs/ncurses[static-libs] ) + test? ( dev-perl/JSON ) + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c ) + !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + server? ( !prefix? ( dev-db/mysql-init-scripts ) ) + ${COMMON_DEPEND} +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" + +pkg_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on + # non x86{,_64} arches + if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} needs to be built with gcc-4.7 or later." + eerror "Please use gcc-config to switch to gcc-4.7 or later version." + die + fi + fi + if has test ${FEATURES} && \ + use server && ! has userpriv ${FEATURES} ; then + eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + + # This should come after all of the die statements + enewgroup mysql 60 || die "problem adding 'mysql' group" + enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" +} + +pkg_preinst() { + # Here we need to see if the implementation switched client libraries + # We check if this is a new instance of the package and a client library already exists + local SHOW_ABI_MESSAGE libpath + if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so" ]] ; then + libpath=$(readlink "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so") + elog "Due to ABI changes when switching between different client libraries," + elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." + elog "Please run: revdep-rebuild --library ${libpath}" + ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" + fi +} + +pkg_postinst() { + # Make sure the vars are correctly initialized + mysql_init_vars + + # Create log directory securely if it does not exist + [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" + + if use server ; then + if [[ -z "${REPLACING_VERSIONS}" ]] ; then + einfo + elog "You might want to run:" + elog "\"emerge --config =${CATEGORY}/${PF}\"" + elog "if this is a new install." + elog + elog "If you are switching server implentations, you should run the" + elog "mysql_upgrade tool." + einfo + else + einfo + elog "If you are upgrading major versions, you should run the" + elog "mysql_upgrade tool." + einfo + fi + fi +} + +src_unpack() { + unpack ${A} + # Grab the patches + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack + + mv -f "${WORKDIR}/${P}" "${S}" || die +} + +src_prepare() { + _disable_engine() { + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die + } + + _disable_plugin() { + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die + } + + if use jemalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + if use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux + if [[ -d "${S}/support-files/SELinux" ]] ; then + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die + fi + + # Don't clash with dev-db/mysql-connector-c + rm \ + man/my_print_defaults.1 \ + man/perror.1 \ + || die + + if use libressl ; then + sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \ + "${S}/cmake/ssl.cmake" || die + fi + + sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die + + local plugin + local server_plugins=( semisync ) + local test_plugins=( audit_null daemon_example fulltext ) + if ! use server; then # These plugins are for the server + for plugin in "${server_plugins[@]}" ; do + _disable_plugin "${plugin}" + done + fi + + if ! use test; then # These plugins are only used during testing + for plugin in "${test_plugins[@]}" ; do + _disable_plugin "${plugin}" + done + fi + + # Don't build example + _disable_engine example + _disable_engine ndb + _disable_plugin innodb_memcached + + cmake-utils_src_prepare +} + +src_configure(){ + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + append-cxxflags -felide-constructors + + # bug #283926, with GCC4.4, this is required to get correct behavior. + append-flags -fno-strict-aliasing + + CMAKE_BUILD_TYPE="RelWithDebInfo" + + # debug hack wrt #497532 + mycmakeargs=( + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" + -DSYSCONFDIR="${EPREFIX}/etc/mysql" + -DINSTALL_BINDIR=bin + -DINSTALL_DOCDIR=share/doc/${PF} + -DINSTALL_DOCREADMEDIR=share/doc/${PF} + -DINSTALL_INCLUDEDIR=include/mysql + -DINSTALL_INFODIR=share/info + -DINSTALL_LIBDIR=$(get_libdir) + -DINSTALL_MANDIR=share/man + -DINSTALL_MYSQLSHAREDIR=share/mysql + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin + -DINSTALL_SCRIPTDIR=share/mysql/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + ### TODO: make this system but issues with UTF-8 prevent it + -DWITH_EDITLINE=bundled + -DWITH_ZLIB=system + -DWITH_LIBWRAP=0 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + # The build forces this to be defined when cross-compiling. We pass it + # all the time for simplicity and to make sure it is actually correct. + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) + -DWITH_LIBEVENT=NO + -DWITHOUT_CLIENTLIBS=YES + -DENABLE_DTRACE=$(usex systemtap) + -DWITH_SSL=$(usex yassl bundled system) + -DINSTALL_MYSQLTESTDIR=$(usex test 'share/mysql/mysql-test' '') + -DWITHOUT_VALIDATE_PASSWORD=1 + ) + + if use server ; then + + if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." + ewarn "You MUST file bugs without these variables set." + + mycmakeargs+=( + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} + ) + + elif ! use latin1 ; then + mycmakeargs+=( + -DDEFAULT_CHARSET=utf8 + -DDEFAULT_COLLATION=utf8_general_ci + ) + else + mycmakeargs+=( + -DDEFAULT_CHARSET=latin1 + -DDEFAULT_COLLATION=latin1_swedish_ci + ) + fi + mycmakeargs+=( + -DWITH_NUMA=$(usex numa ON OFF) + -DEXTRA_CHARSETS=all + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + ) + + if use profiling ; then + # Setting to OFF doesn't work: Once set, profiling options will be added + # to `mysqld --help` output via sql/sys_vars.cc causing + # "main.mysqld--help-notwin" test to fail + mycmakeargs+=( -DENABLED_PROFILING=ON ) + fi + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + # Storage engines + mycmakeargs+=( + -DWITH_ARCHIVE_STORAGE_ENGINE=1 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 + -DWITH_CSV_STORAGE_ENGINE=1 + -DWITH_HEAP_STORAGE_ENGINE=1 + -DWITH_INNOBASE_STORAGE_ENGINE=1 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1 + -DWITH_MYISAM_STORAGE_ENGINE=1 + -DWITH_PARTITION_STORAGE_ENGINE=1 + -DWITH_INNODB_MEMCACHED=0 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + ) + fi + + cmake-utils_src_configure +} + +src_compile() { + cmake-utils_src_compile +} + +src_install() { + cmake-utils_src_install + + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die + # Make sure the vars are correctly initialized + mysql_init_vars + + # Convenience links + einfo "Making Convenience links for mysqlcheck multi-call binary" + dosym "mysqlcheck" "/usr/bin/mysqlanalyze" + dosym "mysqlcheck" "/usr/bin/mysqlrepair" + dosym "mysqlcheck" "/usr/bin/mysqloptimize" + + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir + if [[ -d "${ED}/usr/data" ]] ; then + rm -Rf "${ED}/usr/data" || die + fi + + if [[ -d "${ED%/}/usr/sql-bench" ]] ; then + mv "${ED%/}/usr/sql-bench" "${ED%/}/usr/share/mysql/" || die + fi + + # Unless they explicitly specific USE=test, then do not install the + # testsuite. It DOES have a use to be installed, esp. when you want to do a + # validation of your database configuration after tuning it. + if ! use test ; then + rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" + fi + + # Configuration stuff + einfo "Building default configuration ..." + insinto "${MY_SYSCONFDIR#${EPREFIX}}" + [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf + local mycnf_src="my.cnf-5.6" + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ + "${FILESDIR%/}/${mycnf_src}" \ + > "${TMPDIR%/}/my.cnf.ok" || die + use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok" + if use latin1 ; then + sed -i \ + -e "/character-set/s|utf8|latin1|g" \ + "${TMPDIR%/}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR%/}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" my.cnf + + if use server ; then + einfo "Including support files and sample configurations" + docinto "support-files" + local script + for script in \ + "${S}"/support-files/magic + do + [[ -f "$script" ]] && dodoc "${script}" + done + + docinto "scripts" + for script in "${S}"/scripts/mysql* ; do + [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}" + done + fi + + #Remove mytop if perl is not selected + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" +} + +# Official test instructions: +# USE='perl server static-libs' \ +# FEATURES='test userpriv -usersandbox' \ +# ebuild mysql-X.X.XX.ebuild \ +# digest clean package +src_test() { + + _disable_test() { + local rawtestname reason + rawtestname="${1}" ; shift + reason="${@}" + ewarn "test '${rawtestname}' disabled: '${reason}'" + echo ${rawtestname} : ${reason} >> "${T}/disabled.def" + } + + local TESTDIR="${BUILD_DIR}/mysql-test" + local retstatus_unit + local retstatus_tests + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + # Bug #213475 - MySQL _will_ object strenously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if [[ $UID -eq 0 ]]; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox" + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake-utils_src_test + retstatus_unit=$? + + # Ensure that parallel runs don't die + export MTR_BUILD_THREAD="$((${RANDOM} % 100))" + # Enable parallel testing, auto will try to detect number of cores + # You may set this by hand. + # The default maximum is 8 unless MTR_MAX_PARALLEL is increased + export MTR_PARALLEL="${MTR_PARALLEL:-auto}" + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + # Run mysql tests + pushd "${TESTDIR}" > /dev/null || die + + touch "${T}/disabled.def" + # These are failing in MySQL 5.6 for now and are believed to be + # false positives: + # + local t + + for t in auth_sec.keyring_udf federated.federated_plugin ; do + _disable_test "$t" "False positives in Gentoo" + done + + if ! use latin1 ; then + for t in \ + binlog.binlog_mysqlbinlog_filter \ + binlog.binlog_statement_insert_delayed \ + funcs_1.is_columns_mysql \ + funcs_1.is_tables_mysql \ + funcs_1.is_triggers \ + main.information_schema \ + main.mysql_client_test \ + main.mysqld--help-notwin \ + perfschema.binlog_edge_mix \ + perfschema.binlog_edge_stmt \ + ; do + _disable_test "$t" "Requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" + done + fi + + if has_version '>=dev-libs/openssl-1.1.0' ; then + # Tests are expecting /dev/null || die + + # Cleanup is important for these testcases. + pkill -9 -f "${S}/ndb" 2>/dev/null + pkill -9 -f "${S}/sql" 2>/dev/null + + local failures="" + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" + + [[ -z "$failures" ]] || die "Test failures: $failures" + einfo "Tests successfully completed" +} + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX%/}/usr/share/mysql"} + MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX%/}/etc/mysql"} + MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX%/}/var/lib/mysql"} + MY_LOGDIR=${MY_LOGDIR="${EPREFIX%/}/var/log/mysql"} + + if [[ -z "${MY_DATADIR}" ]] ; then + MY_DATADIR="" + if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then + MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ + | sed -ne '/datadir/s|^--datadir=||p' \ + | tail -n1` + if [[ -z "${MY_DATADIR}" ]] ; then + MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ + | sed -e 's/.*=\s*//' \ + | tail -n1` + fi + fi + if [[ -z "${MY_DATADIR}" ]] ; then + MY_DATADIR="${MY_LOCALSTATEDIR}" + einfo "Using default MY_DATADIR" + fi + elog "MySQL MY_DATADIR is ${MY_DATADIR}" + + if [[ -z "${PREVIOUS_DATADIR}" ]] ; then + if [[ -e "${MY_DATADIR}" ]] ; then + # If you get this and you're wondering about it, see bug #207636 + elog "MySQL datadir found in ${MY_DATADIR}" + elog "A new one will not be created." + PREVIOUS_DATADIR="yes" + else + PREVIOUS_DATADIR="no" + fi + export PREVIOUS_DATADIR + fi + else + if [[ ${EBUILD_PHASE} == "config" ]]; then + local new_MY_DATADIR + new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ + | sed -ne '/datadir/s|^--datadir=||p' \ + | tail -n1` + + if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then + ewarn "MySQL MY_DATADIR has changed" + ewarn "from ${MY_DATADIR}" + ewarn "to ${new_MY_DATADIR}" + MY_DATADIR="${new_MY_DATADIR}" + fi + fi + fi + + export MY_SHAREDSTATEDIR MY_SYSCONFDIR + export MY_LOCALSTATEDIR MY_LOGDIR + export MY_DATADIR +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT%/}"/usr/bin/my_print_defaults + local section="$1" + local flag="--${2}=" + local extra_options="${3}" + "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" + } + local old_MY_DATADIR="${MY_DATADIR}" + local old_HOME="${HOME}" + # my_print_defaults needs to read stuff in $HOME/.my.cnf + export HOME=${EPREFIX%/}/root + + # Make sure the vars are correctly initialized + mysql_init_vars + + [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" + if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then + die "Minimal builds do NOT include the MySQL server" + fi + + if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then + local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}" + MY_DATADIR_s="${MY_DATADIR_s%%/}" + local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}" + old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" + + if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then + if [[ -d "${MY_DATADIR_s}" ]]; then + ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" + ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" + else + elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" + mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ + || die "Moving MY_DATADIR failed" + fi + else + ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" + if [[ -d "${MY_DATADIR_s}" ]]; then + ewarn "Attempting to use ${MY_DATADIR_s}" + else + eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" + die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" + fi + fi + fi + + local pwd1="a" + local pwd2="b" + local maxtry=15 + + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then + local tmp_mysqld_password_source= + + for tmp_mysqld_password_source in mysql client; do + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" + MYSQL_ROOT_PASSWORD= + continue + fi + + einfo "Found password in '${tmp_mysqld_password_source}' section!" + break + fi + done + + # Sometimes --show is required to display passwords in some implementations of my_print_defaults + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" + fi + + unset tmp_mysqld_password_source + fi + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]]; then + einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN" + fi + if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]]; then + einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" + install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG" + fi + + if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then + ewarn "You have already a MySQL database in place." + ewarn "(${ROOT%/}/${MY_DATADIR}/*)" + ewarn "Please rename or delete it if you wish to replace it." + die "MySQL database already exists!" + fi + + # Bug #213475 - MySQL _will_ object strenously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then + + einfo "Please provide a password for the mysql 'root' user now" + einfo "or through the ${HOME}/.my.cnf file." + ewarn "Avoid [\"'\\_%] characters in the password" + read -rsp " >" pwd1 ; echo + + einfo "Retype the password" + read -rsp " >" pwd2 ; echo + + if [[ "x$pwd1" != "x$pwd2" ]] ; then + die "Passwords are not the same" + fi + MYSQL_ROOT_PASSWORD="${pwd1}" + unset pwd1 pwd2 + fi + + local options + local sqltmp="$(emktemp)" + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see http://bugs.mysql.com/bug.php?id=31312 + use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" + + local help_tables="${EROOT%/}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" + [[ -r "${help_tables}" ]] \ + && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ + || touch "${TMPDIR}/fill_help_tables.sql" + help_tables="${TMPDIR}/fill_help_tables.sql" + + # Figure out which options we need to disable to do the setup + local helpfile="${TMPDIR%/}/mysqld-help" + "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null + for opt in host-cache name-resolve networking slave-start \ + federated ssl log-bin relay-log slow-query-log external-locking \ + log-slave-updates \ + ; do + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" + egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" + done + + einfo "Creating the mysql database and setting proper permissions on it ..." + + # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it + PID_DIR="${EROOT%/}/var/run/mysqld" + if [[ ! -d "${PID_DIR}" ]]; then + install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory" + fi + + if [[ ! -d "${MY_DATADIR}" ]]; then + install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory" + fi + + pushd "${TMPDIR}" &>/dev/null || die + + # Filling timezones, see + # http://dev.mysql.com/doc/mysql/en/time-zone-support.html + "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null + chown mysql "${sqltmp}" || die + + local cmd=( "${EROOT%/}/usr/share/mysql/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT%/}/usr/bin/mysql_install_db" ) + if [[ -r "${help_tables}" ]] ; then + cat "${help_tables}" >> "${sqltmp}" + fi + cmd+=( "--basedir=${EPREFIX%/}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" ) + einfo "Command: ${cmd[*]}" + su -s /bin/sh -c "${cmd[*]}" mysql \ + >"${TMPDIR%/}"/mysql_install_db.log 2>&1 + if [ $? -ne 0 ]; then + grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2 + die "Failed to initialize mysqld. Please review ${EPREFIX%/}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log" + fi + popd &>/dev/null || die + [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \ + || die "MySQL databases not installed" + + use prefix || options="${options} --user=mysql" + + local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock" + local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid" + local mysqld="${EROOT%/}/usr/sbin/mysqld \ + ${options} \ + $(use prefix || echo --user=mysql) \ + --log-warnings=0 \ + --basedir=${EROOT%/}/usr \ + --datadir=${ROOT%/}/${MY_DATADIR} \ + --max_allowed_packet=8M \ + --net_buffer_length=16K \ + --socket=${socket} \ + --pid-file=${pidfile} \ + --tmpdir=${ROOT}/${MYSQL_TMPDIR}" + #einfo "About to start mysqld: ${mysqld}" + ebegin "Starting mysqld" + einfo "Command ${mysqld}" + ${mysqld} & + rc=$? + while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + eend $rc + + if ! [[ -S "${socket}" ]]; then + die "Completely failed to start up mysqld with: ${mysqld}" + fi + + ebegin "Setting root password" + # Do this from memory, as we don't want clear text passwords in temp files + local sql="SET PASSWORD FOR 'root'@'localhost' = PASSWORD('${MYSQL_ROOT_PASSWORD}');" + "${EROOT%/}/usr/bin/mysql" \ + --no-defaults \ + "--socket=${socket}" \ + -hlocalhost \ + -e "${sql}" + eend $? + + if [[ -n "${sqltmp}" ]] ; then + ebegin "Loading \"zoneinfo\", this step may require a few seconds" + "${EROOT%/}/usr/bin/mysql" \ + --socket="${socket}" \ + -hlocalhost \ + -uroot \ + --password="${MYSQL_ROOT_PASSWORD}" \ + mysql < "${sqltmp}" + rc=$? + eend $? + [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!" + fi + + # Stop the server and cleanup + einfo "Stopping the server ..." + kill $(< "${pidfile}" ) + rm -f "${sqltmp}" + wait %1 + einfo "Done" +} diff --git a/dev-db/mysql/mysql-5.6.45.ebuild b/dev-db/mysql/mysql-5.6.45.ebuild deleted file mode 100644 index 5526aadc9727..000000000000 --- a/dev-db/mysql/mysql-5.6.45.ebuild +++ /dev/null @@ -1,806 +0,0 @@ -# Copyright 1999-2019 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="6" -MY_EXTRAS_VER="20190604-1109Z" - -CMAKE_MAKEFILE_GENERATOR=emake - -# Keeping eutils in EAPI=6 for emktemp in pkg_config - -inherit eutils flag-o-matic prefix toolchain-funcs \ - user cmake-utils multilib-build - -SRC_URI="http://cdn.mysql.com/Downloads/MySQL-5.6/${P}.tar.gz - https://cdn.mysql.com/archives/mysql-5.6/${P}.tar.gz - http://downloads.mysql.com/archives/MySQL-5.6/${P}.tar.gz" - -# Gentoo patches to MySQL -if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]]; then - SRC_URI="${SRC_URI} - mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://dev.gentoo.org/~grknight/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://dev.gentoo.org/~robbat2/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://dev.gentoo.org/~jmbsvicetto/distfiles/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" -fi - -HOMEPAGE="https://www.mysql.com/" -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" -LICENSE="GPL-2" -SLOT="0/18" -IUSE="client-libs cracklib debug jemalloc latin1 libressl numa +perl profiling selinux - +server static static-libs systemtap tcmalloc test yassl" - -# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests -RESTRICT="libressl? ( test )" - -REQUIRED_USE="?? ( tcmalloc jemalloc ) static? ( yassl )" - -KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" - -# Shorten the path because the socket path length must be shorter than 107 chars -# and we will run a mysql server during test phase -S="${WORKDIR}/mysql" - -if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then - inherit git-r3 - EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git" - EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras" - EGIT_CLONE_TYPE=shallow - MY_PATCH_DIR="${WORKDIR}/mysql-extras" -else - MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" -fi - -PATCHES=( - "${MY_PATCH_DIR}"/01050_all_mysql_config_cleanup-5.6.patch - "${MY_PATCH_DIR}"/02040_all_embedded-library-shared-5.5.10.patch - "${MY_PATCH_DIR}"/20006_all_cmake_elib-mysql-5.6.35.patch - "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-5.6.22.patch - "${MY_PATCH_DIR}"/20008_all_mysql-tzinfo-symlink-5.6.37.patch - "${MY_PATCH_DIR}"/20009_all_mysql_myodbc_symbol_fix-5.6.patch - "${MY_PATCH_DIR}"/20018_all_mysql-5.6.25-without-clientlibs-tools.patch - "${MY_PATCH_DIR}"/20027_all_mysql-5.5-perl5.26-includes.patch - "${MY_PATCH_DIR}"/20031_all_mysql-5.6-fix-monitor.test.patch - "${MY_PATCH_DIR}"/20036_all_mysql-5.6-fix-rpl_semi_sync_shutdown_hang.test.patch - "${MY_PATCH_DIR}"/20018_all_mysql-5.6.44-fix-libressl-support.patch -) - -# Be warned, *DEPEND are version-dependant -# These are used for both runtime and compiletime -COMMON_DEPEND=" - kernel_linux? ( - sys-process/procps:0= - dev-libs/libaio:0= - ) - net-misc/curl - >=sys-apps/sed-4 - >=sys-apps/texinfo-4.7-r1 - jemalloc? ( dev-libs/jemalloc:0= ) - tcmalloc? ( dev-util/google-perftools:0= ) - systemtap? ( >=dev-util/systemtap-1.3:0= ) - !yassl? ( - !libressl? ( =dev-libs/openssl-1.0.2*:0= ) - libressl? ( =dev-libs/libressl-2.6.5*:0= ) - ) - >=sys-libs/zlib-1.2.3:0= - sys-libs/ncurses:0= - server? ( - numa? ( sys-process/numactl ) - ) - !client-libs? ( dev-db/mysql-connector-c[${MULTILIB_USEDEP},static-libs?] ) -" -DEPEND="virtual/yacc - static? ( sys-libs/ncurses[static-libs] ) - test? ( dev-perl/JSON ) - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - client-libs? ( !dev-db/mariadb-connector-c[mysqlcompat] !dev-db/mysql-connector-c ) - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - server? ( !prefix? ( dev-db/mysql-init-scripts ) ) - ${COMMON_DEPEND} -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" - -pkg_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - # Bug 565584. InnoDB now requires atomic functions introduced with gcc-4.7 on - # non x86{,_64} arches - if ! use amd64 && ! use x86 && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} needs to be built with gcc-4.7 or later." - eerror "Please use gcc-config to switch to gcc-4.7 or later version." - die - fi - fi - if has test ${FEATURES} && \ - use server && ! has userpriv ${FEATURES} ; then - eerror "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - - # This should come after all of the die statements - enewgroup mysql 60 || die "problem adding 'mysql' group" - enewuser mysql 60 -1 /dev/null mysql || die "problem adding 'mysql' user" -} - -pkg_preinst() { - # Here we need to see if the implementation switched client libraries - # We check if this is a new instance of the package and a client library already exists - local SHOW_ABI_MESSAGE libpath - if use client-libs && [[ -z ${REPLACING_VERSIONS} && -e "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so" ]] ; then - libpath=$(readlink "${EROOT%/}/usr/$(get_libdir)/libmysqlclient.so") - elog "Due to ABI changes when switching between different client libraries," - elog "revdep-rebuild must find and rebuild all packages linking to libmysqlclient." - elog "Please run: revdep-rebuild --library ${libpath}" - ewarn "Failure to run revdep-rebuild may cause issues with other programs or libraries" - fi -} - -pkg_postinst() { - # Make sure the vars are correctly initialized - mysql_init_vars - - # Create log directory securely if it does not exist - [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" - - if use server ; then - if [[ -z "${REPLACING_VERSIONS}" ]] ; then - einfo - elog "You might want to run:" - elog "\"emerge --config =${CATEGORY}/${PF}\"" - elog "if this is a new install." - elog - elog "If you are switching server implentations, you should run the" - elog "mysql_upgrade tool." - einfo - else - einfo - elog "If you are upgrading major versions, you should run the" - elog "mysql_upgrade tool." - einfo - fi - fi -} - -src_unpack() { - unpack ${A} - # Grab the patches - [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack - - mv -f "${WORKDIR}/${P}" "${S}" || die -} - -src_prepare() { - _disable_engine() { - echo > "${S%/}/storage/${1}/CMakeLists.txt" || die - } - - _disable_plugin() { - echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die - } - - if use jemalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - if use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux - if [[ -d "${S}/support-files/SELinux" ]] ; then - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die - fi - - # Don't clash with dev-db/mysql-connector-c - rm \ - man/my_print_defaults.1 \ - man/perror.1 \ - man/zlib_decompress.1 \ - || die - - if use libressl ; then - sed -i 's/OPENSSL_MAJOR_VERSION STREQUAL "1"/OPENSSL_MAJOR_VERSION STREQUAL "2"/' \ - "${S}/cmake/ssl.cmake" || die - fi - - sed -i 's~ADD_SUBDIRECTORY(storage/ndb)~~' CMakeLists.txt || die - - local plugin - local server_plugins=( semisync ) - local test_plugins=( audit_null daemon_example fulltext ) - if ! use server; then # These plugins are for the server - for plugin in "${server_plugins[@]}" ; do - _disable_plugin "${plugin}" - done - fi - - if ! use test; then # These plugins are only used during testing - for plugin in "${test_plugins[@]}" ; do - _disable_plugin "${plugin}" - done - fi - - # Don't build example - _disable_engine example - _disable_engine ndb - _disable_plugin innodb_memcached - - cmake-utils_src_prepare -} - -src_configure(){ - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - append-cxxflags -felide-constructors - - # bug #283926, with GCC4.4, this is required to get correct behavior. - append-flags -fno-strict-aliasing - - CMAKE_BUILD_TYPE="RelWithDebInfo" - - # debug hack wrt #497532 - mycmakeargs=( - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" - -DSYSCONFDIR="${EPREFIX}/etc/mysql" - -DINSTALL_BINDIR=bin - -DINSTALL_DOCDIR=share/doc/${PF} - -DINSTALL_DOCREADMEDIR=share/doc/${PF} - -DINSTALL_INCLUDEDIR=include/mysql - -DINSTALL_INFODIR=share/info - -DINSTALL_LIBDIR=$(get_libdir) - -DINSTALL_MANDIR=share/man - -DINSTALL_MYSQLSHAREDIR=share/mysql - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin - -DINSTALL_SCRIPTDIR=share/mysql/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - ### TODO: make this system but issues with UTF-8 prevent it - -DWITH_EDITLINE=bundled - -DWITH_ZLIB=system - -DWITH_LIBWRAP=0 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - # The build forces this to be defined when cross-compiling. We pass it - # all the time for simplicity and to make sure it is actually correct. - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) - -DWITH_LIBEVENT=NO - -DWITHOUT_CLIENTLIBS=YES - -DENABLE_DTRACE=$(usex systemtap) - -DWITH_SSL=$(usex yassl bundled system) - -DINSTALL_MYSQLTESTDIR=$(usex test 'share/mysql/mysql-test' '') - -DWITHOUT_VALIDATE_PASSWORD=1 - ) - - if use server ; then - - if [[ ( -n ${MYSQL_DEFAULT_CHARSET} ) && ( -n ${MYSQL_DEFAULT_COLLATION} ) ]]; then - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." - ewarn "You MUST file bugs without these variables set." - - mycmakeargs+=( - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} - ) - - elif ! use latin1 ; then - mycmakeargs+=( - -DDEFAULT_CHARSET=utf8 - -DDEFAULT_COLLATION=utf8_general_ci - ) - else - mycmakeargs+=( - -DDEFAULT_CHARSET=latin1 - -DDEFAULT_COLLATION=latin1_swedish_ci - ) - fi - mycmakeargs+=( - -DWITH_NUMA=$(usex numa ON OFF) - -DEXTRA_CHARSETS=all - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - ) - - if use profiling ; then - # Setting to OFF doesn't work: Once set, profiling options will be added - # to `mysqld --help` output via sql/sys_vars.cc causing - # "main.mysqld--help-notwin" test to fail - mycmakeargs+=( -DENABLED_PROFILING=ON ) - fi - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - # Storage engines - mycmakeargs+=( - -DWITH_ARCHIVE_STORAGE_ENGINE=1 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 - -DWITH_CSV_STORAGE_ENGINE=1 - -DWITH_HEAP_STORAGE_ENGINE=1 - -DWITH_INNOBASE_STORAGE_ENGINE=1 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1 - -DWITH_MYISAM_STORAGE_ENGINE=1 - -DWITH_PARTITION_STORAGE_ENGINE=1 - -DWITH_INNODB_MEMCACHED=0 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - ) - fi - - cmake-utils_src_configure -} - -src_compile() { - cmake-utils_src_compile -} - -src_install() { - cmake-utils_src_install - - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die - # Make sure the vars are correctly initialized - mysql_init_vars - - # Convenience links - einfo "Making Convenience links for mysqlcheck multi-call binary" - dosym "mysqlcheck" "/usr/bin/mysqlanalyze" - dosym "mysqlcheck" "/usr/bin/mysqlrepair" - dosym "mysqlcheck" "/usr/bin/mysqloptimize" - - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir - if [[ -d "${ED}/usr/data" ]] ; then - rm -Rf "${ED}/usr/data" || die - fi - - # Unless they explicitly specific USE=test, then do not install the - # testsuite. It DOES have a use to be installed, esp. when you want to do a - # validation of your database configuration after tuning it. - if ! use test ; then - rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" - fi - - # Configuration stuff - einfo "Building default configuration ..." - insinto "${MY_SYSCONFDIR#${EPREFIX}}" - [[ -f "${S%/}/scripts/mysqlaccess.conf" ]] && doins "${S%/}"/scripts/mysqlaccess.conf - local mycnf_src="my.cnf-5.6" - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ - "${FILESDIR%/}/${mycnf_src}" \ - > "${TMPDIR%/}/my.cnf.ok" || die - use prefix && sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' "${TMPDIR%/}/my.cnf.ok" - if use latin1 ; then - sed -i \ - -e "/character-set/s|utf8|latin1|g" \ - "${TMPDIR%/}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR%/}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" my.cnf - - if use server ; then - einfo "Including support files and sample configurations" - docinto "support-files" - local script - for script in \ - "${S}"/support-files/magic - do - [[ -f "$script" ]] && dodoc "${script}" - done - - docinto "scripts" - for script in "${S}"/scripts/mysql* ; do - [[ ( -f "$script" ) && ( "${script%.sh}" == "${script}" ) ]] && dodoc "${script}" - done - fi - - #Remove mytop if perl is not selected - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" -} - -# Official test instructions: -# USE='perl server static-libs' \ -# FEATURES='test userpriv -usersandbox' \ -# ebuild mysql-X.X.XX.ebuild \ -# digest clean package -src_test() { - - _disable_test() { - local rawtestname reason - rawtestname="${1}" ; shift - reason="${@}" - ewarn "test '${rawtestname}' disabled: '${reason}'" - echo ${rawtestname} : ${reason} >> "${T}/disabled.def" - } - - local TESTDIR="${BUILD_DIR}/mysql-test" - local retstatus_unit - local retstatus_tests - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [[ $UID -eq 0 ]]; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox" - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake-utils_src_test - retstatus_unit=$? - - # Ensure that parallel runs don't die - export MTR_BUILD_THREAD="$((${RANDOM} % 100))" - # Enable parallel testing, auto will try to detect number of cores - # You may set this by hand. - # The default maximum is 8 unless MTR_MAX_PARALLEL is increased - export MTR_PARALLEL="${MTR_PARALLEL:-auto}" - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - # Run mysql tests - pushd "${TESTDIR}" > /dev/null || die - - touch "${T}/disabled.def" - # These are failing in MySQL 5.6 for now and are believed to be - # false positives: - # - local t - - for t in auth_sec.keyring_udf federated.federated_plugin ; do - _disable_test "$t" "False positives in Gentoo" - done - - # Bad test definition - _disable_test main.mysqldump "Test fails after 2018-12-31 with new warnings" - - # run mysql-test tests - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" - retstatus_tests=$? - - popd > /dev/null || die - - # Cleanup is important for these testcases. - pkill -9 -f "${S}/ndb" 2>/dev/null - pkill -9 -f "${S}/sql" 2>/dev/null - - local failures="" - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" - - [[ -z "$failures" ]] || die "Test failures: $failures" - einfo "Tests successfully completed" -} - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX%/}/usr/share/mysql"} - MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX%/}/etc/mysql"} - MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX%/}/var/lib/mysql"} - MY_LOGDIR=${MY_LOGDIR="${EPREFIX%/}/var/log/mysql"} - - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR="" - if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then - MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ - | sed -ne '/datadir/s|^--datadir=||p' \ - | tail -n1` - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ - | sed -e 's/.*=\s*//' \ - | tail -n1` - fi - fi - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR="${MY_LOCALSTATEDIR}" - einfo "Using default MY_DATADIR" - fi - elog "MySQL MY_DATADIR is ${MY_DATADIR}" - - if [[ -z "${PREVIOUS_DATADIR}" ]] ; then - if [[ -e "${MY_DATADIR}" ]] ; then - # If you get this and you're wondering about it, see bug #207636 - elog "MySQL datadir found in ${MY_DATADIR}" - elog "A new one will not be created." - PREVIOUS_DATADIR="yes" - else - PREVIOUS_DATADIR="no" - fi - export PREVIOUS_DATADIR - fi - else - if [[ ${EBUILD_PHASE} == "config" ]]; then - local new_MY_DATADIR - new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ - | sed -ne '/datadir/s|^--datadir=||p' \ - | tail -n1` - - if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]]; then - ewarn "MySQL MY_DATADIR has changed" - ewarn "from ${MY_DATADIR}" - ewarn "to ${new_MY_DATADIR}" - MY_DATADIR="${new_MY_DATADIR}" - fi - fi - fi - - export MY_SHAREDSTATEDIR MY_SYSCONFDIR - export MY_LOCALSTATEDIR MY_LOGDIR - export MY_DATADIR -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT%/}"/usr/bin/my_print_defaults - local section="$1" - local flag="--${2}=" - local extra_options="${3}" - "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" - } - local old_MY_DATADIR="${MY_DATADIR}" - local old_HOME="${HOME}" - # my_print_defaults needs to read stuff in $HOME/.my.cnf - export HOME=${EPREFIX%/}/root - - # Make sure the vars are correctly initialized - mysql_init_vars - - [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" - if [[ ! -x "${EROOT%/}/usr/sbin/mysqld" ]] ; then - die "Minimal builds do NOT include the MySQL server" - fi - - if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]]; then - local MY_DATADIR_s="${ROOT%/}/${MY_DATADIR}" - MY_DATADIR_s="${MY_DATADIR_s%%/}" - local old_MY_DATADIR_s="${ROOT%/}/${old_MY_DATADIR}" - old_MY_DATADIR_s="${old_MY_DATADIR_s%%/}" - - if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]]; then - if [[ -d "${MY_DATADIR_s}" ]]; then - ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" - ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" - else - elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" - mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ - || die "Moving MY_DATADIR failed" - fi - else - ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" - if [[ -d "${MY_DATADIR_s}" ]]; then - ewarn "Attempting to use ${MY_DATADIR_s}" - else - eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" - die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" - fi - fi - fi - - local pwd1="a" - local pwd2="b" - local maxtry=15 - - if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then - local tmp_mysqld_password_source= - - for tmp_mysqld_password_source in mysql client; do - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]]; then - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]]; then - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" - MYSQL_ROOT_PASSWORD= - continue - fi - - einfo "Found password in '${tmp_mysqld_password_source}' section!" - break - fi - done - - # Sometimes --show is required to display passwords in some implementations of my_print_defaults - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]]; then - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" - fi - - unset tmp_mysqld_password_source - fi - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${EROOT%/}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${EROOT%/}/$MYSQL_LOG_BIN" ]]; then - einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" - install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_LOG_BIN" - fi - if [[ ! -d "${EROOT%/}/$MYSQL_RELAY_LOG" ]]; then - einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" - install -d -m 770 -o mysql -g mysql "${EROOT%/}/$MYSQL_RELAY_LOG" - fi - - if [[ -d "${ROOT%/}/${MY_DATADIR}/mysql" ]] ; then - ewarn "You have already a MySQL database in place." - ewarn "(${ROOT%/}/${MY_DATADIR}/*)" - ewarn "Please rename or delete it if you wish to replace it." - die "MySQL database already exists!" - fi - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [ -z "${MYSQL_ROOT_PASSWORD}" ]; then - - einfo "Please provide a password for the mysql 'root' user now" - einfo "or through the ${HOME}/.my.cnf file." - ewarn "Avoid [\"'\\_%] characters in the password" - read -rsp " >" pwd1 ; echo - - einfo "Retype the password" - read -rsp " >" pwd2 ; echo - - if [[ "x$pwd1" != "x$pwd2" ]] ; then - die "Passwords are not the same" - fi - MYSQL_ROOT_PASSWORD="${pwd1}" - unset pwd1 pwd2 - fi - - local options - local sqltmp="$(emktemp)" - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see http://bugs.mysql.com/bug.php?id=31312 - use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" - - local help_tables="${EROOT%/}${MY_SHAREDSTATEDIR}/fill_help_tables.sql" - [[ -r "${help_tables}" ]] \ - && cp "${help_tables}" "${TMPDIR}/fill_help_tables.sql" \ - || touch "${TMPDIR}/fill_help_tables.sql" - help_tables="${TMPDIR}/fill_help_tables.sql" - - # Figure out which options we need to disable to do the setup - local helpfile="${TMPDIR%/}/mysqld-help" - "${EROOT%/}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null - for opt in host-cache name-resolve networking slave-start \ - federated ssl log-bin relay-log slow-query-log external-locking \ - log-slave-updates \ - ; do - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" - egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" - done - - einfo "Creating the mysql database and setting proper permissions on it ..." - - # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it - PID_DIR="${EROOT%/}/var/run/mysqld" - if [[ ! -d "${PID_DIR}" ]]; then - install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory" - fi - - if [[ ! -d "${MY_DATADIR}" ]]; then - install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory" - fi - - pushd "${TMPDIR}" &>/dev/null || die - - # Filling timezones, see - # http://dev.mysql.com/doc/mysql/en/time-zone-support.html - "${EROOT%/}/usr/bin/mysql_tzinfo_to_sql" "${EROOT%/}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null - chown mysql "${sqltmp}" || die - - local cmd=( "${EROOT%/}/usr/share/mysql/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT%/}/usr/bin/mysql_install_db" ) - if [[ -r "${help_tables}" ]] ; then - cat "${help_tables}" >> "${sqltmp}" - fi - cmd+=( "--basedir=${EPREFIX%/}/usr" ${options} "--datadir=${ROOT%/}${MY_DATADIR}" "--tmpdir=${ROOT%/}${MYSQL_TMPDIR}" ) - einfo "Command: ${cmd[*]}" - su -s /bin/sh -c "${cmd[*]}" mysql \ - >"${TMPDIR%/}"/mysql_install_db.log 2>&1 - if [ $? -ne 0 ]; then - grep -B5 -A999 -i "ERROR" "${TMPDIR%/}"/mysql_install_db.log 1>&2 - die "Failed to initialize mysqld. Please review ${EPREFIX%/}/var/log/mysql/mysqld.err AND ${TMPDIR%/}/mysql_install_db.log" - fi - popd &>/dev/null || die - [[ -f "${ROOT%/}/${MY_DATADIR}/mysql/user.frm" ]] \ - || die "MySQL databases not installed" - - use prefix || options="${options} --user=mysql" - - local socket="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.sock" - local pidfile="${EROOT%/}/var/run/mysqld/mysqld${RANDOM}.pid" - local mysqld="${EROOT%/}/usr/sbin/mysqld \ - ${options} \ - $(use prefix || echo --user=mysql) \ - --log-warnings=0 \ - --basedir=${EROOT%/}/usr \ - --datadir=${ROOT%/}/${MY_DATADIR} \ - --max_allowed_packet=8M \ - --net_buffer_length=16K \ - --socket=${socket} \ - --pid-file=${pidfile} \ - --tmpdir=${ROOT}/${MYSQL_TMPDIR}" - #einfo "About to start mysqld: ${mysqld}" - ebegin "Starting mysqld" - einfo "Command ${mysqld}" - ${mysqld} & - rc=$? - while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - eend $rc - - if ! [[ -S "${socket}" ]]; then - die "Completely failed to start up mysqld with: ${mysqld}" - fi - - ebegin "Setting root password" - # Do this from memory, as we don't want clear text passwords in temp files - local sql="SET PASSWORD FOR 'root'@'localhost' = PASSWORD('${MYSQL_ROOT_PASSWORD}');" - "${EROOT%/}/usr/bin/mysql" \ - --no-defaults \ - "--socket=${socket}" \ - -hlocalhost \ - -e "${sql}" - eend $? - - if [[ -n "${sqltmp}" ]] ; then - ebegin "Loading \"zoneinfo\", this step may require a few seconds" - "${EROOT%/}/usr/bin/mysql" \ - --socket="${socket}" \ - -hlocalhost \ - -uroot \ - --password="${MYSQL_ROOT_PASSWORD}" \ - mysql < "${sqltmp}" - rc=$? - eend $? - [[ $rc -ne 0 ]] && ewarn "Failed to load zoneinfo!" - fi - - # Stop the server and cleanup - einfo "Stopping the server ..." - kill $(< "${pidfile}" ) - rm -f "${sqltmp}" - wait %1 - einfo "Done" -} diff --git a/dev-db/mysql/mysql-5.7.26.ebuild b/dev-db/mysql/mysql-5.7.26.ebuild index a956940eb6f7..e7550e70b180 100644 --- a/dev-db/mysql/mysql-5.7.26.ebuild +++ b/dev-db/mysql/mysql-5.7.26.ebuild @@ -546,15 +546,29 @@ src_test() { # Unstable tests # - main.xa_prepared_binlog_off: https://bugs.mysql.com/bug.php?id=83340 + # - rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch: https://bugs.mysql.com/bug.php?id=89223 # - rpl.rpl_non_direct_stm_mixing_engines: MDEV-14489 - for t in main.xa_prepared_binlog_off rpl.rpl_non_direct_stm_mixing_engines ; do - _disable_test "$t" "Unstable test" + for t in \ + main.xa_prepared_binlog_off \ + rpl.rpl_innodb_info_tbl_slave_tmp_tbl_mismatch \ + rpl.rpl_non_direct_stm_mixing_engines \ + ; do + _disable_test "$t" "Unstable test" done - if ! use amd64 ; then - # fixed in >=mysql-8 via commit 0a417e84 - _disable_test "gis.gis_bugs_crashes" "Unstable results on non-amd64 architectures due to floating-point operation" - fi + for t in \ + gis.geometry_class_attri_prop \ + gis.geometry_property_function_issimple \ + gis.gis_bugs_crashes \ + gis.spatial_op_testingfunc_mix \ + gis.spatial_analysis_functions_buffer \ + gis.spatial_analysis_functions_distance \ + gis.spatial_utility_function_distance_sphere \ + gis.spatial_utility_function_simplify \ + gis.spatial_analysis_functions_centroid \ + ; do + _disable_test "$t" "Known rounding error with latest AMD processors" + done if use numa && use kernel_linux ; then # bug 584880 @@ -587,7 +601,39 @@ src_test() { rpl.rpl_xa_survive_disconnect_lsu_off \ rpl.rpl_xa_survive_disconnect_table \ ; do - _disable_test "$t" "requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" + _disable_test "$t" "Requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" + done + fi + + if has_version '>=dev-libs/openssl-1.1.1' ; then + # Tests are expecting =mysql-8 via commit 0a417e84 - _disable_test "gis.gis_bugs_crashes" "Unstable results on non-amd64 architectures due to floating-point operation" - fi + for t in \ + gis.geometry_class_attri_prop \ + gis.geometry_property_function_issimple \ + gis.gis_bugs_crashes \ + gis.spatial_op_testingfunc_mix \ + gis.spatial_analysis_functions_buffer \ + gis.spatial_analysis_functions_distance \ + gis.spatial_utility_function_distance_sphere \ + gis.spatial_utility_function_simplify \ + gis.spatial_analysis_functions_centroid \ + ; do + _disable_test "$t" "Known rounding error with latest AMD processors" + done if use numa && use kernel_linux ; then # bug 584880 @@ -595,7 +608,39 @@ src_test() { rpl.rpl_xa_survive_disconnect_lsu_off \ rpl.rpl_xa_survive_disconnect_table \ ; do - _disable_test "$t" "requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" + _disable_test "$t" "Requires DEFAULT_CHARSET=latin1 but USE=-latin1 is set" + done + fi + + if has_version '>=dev-libs/openssl-1.1.1' ; then + # Tests are expecting /dev/null) + [[ -z "${aio_max_nr}" || ${aio_max_nr} -lt 250000 ]] \ + && die "FEATURES=test will require fs.aio-max-nr=250000 at minimum!" + + if use latin1 ; then + # Upstream only supports tests with default charset + die "Testing with USE=latin1 is not supported." + fi + fi + + if use kernel_linux ; then + if use numa ; then + linux-info_get_any_version + + local CONFIG_CHECK="~NUMA" + + local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" + WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" + + check_extra_config + fi + fi +} + +src_unpack() { + unpack ${A} + + # Grab the patches + [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack + + mv -f "${WORKDIR}/${MY_P}" "${S}" || die +} + +src_prepare() { + # Avoid rpm call which would trigger sandbox, #692368 + sed -i \ + -e 's/MY_RPM rpm/MY_RPM rpmNOTEXISTENT/' \ + CMakeLists.txt || die + + if use jemalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + + if use tcmalloc ; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die + fi + + # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux + if [[ -d "${S}/support-files/SELinux" ]] ; then + echo > "${S}/support-files/SELinux/CMakeLists.txt" || die + fi + + # Remove man pages for client-lib tools we don't install + rm \ + man/my_print_defaults.1 \ + man/perror.1 \ + man/zlib_decompress.1 \ + || die + + cmake-utils_src_prepare +} + +src_configure(){ + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + append-cxxflags -felide-constructors + + # bug #283926, with GCC4.4, this is required to get correct behavior. + append-flags -fno-strict-aliasing + + CMAKE_BUILD_TYPE="RelWithDebInfo" + + # debug hack wrt #497532 + mycmakeargs=( + -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" + -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" + -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" + -DSYSCONFDIR="${EPREFIX}/etc/mysql" + -DINSTALL_BINDIR=bin + -DINSTALL_DOCDIR=share/doc/${PF} + -DINSTALL_DOCREADMEDIR=share/doc/${PF} + -DINSTALL_INCLUDEDIR=include/mysql + -DINSTALL_INFODIR=share/info + -DINSTALL_LIBDIR=$(get_libdir) + -DINSTALL_MANDIR=share/man + -DINSTALL_MYSQLSHAREDIR=share/mysql + -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" + -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_EDITLINE=system + -DWITH_ZLIB=system + -DWITH_SSL=system + -DWITH_LIBWRAP=0 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + # The build forces this to be defined when cross-compiling. We pass it + # all the time for simplicity and to make sure it is actually correct. + -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DWITH_CURL=system + -DWITH_BOOST="${S}/boost" + -DWITH_ROUTER=$(usex router ON OFF) + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) + + # client/mysql.cc:1131:16: error: redefinition of ‘struct _hist_entry’ + mycmakeargs+=( + -DUSE_LIBEDIT_INTERFACE=0 + -DUSE_NEW_EDITLINE_INTERFACE=1 + -DHAVE_HIST_ENTRY=1 + ) + + mycmakeargs+=( + -DWITH_ICU=system + -DWITH_RE2=system + -DWITH_LIBEVENT=system + -DWITH_LZ4=system + -DWITH_PROTOBUF=system + -DWITH_MECAB=$(usex cjk system OFF) + -DWITH_NUMA=$(usex numa ON OFF) + # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex + -DWITH_RAPIDJSON=bundled + ) + + if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then + ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" + ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." + ewarn "You MUST file bugs without these variables set." + ewarn "Tests will probably fail!" + + mycmakeargs+=( + -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} + -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} + ) + elif use latin1 ; then + mycmakeargs+=( + -DDEFAULT_CHARSET=latin1 + -DDEFAULT_COLLATION=latin1_swedish_ci + ) + else + mycmakeargs+=( + -DDEFAULT_CHARSET=utf8mb4 + -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci + ) + fi + + mycmakeargs+=( + -DWITH_EXTRA_CHARSETS=all + -DDISABLE_SHARED=NO + -DWITH_DEBUG=$(usex debug) + ) + + if use profiling ; then + # Setting to OFF doesn't work: Once set, profiling options will be added + # to `mysqld --help` output via sql/sys_vars.cc causing + # "main.mysqld--help-notwin" test to fail + mycmakeargs+=( -DENABLED_PROFILING=ON ) + fi + + # Storage engines + mycmakeargs+=( + -DWITH_EXAMPLE_STORAGE_ENGINE=0 + -DWITH_ARCHIVE_STORAGE_ENGINE=1 + -DWITH_BLACKHOLE_STORAGE_ENGINE=1 + -DWITH_CSV_STORAGE_ENGINE=1 + -DWITH_FEDERATED_STORAGE_ENGINE=1 + -DWITH_HEAP_STORAGE_ENGINE=1 + -DWITH_INNOBASE_STORAGE_ENGINE=1 + -DWITH_INNODB_MEMCACHED=0 + -DWITH_MYISAMMRG_STORAGE_ENGINE=1 + -DWITH_MYISAM_STORAGE_ENGINE=1 + ) + + cmake-utils_src_configure +} + +# Official test instructions: +# ulimit -n 16500 && \ +# USE='perl server' \ +# FEATURES='test userpriv' \ +# ebuild mysql-X.X.XX.ebuild \ +# digest clean package +src_test() { + _disable_test() { + local rawtestname bug reason + rawtestname="${1}" ; shift + bug="${1}" ; shift + reason="${@}" + ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" + echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def" + } + + local TESTDIR="${BUILD_DIR}/mysql-test" + local retstatus_unit + local retstatus_tests + + # Run CTest (test-units) + cmake-utils_src_test + retstatus_unit=$? + + # Ensure that parallel runs don't die + export MTR_BUILD_THREAD="$((${RANDOM} % 100))" + + if [[ -z "${MTR_PARALLEL}" ]] ; then + local -x MTR_PARALLEL=$(makeopts_jobs) + + if [[ ${MTR_PARALLEL} -gt 4 ]] ; then + # Running multiple tests in parallel usually require higher ulimit + # and fs.aio-max-nr setting. In addition, tests like main.multi_update + # are known to hit timeout when system is busy. + # To avoid test failure we will limit MTR_PARALLEL to 4 instead of + # using "auto". + local info_msg="Parallel MySQL test suite jobs limited to 4 (MAKEOPTS=${MTR_PARALLEL})" + info_msg+=" to avoid test failures. Set MTR_PARALLEL if you know what you are doing!" + einfo "${info_msg}" + unset info_msg + MTR_PARALLEL=4 + fi + fi + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + # Run mysql tests + pushd "${TESTDIR}" &>/dev/null || die + + touch "${T}/disabled.def" + + local -a disabled_tests + disabled_tests+=( "auth_sec.keyring_file_data_qa;0;Won't work with user privileges") + disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)") + disabled_tests+=( "main.mysqlslap;1253001;Known failure - no upstream bug yet (RH)" ) + disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet") + disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet") + disabled_tests+=( "perfschema.idx_threads;0;Know failure - no upstream bug yet" ) + disabled_tests+=( "perfschema.idx_session_connect_attrs;0;Know failure - no upstream bug yet" ) + disabled_tests+=( "perfschema.idx_session_account_connect_attrs;0;Know failure - no upstream bug yet" ) + disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" ) + disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Know failure - no upstream bug yet" ) + disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware") + disabled_tests+=( "x.connection;0;Know failure - no upstream bug yet" ) + + local test_ds + for test_infos_str in "${disabled_tests[@]}" ; do + IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" + + if [[ ${#test_infos_arr[@]} != 3 ]] ; then + die "Invalid test data set, not matching format: ${test_infos_str}" + fi + + _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" + done + unset test_ds test_infos_str test_infos_arr + + # Try to increase file limits to increase test coverage + if ! ulimit -n 16500 1>/dev/null 2>&1 ; then + # Upper limit comes from parts.partition_* tests + ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." + + if ! ulimit -n 4162 1>/dev/null 2>&1 ; then + # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' + ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." + + if ! ulimit -n 3000 1>/dev/null 2>&1 ; then + ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." + else + einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." + fi + else + einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." + fi + else + einfo "Will run test suite with open file limit set to 16500 (best test coverage)." + fi + + # run mysql-test tests + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" + retstatus_tests=$? + + popd &>/dev/null || die + + # Cleanup is important for these testcases. + pkill -9 -f "${S}/ndb" 2>/dev/null + pkill -9 -f "${S}/sql" 2>/dev/null + + local failures="" + [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" + [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" + + [[ -z "$failures" ]] || die "Test failures: $failures" + einfo "Tests successfully completed" +} + +src_install() { + cmake-utils_src_install + + # Make sure the vars are correctly initialized + mysql_init_vars + + # Convenience links + einfo "Making Convenience links for mysqlcheck multi-call binary" + dosym "mysqlcheck" "/usr/bin/mysqlanalyze" + dosym "mysqlcheck" "/usr/bin/mysqlrepair" + dosym "mysqlcheck" "/usr/bin/mysqloptimize" + + # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir + if [[ -d "${ED}/usr/data" ]] ; then + rm -Rf "${ED}/usr/data" || die + fi + + # Unless they explicitly specific USE=test, then do not install the + # testsuite. It DOES have a use to be installed, esp. when you want to do a + # validation of your database configuration after tuning it. + if ! use test ; then + rm -rf "${ED}/${MY_SHAREDSTATEDIR#${EPREFIX}}/mysql-test" + fi + + # Configuration stuff + einfo "Building default configuration ..." + insinto "${MY_SYSCONFDIR#${EPREFIX}}" + [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf + cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" + cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + mycnf_src="my.cnf-8.0.distro-server" + sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ + "${FILESDIR}/${mycnf_src}" \ + > "${TMPDIR}/my.cnf.ok" || die + + if use prefix ; then + sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ + "${TMPDIR}/my.cnf.ok" || die + fi + + if use latin1 ; then + sed -i \ + -e "/character-set/s|utf8mb4|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + + eprefixify "${TMPDIR}/my.cnf.ok" + + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + #Remove mytop if perl is not selected + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" + + if use router ; then + rm -rf \ + "${ED}/usr/LICENSE.router" \ + "${ED}/usr/README.router" \ + "${ED}/usr/run" \ + "${ED}/usr/var" \ + || die + fi + + # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. + find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die +} + +pkg_postinst() { + # Make sure the vars are correctly initialized + mysql_init_vars + + # Create log directory securely if it does not exist + # NOTE: $MY_LOGDIR contains $EPREFIX by default + [[ -d "${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${MY_LOGDIR}" + + # Note about configuration change + einfo + elog "This version of ${PN} reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/mysql.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." + elog "You may have as many files as needed and they are read alphabetically." + elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." + einfo + + if [[ -z "${REPLACING_VERSIONS}" ]] ; then + einfo + elog "You might want to run:" + elog " \"emerge --config =${CATEGORY}/${PF}\"" + elog "if this is a new install." + einfo + else + einfo + elog "Upgrade process for ${PN}-8.x has changed. Please read" + elog "https://dev.mysql.com/doc/refman/8.0/en/upgrade-binary-package.html" + einfo + fi +} + +pkg_config() { + local mysqld_binary="${EROOT}/usr/sbin/mysqld" + if [[ ! -x "${mysqld_binary}" ]] ; then + die "'${mysqld_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + local my_print_defaults_binary="${EROOT}/usr/bin/my_print_defaults" + if [[ ! -x "${my_print_defaults_binary}" ]] ; then + die "'${my_print_defaults_binary}' not found! Please re-install dev-db/mysql-connector-c!" + fi + + if [[ -z "${MYSQL_USER}" ]] ; then + MYSQL_USER=mysql + if use prefix ; then + MYSQL_USER=$(id -u -n 2>/dev/null) + if [[ -z "${MYSQL_USER}" ]] ; then + die "Failed to determine current username!" + fi + fi + fi + + if [[ -z "${MYSQL_GROUP}" ]] ; then + MYSQL_GROUP=mysql + if use prefix ; then + MYSQL_GROUP=$(id -g -n 2>/dev/null) + if [[ -z "${MYSQL_GROUP}" ]] ; then + die "Failed to determine current user groupname!" + fi + fi + fi + + einfo "Will use username '${MYSQL_USER}' and group '${MYSQL_GROUP}' ..." + + _getoptval() { + local section="$1" + local flag="--${2}=" + local extra_options="${3}" + local cmd=( + "${my_print_defaults_binary}" + "${extra_options}" + "${section}" + ) + local results=( $(eval "${cmd[@]}" 2>/dev/null | sed -n "/^${flag}/s,${flag},,gp") ) + + if [[ ${#results[@]} -gt 0 ]] ; then + # When option is set multiple times only return last value + echo "${results[-1]}" + fi + } + + _mktemp_dry() { + # emktemp has no --dry-run option + local template="${1}" + + if [[ -z "${template}" ]] ; then + if [[ -z "${T}" ]] ; then + template="/tmp/XXXXXXX" + else + template="${T}/XXXXXXX" + fi + fi + + local template_wo_X=${template//X/} + local n_X + let n_X=${#template}-${#template_wo_X} + if [[ ${n_X} -lt 3 ]] ; then + echo "${FUNCNAME[0]}: too few X's in template ‘${template}’" >&2 + return + fi + + local attempts=0 + local character tmpfile + while [[ true ]] ; do + let attempts=attempts+1 + + new_file= + while read -n1 character ; do + if [[ "${character}" == "X" ]] ; then + tmpfile+="${RANDOM:0:1}" + else + tmpfile+="${character}" + fi + done < <(echo -n "${template}") + + if [[ ! -f "${tmpfile}" ]] + then + echo "${tmpfile}" + return + fi + + if [[ ${attempts} -ge 100 ]] ; then + echo "${FUNCNAME[0]}: Cannot create temporary file after 100 attempts." >&2 + return + fi + done + } + + # my_print_defaults needs to read stuff in $HOME/.my.cnf + local -x HOME="${EROOT}/root" + + # Make sure the vars are correctly initialized + mysql_init_vars + + # Read currently set data directory + MY_DATADIR="$(_getoptval mysqld datadir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + + # Bug #213475 - MySQL _will_ object strenously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if [[ -z "${MY_DATADIR}" ]] ; then + die "Sorry, unable to find MY_DATADIR!" + elif [[ -d "${MY_DATADIR}/mysql" ]] ; then + ewarn "Looks like your data directory '${MY_DATADIR}' is already initialized!" + ewarn "Please rename or delete its content if you wish to initialize a new data directory." + die "${PN} data directory at '${MY_DATADIR}' looks already initialized!" + else + einfo "${PN} data directory detected as '${MY_DATADIR}' ..." + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + # These are dir+prefix + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + + # Create missing directories. + # Always check if mysql user can write to directory even if we just + # created directory because a parent directory might be not + # accessible for that user. + PID_DIR="${EROOT}/run/mysqld" + if [[ ! -d "${PID_DIR}" ]] ; then + einfo "Creating ${PN} PID directory '${PID_DIR}' ..." + install -d -m 755 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${PID_DIR}" \ + || die "Failed to create PID directory '${PID_DIR}'!" + fi + + local _pid_dir_testfile="$(_mktemp_dry "${PID_DIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_pid_dir_testfile}" ]] \ + && die "_mktemp_dry() for '${PID_DIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_pid_dir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_pid_dir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]] ; then + die "${MYSQL_USER} user cannot write into PID dir '${PID_DIR}'!" + else + rm "${_pid_dir_testfile}" || die + unset _pid_dir_testfile + fi + + if [[ ! -d "${MY_DATADIR}" ]] ; then + einfo "Creating ${PN} data directory '${MY_DATADIR}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MY_DATADIR}" \ + || die "Failed to create ${PN} data directory '${MY_DATADIR}'!" + fi + + local _my_datadir_testfile="$(_mktemp_dry "${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_datadir_testfile}" ]] \ + && die "_mktemp_dry() for '${MY_DATADIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_datadir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_datadir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]]; then + die "${MYSQL_USER} user cannot write into data directory '${MY_DATADIR}'!" + else + rm "${_my_datadir_testfile}" || die + unset _my_datadir_testfile + fi + + if [[ -n "${MYSQL_TMPDIR}" && ! -d "${MYSQL_TMPDIR}" ]] ; then + einfo "Creating ${PN} tmpdir '${MYSQL_TMPDIR}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_TMPDIR}" \ + || die "Failed to create ${PN} tmpdir '${MYSQL_TMPDIR}'!" + fi + + if [[ -n "${MYSQL_TMPDIR}" ]] ; then + local _my_tmpdir_testfile="$(_mktemp_dry "${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_tmpdir_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_tmpdir_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_tmpdir_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]]; then + die "${MYSQL_USER} user cannot write into data directory '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + fi + else + # If no tmpdir is set, mysqld will use default system tmpdir. + # However, we are using tmpdir from package manager at the + # moment which maybe isn't writeable for $MYSQL_USER... + MYSQL_TMPDIR="$(_mktemp_dry "${T}/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + if [[ -n "${MYSQL_LOG_BIN}" && ! -d "${MYSQL_LOG_BIN}" ]] ; then + einfo "Creating ${PN} log-bin directory '${MYSQL_LOG_BIN}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_LOG_BIN}" \ + || die "Failed to create ${PN} log-bin directory '${MYSQL_LOG_BIN}'" + fi + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + local _my_logbin_testfile="$(_mktemp_dry "${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_logbin_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_LOG_BIN}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_logbin_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_logbin_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]]; then + die "${MYSQL_USER} user cannot write into log-bin directory '${MYSQL_LOG_BIN}'!" + else + rm "${_my_logbin_testfile}" || die + unset _my_logbin_testfile + fi + fi + + if [[ -n "${MYSQL_RELAY_LOG}" && ! -d "${MYSQL_RELAY_LOG}" ]] ; then + einfo "Creating ${PN} relay-log directory '${MYSQL_RELAY_LOG}' ..." + install -d -m 770 -o ${MYSQL_USER} -g ${MYSQL_GROUP} "${MYSQL_RELAY_LOG}" \ + || die "Failed to create ${PN} relay-log directory '${MYSQL_RELAY_LOG}'!" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + local _my_relaylog_testfile="$(_mktemp_dry "${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX")" + [[ -z "${_my_relaylog_testfile}" ]] \ + && die "_mktemp_dry() for '${MYSQL_RELAY_LOG}/.pkg_config-access-test.XXXXXXXXX' failed!" + + if use prefix ; then + touch "${_my_relaylog_testfile}" &>/dev/null + else + su -s /bin/sh -c "touch ${_my_relaylog_testfile}" ${MYSQL_USER} &>/dev/null + fi + + if [[ $? -ne 0 ]]; then + die "${MYSQL_USER} user cannot write into relay-log directory '${MYSQL_RELAY_LOG}'!" + else + rm "${_my_relaylog_testfile}" || die + unset _my_relaylog_testfile + fi + fi + + local -a config_files + + local config_file="${EROOT}/etc/mysql/mysql.d/50-distro-client.cnf" + if [[ -f "${config_file}" ]] ; then + config_files+=( "${config_file}" ) + else + ewarn "Client configuration '${config_file}' not found; Skipping configuration of default authentication plugin for client ..." + fi + + config_file="${EROOT}/etc/mysql/mysql.d/50-distro-server.cnf" + if [[ -f "${config_file}" ]] ; then + config_files+=( "${config_file}" ) + else + ewarn "Server configuration '${config_file}' not found; Skipping configuration of default authentication plugin for mysqld ..." + fi + + if [[ ${#config_files[@]} -gt 0 ]] ; then + if [[ -z "${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" ]] ; then + local user_answer + + echo + einfo "Please select default authentication plugin (enter number or plugin name):" + einfo "1) caching_sha2_password [MySQL 8.0 default]" + einfo "2) mysql_native_password [MySQL 5.7 default]" + einfo + einfo "For details see:" + einfo "https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password" + read -p " >" user_answer + echo + + case "${user_answer}" in + 1|caching_sha2_password) + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=caching_sha2_password + ;; + 2|mysql_native_password) + MYSQL_DEFAULT_AUTHENTICATION_PLUGIN=mysql_native_password + ;; + '') + die "No authentication plugin selected!" + ;; + *) + die "Authentication plugin '${user_answer}' is unknown/unsupported!" + ;; + esac + + unset user_answer + fi + + local cfg_option cfg_option_tabs cfg_section + for config_file in "${config_files[@]}" ; do + cfg_option="default-authentication-plugin" + cfg_section="mysqld" + cfg_option_tabs="\t\t" + if [[ "${config_file}" == *client.cnf ]] ; then + cfg_option="default-auth" + cfg_section="client" + cfg_option_tabs="\t\t\t\t" + fi + + if grep -qE "^(loose-)?${cfg_option}\b.*=" "${config_file}" 2>/dev/null ; then + einfo "Ensuring that ${cfg_option} is set to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." + sed -i \ + -e "s/^\(loose-\)\?${cfg_option}\b.*=.*/loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}/" \ + "${config_file}" || die "Failed to change ${cfg_option} in '${config_file}'!" + else + einfo "Setting ${cfg_option} to '${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}' in '${config_file}' ..." + sed -i \ + -e "/^\[${cfg_section}\]$/a loose-${cfg_option}${cfg_option_tabs}= ${MYSQL_DEFAULT_AUTHENTICATION_PLUGIN}" \ + "${config_file}" || die "Failed to add ${cfg_option} to '${config_file}'!" + fi + done + unset cfg_option cfg_option_tabs cfg_section + fi + unset config_files config_file + + echo + + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then + local tmp_mysqld_password_source= + + for tmp_mysqld_password_source in mysql client ; do + einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then + if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then + ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" + MYSQL_ROOT_PASSWORD= + continue + fi + + einfo "Found password in '${tmp_mysqld_password_source}' section!" + break + fi + done + + # Sometimes --show is required to display passwords in some implementations of my_print_defaults + if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then + MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" + fi + + unset tmp_mysqld_password_source + fi + + if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then + local pwd1="a" + local pwd2="b" + + echo + einfo "No password for mysql 'root' user was specified via environment" + einfo "variable MYSQL_ROOT_PASSWORD and no password was found in config" + einfo "file like '${HOME}/.my.cnf'." + einfo "To continue please provide a password for the mysql 'root' user" + einfo "now on console:" + ewarn "NOTE: Please avoid [\"'\\_%] characters in the password!" + read -rsp " >" pwd1 ; echo + + einfo "Retype the password" + read -rsp " >" pwd2 ; echo + + if [[ "x$pwd1" != "x$pwd2" ]] ; then + die "Passwords are not the same!" + fi + + MYSQL_ROOT_PASSWORD="${pwd1}" + unset pwd1 pwd2 + + echo + fi + + local -a mysqld_options + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see http://bugs.mysql.com/bug.php?id=31312 + use prefix && mysqld_options+=( "--defaults-file='${MY_SYSCONFDIR}/my.cnf'" ) + + # Figure out which options we need to disable to do the setup + local helpfile="${TMPDIR}/mysqld-help" + "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null + + local opt optexp optfull + for opt in host-cache name-resolve networking slave-start \ + federated ssl log-bin relay-log slow-query-log external-locking \ + log-slave-updates \ + ; do + optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" + egrep -sq -- "${optexp}" "${helpfile}" && mysqld_options+=( "${optfull}" ) + done + + # Prepare timezones, see + # https://dev.mysql.com/doc/mysql/en/time-zone-support.html + local tz_sql="${TMPDIR}/tz.sql" + echo "USE mysql;" >"${tz_sql}" + "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${tz_sql}" 2>/dev/null + if [[ $? -ne 0 ]] ; then + die "mysql_tzinfo_to_sql failed!" + fi + + chown ${MYSQL_USER} "${tz_sql}" || die + + local mysql_install_log="${TMPDIR}/mysql_install_db.log" + touch "${mysql_install_log}" || die + chown ${MYSQL_USER} "${mysql_install_log}" || die + + # --initialize-insecure will not set root password + # --initialize would set a random one in the log which we don't need as we set it ourselves + local cmd=( + "${mysqld_binary}" + "${mysqld_options[@]}" + "--initialize-insecure" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql.ibd" ]] ; then + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_install_log}" 1>&2 + die "Failed to initialize ${PN} data directory. Please review '${mysql_install_log}'!" + fi + + local x=${RANDOM} + local socket="${EROOT}/run/mysqld/mysqld${x}.sock" + local pidfile="${EROOT}/run/mysqld/mysqld${x}.pid" + unset x + + local mysqld_logfile="${TMPDIR}/mysqld.log" + touch "${mysqld_logfile}" || die + chown ${MYSQL_USER} "${mysqld_logfile}" || die + + cmd=( + "${mysqld_binary}" + "${mysqld_options[@]}" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + --max_allowed_packet=8M + --net_buffer_length=16K + "--socket='${socket}'" + "--pid-file='${pidfile}'" + "--log-error='${mysqld_logfile}'" + "--user=${MYSQL_USER}" + ) + + einfo "Starting mysqld to finalize initialization: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysqld_logfile}" 2>&1 & + + echo -n "Waiting for mysqld to accept connections " + local maxtry=15 + while [[ ! -S "${socket}" && "${maxtry}" -gt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + + if [[ -S "${socket}" ]] ; then + # Even with a socket we don't know if mysqld will abort + # start due to an error so just wait a little bit more... + maxtry=5 + while [[ -S "${socket}" && "${maxtry}" -gt 1 ]] ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + fi + + echo + + if [[ ! -S "${socket}" ]] ; then + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysqld_logfile}" 1>&2 + die "mysqld was unable to start from initialized data directory. Please review '${mysqld_logfile}'!" + fi + + local mysql_logfile="${TMPDIR}/set_root_pw.log" + touch "${mysql_logfile}" || die + + ebegin "Setting root password" + # Do this from memory, as we don't want clear text passwords in temp files + local sql="ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'" + cmd=( + "${mysql_binary}" + --no-defaults + "--socket='${socket}'" + -hlocalhost + "-e \"${sql}\"" + ) + eval "${cmd[@]}" >"${mysql_logfile}" 2>&1 + local rc=$? + eend ${rc} + + if [[ ${rc} -ne 0 ]] ; then + # Poor man's solution which tries to avoid having password + # in log. NOTE: sed can fail if user didn't follow advice + # and included character which will require escaping... + sed -i -e "s/${MYSQL_ROOT_PASSWORD}/*****/" "${mysql_logfile}" 2>/dev/null + + grep -B5 -A999 -iE "(Aborting|ERROR|errno)" "${mysql_logfile}" + die "Failed to set ${PN} root password. Please review '${mysql_logfile}'!" + fi + + # Stop the server + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then + echo -n "Stopping the server " + pkill -F "${pidfile}" &>/dev/null + + maxtry=10 + while [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; do + maxtry=$((${maxtry}-1)) + echo -n "." + sleep 1 + done + + echo + + if [[ -f "${pidfile}" ]] && pgrep -F "${pidfile}" &>/dev/null ; then + # We somehow failed to stop server. + # However, not a fatal error. Just warn the user. + ewarn "WARNING: mysqld[$(cat "${pidfile}")] is still running!" + fi + fi + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mysql/mysql-8.0.17_pre1.ebuild b/dev-db/mysql/mysql-8.0.17_pre1.ebuild deleted file mode 100644 index a1c1a4d312e8..000000000000 --- a/dev-db/mysql/mysql-8.0.17_pre1.ebuild +++ /dev/null @@ -1,815 +0,0 @@ -# Copyright 1999-2019 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -MY_EXTRAS_VER="20190802-1549Z" - -CMAKE_MAKEFILE_GENERATOR=emake - -# Keeping eutils in EAPI=6 for emktemp in pkg_config - -inherit cmake-utils eutils flag-o-matic linux-info \ - prefix toolchain-funcs - -MY_PV="${PV//_pre*}" -MY_P="${PN}-${MY_PV}" - -S="${WORKDIR}/${PN}-${MY_PV}" - -SRC_URI="https://cdn.mysql.com/Downloads/MySQL-8.0/mysql-boost-${MY_PV}.tar.gz - https://cdn.mysql.com/archives/mysql-8.0/mysql-boost-${MY_PV}.tar.gz - http://downloads.mysql.com/archives/MySQL-8.0/${PN}-boost-${MY_PV}.tar.gz" - -# Gentoo patches to MySQL -if [[ "${MY_EXTRAS_VER}" != "live" && "${MY_EXTRAS_VER}" != "none" ]] ; then - SRC_URI="${SRC_URI} - mirror://gentoo/mysql-extras-${MY_EXTRAS_VER}.tar.bz2 - https://gitweb.gentoo.org/proj/mysql-extras.git/snapshot/mysql-extras-${MY_EXTRAS_VER}.tar.bz2" -fi - -HOMEPAGE="https://www.mysql.com/" -DESCRIPTION="A fast, multi-threaded, multi-user SQL database server" -LICENSE="GPL-2" -SLOT="0/21" -IUSE="cjk cracklib debug experimental jemalloc latin1 libressl numa +perl profiling - router selinux ssl static tcmalloc test" - -# Tests always fail when libressl is enabled due to hard-coded ciphers in the tests -RESTRICT="libressl? ( test )" - -REQUIRED_USE="?? ( tcmalloc jemalloc )" - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x86-macos ~x64-solaris ~x86-solaris" - -# Shorten the path because the socket path length must be shorter than 107 chars -# and we will run a mysql server during test phase -S="${WORKDIR}/mysql" - -if [[ "${MY_EXTRAS_VER}" == "live" ]] ; then - inherit git-r3 - EGIT_REPO_URI="https://anongit.gentoo.org/git/proj/mysql-extras.git" - EGIT_CHECKOUT_DIR="${WORKDIR}/mysql-extras" - EGIT_CLONE_TYPE=shallow - MY_PATCH_DIR="${WORKDIR}/mysql-extras" -else - MY_PATCH_DIR="${WORKDIR}/mysql-extras-${MY_EXTRAS_VER}" -fi - -PATCHES=( - "${MY_PATCH_DIR}"/20001_all_fix-minimal-build-cmake-mysql-8.0.17.patch - "${MY_PATCH_DIR}"/20007_all_cmake-debug-werror-8.0.17.patch - "${MY_PATCH_DIR}"/20018_all_mysql-5.7.23-fix-grant_user_lock-a-root.patch - "${MY_PATCH_DIR}"/20018_all_mysql-8.0.17-without-clientlibs-tools.patch - "${MY_PATCH_DIR}"/20018_all_mysql-8.0.17-fix-libressl-support.patch -) - -# Be warned, *DEPEND are version-dependant -# These are used for both runtime and compiletime -COMMON_DEPEND="net-misc/curl:= - >=sys-apps/sed-4 - >=sys-apps/texinfo-4.7-r1 - sys-libs/ncurses:0= - dev-db/mysql-connector-c - >=dev-libs/protobuf-3.8 - >=app-arch/lz4-0_p131:= - dev-libs/libedit - cjk? ( app-text/mecab:= ) - dev-libs/libevent:= - net-libs/libtirpc:= - numa? ( sys-process/numactl ) - >=sys-libs/zlib-1.2.3:0= - jemalloc? ( dev-libs/jemalloc:0= ) - kernel_linux? ( - dev-libs/libaio:0= - sys-process/procps:0= - ) - tcmalloc? ( dev-util/google-perftools:0= ) - ssl? ( - !libressl? ( >=dev-libs/openssl-1.0.0:0= ) - libressl? ( dev-libs/libressl:0= ) - ) -" -DEPEND="${COMMON_DEPEND} - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) - virtual/yacc - dev-libs/libevent - experimental? ( net-libs/rpcsvc-proto ) - static? ( sys-libs/ncurses[static-libs] ) - test? ( - acct-group/mysql acct-user/mysql - dev-perl/JSON - ) -" -RDEPEND="${COMMON_DEPEND} - !dev-db/mariadb !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - selinux? ( sec-policy/selinux-mysql ) - !prefix? ( - acct-group/mysql acct-user/mysql - dev-db/mysql-init-scripts - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 )" - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mysql"} - MY_SYSCONFDIR=${MY_SYSCONFDIR="${EPREFIX}/etc/mysql"} - MY_LOCALSTATEDIR=${MY_LOCALSTATEDIR="${EPREFIX}/var/lib/mysql"} - MY_LOGDIR=${MY_LOGDIR="${EPREFIX}/var/log/mysql"} - - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR="" - if [[ -f "${MY_SYSCONFDIR}/my.cnf" ]] ; then - MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ - | sed -ne '/datadir/s|^--datadir=||p' \ - | tail -n1` - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR=`grep ^datadir "${MY_SYSCONFDIR}/my.cnf" \ - | sed -e 's/.*=\s*//' \ - | tail -n1` - fi - fi - if [[ -z "${MY_DATADIR}" ]] ; then - MY_DATADIR="${MY_LOCALSTATEDIR}" - einfo "Using default MY_DATADIR" - fi - elog "MySQL MY_DATADIR is ${MY_DATADIR}" - - if [[ -z "${PREVIOUS_DATADIR}" ]] ; then - if [[ -e "${MY_DATADIR}" ]] ; then - # If you get this and you're wondering about it, see bug #207636 - elog "MySQL datadir found in ${MY_DATADIR}" - elog "A new one will not be created." - PREVIOUS_DATADIR="yes" - else - PREVIOUS_DATADIR="no" - fi - export PREVIOUS_DATADIR - fi - else - if [[ ${EBUILD_PHASE} == "config" ]] ; then - local new_MY_DATADIR - new_MY_DATADIR=`"my_print_defaults" mysqld 2>/dev/null \ - | sed -ne '/datadir/s|^--datadir=||p' \ - | tail -n1` - - if [[ ( -n "${new_MY_DATADIR}" ) && ( "${new_MY_DATADIR}" != "${MY_DATADIR}" ) ]] ; then - ewarn "MySQL MY_DATADIR has changed" - ewarn "from ${MY_DATADIR}" - ewarn "to ${new_MY_DATADIR}" - MY_DATADIR="${new_MY_DATADIR}" - fi - fi - fi - - export MY_SHAREDSTATEDIR MY_SYSCONFDIR - export MY_LOCALSTATEDIR MY_LOGDIR - export MY_DATADIR -} - -pkg_pretend() { - if use numa ; then - local CONFIG_CHECK="~NUMA" - - local WARNING_NUMA="This package expects NUMA support in kernel which this system does not have at the moment;" - WARNING_NUMA+=" Either expect runtime errors, enable NUMA support in kernel or rebuild the package without NUMA support" - - check_extra_config - fi -} - -pkg_postinst() { - # Make sure the vars are correctly initialized - mysql_init_vars - - # Create log directory securely if it does not exist - [[ -d "${ROOT}${MY_LOGDIR}" ]] || install -d -m0750 -o mysql -g mysql "${ROOT}${MY_LOGDIR}" - - if [[ -z "${REPLACING_VERSIONS}" ]] ; then - einfo - elog "You might want to run:" - elog "\"emerge --config =${CATEGORY}/${PF}\"" - elog "if this is a new install." - elog - elog "If you are switching server implentations, you should run the" - elog "mysql_upgrade tool." - einfo - else - einfo - elog "If you are upgrading major versions, you should run the" - elog "mysql_upgrade tool." - einfo - fi - - # Note about configuration change - einfo - elog "This version of ${PN} reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/mysql.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/mysql.d with a .cnf extension." - elog "You may have as many files as needed and they are read alphabetically." - elog "Be sure the options have the appropriate section headers, i.e. [mysqld]." - einfo -} - -src_unpack() { - unpack ${A} - # Grab the patches - [[ "${MY_EXTRAS_VER}" == "live" ]] && S="${WORKDIR}/mysql-extras" git-r3_src_unpack - - mv -f "${WORKDIR}/${MY_P}" "${S}" || die -} - -src_prepare() { - if use jemalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - - if use tcmalloc ; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" || die - fi - - # Remove the centos and rhel selinux policies to support mysqld_safe under SELinux - if [[ -d "${S}/support-files/SELinux" ]] ; then - echo > "${S}/support-files/SELinux/CMakeLists.txt" || die - fi - - # man pages for client-lib tools we don't install - rm \ - man/my_print_defaults.1 \ - man/perror.1 \ - man/zlib_decompress.1 \ - || die - - cmake-utils_src_prepare -} - -src_configure(){ - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - append-cxxflags -felide-constructors - - # bug #283926, with GCC4.4, this is required to get correct behavior. - append-flags -fno-strict-aliasing - - CMAKE_BUILD_TYPE="RelWithDebInfo" - - # debug hack wrt #497532 - mycmakeargs=( - -DCMAKE_C_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="$(usex debug '' '-DNDEBUG')" - -DCMAKE_INSTALL_PREFIX="${EPREFIX}/usr" - -DMYSQL_DATADIR="${EPREFIX}/var/lib/mysql" - -DSYSCONFDIR="${EPREFIX}/etc/mysql" - -DINSTALL_BINDIR=bin - -DINSTALL_DOCDIR=share/doc/${PF} - -DINSTALL_DOCREADMEDIR=share/doc/${PF} - -DINSTALL_INCLUDEDIR=include/mysql - -DINSTALL_INFODIR=share/info - -DINSTALL_LIBDIR=$(get_libdir) - -DINSTALL_MANDIR=share/man - -DINSTALL_MYSQLSHAREDIR=share/mysql - -DINSTALL_PLUGINDIR=$(get_libdir)/mysql/plugin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mysql" - -DCOMPILATION_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - ### TODO: make this system but issues with UTF-8 prevent it - -DWITH_EDITLINE=system - -DWITH_ZLIB=system - -DWITH_SSL=$(usex ssl system wolfssl) - -DWITH_LIBWRAP=0 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - # The build forces this to be defined when cross-compiling. We pass it - # all the time for simplicity and to make sure it is actually correct. - -DSTACK_DIRECTION=$(tc-stack-grows-down && echo -1 || echo 1) - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DWITH_CURL=system - -DWITH_BOOST="${S}/boost" - -DWITH_ROUTER=$(usex router ON OFF) - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mysql/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - mycmakeargs+=( -DWITHOUT_CLIENTLIBS=YES ) - - # client/mysql.cc:1131:16: error: redefinition of ‘struct _hist_entry’ - mycmakeargs+=( - -DUSE_LIBEDIT_INTERFACE=0 - -DUSE_NEW_EDITLINE_INTERFACE=1 - -DHAVE_HIST_ENTRY=1 - ) - - mycmakeargs+=( - -DWITH_ICU=system - -DWITH_RE2=system - -DWITH_LIBEVENT=system - -DWITH_LZ4=system - -DWITH_PROTOBUF=bundled - -DWITH_MECAB=$(usex cjk system OFF) - -DWITH_NUMA=$(usex numa ON OFF) - # Our dev-libs/rapidjson doesn't carry necessary fixes for std::regex - -DWITH_RAPIDJSON=bundled - ) - - if [[ -n "${MYSQL_DEFAULT_CHARSET}" && -n "${MYSQL_DEFAULT_COLLATION}" ]] ; then - ewarn "You are using a custom charset of ${MYSQL_DEFAULT_CHARSET}" - ewarn "and a collation of ${MYSQL_DEFAULT_COLLATION}." - ewarn "You MUST file bugs without these variables set." - ewarn "Tests will probably fail!" - - mycmakeargs+=( - -DDEFAULT_CHARSET=${MYSQL_DEFAULT_CHARSET} - -DDEFAULT_COLLATION=${MYSQL_DEFAULT_COLLATION} - ) - elif use latin1 ; then - mycmakeargs+=( - -DDEFAULT_CHARSET=latin1 - -DDEFAULT_COLLATION=latin1_swedish_ci - ) - else - mycmakeargs+=( - -DDEFAULT_CHARSET=utf8mb4 - -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci - ) - fi - - mycmakeargs+=( - -DWITH_EXTRA_CHARSETS=all - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - ) - - if use profiling ; then - # Setting to OFF doesn't work: Once set, profiling options will be added - # to `mysqld --help` output via sql/sys_vars.cc causing - # "main.mysqld--help-notwin" test to fail - mycmakeargs+=( -DENABLED_PROFILING=ON ) - fi - - if use static ; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - # Storage engines - mycmakeargs+=( - -DWITH_EXAMPLE_STORAGE_ENGINE=0 - -DWITH_ARCHIVE_STORAGE_ENGINE=1 - -DWITH_BLACKHOLE_STORAGE_ENGINE=1 - -DWITH_CSV_STORAGE_ENGINE=1 - -DWITH_FEDERATED_STORAGE_ENGINE=1 - -DWITH_HEAP_STORAGE_ENGINE=1 - -DWITH_INNOBASE_STORAGE_ENGINE=1 - -DWITH_INNODB_MEMCACHED=0 - -DWITH_MYISAMMRG_STORAGE_ENGINE=1 - -DWITH_MYISAM_STORAGE_ENGINE=1 - ) - - cmake-utils_src_configure -} - -# Official test instructions: -# ulimit -n 16500 && \ -# USE='perl server' \ -# FEATURES='test userpriv -usersandbox' \ -# ebuild mysql-X.X.XX.ebuild \ -# digest clean package -src_test() { - _disable_test() { - local rawtestname bug reason - rawtestname="${1}" ; shift - bug="${1}" ; shift - reason="${@}" - ewarn "test '${rawtestname}' disabled: '${reason}' (BUG#${bug})" - echo ${rawtestname} : BUG#${bug} ${reason} >> "${T}/disabled.def" - } - - local TESTDIR="${BUILD_DIR}/mysql-test" - local retstatus_unit - local retstatus_tests - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [[ $UID -eq 0 ]] ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - has usersandbox $FEATURES && ewarn "Some tests may fail with FEATURES=usersandbox" - - if use latin1 ; then - # Upstream only supports tests with default charset - die "Testing with USE=latin1 is not supported." - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake-utils_src_test - retstatus_unit=$? - - # Ensure that parallel runs don't die - export MTR_BUILD_THREAD="$((${RANDOM} % 100))" - # Enable parallel testing, auto will try to detect number of cores - # You may set this by hand. - # The default maximum is 8 unless MTR_MAX_PARALLEL is increased - export MTR_PARALLEL="${MTR_PARALLEL:-auto}" - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - # Run mysql tests - pushd "${TESTDIR}" &>/dev/null || die - - touch "${T}/disabled.def" - - local -a disabled_tests - disabled_tests+=( "gis.spatial_analysis_functions_buffer;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.gis_bugs_crashes;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.geometry_class_attri_prop;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.spatial_utility_function_distance_sphere;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.geometry_property_function_issimple;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.spatial_analysis_functions_centroid;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.spatial_operators_intersection;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.spatial_utility_function_simplify;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.spatial_op_testingfunc_mix;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "gis.spatial_analysis_functions_distance;5452;Known rounding error with latest AMD processors (PS)") - disabled_tests+=( "main.window_std_var;0;Known rounding error with latest AMD processors -- no upstream bug yet") - disabled_tests+=( "main.window_std_var_optimized;0;Known rounding error with latest AMD processors -- no upstream bug yet") - disabled_tests+=( "sys_vars.myisam_data_pointer_size_func;87935;Test will fail on slow hardware") - disabled_tests+=( "rpl_gtid.rpl_gtid_stm_drop_table;90612;Known test failure" ) - disabled_tests+=( "rpl_gtid.rpl_multi_source_mtr_includes;0;Know failure - no upstream bug yet" ) - disabled_tests+=( "x.connection;0;Know failure - no upstream bug yet" ) - disabled_tests+=( "main.mysqlslap;1253001;Known failure - no upstream bug yet (RH)" ) - disabled_tests+=( "perfschema.idx_threads;0;Know failure - no upstream bug yet" ) - disabled_tests+=( "perfschema.idx_session_connect_attrs;0;Know failure - no upstream bug yet" ) - disabled_tests+=( "perfschema.idx_session_account_connect_attrs;0;Know failure - no upstream bug yet" ) - - local test_ds - for test_infos_str in "${disabled_tests[@]}" ; do - IFS=';' read -r -a test_infos_arr <<< "${test_infos_str}" - - if [[ ${#test_infos_arr[@]} != 3 ]] ; then - die "Invalid test data set, not matching format: ${test_infos_str}" - fi - - _disable_test "${test_infos_arr[0]}" "${test_infos_arr[1]}" "${test_infos_arr[2]}" - done - unset test_ds test_infos_str test_infos_arr - - # Try to increase file limits to increase test coverage - if ! ulimit -n 16500 1>/dev/null 2>&1 ; then - # Upper limit comes from parts.partition_* tests - ewarn "For maximum test coverage please raise open file limit to 16500 (ulimit -n 16500) before calling the package manager." - - if ! ulimit -n 4162 1>/dev/null 2>&1 ; then - # Medium limit comes from '[Warning] Buffered warning: Could not increase number of max_open_files to more than 3000 (request: 4162)' - ewarn "For medium test coverage please raise open file limit to 4162 (ulimit -n 4162) before calling the package manager." - - if ! ulimit -n 3000 1>/dev/null 2>&1 ; then - ewarn "For minimum test coverage please raise open file limit to 3000 (ulimit -n 3000) before calling the package manager." - else - einfo "Will run test suite with open file limit set to 3000 (minimum test coverage)." - fi - else - einfo "Will run test suite with open file limit set to 4162 (medium test coverage)." - fi - else - einfo "Will run test suite with open file limit set to 16500 (best test coverage)." - fi - - local aio_max_nr=$(sysctl -n fs.aio-max-nr 2>/dev/null) - if [[ ${aio_max_nr} -lt 250000 ]] ; then - if ! sysctl -w fs.aio-max-nr=250000 2>&1 ; then - ewarn "Failed to rais fs.aio-max-nr to >=250000! Expect test failures ..." - else - einfo "fs.aio-max-nr raised to 250000!" - fi - fi - - # run mysql-test tests - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --skip-test=tokudb --skip-test-list="${T}/disabled.def" - retstatus_tests=$? - - popd &>/dev/null || die - - # Cleanup is important for these testcases. - pkill -9 -f "${S}/ndb" 2>/dev/null - pkill -9 -f "${S}/sql" 2>/dev/null - - local failures="" - [[ $retstatus_unit -eq 0 ]] || failures="${failures} test-unit" - [[ $retstatus_tests -eq 0 ]] || failures="${failures} tests" - - [[ -z "$failures" ]] || die "Test failures: $failures" - einfo "Tests successfully completed" -} - -src_install() { - cmake-utils_src_install - - # Make sure the vars are correctly initialized - mysql_init_vars - - # Convenience links - einfo "Making Convenience links for mysqlcheck multi-call binary" - dosym "mysqlcheck" "/usr/bin/mysqlanalyze" - dosym "mysqlcheck" "/usr/bin/mysqlrepair" - dosym "mysqlcheck" "/usr/bin/mysqloptimize" - - # INSTALL_LAYOUT=STANDALONE causes cmake to create a /usr/data dir - if [[ -d "${ED}/usr/data" ]] ; then - rm -Rf "${ED}/usr/data" || die - fi - - # Unless they explicitly specific USE=test, then do not install the - # testsuite. It DOES have a use to be installed, esp. when you want to do a - # validation of your database configuration after tuning it. - if ! use test ; then - rm -rf "${D}/${MY_SHAREDSTATEDIR}/mysql-test" - fi - - # Configuration stuff - einfo "Building default configuration ..." - insinto "${MY_SYSCONFDIR#${EPREFIX}}" - [[ -f "${S}/scripts/mysqlaccess.conf" ]] && doins "${S}"/scripts/mysqlaccess.conf - cp "${FILESDIR}/my.cnf-5.7" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mysql.d" - cp "${FILESDIR}/my.cnf-8.0.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - mycnf_src="my.cnf-8.0.distro-server" - sed -e "s!@DATADIR@!${MY_DATADIR}!g" \ - "${FILESDIR}/${mycnf_src}" \ - > "${TMPDIR}/my.cnf.ok" || die - - if use prefix ; then - sed -i -r -e '/^user[[:space:]]*=[[:space:]]*mysql$/d' \ - "${TMPDIR}/my.cnf.ok" || die - fi - - if use latin1 ; then - sed -i \ - -e "/character-set/s|utf8mb4|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - - eprefixify "${TMPDIR}/my.cnf.ok" - - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - #Remove mytop if perl is not selected - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" - - if use router ; then - rm -rf \ - "${ED}/usr/LICENSE.router" \ - "${ED}/usr/README.router" \ - "${ED}/usr/run" \ - "${ED}/usr/var" \ - || die - fi - - # Kill old libmysqclient_r symlinks if they exist. Time to fix what depends on them. - find "${D}" -name 'libmysqlclient_r.*' -type l -delete || die -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/bin/my_print_defaults - local section="$1" - local flag="--${2}=" - local extra_options="${3}" - "${mypd}" $extra_options $section | sed -n "/^${flag}/s,${flag},,gp" - } - local old_MY_DATADIR="${MY_DATADIR}" - local old_HOME="${HOME}" - # my_print_defaults needs to read stuff in $HOME/.my.cnf - export HOME=${EPREFIX}/root - - # Make sure the vars are correctly initialized - mysql_init_vars - - [[ -z "${MY_DATADIR}" ]] && die "Sorry, unable to find MY_DATADIR" - if [[ ! -x "${EROOT}/usr/sbin/mysqld" ]] ; then - die "Minimal builds do NOT include the MySQL server" - fi - - if [[ ( -n "${MY_DATADIR}" ) && ( "${MY_DATADIR}" != "${old_MY_DATADIR}" ) ]] ; then - local MY_DATADIR_s="${ROOT}/${MY_DATADIR}" - MY_DATADIR_s="${MY_DATADIR_s%}" - local old_MY_DATADIR_s="${ROOT}/${old_MY_DATADIR}" - old_MY_DATADIR_s="${old_MY_DATADIR_s%}" - - if [[ ( -d "${old_MY_DATADIR_s}" ) && ( "${old_MY_DATADIR_s}" != / ) ]] ; then - if [[ -d "${MY_DATADIR_s}" ]] ; then - ewarn "Both ${old_MY_DATADIR_s} and ${MY_DATADIR_s} exist" - ewarn "Attempting to use ${MY_DATADIR_s} and preserving ${old_MY_DATADIR_s}" - else - elog "Moving MY_DATADIR from ${old_MY_DATADIR_s} to ${MY_DATADIR_s}" - mv --strip-trailing-slashes -T "${old_MY_DATADIR_s}" "${MY_DATADIR_s}" \ - || die "Moving MY_DATADIR failed" - fi - else - ewarn "Previous MY_DATADIR (${old_MY_DATADIR_s}) does not exist" - if [[ -d "${MY_DATADIR_s}" ]] ; then - ewarn "Attempting to use ${MY_DATADIR_s}" - else - eerror "New MY_DATADIR (${MY_DATADIR_s}) does not exist" - die "Configuration Failed! Please reinstall ${CATEGORY}/${PN}" - fi - fi - fi - - local pwd1="a" - local pwd2="b" - local maxtry=15 - - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then - local tmp_mysqld_password_source= - - for tmp_mysqld_password_source in mysql client ; do - einfo "Trying to get password for mysql 'root' user from '${tmp_mysqld_password_source}' section ..." - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password)" - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then - if [[ ${MYSQL_ROOT_PASSWORD} == *$'\n'* ]] ; then - ewarn "Ignoring password from '${tmp_mysqld_password_source}' section due to newline character (do you have multiple password options set?)!" - MYSQL_ROOT_PASSWORD= - continue - fi - - einfo "Found password in '${tmp_mysqld_password_source}' section!" - break - fi - done - - # Sometimes --show is required to display passwords in some implementations of my_print_defaults - if [[ "${MYSQL_ROOT_PASSWORD}" == '*****' ]] ; then - MYSQL_ROOT_PASSWORD="$(_getoptval "${tmp_mysqld_password_source}" password --show)" - fi - - unset tmp_mysqld_password_source - fi - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${EROOT}/$MYSQL_TMPDIR" ]] ; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - - if [[ ! -d "${EROOT}/$MYSQL_LOG_BIN" ]] ; then - einfo "Creating MySQL log-bin directory $MYSQL_LOG_BIN" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_LOG_BIN" - fi - - if [[ ! -d "${EROOT}/$MYSQL_RELAY_LOG" ]] ; then - einfo "Creating MySQL relay-log directory $MYSQL_RELAY_LOG" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_RELAY_LOG" - fi - - if [[ -d "${ROOT}/${MY_DATADIR}/mysql" ]] ; then - ewarn "You have already a MySQL database in place." - ewarn "(${ROOT}/${MY_DATADIR}/*)" - ewarn "Please rename or delete it if you wish to replace it." - die "MySQL database already exists!" - fi - - # Bug #213475 - MySQL _will_ object strenously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if [[ -z "${MYSQL_ROOT_PASSWORD}" ]] ; then - - einfo "Please provide a password for the mysql 'root' user now" - einfo "or through the ${HOME}/.my.cnf file." - ewarn "Avoid [\"'\\_%] characters in the password" - read -rsp " >" pwd1 ; echo - - einfo "Retype the password" - read -rsp " >" pwd2 ; echo - - if [[ "x$pwd1" != "x$pwd2" ]] ; then - die "Passwords are not the same" - fi - MYSQL_ROOT_PASSWORD="${pwd1}" - unset pwd1 pwd2 - fi - - local options - local sqltmp="$(emktemp)" - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see http://bugs.mysql.com/bug.php?id=31312 - use prefix && options="${options} '--defaults-file=${MY_SYSCONFDIR}/my.cnf'" - - # Figure out which options we need to disable to do the setup - local helpfile="${TMPDIR}/mysqld-help" - "${EROOT}/usr/sbin/mysqld" --verbose --help >"${helpfile}" 2>/dev/null - for opt in host-cache name-resolve networking slave-start \ - federated ssl log-bin relay-log slow-query-log external-locking \ - log-slave-updates \ - ; do - optexp="--(skip-)?${opt}" optfull="--loose-skip-${opt}" - egrep -sq -- "${optexp}" "${helpfile}" && options="${options} ${optfull}" - done - - einfo "Creating the mysql database and setting proper permissions on it ..." - - # Now that /var/run is a tmpfs mount point, we need to ensure it exists before using it - PID_DIR="${EROOT}/var/run/mysqld" - if [[ ! -d "${PID_DIR}" ]] ; then - install -d -m 755 -o mysql -g mysql "${PID_DIR}" || die "Could not create pid directory" - fi - - if [[ ! -d "${MY_DATADIR}" ]] ; then - install -d -m 750 -o mysql -g mysql "${MY_DATADIR}" || die "Could not create data directory" - fi - - pushd "${TMPDIR}" &>/dev/null || die - - # Filling timezones, see - # http://dev.mysql.com/doc/mysql/en/time-zone-support.html - echo "USE mysql;" >"${sqltmp}" - "${EROOT}/usr/bin/mysql_tzinfo_to_sql" "${EROOT}/usr/share/zoneinfo" >> "${sqltmp}" 2>/dev/null - chown mysql "${sqltmp}" || die - - # --initialize-insecure will not set root password - # --initialize would set a random one in the log which we don't need as we set it ourselves - local cmd=( "${EROOT}/usr/sbin/mysqld" "--initialize-insecure" "--init-file='${sqltmp}'" ) - cmd+=( "--basedir=${EPREFIX}/usr" ${options} "--datadir=${ROOT}${MY_DATADIR}" "--tmpdir=${ROOT}${MYSQL_TMPDIR}" ) - einfo "Command: ${cmd[*]}" - su -s /bin/sh -c "${cmd[*]}" mysql \ - >"${TMPDIR}"/mysql_install_db.log 2>&1 - if [[ $? -ne 0 ]] ; then - grep -B5 -A999 -i "ERROR" "${TMPDIR}"/mysql_install_db.log 1>&2 - die "Failed to initialize mysqld. Please review ${EPREFIX}/var/log/mysql/mysqld.err AND ${TMPDIR}/mysql_install_db.log" - fi - popd &>/dev/null || die - [[ -f "${ROOT}/${MY_DATADIR}/mysql/user.frm" ]] \ - || die "MySQL databases not installed" - - use prefix || options="${options} --user=mysql" - - local socket="${EROOT}/var/run/mysqld/mysqld${RANDOM}.sock" - local pidfile="${EROOT}/var/run/mysqld/mysqld${RANDOM}.pid" - local mysqld="${EROOT}/usr/sbin/mysqld \ - ${options} \ - $(use prefix || echo --user=mysql) \ - --log-warnings=0 \ - --basedir=${EROOT}/usr \ - --datadir=${ROOT}/${MY_DATADIR} \ - --max_allowed_packet=8M \ - --net_buffer_length=16K \ - --socket=${socket} \ - --pid-file=${pidfile} \ - --tmpdir=${ROOT}/${MYSQL_TMPDIR}" - #einfo "About to start mysqld: ${mysqld}" - ebegin "Starting mysqld" - einfo "Command ${mysqld}" - ${mysqld} & - rc=$? - while ! [[ -S "${socket}" || "${maxtry}" -lt 1 ]] ; do - maxtry=$((${maxtry}-1)) - echo -n "." - sleep 1 - done - eend $rc - - if ! [[ -S "${socket}" ]] ; then - die "Completely failed to start up mysqld with: ${mysqld}" - fi - - ebegin "Setting root password" - # Do this from memory, as we don't want clear text passwords in temp files - local sql="ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '${MYSQL_ROOT_PASSWORD}'" - "${EROOT}/usr/bin/mysql" \ - --no-defaults \ - "--socket=${socket}" \ - -hlocalhost \ - -e "${sql}" - eend $? - - # Stop the server and cleanup - einfo "Stopping the server ..." - kill $(< "${pidfile}" ) - rm -f "${sqltmp}" - wait %1 - einfo "Done" -} -- cgit v1.2.3