class Citus < Formula desc "PostgreSQL-based distributed RDBMS" homepage "https://www.citusdata.com" url "https://github.com/citusdata/citus/archive/v7.1.2.tar.gz" sha256 "f2e3247ed5732b9f2d2bb1cb298ab0b47e017e8f998dc5188c5827eb522d4cd7" head "https://github.com/citusdata/citus.git" bottle do cellar :any sha256 "c74098429e812f9a384343660c08403c3c0e9ef12cde7156b708d4790393c7d6" => :high_sierra sha256 "15e65265190bf75fb0ea0e4b6135f1eefa133daf50fac75fa644fffce17709a7" => :sierra sha256 "6f19e5005aa1b2b5578b79c4036965b6ac2d1af2f57f13605c5515215da0cffe" => :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