118 lines
3.5 KiB
Ruby
118 lines
3.5 KiB
Ruby
class Arangodb < Formula
|
|
desc "Multi-Model NoSQL Database"
|
|
homepage "https://www.arangodb.com/"
|
|
url "https://download.arangodb.com/Source/ArangoDB-3.7.11.tar.gz"
|
|
sha256 "1921be165ee846cbcf6b9b4370db5b0ac8d0681045d8f3b4bff00040ac509fad"
|
|
license "Apache-2.0"
|
|
revision 1
|
|
head "https://github.com/arangodb/arangodb.git", branch: "devel"
|
|
|
|
bottle do
|
|
sha256 big_sur: "df108f4cc57cf4db306da13b629b5d52bb40f70361deb7277f5b42b746734da1"
|
|
sha256 catalina: "30cd203239844f16ebb571b2a2a93de7abb185f16385f9f0a61babdd3b955f3a"
|
|
sha256 mojave: "d895596dccb6ec69a4d9ab7e7984ff876302379d5ef2870601e2e75f94b5884e"
|
|
end
|
|
|
|
depends_on "ccache" => :build
|
|
depends_on "cmake" => :build
|
|
depends_on "go@1.13" => :build
|
|
depends_on "python@3.9" => :build
|
|
depends_on macos: :mojave
|
|
depends_on "openssl@1.1"
|
|
|
|
# the ArangoStarter is in a separate github repository;
|
|
# it is used to easily start single server and clusters
|
|
# with a unified CLI
|
|
resource "starter" do
|
|
url "https://github.com/arangodb-helper/arangodb.git",
|
|
tag: "0.15.0",
|
|
revision: "74b0760828c3b84b63267184ec8eb8492cdf4c6b"
|
|
end
|
|
|
|
def install
|
|
on_macos do
|
|
ENV["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version
|
|
end
|
|
|
|
resource("starter").stage do
|
|
ENV["GO111MODULE"] = "on"
|
|
ENV["DOCKERCLI"] = ""
|
|
system "make", "deps"
|
|
ldflags = %W[
|
|
-s -w
|
|
-X main.projectVersion=#{resource("starter").version}
|
|
-X main.projectBuild=#{Utils.git_head}
|
|
]
|
|
system "go", "build", *std_go_args, "-ldflags", ldflags.join(" "), "github.com/arangodb-helper/arangodb"
|
|
end
|
|
|
|
mkdir "build" do
|
|
openssl = Formula["openssl@1.1"]
|
|
args = std_cmake_args + %W[
|
|
-DHOMEBREW=ON
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
|
-DUSE_MAINTAINER_MODE=Off
|
|
-DUSE_JEMALLOC=Off
|
|
-DCMAKE_SKIP_RPATH=On
|
|
-DOPENSSL_USE_STATIC_LIBS=On
|
|
-DCMAKE_LIBRARY_PATH=#{openssl.opt_lib}
|
|
-DOPENSSL_ROOT_DIR=#{openssl.opt_lib}
|
|
-DCMAKE_OSX_DEPLOYMENT_TARGET=#{MacOS.version}
|
|
-DTARGET_ARCHITECTURE=nehalem
|
|
-DUSE_CATCH_TESTS=Off
|
|
-DUSE_GOOGLE_TESTS=Off
|
|
-DCMAKE_INSTALL_LOCALSTATEDIR=#{var}
|
|
]
|
|
|
|
ENV["V8_CXXFLAGS"] = "-O3 -g -fno-delete-null-pointer-checks" if ENV.compiler == "gcc-6"
|
|
|
|
system "cmake", "..", *args
|
|
system "make", "install"
|
|
end
|
|
end
|
|
|
|
def post_install
|
|
(var/"lib/arangodb3").mkpath
|
|
(var/"log/arangodb3").mkpath
|
|
end
|
|
|
|
def caveats
|
|
<<~EOS
|
|
An empty password has been set. Please change it by executing
|
|
#{opt_sbin}/arango-secure-installation
|
|
EOS
|
|
end
|
|
|
|
service do
|
|
run opt_sbin/"arangod"
|
|
keep_alive true
|
|
end
|
|
|
|
test do
|
|
require "pty"
|
|
|
|
testcase = "require('@arangodb').print('it works!')"
|
|
output = shell_output("#{bin}/arangosh --server.password \"\" --javascript.execute-string \"#{testcase}\"")
|
|
assert_equal "it works!", output.chomp
|
|
|
|
ohai "#{bin}/arangodb --starter.instance-up-timeout 1m --starter.mode single"
|
|
PTY.spawn("#{bin}/arangodb", "--starter.instance-up-timeout", "1m",
|
|
"--starter.mode", "single", "--starter.disable-ipv6",
|
|
"--server.arangod", "#{sbin}/arangod",
|
|
"--server.js-dir", "#{share}/arangodb3/js") do |r, _, pid|
|
|
loop do
|
|
available = IO.select([r], [], [], 60)
|
|
refute_equal available, nil
|
|
|
|
line = r.readline.strip
|
|
ohai line
|
|
|
|
break if line.include?("Your single server can now be accessed")
|
|
end
|
|
ensure
|
|
Process.kill "SIGINT", pid
|
|
ohai "shutting down #{pid}"
|
|
end
|
|
end
|
|
end
|