homebrew-core/Formula/citus.rb
2017-09-28 23:32:35 -07:00

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/v7.0.2.tar.gz"
sha256 "ee3a899859b94d9eafa4f49b71d4d32c30b010bc65e572bb8f1bf6b6ab9b7cc9"
head "https://github.com/citusdata/citus.git"
bottle do
cellar :any
sha256 "71eeb90887106278c43f8bb2ea5ceea638a9794204a80f4c5224cf3e73674f34" => :high_sierra
sha256 "c859b518b9cb6e41febc4935e7de7cafcc8e72da793f89c0b84ea672e6b0d796" => :sierra
sha256 "8ab1223df5c9b71aea4c1bb9632c4343793b7316e994e89392f2183954f5b67b" => :el_capitan
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