homebrew-core/Formula/citus.rb

64 lines
2.1 KiB
Ruby

class Citus < Formula
desc "PostgreSQL-based distributed RDBMS"
homepage "https://www.citusdata.com"
url "https://github.com/citusdata/citus/archive/v9.2.2.tar.gz"
sha256 "8992ceaaaa1a2c1fa0fb25c9e32f5f4ec02e329681029c297004b786c6a05d87"
head "https://github.com/citusdata/citus.git"
bottle do
cellar :any
sha256 "821d25f1a2ce6cea994417caaec8a3f5f4eb7cb0945234b062c73c0b42802ba0" => :catalina
sha256 "8ece14a7552aa4206f3e4da10df8c6b9dbda042b9b7da5f8d396b05ec3879399" => :mojave
sha256 "872e2e9f2348a0c70d67b8c9db8e326ee921b41ec4009566c69b5c63074f50a3" => :high_sierra
end
depends_on "postgresql"
depends_on "readline"
def install
ENV["PG_CONFIG"] = Formula["postgresql"].opt_bin/"pg_config"
system "./configure"
# workaround for https://github.com/Homebrew/homebrew/issues/49948
system "make", "libpq=-L#{Formula["postgresql"].opt_lib} -lpq"
# Use stage directory to prevent installing to pg_config-defined dirs,
# which would not be within this package's Cellar.
mkdir "stage"
system "make", "install", "DESTDIR=#{buildpath}/stage"
bin.install Dir["stage/**/bin/*"]
lib.install Dir["stage/**/lib/*"]
include.install Dir["stage/**/include/*"]
(share/"postgresql/extension").install Dir["stage/**/share/postgresql/extension/*"]
end
test do
pg_bin = Formula["postgresql"].opt_bin
pg_port = "55561"
system "#{pg_bin}/initdb", testpath/"test"
pid = fork do
exec("#{pg_bin}/postgres",
"-D", testpath/"test",
"-c", "shared_preload_libraries=citus",
"-p", pg_port)
end
begin
sleep 2
count_workers_query = "SELECT COUNT(*) FROM master_get_active_worker_nodes();"
system "#{pg_bin}/createdb", "-p", pg_port, "test"
system "#{pg_bin}/psql", "-p", pg_port, "-d", "test", "--command", "CREATE EXTENSION citus;"
assert_equal "0", shell_output("#{pg_bin}/psql -p #{pg_port} -d test -Atc" \
"'#{count_workers_query}'").strip
ensure
Process.kill 9, pid
Process.wait pid
end
end
end