homebrew-core/Formula/percona-xtrabackup.rb

170 lines
5.9 KiB
Ruby

class PerconaXtrabackup < Formula
desc "Open source hot backup tool for InnoDB and XtraDB databases"
homepage "https://www.percona.com/software/mysql-database/percona-xtrabackup"
url "https://downloads.percona.com/downloads/Percona-XtraBackup-LATEST/Percona-XtraBackup-8.0.29-22/source/tarball/percona-xtrabackup-8.0.29-22.tar.gz"
sha256 "7c3bdfaf0b02ec4c09b3cdb41b2a7f18f79dce9c5d396ada36fbc2557562ff55"
revision 1
livecheck do
url "https://www.percona.com/downloads/Percona-XtraBackup-LATEST/"
regex(/value=.*?Percona-XtraBackup[._-]v?(\d+(?:\.\d+)+-\d+)["' >]/i)
end
bottle do
rebuild 1
sha256 arm64_ventura: "8b8c907a1ef919347c9e4470f555007d0d737ce0beff94e5e83562ff72f8029e"
sha256 arm64_monterey: "458c3e1c42fb886b761b488c96b16cf2b6fabf9c15f9757be2bb1252a097b3fe"
sha256 arm64_big_sur: "6334b08778ac9f84cdc5bae40a3e79a3c5847bc5d4ad940c55b0d577792609e2"
sha256 ventura: "a04107ecab6fbda3c4d54626370dc45c10064ab268c3cbb41392037bbfe99d83"
sha256 monterey: "50e0cea6a56236121455148b9409a96321e6bfda33ccbd544b69f76d5c95a42e"
sha256 big_sur: "dfb6c59a87caac4de10d941443761d0cf11a8ce293339f48dff126a0e10ec82a"
sha256 catalina: "ed9c776f742ab91702841843d76f357a217483ff2baa1806be817efa2bf18522"
sha256 x86_64_linux: "a48195f5f43f4c86e45e13dda822de73917e791f8bc654d05fe0d396a6d4acf5"
end
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "sphinx-doc" => :build
depends_on "icu4c"
depends_on "libev"
depends_on "libevent"
depends_on "libfido2"
depends_on "libgcrypt"
depends_on "lz4"
depends_on "mysql-client"
depends_on "openssl@1.1"
depends_on "protobuf"
depends_on "zstd"
uses_from_macos "vim" => :build # needed for xxd
uses_from_macos "curl"
uses_from_macos "cyrus-sasl"
uses_from_macos "libedit"
uses_from_macos "perl"
uses_from_macos "zlib"
on_linux do
depends_on "patchelf" => :build
depends_on "libaio"
end
conflicts_with "percona-server", because: "both install a `kmip.h`"
fails_with :gcc do
version "6"
cause "The build requires GCC 7.1 or later."
end
# Should be installed before DBD::mysql
resource "Devel::CheckLib" do
url "https://cpan.metacpan.org/authors/id/M/MA/MATTN/Devel-CheckLib-1.14.tar.gz"
sha256 "f21c5e299ad3ce0fdc0cb0f41378dca85a70e8d6c9a7599f0e56a957200ec294"
end
# This is not part of the system Perl on Linux and on macOS since Mojave
resource "DBI" do
url "https://cpan.metacpan.org/authors/id/T/TI/TIMB/DBI-1.643.tar.gz"
sha256 "8a2b993db560a2c373c174ee976a51027dd780ec766ae17620c20393d2e836fa"
end
resource "DBD::mysql" do
url "https://cpan.metacpan.org/authors/id/D/DV/DVEEDEN/DBD-mysql-4.050.tar.gz"
sha256 "4f48541ff15a0a7405f76adc10f81627c33996fbf56c95c26c094444c0928d78"
end
# https://github.com/percona/percona-xtrabackup/blob/percona-xtrabackup-#{version}/cmake/boost.cmake
resource "boost" do
url "https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2"
sha256 "fc9f85fc030e233142908241af7a846e60630aa7388de9a5fafb1f3a26840854"
end
# Fix CMake install error with manpages.
# https://github.com/percona/percona-xtrabackup/pull/1266
patch do
url "https://github.com/percona/percona-xtrabackup/commit/1d733eade782dd9fdf8ef66b9e9cb9e00f572606.patch?full_index=1"
sha256 "9b38305b4e4bae23b085b3ef9cb406451fa3cc14963524e95fc1e6cbf761c7cf"
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/percona-server/boost-check.patch"
sha256 "3223f7eebd04b471de1c21104c46b2cdec3fe7b26e13535bdcd0d7b8fd341bde"
end
def install
# Disable ABI checking
inreplace "cmake/abi_check.cmake", "RUN_ABI_CHECK 1", "RUN_ABI_CHECK 0" if OS.linux?
cmake_args = %W[
-DBUILD_CONFIG=xtrabackup_release
-DCOMPILATION_COMMENT=Homebrew
-DINSTALL_PLUGINDIR=lib/percona-xtrabackup/plugin
-DINSTALL_MANDIR=share/man
-DWITH_MAN_PAGES=ON
-DINSTALL_MYSQLTESTDIR=
-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@1.1"].opt_prefix}
-DWITH_ZLIB=system
-DWITH_ZSTD=system
]
(buildpath/"boost").install resource("boost")
cmake_args << "-DWITH_BOOST=#{buildpath}/boost"
cmake_args.concat std_cmake_args
# Remove conflicting manpages
rm (Dir["man/*"] - ["man/CMakeLists.txt"])
mkdir "build" do
system "cmake", "..", *cmake_args
system "make"
system "make", "install"
end
# remove conflicting library that is already installed by mysql
rm lib/"libmysqlservices.a"
ENV.prepend_create_path "PERL5LIB", buildpath/"build_deps/lib/perl5"
resource("Devel::CheckLib").stage do
system "perl", "Makefile.PL", "INSTALL_BASE=#{buildpath}/build_deps"
system "make", "install"
end
ENV.prepend_create_path "PERL5LIB", libexec/"lib/perl5"
# This is not part of the system Perl on Linux and on macOS since Mojave
if OS.linux? || MacOS.version >= :mojave
resource("DBI").stage do
system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}"
system "make", "install"
end
end
resource("DBD::mysql").stage do
system "perl", "Makefile.PL", "INSTALL_BASE=#{libexec}"
system "make", "install"
end
bin.env_script_all_files(libexec/"bin", PERL5LIB: libexec/"lib/perl5")
end
test do
assert_match version.to_s, shell_output("#{bin}/xtrabackup --version 2>&1")
mkdir "backup"
output = shell_output("#{bin}/xtrabackup --target-dir=backup --backup 2>&1", 1)
assert_match "Failed to connect to MySQL server", output
end
end