63 lines
2.1 KiB
Ruby
63 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/v8.3.1.tar.gz"
|
|
sha256 "a3cb6a1301e62a2d185a10559e46d8dbe5498efd0c58f954d561c41fbd3bb4f3"
|
|
head "https://github.com/citusdata/citus.git"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "f9f7a49bd777642d5c6c28e3d04be395dd0b688e5826710c9eb5c8d22105cfbd" => :mojave
|
|
sha256 "1791ce77e143cdae4c7b649e9be6dc6b155f47e7c917559cad12cc85db2f58cc" => :high_sierra
|
|
sha256 "2e28da89627570d7f64c8cf7690dd0fb1241b89b327a282c83d4269a148ea57b" => :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
|