Skip to content

Commit

Permalink
percona-server 8.4.3-3
Browse files Browse the repository at this point in the history
  • Loading branch information
cho-m committed Jan 17, 2025
1 parent 75b0270 commit fd285d0
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 70 deletions.
1 change: 1 addition & 0 deletions Aliases/[email protected]
176 changes: 106 additions & 70 deletions Formula/p/percona-server.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
class PerconaServer < Formula
desc "Drop-in MySQL replacement"
homepage "https://www.percona.com"
url "https://downloads.percona.com/downloads/Percona-Server-8.0/Percona-Server-8.0.36-28/source/tarball/percona-server-8.0.36-28.tar.gz"
sha256 "8a4b44bd9cf79a38e6275e8f5f9d4e8d2c308854b71fd5bf5d1728fff43a6844"
url "https://downloads.percona.com/downloads/Percona-Server-8.4/Percona-Server-8.4.3-3/source/tarball/percona-server-8.4.3-3.tar.gz"
sha256 "dfb5b46fccd8284ad3a09054f9a62d0a6423a2b703b6fb86d186cec09cee660a"
license "BSD-3-Clause"
revision 6

livecheck do
url "https://docs.percona.com/percona-server/latest/"
url "https://docs.percona.com/percona-server/#{version.major_minor}/"
regex(/href=.*?v?(\d+(?:[.-]\d+)+)\.html/i)
strategy :page_match do |page, regex|
page.scan(regex).map do |match|
Expand All @@ -32,7 +31,6 @@ class PerconaServer < Formula
depends_on "pkgconf" => :build
depends_on "abseil"
depends_on "icu4c@76"
depends_on "libevent"
depends_on "libfido2"
depends_on "lz4"
depends_on "openldap" # Needs `ldap_set_urllist_proc`, not provided by LDAP.framework
Expand All @@ -49,44 +47,38 @@ class PerconaServer < Formula
on_linux do
depends_on "patchelf" => :build
depends_on "libtirpc"
depends_on "readline"
end

conflicts_with "mariadb", "mysql", because: "percona, mariadb, and mysql install the same binaries"

# https://bugs.mysql.com/bug.php?id=86711
# https://github.com/Homebrew/homebrew-core/pull/20538
# https://github.com/percona/percona-server/blob/8.4/cmake/os/Darwin.cmake
fails_with :clang do
build 800
cause "Wrong inlining with Clang 8.0, see MySQL Bug #86711"
build 999
cause "Requires Apple Clang 10.0 or newer"
end

# https://github.com/percona/percona-server/blob/Percona-Server-#{version}/cmake/boost.cmake
resource "boost" do
url "https://downloads.sourceforge.net/project/boost/boost/1.77.0/boost_1_77_0.tar.bz2"
sha256 "fc9f85fc030e233142908241af7a846e60630aa7388de9a5fafb1f3a26840854"
end

# Backport support for newer Protobuf. Remove with 8.0.39 / 8.4.2
patch do
url "https://github.com/percona/percona-server/commit/089c011f8e2a865e4bd97715653b4bc0973c43a1.patch?full_index=1"
sha256 "aac166f579e636923abeb86cc89934efaf0185df35355aab2d08192d9bf9efd8"
end
# Backport support for Protobuf 22+ on Linux. Remove with 8.0.40 / 8.4.3
patch do
url "https://github.com/mysql/mysql-server/commit/269abc0409b22bb87ec88bd4d53dfb7a1403eace.patch?full_index=1"
sha256 "ffcee32804e7e1237907432adb3590fcbf30c625eea836df6760c05a312a84e1"
# https://github.com/percona/percona-server/blob/8.4/cmake/os/Linux.cmake
fails_with :gcc do
version "9"
cause "Requires GCC 10 or newer"
end

# Patch out check for Homebrew `boost`.
# This should not be necessary when building inside `brew`.
# https://github.com/Homebrew/homebrew-test-bot/pull/820
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/030f7433e89376ffcff836bb68b3903ab90f9cdc/mysql/boost-check.patch"
sha256 "af27e4b82c84f958f91404a9661e999ccd1742f57853978d8baec2f993b51153"
patch :DATA

def datadir
var/"mysql"
end

def install

Check failure on line 75 in Formula/p/percona-server.rb

View workflow job for this annotation

GitHub Actions / Linux

`brew install --verbose --formula --build-bottle percona-server` failed on Linux!

::error::percona-server 8.4.3-3 did not build
# Remove bundled libraries other than explicitly allowed below.
# `boost` and `rapidjson` must use bundled copy due to patches.
# `lz4` is still needed due to xxhash.c used by mysqlgcs
keep = %w[boost duktape libbacktrace libcno libkmip lz4 opensslpp rapidjson unordered_dense]
(buildpath/"extra").each_child { |dir| rm_r(dir) unless keep.include?(dir.basename.to_s) }

# Find Homebrew OpenLDAP instead of the macOS framework
inreplace "cmake/ldap.cmake", "NAMES ldap_r ldap", "NAMES ldap"

Expand All @@ -98,6 +90,8 @@ def install
# Disable ABI checking
inreplace "cmake/abi_check.cmake", "RUN_ABI_CHECK 1", "RUN_ABI_CHECK 0" if OS.linux?

icu4c = deps.find { |dep| dep.name.match?(/^icu4c(@\d+)?$/) }
.to_formula
# -DINSTALL_* are relative to `CMAKE_INSTALL_PREFIX` (`prefix`)
args = %W[
-DCOMPILATION_COMMENT=Homebrew
Expand All @@ -109,66 +103,48 @@ def install
-DINSTALL_MANDIR=share/man
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DINSTALL_PLUGINDIR=lib/percona-server/plugin
-DMYSQL_DATADIR=#{var}/mysql
-DMYSQL_DATADIR=#{datadir}
-DSYSCONFDIR=#{etc}
-DWITH_EMBEDDED_SERVER=ON
-DWITH_INNODB_MEMCACHED=ON
-DWITH_UNIT_TESTS=OFF
-DBISON_EXECUTABLE=#{Formula["bison"].opt_bin}/bison
-DOPENSSL_ROOT_DIR=#{Formula["openssl@3"].opt_prefix}
-DWITH_ICU=#{icu4c.opt_prefix}
-DWITH_SYSTEM_LIBS=ON
-DWITH_EDITLINE=system
-DWITH_FIDO=system
-DWITH_ICU=system
-DWITH_LIBEVENT=system
-DWITH_LZ4=system
-DWITH_PROTOBUF=system
-DWITH_SSL=system
-DOPENSSL_ROOT_DIR=#{Formula["openssl@3"].opt_prefix}
-DWITH_ZLIB=system
-DWITH_ZSTD=system
-DWITH_UNIT_TESTS=OFF
]

# MySQL >5.7.x mandates Boost as a requirement to build & has a strict
# version check in place to ensure it only builds against expected release.
# This is problematic when Boost releases don't align with MySQL releases.
(buildpath/"boost").install resource("boost")
args << "-DWITH_BOOST=#{buildpath}/boost"

# Percona MyRocks does not compile on macOS
# https://bugs.launchpad.net/percona-server/+bug/1741639
args << "-DWITHOUT_ROCKSDB=1"

# TokuDB does not compile on macOS
# https://bugs.launchpad.net/percona-server/+bug/1531446
args << "-DWITHOUT_TOKUDB=1"
args << "-DWITH_KERBEROS=system" unless OS.mac?

system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"

(prefix/"mysql-test").cd do
test_args = ["--vardir=#{Dir.mktmpdir}"]
# For Linux, disable failing on warning: "Setting thread 31563 nice to 0 failed"
# Docker containers lack CAP_SYS_NICE capability by default.
test_args << "--nowarnings" if OS.linux?
system "./mysql-test-run.pl", "status", *test_args
cd prefix/"mysql-test" do
system "./mysql-test-run.pl", "status", "--vardir=#{buildpath}/mysql-test-vardir"
end

# Remove the tests directory
rm_r(prefix/"mysql-test")

# Fix up the control script and link into bin.
inreplace "#{prefix}/support-files/mysql.server",
inreplace prefix/"support-files/mysql.server",
/^(PATH=".*)(")/,
"\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"

# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
(buildpath/"my.cnf").write <<~INI
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
mysqlx-bind-address = 127.0.0.1
INI
etc.install "my.cnf"
end

Expand All @@ -179,23 +155,26 @@ def post_install
# Don't initialize database, it clashes when testing other MySQL-like implementations.
return if ENV["HOMEBREW_GITHUB_ACTIONS"]

unless (var/"mysql/mysql/user.frm").exist?
unless (datadir/"mysql/general_log.CSM").exist?
ENV["TMPDIR"] = nil
system bin/"mysqld", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{var}/mysql", "--tmpdir=/tmp"
"--basedir=#{prefix}", "--datadir=#{datadir}", "--tmpdir=/tmp"
end
end

def caveats
s = <<~EOS
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -uroot
mysql -u root
EOS
if (my_cnf = ["/etc/my.cnf", "/etc/mysql/my.cnf"].find { |x| File.exist? x })
s += <<~EOS
A "#{my_cnf}" from another install may interfere with a Homebrew-built
server starting up correctly.
EOS
Expand All @@ -212,16 +191,73 @@ def caveats
test do
(testpath/"mysql").mkpath
(testpath/"tmp").mkpath
system bin/"mysqld", "--no-defaults", "--initialize-insecure", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{testpath}/mysql", "--tmpdir=#{testpath}/tmp"

port = free_port
fork do
system bin/"mysqld", "--no-defaults", "--user=#{ENV["USER"]}",
"--datadir=#{testpath}/mysql", "--port=#{port}", "--tmpdir=#{testpath}/tmp"
socket = testpath/"mysql.sock"
mysqld_args = %W[
--no-defaults
--mysqlx=OFF
--user=#{ENV["USER"]}
--port=#{port}
--socket=#{socket}
--basedir=#{prefix}
--datadir=#{testpath}/mysql
--tmpdir=#{testpath}/tmp
]
client_args = %W[
--port=#{port}
--socket=#{socket}
--user=root
--password=
]

system bin/"mysqld", *mysqld_args, "--initialize-insecure"
pid = spawn(bin/"mysqld", *mysqld_args)
begin
sleep 5
output = shell_output("#{bin}/mysql #{client_args.join(" ")} --execute='show databases;'")
assert_match "information_schema", output
ensure
system bin/"mysqladmin", *client_args, "shutdown"
Process.kill "TERM", pid
end
sleep 5
assert_match "information_schema",
shell_output("#{bin}/mysql --port=#{port} --user=root --password= --execute='show databases;'")
system bin/"mysqladmin", "--port=#{port}", "--user=root", "--password=", "shutdown"
end
end

__END__
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 438dff720c5..47863c17e23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1948,31 +1948,6 @@ MYSQL_CHECK_RAPIDJSON()
MYSQL_CHECK_FIDO()
MYSQL_CHECK_FIDO_DLLS()

-IF(APPLE)
- GET_FILENAME_COMPONENT(HOMEBREW_BASE ${HOMEBREW_HOME} DIRECTORY)
- IF(EXISTS ${HOMEBREW_BASE}/include/boost)
- FOREACH(SYSTEM_LIB ICU LZ4 PROTOBUF ZSTD FIDO)
- IF(WITH_${SYSTEM_LIB} STREQUAL "system")
- MESSAGE(FATAL_ERROR
- "WITH_${SYSTEM_LIB}=system is not compatible with Homebrew boost\n"
- "MySQL depends on ${BOOST_PACKAGE_NAME} with a set of patches.\n"
- "Including headers from ${HOMEBREW_BASE}/include "
- "will break the build.\n"
- "Please use WITH_${SYSTEM_LIB}=bundled\n"
- "or do 'brew uninstall boost' or 'brew unlink boost'"
- )
- ENDIF()
- ENDFOREACH()
- ENDIF()
- # Ensure that we look in /usr/local/include or /opt/homebrew/include
- FOREACH(SYSTEM_LIB ICU LZ4 PROTOBUF ZSTD FIDO)
- IF(WITH_${SYSTEM_LIB} STREQUAL "system")
- INCLUDE_DIRECTORIES(SYSTEM ${HOMEBREW_BASE}/include)
- BREAK()
- ENDIF()
- ENDFOREACH()
-ENDIF()
-
IF(WITH_AUTHENTICATION_WEBAUTHN OR
WITH_AUTHENTICATION_CLIENT_PLUGINS)
IF(WITH_FIDO STREQUAL "system" AND

0 comments on commit fd285d0

Please sign in to comment.