81 lines
2.8 KiB
Ruby
81 lines
2.8 KiB
Ruby
class Trino < Formula
|
|
desc "Distributed SQL query engine for big data"
|
|
homepage "https://trino.io"
|
|
url "https://search.maven.org/remotecontent?filepath=io/trino/trino-server/360/trino-server-360.tar.gz"
|
|
sha256 "cd313867fd5461a26920ca6cb170413893853b0cc1acc4f454d4141a0790a50e"
|
|
license "Apache-2.0"
|
|
|
|
livecheck do
|
|
url "https://search.maven.org/remotecontent?filepath=io/trino/trino-server/"
|
|
regex(%r{href=["']?v?(\d+(?:\.\d+)*)/?["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, all: "8dfd61e34f50f01f90c7ea51f93cfce06da99ab5008e66bb63768b293647370e"
|
|
end
|
|
|
|
depends_on "gnu-tar" => :build
|
|
depends_on arch: :x86_64
|
|
depends_on "openjdk"
|
|
|
|
resource "trino-src" do
|
|
url "https://github.com/trinodb/trino/archive/360.tar.gz", using: :nounzip
|
|
sha256 "48fbe2f29f67b5c655d4de6eaec905c94f735c42df17e5509dc3c387e732aeb2"
|
|
end
|
|
|
|
resource "trino-cli" do
|
|
url "https://search.maven.org/remotecontent?filepath=io/trino/trino-cli/360/trino-cli-360-executable.jar"
|
|
sha256 "9203abd2ee3e36b7476aba23102b93e2adca7b030031fa3828e2320cb4c38be2"
|
|
end
|
|
|
|
def install
|
|
libexec.install Dir["*"]
|
|
|
|
# Manually untar, since macOS-bundled tar produces the error:
|
|
# trino-360/plugin/trino-hive/src/test/resources/<truncated>.snappy.orc.crc: Failed to restore metadata
|
|
# Remove when https://github.com/trinodb/trino/issues/8877 is fixed
|
|
resource("trino-src").stage do |r|
|
|
ENV.prepend_path "PATH", Formula["gnu-tar"].opt_libexec/"gnubin"
|
|
system "tar", "-xzf", "trino-#{r.version}.tar.gz"
|
|
(libexec/"etc").install Dir["trino-#{r.version}/core/docker/default/etc/*"]
|
|
inreplace libexec/"etc/node.properties", "docker", "homebrew"
|
|
inreplace libexec/"etc/node.properties", "/data/trino", "#{var}/trino/data"
|
|
end
|
|
|
|
(bin/"trino-server").write_env_script libexec/"bin/launcher", Language::Java.overridable_java_home_env
|
|
|
|
resource("trino-cli").stage do
|
|
libexec.install "trino-cli-#{version}-executable.jar"
|
|
bin.write_jar_script libexec/"trino-cli-#{version}-executable.jar", "trino"
|
|
end
|
|
end
|
|
|
|
def post_install
|
|
(var/"trino/data").mkpath
|
|
end
|
|
|
|
service do
|
|
run [opt_bin/"trino-server", "run"]
|
|
working_dir opt_libexec
|
|
end
|
|
|
|
test do
|
|
port = free_port
|
|
cp libexec/"etc/config.properties", testpath/"config.properties"
|
|
inreplace testpath/"config.properties", "8080", port.to_s
|
|
server = fork do
|
|
exec bin/"trino-server", "run", "--verbose",
|
|
"--data-dir", testpath,
|
|
"--config", testpath/"config.properties"
|
|
end
|
|
sleep 30
|
|
|
|
query = "SELECT state FROM system.runtime.nodes"
|
|
output = shell_output(bin/"trino --debug --server localhost:#{port} --execute '#{query}'")
|
|
assert_match "\"active\"", output
|
|
ensure
|
|
Process.kill("TERM", server)
|
|
Process.wait server
|
|
end
|
|
end
|