homebrew-core/Formula/tarantool.rb

100 lines
3.4 KiB
Ruby

class Tarantool < Formula
desc "In-memory database and Lua application server"
homepage "https://tarantool.org/"
url "https://download.tarantool.org/tarantool/src/tarantool-2.10.0.tar.gz"
sha256 "42bb5a714ddf788a89ba4b2062582aee16a2bc7b68c7c3b8c03d7a30be878e2b"
license "BSD-2-Clause"
version_scheme 1
head "https://github.com/tarantool/tarantool.git", branch: "master"
livecheck do
url :head
strategy :github_latest
end
bottle do
sha256 cellar: :any, arm64_monterey: "9646eb4c0ba4cb56912beca48eb1cd41ccd87dc6af6a4fff6f552e9395cf3db3"
sha256 cellar: :any, arm64_big_sur: "661485d7a59dc82443aa73f49eab95917cda5a3ae5c8a98e8507f111e68d23f9"
sha256 monterey: "9c3fa160fedc241a7ee1b91c5d2af42db44073a04ce8336309c0cf22952c73a3"
sha256 big_sur: "a6c5f8710409d16108329ff31349f00725d5d351fbd90a80396284d950aecc79"
sha256 catalina: "23eef1dee80232dccb1bec7b317d181bcf8bfab49725f81f08ae739f1d71228c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "e1f48d09daabaa7b163335b886617869516ad4a1e6d9bd87ee568b53df85dcfe"
end
depends_on "cmake" => :build
depends_on "icu4c"
depends_on "libyaml"
depends_on "openssl@1.1"
depends_on "readline"
depends_on "zstd"
uses_from_macos "curl"
uses_from_macos "ncurses"
def install
# Avoid keeping references to Homebrew's clang/clang++ shims
inreplace "src/trivia/config.h.cmake",
"#define COMPILER_INFO \"@CMAKE_C_COMPILER@ @CMAKE_CXX_COMPILER@\"",
"#define COMPILER_INFO \"/usr/bin/clang /usr/bin/clang++\""
args = std_cmake_args
args << "-DCMAKE_INSTALL_MANDIR=#{doc}"
args << "-DCMAKE_INSTALL_SYSCONFDIR=#{etc}"
args << "-DCMAKE_INSTALL_LOCALSTATEDIR=#{var}"
args << "-DENABLE_DIST=ON"
args << "-DOPENSSL_ROOT_DIR=#{Formula["openssl@1.1"].opt_prefix}"
args << "-DREADLINE_ROOT=#{Formula["readline"].opt_prefix}"
args << "-DENABLE_BUNDLED_LIBCURL=OFF"
args << "-DENABLE_BUNDLED_LIBYAML=OFF"
args << "-DENABLE_BUNDLED_ZSTD=OFF"
if OS.mac?
if MacOS.version >= :big_sur
sdk = MacOS.sdk_path_if_needed
lib_suffix = "tbd"
else
sdk = ""
lib_suffix = "dylib"
end
args << "-DCURL_INCLUDE_DIR=#{sdk}/usr/include"
args << "-DCURL_LIBRARY=#{sdk}/usr/lib/libcurl.#{lib_suffix}"
args << "-DCURSES_NEED_NCURSES=ON"
args << "-DCURSES_NCURSES_INCLUDE_PATH=#{sdk}/usr/include"
args << "-DCURSES_NCURSES_LIBRARY=#{sdk}/usr/lib/libncurses.#{lib_suffix}"
args << "-DICONV_INCLUDE_DIR=#{sdk}/usr/include"
else
args << "-DCURL_ROOT=#{Formula["curl"].opt_prefix}"
end
system "cmake", ".", *args
system "make"
system "make", "install"
end
def post_install
local_user = ENV["USER"]
inreplace etc/"default/tarantool", /(username\s*=).*/, "\\1 '#{local_user}'"
(var/"lib/tarantool").mkpath
(var/"log/tarantool").mkpath
(var/"run/tarantool").mkpath
end
test do
(testpath/"test.lua").write <<~EOS
box.cfg{}
local s = box.schema.create_space("test")
s:create_index("primary")
local tup = {1, 2, 3, 4}
s:insert(tup)
local ret = s:get(tup[1])
if (ret[3] ~= tup[3]) then
os.exit(-1)
end
os.exit(0)
EOS
system bin/"tarantool", "#{testpath}/test.lua"
end
end