class Citus < Formula desc "PostgreSQL-based distributed RDBMS" homepage "https://www.citusdata.com" url "https://github.com/citusdata/citus/archive/v9.1.2.tar.gz" sha256 "0f36ffc2e4e478562ca038459cb11227150b450356454fd029b078e75d28746b" head "https://github.com/citusdata/citus.git" bottle do cellar :any sha256 "ab89dd7f0b3b14db92df66ddfd9bea559feff8c3280413228ebdfbc803de106f" => :catalina sha256 "e1ead7ded6d95262597dc5fc7ff7dc08564a0c410b883d94e3de72e5ce045ea0" => :mojave sha256 "0aa006496f44a097bf3235e3f2e1dba8a7004e509b9aea88f6c83aa609ae9bae" => :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