homebrew-core/Formula/tarantool.rb

102 lines
3.6 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.4.tar.gz"
sha256 "cb4a99c1d6c61f1a7a6665f583447c4402ca83920ee27d7e2728f86cce865ded"
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_ventura: "277c3dc7437f49867ffb50037f91ad49e5dd7c2495aa9a2c5757ef89dca29192"
sha256 cellar: :any, arm64_monterey: "b2a4ac6e78b1e84a894c1e45c9289c57666865240934b489247b7fd7ab7d85d3"
sha256 cellar: :any, arm64_big_sur: "f2ea0ced740c5bba580c224ed9837f8d1538afefede7b850685f238a1782ad70"
sha256 cellar: :any, ventura: "8f1faad2cc53e8f9aaea442e89ce435da4ea5e44ae2695ca7b96f1e499b2d322"
sha256 cellar: :any, monterey: "aea440bec58225251e671777b02f5ef1611a8abfc3ec9b5f24b614be760e57f7"
sha256 cellar: :any, big_sur: "56b453622ec9b100e63413cca4302fb553465f24add9d9d74fd8440efff7c244"
sha256 cellar: :any, catalina: "a3fc168c0c97c82368f4e9a10e40620e2022903d4f9dda2d8d5a3f979d53556c"
sha256 cellar: :any_skip_relocation, x86_64_linux: "91a47695fada66efdbca21d0506860883167d170daa51e817380cca7f4de7ee9"
end
depends_on "cmake" => :build
depends_on "icu4c"
depends_on "libyaml"
depends_on "openssl@3"
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_ID@-@CMAKE_C_COMPILER_VERSION@\"",
"#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