62 lines
2 KiB
Ruby
62 lines
2 KiB
Ruby
class Citus < Formula
|
|
desc "PostgreSQL-based distributed RDBMS"
|
|
homepage "https://www.citusdata.com"
|
|
url "https://github.com/citusdata/citus/archive/v5.1.1.tar.gz"
|
|
sha256 "4c7e1f18a2d919c86b292b137b6f113fc868e64ff1d09a519a2bd5b870365389"
|
|
|
|
head "https://github.com/citusdata/citus.git"
|
|
|
|
bottle do
|
|
sha256 "bb8b3fba00eb45ae15601ebba7ba37473b008f9aadc6e5415cb435763d72d9e1" => :el_capitan
|
|
sha256 "be143c0fce998109ceeda5cf1959b8e79722d843e2dcedbd79b7f359a9294ecd" => :yosemite
|
|
sha256 "f05dab8a33f80461bfe47497bff04c40238f318d4768404c61ce06afc46c547c" => :mavericks
|
|
end
|
|
|
|
depends_on "postgresql"
|
|
|
|
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
|