From 9aa80713372911cec499b3adb2cd746790920916 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Tue, 29 Jun 2021 10:15:54 +0100 Subject: gentoo resync : 29.06.2021 --- dev-db/mariadb/Manifest | 34 +- dev-db/mariadb/mariadb-10.2.32-r3.ebuild | 1010 ----------------------- dev-db/mariadb/mariadb-10.2.32-r4.ebuild | 1011 +++++++++++++++++++++++ dev-db/mariadb/mariadb-10.2.34-r1.ebuild | 1016 +++++++++++++++++++++++ dev-db/mariadb/mariadb-10.2.34.ebuild | 1015 ----------------------- dev-db/mariadb/mariadb-10.2.35-r1.ebuild | 1017 +++++++++++++++++++++++ dev-db/mariadb/mariadb-10.2.35.ebuild | 1016 ----------------------- dev-db/mariadb/mariadb-10.2.36-r1.ebuild | 1017 +++++++++++++++++++++++ dev-db/mariadb/mariadb-10.2.36.ebuild | 1016 ----------------------- dev-db/mariadb/mariadb-10.2.37-r3.ebuild | 1285 ----------------------------- dev-db/mariadb/mariadb-10.2.37-r4.ebuild | 1286 +++++++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.2.38-r1.ebuild | 1290 +++++++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.2.38.ebuild | 1289 ----------------------------- dev-db/mariadb/mariadb-10.3.27-r1.ebuild | 1008 +++++++++++++++++++++++ dev-db/mariadb/mariadb-10.3.27.ebuild | 1007 ----------------------- dev-db/mariadb/mariadb-10.3.28-r3.ebuild | 1277 ----------------------------- dev-db/mariadb/mariadb-10.3.28-r4.ebuild | 1278 +++++++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.3.29-r1.ebuild | 1282 +++++++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.3.29.ebuild | 1281 ----------------------------- dev-db/mariadb/mariadb-10.4.13-r3.ebuild | 1034 ------------------------ dev-db/mariadb/mariadb-10.4.13-r4.ebuild | 1035 ++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.4.15-r1.ebuild | 1037 ++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.4.15.ebuild | 1036 ------------------------ dev-db/mariadb/mariadb-10.4.16-r1.ebuild | 1039 ++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.4.16.ebuild | 1038 ------------------------ dev-db/mariadb/mariadb-10.4.17-r1.ebuild | 1039 ++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.4.17.ebuild | 1038 ------------------------ dev-db/mariadb/mariadb-10.4.18-r3.ebuild | 1296 ----------------------------- dev-db/mariadb/mariadb-10.4.18-r4.ebuild | 1297 +++++++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.4.19-r1.ebuild | 1303 ++++++++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.4.19.ebuild | 1302 ----------------------------- dev-db/mariadb/mariadb-10.5.10-r1.ebuild | 1297 +++++++++++++++++++++++++++++ dev-db/mariadb/mariadb-10.5.10.ebuild | 1296 ----------------------------- dev-db/mariadb/mariadb-10.5.9-r5.ebuild | 1292 ----------------------------- dev-db/mariadb/mariadb-10.5.9-r6.ebuild | 1293 +++++++++++++++++++++++++++++ 35 files changed, 19562 insertions(+), 19545 deletions(-) delete mode 100644 dev-db/mariadb/mariadb-10.2.32-r3.ebuild create mode 100644 dev-db/mariadb/mariadb-10.2.32-r4.ebuild create mode 100644 dev-db/mariadb/mariadb-10.2.34-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.2.34.ebuild create mode 100644 dev-db/mariadb/mariadb-10.2.35-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.2.35.ebuild create mode 100644 dev-db/mariadb/mariadb-10.2.36-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.2.36.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.2.37-r3.ebuild create mode 100644 dev-db/mariadb/mariadb-10.2.37-r4.ebuild create mode 100644 dev-db/mariadb/mariadb-10.2.38-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.2.38.ebuild create mode 100644 dev-db/mariadb/mariadb-10.3.27-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.3.27.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.3.28-r3.ebuild create mode 100644 dev-db/mariadb/mariadb-10.3.28-r4.ebuild create mode 100644 dev-db/mariadb/mariadb-10.3.29-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.3.29.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.4.13-r3.ebuild create mode 100644 dev-db/mariadb/mariadb-10.4.13-r4.ebuild create mode 100644 dev-db/mariadb/mariadb-10.4.15-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.4.15.ebuild create mode 100644 dev-db/mariadb/mariadb-10.4.16-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.4.16.ebuild create mode 100644 dev-db/mariadb/mariadb-10.4.17-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.4.17.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.4.18-r3.ebuild create mode 100644 dev-db/mariadb/mariadb-10.4.18-r4.ebuild create mode 100644 dev-db/mariadb/mariadb-10.4.19-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.4.19.ebuild create mode 100644 dev-db/mariadb/mariadb-10.5.10-r1.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.5.10.ebuild delete mode 100644 dev-db/mariadb/mariadb-10.5.9-r5.ebuild create mode 100644 dev-db/mariadb/mariadb-10.5.9-r6.ebuild (limited to 'dev-db/mariadb') diff --git a/dev-db/mariadb/Manifest b/dev-db/mariadb/Manifest index 464e979e94b2..3e853b7ed62a 100644 --- a/dev-db/mariadb/Manifest +++ b/dev-db/mariadb/Manifest @@ -37,21 +37,21 @@ DIST mariadb-10.5.10-patches-01.tar.xz 5944 BLAKE2B ce374e58b7730d45a8dbca4cccd4 DIST mariadb-10.5.10.tar.gz 99019617 BLAKE2B 85b5c43ae9eeb1dbf9ff7935d4cf4bddbd18cadeffb79a3bff172b4522e196c7ac8916c63a6750d0b3b910c6f0f933213b3b4f6c7bf0d43bbb07714ed9337750 SHA512 93dd1405f8b31989e130dee5b7d4a0b447aa0e017fb9ee02c792c52142d84d1103e8fd591101d72deda1ac65b10c48053582f6e61bd1757e6aa92e42d98c56cd DIST mariadb-10.5.9-patches-05.tar.xz 17120 BLAKE2B a6ea7c3ba3718e9667510db9fdfcedb3fa4a6a2da89f1c49f9a419c84191af9bf6148815afa836e31f47d752cafdaefdd98b530c29c849fa86af4ff0be9732ea SHA512 e39393505d5c5d45b3352d15b9e10a02a1057d5eb381335953c5dfca312791976be9e0e3b2adb6536a2f5cc6f00f01b9379a17806a029a9b73eb674a2a1fb583 DIST mariadb-10.5.9.tar.gz 88639930 BLAKE2B 512c3fb0541bbeb19878979104f7858ce18ce67187507c8395798cfc9ffe92bd83e39bd47251419363600348a85716406286bd27b3c28662ea63e8ec761a4e01 SHA512 d23d5bf8510b3c36a6521fb3244cf323ef0f5d100ba379ed7b5bbc2acae1765a5b46c17bd929f0b27b28923eb1b5975314abdf7ffb96905cf7a93a5c8837294e -EBUILD mariadb-10.2.32-r3.ebuild 33618 BLAKE2B c9f924641af200d6d8003a17a1957259f16afe200c5a9abb9e010eac1bfd8a841d961c768adc67efe85237cce4ecf9100baf5dc13b252f522df6cd52c670ca58 SHA512 9ef436d76eca6064224ef124a4c5d421d952ddc8e2caec6abbca9b02e601c17c3a54ce46ac1df3498dffdca2de7e7169c644659b3e173825fa7be976a5838d16 -EBUILD mariadb-10.2.34.ebuild 33748 BLAKE2B 4dee3db71121d7def075565402634c367f9f8dd6c89ec11a9b1ba627adc7a852d227e576681b99b413fe23de4e479c2c644b97d84f2b33c05ef67109c519387e SHA512 71e783e629845ee3438b144ab364d64a5f8a82e5b2b6df40371c1d2c07cec6e2e470476e5faf1b9e6529c39277b14da2572208499d2ce3026498f5c54a9724e0 -EBUILD mariadb-10.2.35.ebuild 33807 BLAKE2B 75c52a9c1c744a0b58f3a81ed5163df352dde9eadfa41ef0b0d598aea0faa024796c1c7a2164688744ead3e950db5aa87789dc6aad412e751fbd44d9ff541aa8 SHA512 6904ed0f3217ee3d4ab0139e67d7c1312bcd9771c534fb637279722ebba24af9c5168efb8e4391d553acc38add3229fb2ee62a92bed22262fa4076d0520cd6ea -EBUILD mariadb-10.2.36.ebuild 33802 BLAKE2B 951616432079ee5e54eaafc8ae1e2e893eeed6b78e0d82f0f600c00eefaa17af32d5280c89c28c377f9f96b930a3d2219062fd9d0214e1addaa612c1c4c0f5af SHA512 551aefbe395f7c35150b59abfd72643316f11fac00116c3119f0b2ffee63afa9d82b3d335455c3cbe402283f98c67966d2767a6d9759db262f8b461a6b956967 -EBUILD mariadb-10.2.37-r3.ebuild 41505 BLAKE2B c72e7fd67c44884cbbb19777e51822abafb598e61ed7f6934d45a8bf20858a6577317852dd642b7cf7caff69d42bfc0eb3dcc0d879652769c1e34d97894ffb2c SHA512 6703492272ef7da489164ff17f4ce1e3802032c16d51eade850ba4caa7222ff3fac55967d5174a7164cca2362c9187743c3e67f79282f601e0f6042bdb37008f -EBUILD mariadb-10.2.38.ebuild 41735 BLAKE2B 849b333549ebfa399e82b0ca29531d6d8d2025c05edd9753ff3616c56a09da5f487d71cf1ffb143e8a9ca905acae38ad671d2494193efef49ab2f100081ec442 SHA512 e00a515c78769dea730a7409a4db33760b4891539d5df624f74842cde55e9a940ec1901cd21112b6ecfd07c2571cb0aef4a434ed2c6ea17a06e39137b04b5b4a -EBUILD mariadb-10.3.27.ebuild 33315 BLAKE2B dddcb00e569ab38a470fc69932fa1974b18e78e3bc5315dd99281a8b3b491eed9078844abb0c21d4b60e4abbb3e2a1c9468ffbb7414f34410c1b8fa748dff2cd SHA512 da81a47686f868cb881711cfd14736a98ee21fa23a5cb1a7a034f4efef9d36021cac376af976301fb6170e665140a6a04b065f7ad21801d7533609be416f66d4 -EBUILD mariadb-10.3.28-r3.ebuild 41037 BLAKE2B b57fe4df2bbca5c9c1433bc1718447efa4d499c5700734203897aa2bbb48a5ba48f1a84789d06bf879e6fd558e8699d8a2feffa9e680117c74e925eff70adfd9 SHA512 5f67b938748f65f07b101391a3c07296513ccd93d4733198f62faa51701c16d27ebc4f2deb44ae166baed9ab5e72896b661fce6f73a154adbc5f76032bc9267a -EBUILD mariadb-10.3.29.ebuild 41291 BLAKE2B 8007953ab47d82980f9d16430c9aadf7cd8f81794aa5e34b4897847d161f1bf0ebd364ff711196fefdf3409b13f8210e045acde787824c777df7aa61bd8be15f SHA512 1d058d59cea3e913481f6357713bef25773e72935f2b32755c747f5e6514cff05e80850ef17a64d9849a4da84463671cf3bc180c4de03eb9086f746f6332defd -EBUILD mariadb-10.4.13-r3.ebuild 33935 BLAKE2B 74eb39d6fec14db04ca11891db579ffec0245794eae688119b74b3e6ca6fecd362494132d3fc64ffd6780e70cc1e0432dc5b98c925decf12f57b3c3648ecec93 SHA512 d48420d78d7357c8c3fe492a0c45380823246ad29ff71b8c5f8ac164089723d78dc8cc6169127247f699c1404199b6d996788583c3d4f48bcd603cb91f9a6ee4 -EBUILD mariadb-10.4.15.ebuild 33966 BLAKE2B 7102c4c5010816fb80199b030218ec7d57b3e7867dacab26cfbefd415e159cd098a51988a78da7cf691d986596112ea6432c823bc791be538ea13ba12fcb7a55 SHA512 94d386d0af525b59d33deca8dcc0af1deb0328218ff371151fcd876d5b0ec586d062ee64391d74c3259e72c6b3ce55eebf6ec8f75bb3fe684136459d472f5e72 -EBUILD mariadb-10.4.16.ebuild 34099 BLAKE2B 88476cfc7a91578451236805dc2d73ecd83535dd7114d5f9bea673fbecad5798b46c0b5a471e0d3b6a00b63a3b05ca01320f2002214e8e4b212ce9116ae35abc SHA512 6d9417fc8d7992dda73b544fdb73b1be24bcfae1de138f84b4560ec7336ad8694b98bab2de3349f477c54865e51d899645f08a9643baf39e17d573b31119c77f -EBUILD mariadb-10.4.17.ebuild 34094 BLAKE2B 62c8a5485a629e07c61fa493f0852da45d8512f3465da758816c7bbed7844ef59a99ec821cff9378fc6bed05f3588f757727fc0c1eedb0e39f2684662f5e7e98 SHA512 9c1daebbeaea6d7feb31f30e0576d2e1188f1fce35f15914b6cc51748bc0057642a975c536a35714ea075302427dbbc45ae2cd33470af84be2f9b122bc95554e -EBUILD mariadb-10.4.18-r3.ebuild 41594 BLAKE2B 9e3c6f1794df4e08dd99363acd40a3568d46fa188ca03ce32e8bbf8353ae17d0ee20263166cf56b2d55eb0f0f78dad1dc8137688e812cc421cd3136a810aa6a7 SHA512 4660aac0f5b3f97c1931a6cf3a25278d03e5f34454c8fd686d730fe87edf39ddbd445b352b24e7824dc6a572a03fb8b99f867dcf38032e33f05cd85a6419ff12 -EBUILD mariadb-10.4.19.ebuild 42003 BLAKE2B 0ecd66ea4fff900faae8dbc4d025e5ba68436a5d7a0669bd83d198ed18d759bebb3f4cf5292536e37a7da7893dc4fa2dd6345abdb8446d7fc37395e6fd9197e8 SHA512 3dfd2fd2e2afa1a7d14d0101b82bf22624cb8fb291d642a5a1191ac9b7066aad32fe3f55a184d29728da9071fd630cd31e4ab91944310c304e1bd09b9ecaa145 -EBUILD mariadb-10.5.10.ebuild 41427 BLAKE2B 17dee0a97d62cab3677ae091f1134f6033af7d1b82211f2c9287abf1e2225199fd18930a4183733d1631e4c76d6655b6359fc995347061d05f7900b5e3dc83de SHA512 6bc9ab6760dfb088235b04ba126ad7ddf11927b24955904b34aa124e809edfeb0f528a239a8088eb3c1dbbad98056adcfac542be44e84c35b0d8a55af2100c57 -EBUILD mariadb-10.5.9-r5.ebuild 41092 BLAKE2B 8bde28f7f5a3ef726b8bc77f62cc7da65c061699d76b98692d8434866cf4e9c9b8278ddad852ffedce939a57cc34ae3fed72c7c3663b760aa5c835739dcbc569 SHA512 17815ddb3321640897ea839193c324b9c68c56eb666e3d575babebaafb595b6d29a57bfd77bf0a6ed918a5e14c26462fb772dd7adb186957553209a5ef5b142d +EBUILD mariadb-10.2.32-r4.ebuild 33638 BLAKE2B 5907316f055b988a60530c46d48bbca657ec169626692424050fb8640c1f223b850bec46cf2d421f93a7f414195808e3c01d1b80d035840a92bfd30b65bd1da2 SHA512 f335437a2fdbc23be722b9327b3b774f27cb27e711286c25262800f1c50f7112ffaccb238fdd45e5fb5ecbb11faf2170670d21f1b89f77784c5c3737724c33d8 +EBUILD mariadb-10.2.34-r1.ebuild 33768 BLAKE2B 2b667af186c56c34aa4811c897338a57717f01f0a129f7683458d9d982d4fd324c5d9a72c55b08170853281febd2452fe754bf59e9d251a265ac200491ea3448 SHA512 68987ae556b5befb5faf5e8524c5a02516fbfb0bf775720356aedc8e14fc5e6e339a11338987361c39924ebaaca76fa3184b32b1c0f418fc26e4f8070a100f9a +EBUILD mariadb-10.2.35-r1.ebuild 33827 BLAKE2B adae13f4088dc225309d397515c8ee988857164628b34e8119bfbf6d279be3ca43a4c4fee346e23f8cbabd8e3d22020358da4a1e5318f8286cf7547aa0040401 SHA512 d1b3d89d084f11dcd03847bad555fdaa6589e320b1ceaf48a66368a69e4afccdd1431d6ea0a7bbcf10ce527c3e590b91eef0a56ef2dd150018560a723e40fa44 +EBUILD mariadb-10.2.36-r1.ebuild 33822 BLAKE2B b40a7f91ada12281e719d2104a6664df00cdf7a00dfa6ddfc06e2e3bd019242e608e80bdde4068d7d13200bd5ff4459a7a1bde65fedd4285b7437bf032950bc4 SHA512 141c66d81dbcb04e677d4124bafc86bd9f5bb04d4b51580d3172ebb6323f7f58f95410bf72a0033290b2cd6094a86395555c19a7e4cf57afacb9b5e55a95fa59 +EBUILD mariadb-10.2.37-r4.ebuild 41525 BLAKE2B de4885bfb27431c1d23c9496bf498a5be11d3bd398047ed6541379c0e422a6759859d6895eb27932cb40502c472b86d766c3cbd3a390a116cb6ee1060bd6831e SHA512 f44c81f92c49fc883586d988d2a0930ee0b06497cd136dc2992b041adea8b09ec2694ea57d340ebbe31a4e67888ce05f0eb2b61d366500a0d68a896397af306f +EBUILD mariadb-10.2.38-r1.ebuild 41755 BLAKE2B 4d52765bdb0fc46e3c4dac19ba15b4700835e76666ad906f6c519a7123e462f478c4656d5930a0ce58638e24932fd337fa3745aa3f4bb739cf6fce7874d09c74 SHA512 2e420dfe7f9c0352cbd90370ead28119140dc2cafed2812cc6ed9c4bf5229d8a5724ce075c6e6207d8f1a4fc78f19029905349943d3ac8a688c75fe3b8648051 +EBUILD mariadb-10.3.27-r1.ebuild 33335 BLAKE2B da048552e021b826491eda064a6ca2deb9e7bb1a072c7742d83c48a487416989839d151278f62d05482d45003074bd5a6101424e6691c3a48fcfffdf0f3dde87 SHA512 7614cd9cb76f9ae92d5c1cf5862d6d7e40421e686f97654d3b2c68e0a666a14504445ff6648262a18a94af4a1b83f002f8db88d917e677c5e0bc6ee8d09a0da8 +EBUILD mariadb-10.3.28-r4.ebuild 41057 BLAKE2B e3cebad5a639a16ae3db81a52ee0ca5403a9513de2812b4bc8bd78f691912249da43a40fd4a048f0f793037e81a22ae2b4f8bc87bda68dcbcc5176efe9aec14b SHA512 7984168020200cf847ff397cbd4a4f8e9744d2506af10bcc16f3982c00a576dad9fe8870e487dd8998fa6320555eba8f7de62cf3959c0958a56321defaeb05a5 +EBUILD mariadb-10.3.29-r1.ebuild 41311 BLAKE2B 4be9f384362bfb5b1be34a2b752c32cf3f2080d5312b34a16b7e6f3bb632d85f6186a372d1f2749f751748034dfffd009a486d9760e104422229e4229670cba9 SHA512 72959af848d7d12df1f6c614d8a0a3defbbab9b91b05fe252c6666909094ad0ec94f8f337bab086bd8925e8a8112c642d7f72b3290e8e0d058294c3b5bde0dc9 +EBUILD mariadb-10.4.13-r4.ebuild 33955 BLAKE2B f06a7288dc01c7d11380f75a118dec8649d5f03d3bc376be44842c911effcec144b863b37500ff828f0d88a0cac041c29d4ba2b19f74e8f30e8277e255a57a26 SHA512 c65c25a7cd4dcbe57ce7245ff05968761a29e5d1c7ef69736268cc28bead8013fc70181e0322bce3ecb5e0a14d3c794c6fc06db06eb5c38cda0ec886ba3dc95f +EBUILD mariadb-10.4.15-r1.ebuild 33986 BLAKE2B 07c94a20a76c3bd354ba6905acdfb24020ac1b82b7838bc3f78cb35eb308d9943ce60aa84253696337271f1733d1ce9aba3d08f59f41472cc3aa09f6b13e83bd SHA512 264df0c6bfa2bbe8f424b794e83c450cb7a59845fdeb286ea9d9fd9694e28b3e7bd3667925f4f9c07edb55dae7089cd0379d78e437598a9c9570e7167c242eea +EBUILD mariadb-10.4.16-r1.ebuild 34119 BLAKE2B a2e9a0ca1a8d5be628eb2205a0f7b30a3e8f44e96f11bc92a8d69ee1208a3146b91b67a76ef215f221d0f31335d54925f5805de8b9476ae0220d3d15ea2bbf86 SHA512 5565d8ead2d1817a14fc46915f30b36b72e1760290582b2d9f9035769280db63197c1e7f0271ba6396fa99dec7cd8c2b6c9b331d9daa35935c2221ca3bb0b533 +EBUILD mariadb-10.4.17-r1.ebuild 34114 BLAKE2B 878cee3ab2d1b836ca6abdae13ba22e449a558ae6b429dbc5cf991ab41dd6fadd54c4141f7943ed6bfc467fbb2aaef737eafaf7e5fe3f2f92d6e0c9e23a75194 SHA512 659d7550bdd1eb580e28a710f3267f9673ee37ed0b8479cce9dbc2e3c9642018edaf2453dbd4e07680d76f867a298e28e2a0eb2f759a6ae55898335a4236fae5 +EBUILD mariadb-10.4.18-r4.ebuild 41614 BLAKE2B 0dcc328990ba19513e8e3930ebcd186c28c9ef52c0644db7298fb7a47981147a866117ddfc99136dfc2ccee8d3687ba0fd792d4fc061e584068a14e365f7d0ae SHA512 fc39145a63140ce0496d8b6cb003019de68eb24063d13baa0c1f27f97e803b5c4fb45a7ff4091b10add05a7fd19cf5177350837a7640d2c72c17f972ae15d51e +EBUILD mariadb-10.4.19-r1.ebuild 42023 BLAKE2B 8ce14391589a0df73b6f2f100b9cb7fd680d057ce9bfafc51c2f6d8e18fd218004da26ae2affbe47ba6e2bcf8756daf2381d25d9d2955a50d5189e92aba8598f SHA512 383c511249db093c010fe54863cec7f39c86de69f2c4e5d2586a0e235175465c834fe8e479feddf476493b5ae201f9345c9785eb7fac1b6435d36f130e2a6b9e +EBUILD mariadb-10.5.10-r1.ebuild 41447 BLAKE2B dbe99c0aa52367596551c6954a6f75e2d95639ab7c8835ce60c6c55546aa229a18c7a69db19ee19e12e7836ae881521a7a9556b6ae3b3f5c0b207e66d0304cde SHA512 79d98adbcd1fe30f0c3a5f8b1df53a7b4e798c33c148d8c7a23f02bc31175ad1eadefef24f152681053a82ed10de7099f623ccffb9cf9439d8bc7fbc5dbbaf66 +EBUILD mariadb-10.5.9-r6.ebuild 41112 BLAKE2B ddf6ef3f0176acf4d2a5ed9933a1246dcccbe4cbec4930f3fc435f1725d1932938b2cc37abf0f1428aa35e914cc594b7ad5a4a4d3b78286a2a7c88a2a84231b4 SHA512 57f3140ec63bf88e12b2ae9c1bff7bd585baefd0849a99f585d3df63729818caf02b562b63dfc8266f29664f704af19782296722f12bd2230e517c601deb3fb7 MISC metadata.xml 2625 BLAKE2B 649e3bfdce49ed2352d31849a7d4547e0eeee23fab8ee58705fab62f8e1dee1874885027897bcb2895def5dcfeeea66caa69f83161ac1cfd19154a8712bdf573 SHA512 edbbfc7be64f124c0969f7de67337ba0b579292837d10e18da56b7e4e1cca88a36ac304e7c2625d9ae2bcf625d632a707f9813a0382242fc3d59d384b5b7bd54 diff --git a/dev-db/mariadb/mariadb-10.2.32-r3.ebuild b/dev-db/mariadb/mariadb-10.2.32-r3.ebuild deleted file mode 100644 index 90d4e0ae97e2..000000000000 --- a/dev-db/mariadb/mariadb-10.2.32-r3.ebuild +++ /dev/null @@ -1,1010 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="6" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -# Keeping eutils in EAPI=6 for emktemp in pkg_config - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake-utils - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.32-patches-03.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.2/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -DEPEND="virtual/yacc - static? ( sys-libs/ncurses[static-libs] ) - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) - server? ( - galera? ( - sst-xtrabackup? ( - || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) - ) - ) - )" - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR%/}/${P}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - eapply "${FILESDIR}"/mariadb-10.3-CVE-2020-15180.patch - - eapply_user - - _disable_plugin() { - echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S%/}/storage/${1}/CMakeLists.txt" || die - } - - local malloc - for malloc in jemalloc tcmalloc ; do - if use ${malloc}; then - echo "TARGET_LINK_LIBRARIES(mysqld ${malloc})" >> "${S}/sql/CMakeLists.txt" - fi - done - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake-utils_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_JEMALLOC=$(usex jemalloc system) - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR=share/mariadb - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake-utils_src_configure -} - -src_compile() { - cmake-utils_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - 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))" - - 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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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 - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - #Remove mytop if perl is not selected - [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if use sst-xtrabackup ; then - ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" - ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" - ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." - ewarn "sst-xtrabackup is being removed in 10.3 and higher." - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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 https://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 grant-tables 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 - # https://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 - - local cmd=( "${EROOT}usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" ) - 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} \ - --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" - "${EROOT}/usr/bin/mysql" \ - "--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/mariadb/mariadb-10.2.32-r4.ebuild b/dev-db/mariadb/mariadb-10.2.32-r4.ebuild new file mode 100644 index 000000000000..30291e9a29a2 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.2.32-r4.ebuild @@ -0,0 +1,1011 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="6" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +# Keeping eutils in EAPI=6 for emktemp in pkg_config + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake-utils + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.32-patches-03.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.2/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +DEPEND="virtual/yacc + static? ( sys-libs/ncurses[static-libs] ) + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) + server? ( + galera? ( + sst-xtrabackup? ( + || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) + ) + ) + )" + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR%/}/${P}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + eapply "${FILESDIR}"/mariadb-10.3-CVE-2020-15180.patch + + eapply_user + + _disable_plugin() { + echo > "${S%/}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S%/}/storage/${1}/CMakeLists.txt" || die + } + + local malloc + for malloc in jemalloc tcmalloc ; do + if use ${malloc}; then + echo "TARGET_LINK_LIBRARIES(mysqld ${malloc})" >> "${S}/sql/CMakeLists.txt" + fi + done + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake-utils_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_JEMALLOC=$(usex jemalloc system) + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR=share/mariadb + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake-utils_src_configure +} + +src_compile() { + cmake-utils_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + 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))" + + 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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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 + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + #Remove mytop if perl is not selected + [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl && rm -f "${ED}/usr/bin/mytop" +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if use sst-xtrabackup ; then + ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" + ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" + ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." + ewarn "sst-xtrabackup is being removed in 10.3 and higher." + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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 https://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 grant-tables 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 + # https://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 + + local cmd=( "${EROOT}usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}usr/bin/mysql_install_db" ) + 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} \ + --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" + "${EROOT}/usr/bin/mysql" \ + "--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/mariadb/mariadb-10.2.34-r1.ebuild b/dev-db/mariadb/mariadb-10.2.34-r1.ebuild new file mode 100644 index 000000000000..13b73dc1bfb2 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.2.34-r1.ebuild @@ -0,0 +1,1016 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.33-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.2/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) + server? ( + galera? ( + sst-xtrabackup? ( + || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) + ) + ) + )" + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_JEMALLOC=$(usex jemalloc system) + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR=share/mariadb + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if use sst-xtrabackup ; then + ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" + ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" + ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." + ewarn "sst-xtrabackup is being removed in 10.3 and higher." + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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} \ + --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" + "${EROOT}/usr/bin/mysql" \ + "--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/mariadb/mariadb-10.2.34.ebuild b/dev-db/mariadb/mariadb-10.2.34.ebuild deleted file mode 100644 index 906f4db9f256..000000000000 --- a/dev-db/mariadb/mariadb-10.2.34.ebuild +++ /dev/null @@ -1,1015 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.33-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.2/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) - server? ( - galera? ( - sst-xtrabackup? ( - || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) - ) - ) - )" - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_JEMALLOC=$(usex jemalloc system) - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR=share/mariadb - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if use sst-xtrabackup ; then - ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" - ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" - ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." - ewarn "sst-xtrabackup is being removed in 10.3 and higher." - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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} \ - --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" - "${EROOT}/usr/bin/mysql" \ - "--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/mariadb/mariadb-10.2.35-r1.ebuild b/dev-db/mariadb/mariadb-10.2.35-r1.ebuild new file mode 100644 index 000000000000..e08c640b65bc --- /dev/null +++ b/dev-db/mariadb/mariadb-10.2.35-r1.ebuild @@ -0,0 +1,1017 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.35-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.2/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) + server? ( + galera? ( + sst-xtrabackup? ( + || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) + ) + ) + )" + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_JEMALLOC=$(usex jemalloc system) + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR=share/mariadb + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if use sst-xtrabackup ; then + ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" + ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" + ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." + ewarn "sst-xtrabackup is being removed in 10.3 and higher." + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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} \ + --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" + "${EROOT}/usr/bin/mysql" \ + "--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/mariadb/mariadb-10.2.35.ebuild b/dev-db/mariadb/mariadb-10.2.35.ebuild deleted file mode 100644 index 31413b22c032..000000000000 --- a/dev-db/mariadb/mariadb-10.2.35.ebuild +++ /dev/null @@ -1,1016 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.35-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.2/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) - server? ( - galera? ( - sst-xtrabackup? ( - || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) - ) - ) - )" - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_JEMALLOC=$(usex jemalloc system) - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR=share/mariadb - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if use sst-xtrabackup ; then - ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" - ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" - ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." - ewarn "sst-xtrabackup is being removed in 10.3 and higher." - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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} \ - --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" - "${EROOT}/usr/bin/mysql" \ - "--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/mariadb/mariadb-10.2.36-r1.ebuild b/dev-db/mariadb/mariadb-10.2.36-r1.ebuild new file mode 100644 index 000000000000..7e85628ac113 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.2.36-r1.ebuild @@ -0,0 +1,1017 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.36-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.2/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) + server? ( + galera? ( + sst-xtrabackup? ( + || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) + ) + ) + )" + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_JEMALLOC=$(usex jemalloc system) + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR=share/mariadb + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if use sst-xtrabackup ; then + ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" + ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" + ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." + ewarn "sst-xtrabackup is being removed in 10.3 and higher." + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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} \ + --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" + "${EROOT}/usr/bin/mysql" \ + "--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/mariadb/mariadb-10.2.36.ebuild b/dev-db/mariadb/mariadb-10.2.36.ebuild deleted file mode 100644 index e710a0d553aa..000000000000 --- a/dev-db/mariadb/mariadb-10.2.36.ebuild +++ /dev/null @@ -1,1016 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.36-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.2/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) - server? ( - galera? ( - sst-xtrabackup? ( - || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) - ) - ) - )" - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_JEMALLOC=$(usex jemalloc system) - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR=share/mariadb - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if use sst-xtrabackup ; then - ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" - ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" - ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." - ewarn "sst-xtrabackup is being removed in 10.3 and higher." - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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} \ - --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" - "${EROOT}/usr/bin/mysql" \ - "--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/mariadb/mariadb-10.2.37-r3.ebuild b/dev-db/mariadb/mariadb-10.2.37-r3.ebuild deleted file mode 100644 index 2622cb71a80b..000000000000 --- a/dev-db/mariadb/mariadb-10.2.37-r3.ebuild +++ /dev/null @@ -1,1285 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.37-patches-03.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.2/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) - server? ( - galera? ( - sst-xtrabackup? ( - || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) - ) - ) - )" - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_JEMALLOC=$(usex jemalloc system) - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR=share/mariadb - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if use sst-xtrabackup ; then - ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" - ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" - ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." - ewarn "sst-xtrabackup is being removed in 10.3 and higher." - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.2.37-r4.ebuild b/dev-db/mariadb/mariadb-10.2.37-r4.ebuild new file mode 100644 index 000000000000..b8895edb01e1 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.2.37-r4.ebuild @@ -0,0 +1,1286 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.37-patches-03.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.2/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) + server? ( + galera? ( + sst-xtrabackup? ( + || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) + ) + ) + )" + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_JEMALLOC=$(usex jemalloc system) + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR=share/mariadb + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if use sst-xtrabackup ; then + ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" + ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" + ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." + ewarn "sst-xtrabackup is being removed in 10.3 and higher." + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mariadb/mariadb-10.2.38-r1.ebuild b/dev-db/mariadb/mariadb-10.2.38-r1.ebuild new file mode 100644 index 000000000000..ce5b4bee8a98 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.2.38-r1.ebuild @@ -0,0 +1,1290 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.38-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.2/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !dev-db/mariadb:10.6 + !=virtual/jre-1.8 ) ) + ) +" +# For other stuff to bring us in +# dev-perl/DBD-mysql is needed by some scripts installed by MySQL +# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed +PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) + server? ( + galera? ( + sst-xtrabackup? ( + || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) + ) + ) + )" + +mysql_init_vars() { + MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + # Connect and Federated{,X} must be treated special + # otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_CONNECT=NO + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO + ) + fi + + mycmakeargs+=( + -DWITH_JEMALLOC=$(usex jemalloc system) + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_AWS_KEY_MANAGEMENT=NO + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR=share/mariadb + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if use sst-xtrabackup ; then + ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" + ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" + ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." + ewarn "sst-xtrabackup is being removed in 10.3 and higher." + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mariadb/mariadb-10.2.38.ebuild b/dev-db/mariadb/mariadb-10.2.38.ebuild deleted file mode 100644 index bb7a2db6f098..000000000000 --- a/dev-db/mariadb/mariadb-10.2.38.ebuild +++ /dev/null @@ -1,1289 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.2.38-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.2/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup sst-xtrabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !dev-db/mariadb:10.6 - !=virtual/jre-1.8 ) ) - ) -" -# For other stuff to bring us in -# dev-perl/DBD-mysql is needed by some scripts installed by MySQL -# percona-xtrabackup-bin causes a circular dependency if DBD-mysql is not already installed -PDEPEND="perl? ( >=dev-perl/DBD-mysql-2.9004 ) - server? ( - galera? ( - sst-xtrabackup? ( - || ( >=dev-db/percona-xtrabackup-bin-2.2.4 dev-db/percona-xtrabackup ) - ) - ) - )" - -mysql_init_vars() { - MY_SHAREDSTATEDIR=${MY_SHAREDSTATEDIR="${EPREFIX}/usr/share/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - # Connect and Federated{,X} must be treated special - # otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_CONNECT=NO - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO - ) - fi - - mycmakeargs+=( - -DWITH_JEMALLOC=$(usex jemalloc system) - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_AWS_KEY_MANAGEMENT=NO - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR=share/mariadb - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.join_cache;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if use sst-xtrabackup ; then - ewarn "As per https://mariadb.com/kb/en/meta/xtrabackup_warning/, XtraBackup" - ewarn "as an SST is broken by default beginning with 10.2.19 with the setting" - ewarn "innodb_safe_truncate=ON. Please migrate to sst-mariabackup instead." - ewarn "sst-xtrabackup is being removed in 10.3 and higher." - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.3.27-r1.ebuild b/dev-db/mariadb/mariadb-10.3.27-r1.ebuild new file mode 100644 index 000000000000..37c08b7c1749 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.3.27-r1.ebuild @@ -0,0 +1,1008 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.3.27-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.3/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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} \ + --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" + "${EROOT}/usr/bin/mysql" \ + "--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/mariadb/mariadb-10.3.27.ebuild b/dev-db/mariadb/mariadb-10.3.27.ebuild deleted file mode 100644 index 700176d0f579..000000000000 --- a/dev-db/mariadb/mariadb-10.3.27.ebuild +++ /dev/null @@ -1,1007 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.3.27-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.3/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' 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 https://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 grant-tables 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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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} \ - --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="UPDATE mysql.user SET Password = PASSWORD('${MYSQL_ROOT_PASSWORD}') WHERE USER='root'; FLUSH PRIVILEGES" - "${EROOT}/usr/bin/mysql" \ - "--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/mariadb/mariadb-10.3.28-r3.ebuild b/dev-db/mariadb/mariadb-10.3.28-r3.ebuild deleted file mode 100644 index 995a619bc5cc..000000000000 --- a/dev-db/mariadb/mariadb-10.3.28-r3.ebuild +++ /dev/null @@ -1,1277 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.3.28-patches-03.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.3/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--skip-test-db" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.3.28-r4.ebuild b/dev-db/mariadb/mariadb-10.3.28-r4.ebuild new file mode 100644 index 000000000000..ec094831bfc9 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.3.28-r4.ebuild @@ -0,0 +1,1278 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.3.28-patches-03.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.3/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--skip-test-db" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mariadb/mariadb-10.3.29-r1.ebuild b/dev-db/mariadb/mariadb-10.3.29-r1.ebuild new file mode 100644 index 000000000000..41b6508de74a --- /dev/null +++ b/dev-db/mariadb/mariadb-10.3.29-r1.ebuild @@ -0,0 +1,1282 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.3.29-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.3/${SUBSLOT:-0}" +IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.5 + !dev-db/mariadb:10.6 + !=virtual/jre-1.8 ) ) + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + cmake_src_prepare + java-pkg-opt-2_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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + # Connect and Federated{,X} must be treated special + # otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_CONNECT=NO + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO + ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_AWS_KEY_MANAGEMENT=NO + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.grant;0;Sporadically failing test" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_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 [[ -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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--skip-test-db" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mariadb/mariadb-10.3.29.ebuild b/dev-db/mariadb/mariadb-10.3.29.ebuild deleted file mode 100644 index 2ee72e2b26df..000000000000 --- a/dev-db/mariadb/mariadb-10.3.29.ebuild +++ /dev/null @@ -1,1281 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.3.29-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.3/${SUBSLOT:-0}" -IUSE="+backup bindist client-libs cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.5 - !dev-db/mariadb:10.6 - !=virtual/jre-1.8 ) ) - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - cmake_src_prepare - java-pkg-opt-2_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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - # Connect and Federated{,X} must be treated special - # otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_CONNECT=NO - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO - ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_AWS_KEY_MANAGEMENT=NO - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.grant;0;Sporadically failing test" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_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 [[ -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--skip-test-db" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.4.13-r3.ebuild b/dev-db/mariadb/mariadb-10.4.13-r3.ebuild deleted file mode 100644 index 4e128c050daf..000000000000 --- a/dev-db/mariadb/mariadb-10.4.13-r3.ebuild +++ /dev/null @@ -1,1034 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.13-patches-03.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.4/${SUBSLOT:-0}" -IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - eapply "${FILESDIR}"/mariadb-10.4-CVE-2020-15180.patch - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' user now" - einfo "or through the ${HOME}/.my.cnf file." - ewarn "Avoid [\"'\\_%] characters in the password" - einfo "Not entering a password defaults to UNIX authentication" - read -rsp " >" pwd1 ; echo - - if [[ -n "${pwd1}" ]] ; then - - 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}" - fi - unset pwd1 pwd2 - fi - - local options - local sqltmp="$(emktemp)" - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see https://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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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" - - if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then - einfo "Done" - exit 0 - fi - - 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} \ - --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 - - [[ -S "${socket}" ]] || - die "Completely failed to start up mysqld with: ${mysqld}" - - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then - 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" \ - "--socket=${socket}" \ - -hlocalhost \ - -e "${sql}" - unset sql - eend $? - fi - - 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/mariadb/mariadb-10.4.13-r4.ebuild b/dev-db/mariadb/mariadb-10.4.13-r4.ebuild new file mode 100644 index 000000000000..7983b75dfd42 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.4.13-r4.ebuild @@ -0,0 +1,1035 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.13-patches-03.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.4/${SUBSLOT:-0}" +IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + eapply "${FILESDIR}"/mariadb-10.4-CVE-2020-15180.patch + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' user now" + einfo "or through the ${HOME}/.my.cnf file." + ewarn "Avoid [\"'\\_%] characters in the password" + einfo "Not entering a password defaults to UNIX authentication" + read -rsp " >" pwd1 ; echo + + if [[ -n "${pwd1}" ]] ; then + + 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}" + fi + unset pwd1 pwd2 + fi + + local options + local sqltmp="$(emktemp)" + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see https://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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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" + + if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then + einfo "Done" + exit 0 + fi + + 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} \ + --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 + + [[ -S "${socket}" ]] || + die "Completely failed to start up mysqld with: ${mysqld}" + + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then + 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" \ + "--socket=${socket}" \ + -hlocalhost \ + -e "${sql}" + unset sql + eend $? + fi + + 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/mariadb/mariadb-10.4.15-r1.ebuild b/dev-db/mariadb/mariadb-10.4.15-r1.ebuild new file mode 100644 index 000000000000..596a01f8e541 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.4.15-r1.ebuild @@ -0,0 +1,1037 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.14-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.4/${SUBSLOT:-0}" +IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' user now" + einfo "or through the ${HOME}/.my.cnf file." + ewarn "Avoid [\"'\\_%] characters in the password" + einfo "Not entering a password defaults to UNIX authentication" + read -rsp " >" pwd1 ; echo + + if [[ -n "${pwd1}" ]] ; then + 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}" + fi + + unset pwd1 pwd2 + fi + + local options + local sqltmp="$(emktemp)" + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see https://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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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" + + if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then + einfo "Done" + exit 0 + fi + + 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} \ + --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 + + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then + 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" \ + "--socket=${socket}" \ + -hlocalhost \ + -e "${sql}" + unset sql + eend $? + fi + + 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/mariadb/mariadb-10.4.15.ebuild b/dev-db/mariadb/mariadb-10.4.15.ebuild deleted file mode 100644 index 753ddd9b8a80..000000000000 --- a/dev-db/mariadb/mariadb-10.4.15.ebuild +++ /dev/null @@ -1,1036 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.14-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.4/${SUBSLOT:-0}" -IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' user now" - einfo "or through the ${HOME}/.my.cnf file." - ewarn "Avoid [\"'\\_%] characters in the password" - einfo "Not entering a password defaults to UNIX authentication" - read -rsp " >" pwd1 ; echo - - if [[ -n "${pwd1}" ]] ; then - 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}" - fi - - unset pwd1 pwd2 - fi - - local options - local sqltmp="$(emktemp)" - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see https://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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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" - - if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then - einfo "Done" - exit 0 - fi - - 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} \ - --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 - - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then - 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" \ - "--socket=${socket}" \ - -hlocalhost \ - -e "${sql}" - unset sql - eend $? - fi - - 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/mariadb/mariadb-10.4.16-r1.ebuild b/dev-db/mariadb/mariadb-10.4.16-r1.ebuild new file mode 100644 index 000000000000..c972190f3325 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.4.16-r1.ebuild @@ -0,0 +1,1039 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.16-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.4/${SUBSLOT:-0}" +IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' user now" + einfo "or through the ${HOME}/.my.cnf file." + ewarn "Avoid [\"'\\_%] characters in the password" + einfo "Not entering a password defaults to UNIX authentication" + read -rsp " >" pwd1 ; echo + + if [[ -n "${pwd1}" ]] ; then + 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}" + fi + + unset pwd1 pwd2 + fi + + local options + local sqltmp="$(emktemp)" + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see https://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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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" + + if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then + einfo "Done" + exit 0 + fi + + 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} \ + --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 + + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then + 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" \ + "--socket=${socket}" \ + -hlocalhost \ + -e "${sql}" + unset sql + eend $? + fi + + 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/mariadb/mariadb-10.4.16.ebuild b/dev-db/mariadb/mariadb-10.4.16.ebuild deleted file mode 100644 index a4b2fc06a1f4..000000000000 --- a/dev-db/mariadb/mariadb-10.4.16.ebuild +++ /dev/null @@ -1,1038 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.16-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.4/${SUBSLOT:-0}" -IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' user now" - einfo "or through the ${HOME}/.my.cnf file." - ewarn "Avoid [\"'\\_%] characters in the password" - einfo "Not entering a password defaults to UNIX authentication" - read -rsp " >" pwd1 ; echo - - if [[ -n "${pwd1}" ]] ; then - 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}" - fi - - unset pwd1 pwd2 - fi - - local options - local sqltmp="$(emktemp)" - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see https://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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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" - - if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then - einfo "Done" - exit 0 - fi - - 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} \ - --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 - - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then - 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" \ - "--socket=${socket}" \ - -hlocalhost \ - -e "${sql}" - unset sql - eend $? - fi - - 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/mariadb/mariadb-10.4.17-r1.ebuild b/dev-db/mariadb/mariadb-10.4.17-r1.ebuild new file mode 100644 index 000000000000..9c4627f1d03d --- /dev/null +++ b/dev-db/mariadb/mariadb-10.4.17-r1.ebuild @@ -0,0 +1,1039 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.17-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.4/${SUBSLOT:-0}" +IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) + perl? ( + !dev-db/mytop + virtual/perl-Getopt-Long + dev-perl/TermReadKey + virtual/perl-Term-ANSIColor + virtual/perl-Time-HiRes + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=share/mariadb/scripts + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove mytop if perl is not selected + if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then + rm -f "${ED}/usr/bin/mytop" || die + fi + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _getoptval() { + local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" + # These are dir+prefix + MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" + MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} + MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" + MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} + + if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then + einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" + install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" + fi + if [[ ! -d "${ROOT}/$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'@'localhost' user now" + einfo "or through the ${HOME}/.my.cnf file." + ewarn "Avoid [\"'\\_%] characters in the password" + einfo "Not entering a password defaults to UNIX authentication" + read -rsp " >" pwd1 ; echo + + if [[ -n "${pwd1}" ]] ; then + 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}" + fi + + unset pwd1 pwd2 + fi + + local options + local sqltmp="$(emktemp)" + + # Fix bug 446200. Don't reference host my.cnf, needs to come first, + # see https://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 + # https://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 + + local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) + [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) + 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" + + if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then + einfo "Done" + exit 0 + fi + + 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} \ + --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 + + if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then + 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" \ + "--socket=${socket}" \ + -hlocalhost \ + -e "${sql}" + unset sql + eend $? + fi + + 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/mariadb/mariadb-10.4.17.ebuild b/dev-db/mariadb/mariadb-10.4.17.ebuild deleted file mode 100644 index 0abf3fccea70..000000000000 --- a/dev-db/mariadb/mariadb-10.4.17.ebuild +++ /dev/null @@ -1,1038 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.17-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.4/${SUBSLOT:-0}" -IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) - perl? ( - !dev-db/mytop - virtual/perl-Getopt-Long - dev-perl/TermReadKey - virtual/perl-Term-ANSIColor - virtual/perl-Time-HiRes - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=share/mariadb/scripts - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove mytop if perl is not selected - if [[ -e "${ED}/usr/bin/mytop" ]] && ! use perl ; then - rm -f "${ED}/usr/bin/mytop" || die - fi - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _getoptval() { - local mypd="${EROOT}"/usr/libexec/mariadb/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 | tail -n1)" - # These are dir+prefix - MYSQL_RELAY_LOG="$(_getoptval mysqld relay-log | tail -n1)" - MYSQL_RELAY_LOG=${MYSQL_RELAY_LOG%/*} - MYSQL_LOG_BIN="$(_getoptval mysqld log-bin | tail -n1)" - MYSQL_LOG_BIN=${MYSQL_LOG_BIN%/*} - - if [[ ! -d "${ROOT}/$MYSQL_TMPDIR" ]]; then - einfo "Creating MySQL tmpdir $MYSQL_TMPDIR" - install -d -m 770 -o mysql -g mysql "${EROOT}/$MYSQL_TMPDIR" - fi - if [[ ! -d "${ROOT}/$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'@'localhost' user now" - einfo "or through the ${HOME}/.my.cnf file." - ewarn "Avoid [\"'\\_%] characters in the password" - einfo "Not entering a password defaults to UNIX authentication" - read -rsp " >" pwd1 ; echo - - if [[ -n "${pwd1}" ]] ; then - 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}" - fi - - unset pwd1 pwd2 - fi - - local options - local sqltmp="$(emktemp)" - - # Fix bug 446200. Don't reference host my.cnf, needs to come first, - # see https://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 - # https://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 - - local cmd=( "${EROOT}/usr/share/mariadb/scripts/mysql_install_db" ) - [[ -f "${cmd}" ]] || cmd=( "${EROOT}/usr/bin/mysql_install_db" ) - 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" - - if [[ -z ${sqltmp} && -z ${MYSQL_ROOT_PASSWORD} ]] ; then - einfo "Done" - exit 0 - fi - - 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} \ - --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 - - if [[ -n "${MYSQL_ROOT_PASSWORD}" ]] ; then - 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" \ - "--socket=${socket}" \ - -hlocalhost \ - -e "${sql}" - unset sql - eend $? - fi - - 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/mariadb/mariadb-10.4.18-r3.ebuild b/dev-db/mariadb/mariadb-10.4.18-r3.ebuild deleted file mode 100644 index 1c922e47c714..000000000000 --- a/dev-db/mariadb/mariadb-10.4.18-r3.ebuild +++ /dev/null @@ -1,1296 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.18-patches-03.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.4/${SUBSLOT:-0}" -IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.5 - !=virtual/jre-1.6 ) ) - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--skip-test-db" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.4.18-r4.ebuild b/dev-db/mariadb/mariadb-10.4.18-r4.ebuild new file mode 100644 index 000000000000..f548957ede25 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.4.18-r4.ebuild @@ -0,0 +1,1297 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.18-patches-03.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.4/${SUBSLOT:-0}" +IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.5 + !=virtual/jre-1.6 ) ) + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--skip-test-db" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mariadb/mariadb-10.4.19-r1.ebuild b/dev-db/mariadb/mariadb-10.4.19-r1.ebuild new file mode 100644 index 000000000000..1b6f65b0eac8 --- /dev/null +++ b/dev-db/mariadb/mariadb-10.4.19-r1.ebuild @@ -0,0 +1,1303 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.19-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.4/${SUBSLOT:-0}" +IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap tcmalloc + test tokudb xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + server? ( tokudb? ( jemalloc !tcmalloc ) ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# 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= + ) + >=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= ) + >=sys-libs/zlib-1.2.3:0= + kerberos? ( virtual/krb5 ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) + sys-libs/ncurses:0= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + server? ( + backup? ( app-arch/libarchive:0= ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + systemd? ( sys-apps/systemd:= ) + tokudb? ( app-arch/snappy ) + ) + >=dev-libs/libpcre-8.41-r1:3= + virtual/libcrypt:= +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="static? ( sys-libs/ncurses[static-libs] ) + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + ${COMMON_DEPEND}" +RDEPEND="selinux? ( sec-policy/selinux-mysql ) + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.5 + !dev-db/mariadb:10.6 + !=virtual/jre-1.8 ) ) + ) +" +# 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/mariadb"} + 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_setup() { + if [[ ${MERGE_TYPE} != binary ]] ; then + local GCC_MAJOR_SET=$(gcc-major-version) + local GCC_MINOR_SET=$(gcc-minor-version) + + if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ + ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then + eerror "${PN} with tokudb 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 + + # 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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + # Don't build bundled xz-utils for tokudb + echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die + sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die + sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + # Connect and Federated{,X} must be treated special + # otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_CONNECT=NO + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO + ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_TOKUDB=$(usex tokudb YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_AWS_KEY_MANAGEMENT=NO + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + # Workaround for MDEV-14524 + use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "main.upgrade_MDEV-19650;25096;Known to be broken" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + disabled_tests+=( "sys_vars.wsrep_on_without_provider;25625;Known to be broken" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + 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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--skip-test-db" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mariadb/mariadb-10.4.19.ebuild b/dev-db/mariadb/mariadb-10.4.19.ebuild deleted file mode 100644 index 24c258c10699..000000000000 --- a/dev-db/mariadb/mariadb-10.4.19.ebuild +++ /dev/null @@ -1,1302 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.4.19-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.4/${SUBSLOT:-0}" -IUSE="+backup bindist cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap tcmalloc - test tokudb xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - server? ( tokudb? ( jemalloc !tcmalloc ) ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# 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= - ) - >=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= ) - >=sys-libs/zlib-1.2.3:0= - kerberos? ( virtual/krb5 ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) - sys-libs/ncurses:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - server? ( - backup? ( app-arch/libarchive:0= ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - systemd? ( sys-apps/systemd:= ) - tokudb? ( app-arch/snappy ) - ) - >=dev-libs/libpcre-8.41-r1:3= -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="static? ( sys-libs/ncurses[static-libs] ) - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - ${COMMON_DEPEND}" -RDEPEND="selinux? ( sec-policy/selinux-mysql ) - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.5 - !dev-db/mariadb:10.6 - !=virtual/jre-1.8 ) ) - ) -" -# 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/mariadb"} - 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_setup() { - if [[ ${MERGE_TYPE} != binary ]] ; then - local GCC_MAJOR_SET=$(gcc-major-version) - local GCC_MINOR_SET=$(gcc-minor-version) - - if use tokudb && [[ ${GCC_MAJOR_SET} -lt 4 || \ - ${GCC_MAJOR_SET} -eq 4 && ${GCC_MINOR_SET} -lt 7 ]] ; then - eerror "${PN} with tokudb 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 - - # 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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mysqld LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - # Don't build bundled xz-utils for tokudb - echo > "${S}/storage/tokudb/PerconaFT/cmake_modules/TokuThirdParty.cmake" || die - sed -i -e 's/ build_lzma//' -e 's/ build_snappy//' "${S}/storage/tokudb/PerconaFT/ft/CMakeLists.txt" || die - sed -i -e 's/add_dependencies\(tokuportability_static_conv build_jemalloc\)//' "${S}/storage/tokudb/PerconaFT/portability/CMakeLists.txt" || die - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - # Connect and Federated{,X} must be treated special - # otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_CONNECT=NO - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO - ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_TOKUDB=$(usex tokudb YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_AWS_KEY_MANAGEMENT=NO - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - # Workaround for MDEV-14524 - use tokudb && mycmakeargs+=( -DTOKUDB_OK=1 ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "main.upgrade_MDEV-19650;25096;Known to be broken" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - disabled_tests+=( "sys_vars.wsrep_on_without_provider;25625;Known to be broken" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - 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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--skip-test-db" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.5.10-r1.ebuild b/dev-db/mariadb/mariadb-10.5.10-r1.ebuild new file mode 100644 index 000000000000..6c847922246a --- /dev/null +++ b/dev-db/mariadb/mariadb-10.5.10-r1.ebuild @@ -0,0 +1,1297 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.5.10-patches-01.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.5/${SUBSLOT:-0}" +IUSE="+backup bindist columnstore cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap s3 tcmalloc + test xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# Be warned, *DEPEND are version-dependant +# These are used for both runtime and compiletime +COMMON_DEPEND=" + >=dev-libs/libpcre2-10.34:= + >=sys-apps/sed-4 + >=sys-apps/texinfo-4.7-r1 + sys-libs/ncurses:0= + >=sys-libs/zlib-1.2.3:0= + virtual/libcrypt:= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + jemalloc? ( dev-libs/jemalloc:0= ) + kerberos? ( virtual/krb5 ) + kernel_linux? ( + sys-process/procps:0= + dev-libs/libaio:0= + ) + server? ( + app-arch/bzip2 + app-arch/xz-utils + backup? ( app-arch/libarchive:0= ) + columnstore? ( + app-arch/snappy + dev-libs/boost:0= + dev-libs/libxml2:2= + ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + s3? ( net-misc/curl ) + systemd? ( sys-apps/systemd:= ) + ) + systemtap? ( >=dev-util/systemtap-1.3:0= ) + tcmalloc? ( dev-util/google-perftools:0= ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="${COMMON_DEPEND} + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + static? ( sys-libs/ncurses[static-libs] ) +" +RDEPEND="${COMMON_DEPEND} + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !dev-db/mariadb:10.6 + !=virtual/jre-1.8 ) ) + galera? ( + sys-apps/iproute2 + =sys-cluster/galera-26* + sst-rsync? ( sys-process/lsof ) + sst-mariabackup? ( net-misc/socat[ssl] ) + ) + !prefix? ( dev-db/mysql-init-scripts acct-group/mysql acct-user/mysql ) + ) +" +# 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/mariadb"} + 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_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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mariadbd LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mariadbd LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + # Connect and Federated{,X} must be treated special + # otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_CONNECT=NO + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO + ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_AWS_KEY_MANAGEMENT=NO + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_S3=$(usex s3 YES NO) + -DPLUGIN_COLUMNSTORE=$(usex columnstore YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "main.upgrade_MDEV-19650;25096;Known to be broken" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + disabled_tests+=( "sys_vars.wsrep_on_without_provider;25625;Known to be broken" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--skip-test-db" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} diff --git a/dev-db/mariadb/mariadb-10.5.10.ebuild b/dev-db/mariadb/mariadb-10.5.10.ebuild deleted file mode 100644 index 264fc2efd676..000000000000 --- a/dev-db/mariadb/mariadb-10.5.10.ebuild +++ /dev/null @@ -1,1296 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.5.10-patches-01.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.5/${SUBSLOT:-0}" -IUSE="+backup bindist columnstore cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap s3 tcmalloc - test xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 arm arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# Be warned, *DEPEND are version-dependant -# These are used for both runtime and compiletime -COMMON_DEPEND=" - >=dev-libs/libpcre2-10.34:= - >=sys-apps/sed-4 - >=sys-apps/texinfo-4.7-r1 - sys-libs/ncurses:0= - >=sys-libs/zlib-1.2.3:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - jemalloc? ( dev-libs/jemalloc:0= ) - kerberos? ( virtual/krb5 ) - kernel_linux? ( - sys-process/procps:0= - dev-libs/libaio:0= - ) - server? ( - app-arch/bzip2 - app-arch/xz-utils - backup? ( app-arch/libarchive:0= ) - columnstore? ( - app-arch/snappy - dev-libs/boost:0= - dev-libs/libxml2:2= - ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - s3? ( net-misc/curl ) - systemd? ( sys-apps/systemd:= ) - ) - systemtap? ( >=dev-util/systemtap-1.3:0= ) - tcmalloc? ( dev-util/google-perftools:0= ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="${COMMON_DEPEND} - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.8 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - static? ( sys-libs/ncurses[static-libs] ) -" -RDEPEND="${COMMON_DEPEND} - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !dev-db/mariadb:10.6 - !=virtual/jre-1.8 ) ) - galera? ( - sys-apps/iproute2 - =sys-cluster/galera-26* - sst-rsync? ( sys-process/lsof ) - sst-mariabackup? ( net-misc/socat[ssl] ) - ) - !prefix? ( dev-db/mysql-init-scripts acct-group/mysql acct-user/mysql ) - ) -" -# 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/mariadb"} - 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_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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mariadbd LINK_PUBLIC jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mariadbd LINK_PUBLIC tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - # Connect and Federated{,X} must be treated special - # otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_CONNECT=NO - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO - ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_AWS_KEY_MANAGEMENT=NO - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_S3=$(usex s3 YES NO) - -DPLUGIN_COLUMNSTORE=$(usex columnstore YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "innodb_gis.1;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "innodb_gis.gis;25095;Known rounding error with latest AMD processors" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "main.upgrade_MDEV-19650;25096;Known to be broken" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - disabled_tests+=( "sys_vars.wsrep_on_without_provider;25625;Known to be broken" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--skip-test-db" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.5.9-r5.ebuild b/dev-db/mariadb/mariadb-10.5.9-r5.ebuild deleted file mode 100644 index 35a14850bf6e..000000000000 --- a/dev-db/mariadb/mariadb-10.5.9-r5.ebuild +++ /dev/null @@ -1,1292 +0,0 @@ -# Copyright 1999-2021 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI="7" -SUBSLOT="18" - -JAVA_PKG_OPT_USE="jdbc" - -inherit eutils systemd flag-o-matic prefix toolchain-funcs \ - multiprocessing java-pkg-opt-2 cmake - -# Patch version -PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.5.9-patches-05.tar.xz" - -SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz - ${PATCH_SET}" - -HOMEPAGE="https://mariadb.org/" -DESCRIPTION="An enhanced, drop-in replacement for MySQL" -LICENSE="GPL-2 LGPL-2.1+" -SLOT="10.5/${SUBSLOT:-0}" -IUSE="+backup bindist columnstore cracklib debug extraengine galera innodb-lz4 - innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga - numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx - sst-rsync sst-mariabackup static systemd systemtap s3 tcmalloc - test xml yassl" - -RESTRICT="!bindist? ( bindist ) !test? ( test )" - -REQUIRED_USE="jdbc? ( extraengine server !static ) - ?? ( tcmalloc jemalloc ) - static? ( yassl !pam )" - -KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" - -# 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" - -# Be warned, *DEPEND are version-dependant -# These are used for both runtime and compiletime -COMMON_DEPEND=" - >=dev-libs/libpcre2-10.34:= - >=sys-apps/sed-4 - >=sys-apps/texinfo-4.7-r1 - sys-libs/ncurses:0= - >=sys-libs/zlib-1.2.3:0= - !bindist? ( - sys-libs/binutils-libs:0= - >=sys-libs/readline-4.1:0= - ) - jemalloc? ( dev-libs/jemalloc:0= ) - kerberos? ( virtual/krb5 ) - kernel_linux? ( - sys-process/procps:0= - dev-libs/libaio:0= - ) - server? ( - app-arch/bzip2 - app-arch/xz-utils - backup? ( app-arch/libarchive:0= ) - columnstore? ( - app-arch/snappy - dev-libs/boost:0= - dev-libs/libxml2:2= - ) - cracklib? ( sys-libs/cracklib:0= ) - extraengine? ( - odbc? ( dev-db/unixODBC:0= ) - xml? ( dev-libs/libxml2:2= ) - ) - innodb-lz4? ( app-arch/lz4 ) - innodb-lzo? ( dev-libs/lzo ) - innodb-snappy? ( app-arch/snappy ) - mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) - numa? ( sys-process/numactl ) - oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) - pam? ( sys-libs/pam:0= ) - s3? ( net-misc/curl ) - systemd? ( sys-apps/systemd:= ) - ) - systemtap? ( >=dev-util/systemtap-1.3:0= ) - tcmalloc? ( dev-util/google-perftools:0= ) - yassl? ( net-libs/gnutls:0= ) - !yassl? ( - >=dev-libs/openssl-1.0.0:0= - ) -" -BDEPEND="virtual/yacc - || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) -" -DEPEND="${COMMON_DEPEND} - server? ( - extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) - test? ( acct-group/mysql acct-user/mysql ) - ) - static? ( sys-libs/ncurses[static-libs] ) -" -RDEPEND="${COMMON_DEPEND} - !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster - !dev-db/mariadb:0 - !dev-db/mariadb:5.5 - !dev-db/mariadb:10.1 - !dev-db/mariadb:10.2 - !dev-db/mariadb:10.3 - !dev-db/mariadb:10.4 - !=virtual/jre-1.6 ) ) - galera? ( - sys-apps/iproute2 - =sys-cluster/galera-26* - sst-rsync? ( sys-process/lsof ) - sst-mariabackup? ( net-misc/socat[ssl] ) - ) - !prefix? ( dev-db/mysql-init-scripts acct-group/mysql acct-user/mysql ) - ) -" -# 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/mariadb"} - 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_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 - - if has test ${FEATURES} ; then - # Bug #213475 - MySQL _will_ object strenuously if your machine is named - # localhost. Also causes weird failures. - [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" - - if ! has userpriv ${FEATURES} ; then - die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." - fi - fi - fi - - java-pkg-opt-2_pkg_setup -} - -src_unpack() { - unpack ${A} - - mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die -} - -src_prepare() { - eapply "${WORKDIR}"/mariadb-patches - - eapply_user - - _disable_plugin() { - echo > "${S}/plugin/${1}/CMakeLists.txt" || die - } - _disable_engine() { - echo > "${S}/storage/${1}/CMakeLists.txt" || die - } - - if use jemalloc; then - echo "TARGET_LINK_LIBRARIES(mariadbd jemalloc)" >> "${S}/sql/CMakeLists.txt" - elif use tcmalloc; then - echo "TARGET_LINK_LIBRARIES(mariadbd tcmalloc)" >> "${S}/sql/CMakeLists.txt" - fi - - local plugin - local server_plugins=( handler_socket auth_socket feedback metadata_lock_info - locale_info qc_info server_audit sql_errlog auth_ed25519 ) - local test_plugins=( audit_null auth_examples daemon_example fulltext - debug_key_management example_key_management versioning ) - 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 - _disable_engine test_sql_discovery - echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die - fi - - _disable_engine example - - if ! use oqgraph ; then # avoids extra library checks - _disable_engine oqgraph - fi - - if use mroonga ; then - # Remove the bundled groonga - # There is no CMake flag, it simply checks for existance - rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" - else - _disable_engine mroonga - fi - - # Fix static bindings in galera replication - sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ - "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die - sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ - "${S}"/wsrep-lib/src/CMakeLists.txt || die - - # Fix galera_recovery.sh script - sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ - scripts/galera_recovery.sh || die - - sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ - "${S}"/scripts/mysql_install_db.sh || die - - cmake_src_prepare - java-pkg-opt-2_src_prepare -} - -src_configure() { - # bug 508724 mariadb cannot use ld.gold - tc-ld-disable-gold - # Bug #114895, bug #110149 - filter-flags "-O" "-O[01]" - - # It fails on alpha without this - use alpha && append-ldflags "-Wl,--no-relax" - - 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')" - -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/mariadb - -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin - -DINSTALL_SCRIPTDIR=bin - -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" - -DINSTALL_SBINDIR=sbin - -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" - -DWITH_COMMENT="Gentoo Linux ${PF}" - -DWITH_UNIT_TESTS=$(usex test ON OFF) - -DWITH_LIBEDIT=0 - -DWITH_ZLIB=system - -DWITHOUT_LIBWRAP=1 - -DENABLED_LOCAL_INFILE=1 - -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" - -DWITH_DEFAULT_COMPILER_OPTIONS=0 - -DWITH_DEFAULT_FEATURE_SET=0 - -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" - # 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) - -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) - -DCONC_WITH_EXTERNAL_ZLIB=YES - -DWITH_EXTERNAL_ZLIB=YES - -DSUFFIX_INSTALL_DIR="" - -DWITH_UNITTEST=OFF - -DWITHOUT_CLIENTLIBS=YES - -DCLIENT_PLUGIN_DIALOG=OFF - -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF - -DCLIENT_PLUGIN_CLIENT_ED25519=OFF - -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC - -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF - ) - if use test ; then - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) - else - mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) - fi - - if ! use yassl ; then - mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) - else - mycmakeargs+=( -DWITH_SSL=bundled ) - fi - - # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION - mycmakeargs+=( - -DWITH_READLINE=$(usex bindist 1 0) - -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) - -DENABLE_DTRACE=$(usex systemtap) - ) - - if use server ; then - - # Federated{,X} must be treated special otherwise they will not be built as plugins - if ! use extraengine ; then - mycmakeargs+=( - -DPLUGIN_FEDERATED=NO - -DPLUGIN_FEDERATEDX=NO - ) - fi - - mycmakeargs+=( - -DWITH_PCRE=system - -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) - -DPLUGIN_SPHINX=$(usex sphinx YES NO) - -DPLUGIN_AUTH_PAM=$(usex pam YES NO) - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) - -DPLUGIN_CASSANDRA=NO - -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) - -DPLUGIN_SPIDER=$(usex extraengine YES NO) - -DPLUGIN_S3=$(usex s3 YES NO) - -DPLUGIN_COLUMNSTORE=$(usex columnstore YES NO) - -DPLUGIN_CONNECT=$(usex extraengine YES NO) - -DCONNECT_WITH_MYSQL=1 - -DCONNECT_WITH_LIBXML2=$(usex xml) - -DCONNECT_WITH_ODBC=$(usex odbc) - -DCONNECT_WITH_JDBC=$(usex jdbc) - # Build failure and autodep wrt bug 639144 - -DCONNECT_WITH_MONGO=OFF - -DWITH_WSREP=$(usex galera) - -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) - -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) - -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) - -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) - -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) - -DWITH_MARIABACKUP=$(usex backup ON OFF) - -DWITH_LIBARCHIVE=$(usex backup ON OFF) - -DINSTALL_SQLBENCHDIR="" - -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) - # systemd is only linked to for server notification - -DWITH_SYSTEMD=$(usex systemd yes no) - -DWITH_NUMA=$(usex numa ON OFF) - ) - - if use test ; then - # This is needed for the new client lib which tests a real, open server - mycmakeargs+=( -DSKIP_TESTS=ON ) - fi - - 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+=( - -DEXTRA_CHARSETS=all - -DMYSQL_USER=mysql - -DDISABLE_SHARED=$(usex static YES NO) - -DWITH_DEBUG=$(usex debug) - -DWITH_EMBEDDED_SERVER=OFF - -DWITH_PROFILING=$(usex profiling) - ) - - if use static; then - mycmakeargs+=( -DWITH_PIC=1 ) - fi - - if use jemalloc || use tcmalloc ; then - mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) - 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 - ) - - else - mycmakeargs+=( - -DWITHOUT_SERVER=1 - -DWITH_EMBEDDED_SERVER=OFF - -DEXTRA_CHARSETS=none - -DINSTALL_SQLBENCHDIR= - -DWITH_SYSTEMD=no - ) - fi - - cmake_src_configure -} - -src_compile() { - cmake_src_compile -} - -# Official test instructions: -# USE='extraengine perl server' \ -# FEATURES='test userpriv' \ -# ebuild mariadb-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 - - if ! use server ; then - einfo "Skipping server tests due to minimal build." - return 0 - fi - - einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" - - # Run CTest (test-units) - cmake_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 - else - einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" - fi - - # 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 - - # create directories because mysqladmin might run out of order - mkdir -p "${T}"/var-tests{,/log} || die - - cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die - - local -a disabled_tests - disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) - disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) - disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) - disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) - disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) - disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) - disabled_tests+=( "main.upgrade_MDEV-19650;25096;Known to be broken" ) - disabled_tests+=( "mariabackup.*;0;Broken test suite" ) - disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) - disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) - disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) - disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) - disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) - - if ! use latin1 ; then - disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) - disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) - disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) - disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) - disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) - fi - - local test_infos_str test_infos_arr - 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_infos_str test_infos_arr - - # run mysql-test tests - pushd "${TESTDIR}" &>/dev/null || die - perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --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_src_install - - # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used - if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then - rm "${ED}/usr/include/mysql/server/private/config.h" || die - fi - - # 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-10.2" "${TMPDIR}/my.cnf" || die - eprefixify "${TMPDIR}/my.cnf" - doins "${TMPDIR}/my.cnf" - insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" - cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die - eprefixify "${TMPDIR}/50-distro-client.cnf" - doins "${TMPDIR}/50-distro-client.cnf" - - if use server ; then - mycnf_src="my.cnf.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|utf8|latin1|g" \ - "${TMPDIR}/my.cnf.ok" || die - fi - eprefixify "${TMPDIR}/my.cnf.ok" - newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf - - 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 - # Manually install supporting files that conflict with other packages - # but are needed for galera and initial installation - exeinto /usr/libexec/mariadb - doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" - - if use pam ; then - keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir - fi - fi - - # Remove bundled mytop in favor of dev-db/mytop - local mytop_file - for mytop_file in \ - "${ED}/usr/bin/mytop" \ - "${ED}/usr/share/man/man1/mytop.1" \ - ; do - if [[ -e "${mytop_file}" ]] ; then - rm -v "${mytop_file}" || die - fi - done - - # Fix a dangling symlink when galera is not built - if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then - rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die - fi - - # Remove broken SST scripts that are incompatible - local scriptremove - for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do - if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then - rm "${ED}/usr/bin/${scriptremove}" || die - fi - done -} - -pkg_preinst() { - java-pkg-opt-2_pkg_preinst -} - -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 use pam; then - einfo - elog "This install includes the PAM authentication plugin." - elog "To activate and configure the PAM plugin, please read:" - elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" - einfo - chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die - fi - - 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 - - if use galera ; then - einfo - elog "Be sure to edit the my.cnf file to activate your cluster settings." - elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" - elog "The first time the cluster is activated, you should add" - elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." - elog "This option should then be removed for subsequent starts." - einfo - if [[ -n "${REPLACING_VERSIONS}" ]] ; then - local rver - for rver in ${REPLACING_VERSIONS} ; do - if ver_test "${rver}" -lt "10.4.0" ; then - ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." - ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" - ewarn "for more information" - fi - done - fi - fi - fi - - # Note about configuration change - einfo - elog "This version of mariadb reorganizes the configuration from a single my.cnf" - elog "to several files in /etc/mysql/${PN}.d." - elog "Please backup any changes you made to /etc/mysql/my.cnf" - elog "and add them as a new file under /etc/mysql/${PN}.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 -} - -pkg_config() { - _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 - } - - local mysql_binary="${EROOT}/usr/bin/mysql" - if [[ ! -x "${mysql_binary}" ]] ; then - die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" - fi - - 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" - if [[ ! -x "${mysql_install_db_binary}" ]] ; then - die "'${mysql_install_db_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 - - # 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!" - fi - - MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" - MYSQL_TMPDIR=${MYSQL_TMPDIR%/} - # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then - MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" - [[ -z "${MYSQL_TMPDIR}" ]] \ - && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" - - mkdir "${MYSQL_TMPDIR}" || die - chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die - fi - - # Now we need to test MYSQL_TMPDIR... - 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 tmpdir '${MYSQL_TMPDIR}'!" - else - rm "${_my_tmpdir_testfile}" || die - unset _my_tmpdir_testfile - 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) - [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" - - # Limit access - chmod 0770 "${SETUP_TMPDIR}" || die - chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die - - local mysql_install_log="${SETUP_TMPDIR}/install_db.log" - local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" - - echo "" - einfo "Detected settings:" - einfo "==================" - einfo "MySQL User:\t\t\t\t${MYSQL_USER}" - einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" - einfo "MySQL DATA directory:\t\t${MY_DATADIR}" - einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" - - if [[ -n "${MYSQL_LOG_BIN}" ]] ; then - einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" - fi - - if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then - einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" - fi - - einfo "PID DIR:\t\t\t\t${PID_DIR}" - einfo "Install db log:\t\t\t${mysql_install_log}" - einfo "Install server log:\t\t\t${mysqld_logfile}" - - 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="${SETUP_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 - - local cmd=( - "${mysql_install_db_binary}" - "${mysqld_options[@]}" - "--init-file='${tz_sql}'" - "--basedir='${EROOT}/usr'" - "--datadir='${MY_DATADIR}'" - "--tmpdir='${MYSQL_TMPDIR}'" - "--log-error='${mysql_install_log}'" - "--rpm" - "--cross-bootstrap" - "--skip-test-db" - "--user=${MYSQL_USER}" - ) - - einfo "Initializing ${PN} data directory: ${cmd[@]}" - eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 - - if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" - [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" - local pidfile="${PID_DIR}/mysqld.${x}.pid" - [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" - unset x - - 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="${SETUP_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 - - rm -r "${SETUP_TMPDIR}" || die - - einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" -} diff --git a/dev-db/mariadb/mariadb-10.5.9-r6.ebuild b/dev-db/mariadb/mariadb-10.5.9-r6.ebuild new file mode 100644 index 000000000000..49db86b6188a --- /dev/null +++ b/dev-db/mariadb/mariadb-10.5.9-r6.ebuild @@ -0,0 +1,1293 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI="7" +SUBSLOT="18" + +JAVA_PKG_OPT_USE="jdbc" + +inherit eutils systemd flag-o-matic prefix toolchain-funcs \ + multiprocessing java-pkg-opt-2 cmake + +# Patch version +PATCH_SET="https://dev.gentoo.org/~whissi/dist/${PN}/${PN}-10.5.9-patches-05.tar.xz" + +SRC_URI="https://downloads.mariadb.org/interstitial/${P}/source/${P}.tar.gz + ${PATCH_SET}" + +HOMEPAGE="https://mariadb.org/" +DESCRIPTION="An enhanced, drop-in replacement for MySQL" +LICENSE="GPL-2 LGPL-2.1+" +SLOT="10.5/${SUBSLOT:-0}" +IUSE="+backup bindist columnstore cracklib debug extraengine galera innodb-lz4 + innodb-lzo innodb-snappy jdbc jemalloc kerberos latin1 mroonga + numa odbc oqgraph pam +perl profiling rocksdb selinux +server sphinx + sst-rsync sst-mariabackup static systemd systemtap s3 tcmalloc + test xml yassl" + +RESTRICT="!bindist? ( bindist ) !test? ( test )" + +REQUIRED_USE="jdbc? ( extraengine server !static ) + ?? ( tcmalloc jemalloc ) + static? ( yassl !pam )" + +KEYWORDS="~alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris ~x86-solaris" + +# 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" + +# Be warned, *DEPEND are version-dependant +# These are used for both runtime and compiletime +COMMON_DEPEND=" + >=dev-libs/libpcre2-10.34:= + >=sys-apps/sed-4 + >=sys-apps/texinfo-4.7-r1 + sys-libs/ncurses:0= + >=sys-libs/zlib-1.2.3:0= + virtual/libcrypt:= + !bindist? ( + sys-libs/binutils-libs:0= + >=sys-libs/readline-4.1:0= + ) + jemalloc? ( dev-libs/jemalloc:0= ) + kerberos? ( virtual/krb5 ) + kernel_linux? ( + sys-process/procps:0= + dev-libs/libaio:0= + ) + server? ( + app-arch/bzip2 + app-arch/xz-utils + backup? ( app-arch/libarchive:0= ) + columnstore? ( + app-arch/snappy + dev-libs/boost:0= + dev-libs/libxml2:2= + ) + cracklib? ( sys-libs/cracklib:0= ) + extraengine? ( + odbc? ( dev-db/unixODBC:0= ) + xml? ( dev-libs/libxml2:2= ) + ) + innodb-lz4? ( app-arch/lz4 ) + innodb-lzo? ( dev-libs/lzo ) + innodb-snappy? ( app-arch/snappy ) + mroonga? ( app-text/groonga-normalizer-mysql >=app-text/groonga-7.0.4 ) + numa? ( sys-process/numactl ) + oqgraph? ( >=dev-libs/boost-1.40.0:0= dev-libs/judy:0= ) + pam? ( sys-libs/pam:0= ) + s3? ( net-misc/curl ) + systemd? ( sys-apps/systemd:= ) + ) + systemtap? ( >=dev-util/systemtap-1.3:0= ) + tcmalloc? ( dev-util/google-perftools:0= ) + yassl? ( net-libs/gnutls:0= ) + !yassl? ( + >=dev-libs/openssl-1.0.0:0= + ) +" +BDEPEND="virtual/yacc + || ( >=sys-devel/gcc-3.4.6 >=sys-devel/gcc-apple-4.0 ) +" +DEPEND="${COMMON_DEPEND} + server? ( + extraengine? ( jdbc? ( >=virtual/jdk-1.6 ) ) + test? ( acct-group/mysql acct-user/mysql ) + ) + static? ( sys-libs/ncurses[static-libs] ) +" +RDEPEND="${COMMON_DEPEND} + !dev-db/mysql !dev-db/mariadb-galera !dev-db/percona-server !dev-db/mysql-cluster + !dev-db/mariadb:0 + !dev-db/mariadb:5.5 + !dev-db/mariadb:10.1 + !dev-db/mariadb:10.2 + !dev-db/mariadb:10.3 + !dev-db/mariadb:10.4 + !=virtual/jre-1.6 ) ) + galera? ( + sys-apps/iproute2 + =sys-cluster/galera-26* + sst-rsync? ( sys-process/lsof ) + sst-mariabackup? ( net-misc/socat[ssl] ) + ) + !prefix? ( dev-db/mysql-init-scripts acct-group/mysql acct-user/mysql ) + ) +" +# 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/mariadb"} + 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_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 + + if has test ${FEATURES} ; then + # Bug #213475 - MySQL _will_ object strenuously if your machine is named + # localhost. Also causes weird failures. + [[ "${HOSTNAME}" == "localhost" ]] && die "Your machine must NOT be named localhost" + + if ! has userpriv ${FEATURES} ; then + die "Testing with FEATURES=-userpriv is no longer supported by upstream. Tests MUST be run as non-root." + fi + fi + fi + + java-pkg-opt-2_pkg_setup +} + +src_unpack() { + unpack ${A} + + mv -f "${WORKDIR}/${P/_rc/}" "${S}" || die +} + +src_prepare() { + eapply "${WORKDIR}"/mariadb-patches + + eapply_user + + _disable_plugin() { + echo > "${S}/plugin/${1}/CMakeLists.txt" || die + } + _disable_engine() { + echo > "${S}/storage/${1}/CMakeLists.txt" || die + } + + if use jemalloc; then + echo "TARGET_LINK_LIBRARIES(mariadbd jemalloc)" >> "${S}/sql/CMakeLists.txt" + elif use tcmalloc; then + echo "TARGET_LINK_LIBRARIES(mariadbd tcmalloc)" >> "${S}/sql/CMakeLists.txt" + fi + + local plugin + local server_plugins=( handler_socket auth_socket feedback metadata_lock_info + locale_info qc_info server_audit sql_errlog auth_ed25519 ) + local test_plugins=( audit_null auth_examples daemon_example fulltext + debug_key_management example_key_management versioning ) + 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 + _disable_engine test_sql_discovery + echo > "${S}/plugin/auth_pam/testing/CMakeLists.txt" || die + fi + + _disable_engine example + + if ! use oqgraph ; then # avoids extra library checks + _disable_engine oqgraph + fi + + if use mroonga ; then + # Remove the bundled groonga + # There is no CMake flag, it simply checks for existance + rm -r "${S}"/storage/mroonga/vendor/groonga || die "could not remove packaged groonga" + else + _disable_engine mroonga + fi + + # Fix static bindings in galera replication + sed -i -e 's~add_library(wsrep_api_v26$~add_library(wsrep_api_v26 STATIC~' \ + "${S}"/wsrep-lib/wsrep-API/CMakeLists.txt || die + sed -i -e 's~add_library(wsrep-lib$~add_library(wsrep-lib STATIC~' \ + "${S}"/wsrep-lib/src/CMakeLists.txt || die + + # Fix galera_recovery.sh script + sed -i -e "s~@bindir@/my_print_defaults~${EPREFIX}/usr/libexec/mariadb/my_print_defaults~" \ + scripts/galera_recovery.sh || die + + sed -i -e 's~ \$basedir/lib/\*/mariadb19/plugin~~' \ + "${S}"/scripts/mysql_install_db.sh || die + + cmake_src_prepare + java-pkg-opt-2_src_prepare +} + +src_configure() { + # bug 508724 mariadb cannot use ld.gold + tc-ld-disable-gold + # Bug #114895, bug #110149 + filter-flags "-O" "-O[01]" + + # It fails on alpha without this + use alpha && append-ldflags "-Wl,--no-relax" + + 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')" + -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/mariadb + -DINSTALL_PLUGINDIR=$(get_libdir)/mariadb/plugin + -DINSTALL_SCRIPTDIR=bin + -DINSTALL_MYSQLDATADIR="${EPREFIX}/var/lib/mysql" + -DINSTALL_SBINDIR=sbin + -DINSTALL_SUPPORTFILESDIR="${EPREFIX}/usr/share/mariadb" + -DWITH_COMMENT="Gentoo Linux ${PF}" + -DWITH_UNIT_TESTS=$(usex test ON OFF) + -DWITH_LIBEDIT=0 + -DWITH_ZLIB=system + -DWITHOUT_LIBWRAP=1 + -DENABLED_LOCAL_INFILE=1 + -DMYSQL_UNIX_ADDR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DINSTALL_UNIX_ADDRDIR="${EPREFIX}/var/run/mysqld/mysqld.sock" + -DWITH_DEFAULT_COMPILER_OPTIONS=0 + -DWITH_DEFAULT_FEATURE_SET=0 + -DINSTALL_SYSTEMD_UNITDIR="$(systemd_get_systemunitdir)" + # 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) + -DPKG_CONFIG_EXECUTABLE="${EPREFIX}/usr/bin/$(tc-getPKG_CONFIG)" + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DAUTH_GSSAPI_PLUGIN_TYPE=$(usex kerberos DYNAMIC OFF) + -DCONC_WITH_EXTERNAL_ZLIB=YES + -DWITH_EXTERNAL_ZLIB=YES + -DSUFFIX_INSTALL_DIR="" + -DWITH_UNITTEST=OFF + -DWITHOUT_CLIENTLIBS=YES + -DCLIENT_PLUGIN_DIALOG=OFF + -DCLIENT_PLUGIN_AUTH_GSSAPI_CLIENT=OFF + -DCLIENT_PLUGIN_CLIENT_ED25519=OFF + -DCLIENT_PLUGIN_MYSQL_CLEAR_PASSWORD=STATIC + -DCLIENT_PLUGIN_CACHING_SHA2_PASSWORD=OFF + ) + if use test ; then + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR=share/mariadb/mysql-test ) + else + mycmakeargs+=( -DINSTALL_MYSQLTESTDIR='' ) + fi + + if ! use yassl ; then + mycmakeargs+=( -DWITH_SSL=system -DCLIENT_PLUGIN_SHA256_PASSWORD=STATIC ) + else + mycmakeargs+=( -DWITH_SSL=bundled ) + fi + + # bfd.h is only used starting with 10.1 and can be controlled by NOT_FOR_DISTRIBUTION + mycmakeargs+=( + -DWITH_READLINE=$(usex bindist 1 0) + -DNOT_FOR_DISTRIBUTION=$(usex bindist 0 1) + -DENABLE_DTRACE=$(usex systemtap) + ) + + if use server ; then + + # Federated{,X} must be treated special otherwise they will not be built as plugins + if ! use extraengine ; then + mycmakeargs+=( + -DPLUGIN_FEDERATED=NO + -DPLUGIN_FEDERATEDX=NO + ) + fi + + mycmakeargs+=( + -DWITH_PCRE=system + -DPLUGIN_OQGRAPH=$(usex oqgraph DYNAMIC NO) + -DPLUGIN_SPHINX=$(usex sphinx YES NO) + -DPLUGIN_AUTH_PAM=$(usex pam YES NO) + -DPLUGIN_CRACKLIB_PASSWORD_CHECK=$(usex cracklib YES NO) + -DPLUGIN_CASSANDRA=NO + -DPLUGIN_SEQUENCE=$(usex extraengine YES NO) + -DPLUGIN_SPIDER=$(usex extraengine YES NO) + -DPLUGIN_S3=$(usex s3 YES NO) + -DPLUGIN_COLUMNSTORE=$(usex columnstore YES NO) + -DPLUGIN_CONNECT=$(usex extraengine YES NO) + -DCONNECT_WITH_MYSQL=1 + -DCONNECT_WITH_LIBXML2=$(usex xml) + -DCONNECT_WITH_ODBC=$(usex odbc) + -DCONNECT_WITH_JDBC=$(usex jdbc) + # Build failure and autodep wrt bug 639144 + -DCONNECT_WITH_MONGO=OFF + -DWITH_WSREP=$(usex galera) + -DWITH_INNODB_LZ4=$(usex innodb-lz4 ON OFF) + -DWITH_INNODB_LZO=$(usex innodb-lzo ON OFF) + -DWITH_INNODB_SNAPPY=$(usex innodb-snappy ON OFF) + -DPLUGIN_MROONGA=$(usex mroonga DYNAMIC NO) + -DPLUGIN_AUTH_GSSAPI=$(usex kerberos DYNAMIC NO) + -DWITH_MARIABACKUP=$(usex backup ON OFF) + -DWITH_LIBARCHIVE=$(usex backup ON OFF) + -DINSTALL_SQLBENCHDIR="" + -DPLUGIN_ROCKSDB=$(usex rocksdb DYNAMIC NO) + # systemd is only linked to for server notification + -DWITH_SYSTEMD=$(usex systemd yes no) + -DWITH_NUMA=$(usex numa ON OFF) + ) + + if use test ; then + # This is needed for the new client lib which tests a real, open server + mycmakeargs+=( -DSKIP_TESTS=ON ) + fi + + 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+=( + -DEXTRA_CHARSETS=all + -DMYSQL_USER=mysql + -DDISABLE_SHARED=$(usex static YES NO) + -DWITH_DEBUG=$(usex debug) + -DWITH_EMBEDDED_SERVER=OFF + -DWITH_PROFILING=$(usex profiling) + ) + + if use static; then + mycmakeargs+=( -DWITH_PIC=1 ) + fi + + if use jemalloc || use tcmalloc ; then + mycmakeargs+=( -DWITH_SAFEMALLOC=OFF ) + 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 + ) + + else + mycmakeargs+=( + -DWITHOUT_SERVER=1 + -DWITH_EMBEDDED_SERVER=OFF + -DEXTRA_CHARSETS=none + -DINSTALL_SQLBENCHDIR= + -DWITH_SYSTEMD=no + ) + fi + + cmake_src_configure +} + +src_compile() { + cmake_src_compile +} + +# Official test instructions: +# USE='extraengine perl server' \ +# FEATURES='test userpriv' \ +# ebuild mariadb-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 + + if ! use server ; then + einfo "Skipping server tests due to minimal build." + return 0 + fi + + einfo ">>> Test phase [test]: ${CATEGORY}/${PF}" + + # Run CTest (test-units) + cmake_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 + else + einfo "MTR_PARALLEL is set to '${MTR_PARALLEL}'" + fi + + # 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 + + # create directories because mysqladmin might run out of order + mkdir -p "${T}"/var-tests{,/log} || die + + cp "${S}"/mysql-test/unstable-tests "${T}/disabled.def" || die + + local -a disabled_tests + disabled_tests+=( "compat/oracle.plugin;0;Needs example plugin which Gentoo disables" ) + disabled_tests+=( "main.explain_non_select;0;Sporadically failing test" ) + disabled_tests+=( "main.func_time;0;Dependent on time test was written" ) + disabled_tests+=( "main.plugin_auth;0;Needs client libraries built" ) + disabled_tests+=( "main.stat_tables;0;Sporadically failing test" ) + disabled_tests+=( "main.stat_tables_innodb;0;Sporadically failing test" ) + disabled_tests+=( "main.upgrade_MDEV-19650;25096;Known to be broken" ) + disabled_tests+=( "mariabackup.*;0;Broken test suite" ) + disabled_tests+=( "perfschema.nesting;23458;Known to be broken" ) + disabled_tests+=( "plugins.auth_ed25519;0;Needs client libraries built" ) + disabled_tests+=( "plugins.cracklib_password_check;0;False positive due to varying policies" ) + disabled_tests+=( "plugins.two_password_validations;0;False positive due to varying policies" ) + disabled_tests+=( "roles.acl_statistics;0;False positive due to a user count mismatch caused by previous test" ) + + if ! use latin1 ; then + disabled_tests+=( "funcs_1.is_columns_mysql;0;Requires USE=latin1" ) + disabled_tests+=( "main.information_schema;0;Requires USE=latin1" ) + disabled_tests+=( "main.sp2;24177;Requires USE=latin1" ) + disabled_tests+=( "main.system_mysql_db;0;Requires USE=latin1" ) + disabled_tests+=( "main.upgrade_MDEV-19650;24178;Requires USE=latin1" ) + fi + + local test_infos_str test_infos_arr + 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_infos_str test_infos_arr + + # run mysql-test tests + pushd "${TESTDIR}" &>/dev/null || die + perl mysql-test-run.pl --force --vardir="${T}/var-tests" --reorder --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_src_install + + # Remove an unnecessary, private config header which will never match between ABIs and is not meant to be used + if [[ -f "${ED}/usr/include/mysql/server/private/config.h" ]] ; then + rm "${ED}/usr/include/mysql/server/private/config.h" || die + fi + + # 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-10.2" "${TMPDIR}/my.cnf" || die + eprefixify "${TMPDIR}/my.cnf" + doins "${TMPDIR}/my.cnf" + insinto "${MY_SYSCONFDIR#${EPREFIX}}/mariadb.d" + cp "${FILESDIR}/my.cnf.distro-client" "${TMPDIR}/50-distro-client.cnf" || die + eprefixify "${TMPDIR}/50-distro-client.cnf" + doins "${TMPDIR}/50-distro-client.cnf" + + if use server ; then + mycnf_src="my.cnf.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|utf8|latin1|g" \ + "${TMPDIR}/my.cnf.ok" || die + fi + eprefixify "${TMPDIR}/my.cnf.ok" + newins "${TMPDIR}/my.cnf.ok" 50-distro-server.cnf + + 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 + # Manually install supporting files that conflict with other packages + # but are needed for galera and initial installation + exeinto /usr/libexec/mariadb + doexe "${BUILD_DIR}/extra/my_print_defaults" "${BUILD_DIR}/extra/perror" + + if use pam ; then + keepdir /usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir + fi + fi + + # Remove bundled mytop in favor of dev-db/mytop + local mytop_file + for mytop_file in \ + "${ED}/usr/bin/mytop" \ + "${ED}/usr/share/man/man1/mytop.1" \ + ; do + if [[ -e "${mytop_file}" ]] ; then + rm -v "${mytop_file}" || die + fi + done + + # Fix a dangling symlink when galera is not built + if [[ -L "${ED}/usr/bin/wsrep_sst_rsync_wan" ]] && ! use galera ; then + rm "${ED}/usr/bin/wsrep_sst_rsync_wan" || die + fi + + # Remove broken SST scripts that are incompatible + local scriptremove + for scriptremove in wsrep_sst_xtrabackup wsrep_sst_xtrabackup-v2 ; do + if [[ -e "${ED}/usr/bin/${scriptremove}" ]] ; then + rm "${ED}/usr/bin/${scriptremove}" || die + fi + done +} + +pkg_preinst() { + java-pkg-opt-2_pkg_preinst +} + +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 use pam; then + einfo + elog "This install includes the PAM authentication plugin." + elog "To activate and configure the PAM plugin, please read:" + elog "https://mariadb.com/kb/en/mariadb/pam-authentication-plugin/" + einfo + chown mysql:mysql "${EROOT}/usr/$(get_libdir)/mariadb/plugin/auth_pam_tool_dir" || die + fi + + 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 + + if use galera ; then + einfo + elog "Be sure to edit the my.cnf file to activate your cluster settings." + elog "This should be done after running \"emerge --config =${CATEGORY}/${PF}\"" + elog "The first time the cluster is activated, you should add" + elog "--wsrep-new-cluster to the options in /etc/conf.d/mysql for one node." + elog "This option should then be removed for subsequent starts." + einfo + if [[ -n "${REPLACING_VERSIONS}" ]] ; then + local rver + for rver in ${REPLACING_VERSIONS} ; do + if ver_test "${rver}" -lt "10.4.0" ; then + ewarn "Upgrading galera from a previous version requires admin restart of the entire cluster." + ewarn "Please refer to https://mariadb.com/kb/en/library/changes-improvements-in-mariadb-104/#galera-4" + ewarn "for more information" + fi + done + fi + fi + fi + + # Note about configuration change + einfo + elog "This version of mariadb reorganizes the configuration from a single my.cnf" + elog "to several files in /etc/mysql/${PN}.d." + elog "Please backup any changes you made to /etc/mysql/my.cnf" + elog "and add them as a new file under /etc/mysql/${PN}.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 +} + +pkg_config() { + _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 + } + + local mysql_binary="${EROOT}/usr/bin/mysql" + if [[ ! -x "${mysql_binary}" ]] ; then + die "'${mysql_binary}' not found! Please re-install ${CATEGORY}/${PN}!" + fi + + 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_install_db_binary="${EROOT}/usr/bin/mysql_install_db" + if [[ ! -x "${mysql_install_db_binary}" ]] ; then + die "'${mysql_install_db_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 + + # 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!" + fi + + MYSQL_TMPDIR="$(_getoptval mysqld tmpdir "--defaults-file='${MY_SYSCONFDIR}/my.cnf'")" + MYSQL_TMPDIR=${MYSQL_TMPDIR%/} + # 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 [[ -z "${MYSQL_TMPDIR}" ]] ; then + MYSQL_TMPDIR="$(_mktemp_dry "${EROOT}/tmp/mysqld-tmp.XXXXXXXXX")" + [[ -z "${MYSQL_TMPDIR}" ]] \ + && die "_mktemp_dry() for '${MYSQL_TMPDIR}' failed!" + + mkdir "${MYSQL_TMPDIR}" || die + chown ${MYSQL_USER} "${MYSQL_TMPDIR}" || die + fi + + # Now we need to test MYSQL_TMPDIR... + 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 tmpdir '${MYSQL_TMPDIR}'!" + else + rm "${_my_tmpdir_testfile}" || die + unset _my_tmpdir_testfile + 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 SETUP_TMPDIR=$(mktemp -d "/tmp/${PN}-config.XXXXXXXXX" 2>/dev/null) + [[ -z "${SETUP_TMPDIR}" ]] && die "Failed to create setup tmpdir" + + # Limit access + chmod 0770 "${SETUP_TMPDIR}" || die + chown ${MYSQL_USER} "${SETUP_TMPDIR}" || die + + local mysql_install_log="${SETUP_TMPDIR}/install_db.log" + local mysqld_logfile="${SETUP_TMPDIR}/mysqld.log" + + echo "" + einfo "Detected settings:" + einfo "==================" + einfo "MySQL User:\t\t\t\t${MYSQL_USER}" + einfo "MySQL Group:\t\t\t\t${MYSQL_GROUP}" + einfo "MySQL DATA directory:\t\t${MY_DATADIR}" + einfo "MySQL TMP directory:\t\t\t${MYSQL_TMPDIR}" + + if [[ -n "${MYSQL_LOG_BIN}" ]] ; then + einfo "MySQL Binary Log File location:\t${MYSQL_LOG_BIN}" + fi + + if [[ -n "${MYSQL_RELAY_LOG}" ]] ; then + einfo "MySQL Relay Log File location:\t${MYSQL_RELAY_LOG}" + fi + + einfo "PID DIR:\t\t\t\t${PID_DIR}" + einfo "Install db log:\t\t\t${mysql_install_log}" + einfo "Install server log:\t\t\t${mysqld_logfile}" + + 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="${SETUP_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 + + local cmd=( + "${mysql_install_db_binary}" + "${mysqld_options[@]}" + "--init-file='${tz_sql}'" + "--basedir='${EROOT}/usr'" + "--datadir='${MY_DATADIR}'" + "--tmpdir='${MYSQL_TMPDIR}'" + "--log-error='${mysql_install_log}'" + "--rpm" + "--cross-bootstrap" + "--skip-test-db" + "--user=${MYSQL_USER}" + ) + + einfo "Initializing ${PN} data directory: ${cmd[@]}" + eval "${cmd[@]}" >>"${mysql_install_log}" 2>&1 + + if [[ $? -ne 0 || ! -f "${MY_DATADIR}/mysql/user.frm" ]] ; 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="${PID_DIR}/mysqld.${x}.sock" + [[ -f "${socket}" ]] && die "Randomness failed; Socket ${socket} already exists!" + local pidfile="${PID_DIR}/mysqld.${x}.pid" + [[ -f "${pidfile}" ]] && die "Randomness failed; Pidfile ${pidfile} already exists!" + unset x + + 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="${SETUP_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 + + rm -r "${SETUP_TMPDIR}" || die + + einfo "${PN} data directory at '${MY_DATADIR}' successfully initialized!" +} -- cgit v1.2.3