homebrew-core/Formula/arangodb.rb

126 lines
3.8 KiB
Ruby

class Arangodb < Formula
desc "Multi-Model NoSQL Database"
homepage "https://www.arangodb.com/"
url "https://download.arangodb.com/Source/ArangoDB-3.9.0.tar.bz2"
sha256 "a6fb06bdfcaa8884d8a060e4aa1164d94db12bf2df332a2e44b2de2283204bca"
license "Apache-2.0"
head "https://github.com/arangodb/arangodb.git", branch: "devel"
livecheck do
url "https://www.arangodb.com/download-major/source/"
regex(/href=.*?ArangoDB[._-]v?(\d+(?:\.\d+)+)(-\d+)?\.t/i)
end
bottle do
sha256 monterey: "3e642fea46662626f97b4d4f40dc1bc0b7e3684f5904659f20340a32ea21e510"
sha256 big_sur: "5e18ae6110ed7cd419acba77be9e722c21bb70a4cfc3dc1a5d1052e5debe7615"
sha256 catalina: "e2eb992537c33e30ca4294b03060f11e86dafb70563e0cc2aa9ab761e389e180"
sha256 x86_64_linux: "02c8b6c395f786324e6f262382eb1d95d52a161af93ede1a79f62ac27eb77714"
end
depends_on "ccache" => :build
depends_on "cmake" => :build
depends_on "go@1.16" => :build
depends_on "python@3.9" => :build
depends_on macos: :mojave
depends_on "openssl@1.1"
on_linux do
depends_on "gcc"
end
fails_with gcc: "5"
# 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.3",
revision: "814f8be9e5cc613a63ac1dc161b879ccb7ec23e0"
end
def install
ENV["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version if OS.mac?
resource("starter").stage do
ENV["GO111MODULE"] = "on"
ENV["DOCKERCLI"] = ""
ldflags = %W[
-s -w
-X main.projectVersion=#{resource("starter").version}
-X main.projectBuild=#{Utils.git_head}
]
system "go", "build", *std_go_args(ldflags: ldflags), "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 = r.wait_readable(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