homebrew-core/Formula/tarantool.rb
2018-09-06 14:14:35 +02:00

65 lines
2.1 KiB
Ruby

class Tarantool < Formula
desc "In-memory database and Lua application server"
homepage "https://tarantool.org/"
url "https://download.tarantool.org/tarantool/1.9/src/tarantool-1.9.2.0.tar.gz"
sha256 "0b59c3aff12a5f1ff41a0073cf65101e20ba20bcc65b460b99f76c58d545e52d"
head "https://github.com/tarantool/tarantool.git", :branch => "2.0", :shallow => false
bottle do
sha256 "23f25965065306a21c07c8ce4691d1b090f97520d1a50d5853ec1d2149f0d720" => :mojave
sha256 "d9ac5b182fbf02fe111f9719c63ffcd806108452fd0492bc3193991f4533af94" => :high_sierra
sha256 "1e3f5e5411f95feea7850f027562cdde844034301aa9de6aef4bdd16c7f81de5" => :sierra
sha256 "da8e27cdfdb395cd0a0141ea66a00c8a4d3fcc423d6f0bad851160a5f711b022" => :el_capitan
end
depends_on "cmake" => :build
depends_on "icu4c"
depends_on "openssl"
depends_on "readline"
def install
sdk = MacOS::CLT.installed? ? "" : MacOS.sdk_path
# Necessary for luajit to build on macOS Mojave (see luajit formula)
ENV["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version
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"].opt_prefix}"
args << "-DREADLINE_ROOT=#{Formula["readline"].opt_prefix}"
args << "-DCURL_INCLUDE_DIR=#{sdk}/usr/include"
args << "-DCURL_LIBRARY=/usr/lib/libcurl.dylib"
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