homebrew-core/Formula/citus.rb
2017-10-17 14:12:47 -07:00

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/v7.0.3.tar.gz"
sha256 "38698986cb807309875b11f548e96b06a35390c9a3e60c233b59356faacd1663"
revision 1
head "https://github.com/citusdata/citus.git"
bottle do
cellar :any
sha256 "5cc758c0bb95597d8947a78ce4afc107f20519207267bb318b1d7113ac3d5b51" => :high_sierra
sha256 "ac494cbb3e023e363f2cd86ecf0b69d9c21359c41477af4b6856e2e4b3a0b6f5" => :sierra
sha256 "2a1a8abb0b7ab448b40bc187c23eeed0c01f9372d1ca8886146f34b5dba07bf7" => :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