class Citus < Formula desc "PostgreSQL-based distributed RDBMS" homepage "https://www.citusdata.com" url "https://github.com/citusdata/citus/archive/v6.0.1.tar.gz" sha256 "642c194ad229a30f9e960a78d4400566fc08dec3fce1694990592d964d26bf3d" revision 1 head "https://github.com/citusdata/citus.git" bottle do cellar :any sha256 "dc99c3fd8339686e7e0e0fa331ae644b74ffbfb413a6625a93729b79b9d7bcff" => :sierra sha256 "1fd647fc24ef0cffef192bc0c36a987c81e1c46d26b368120f2a618f41babdc0" => :el_capitan sha256 "9a54d8afdbcb0353430f3486c7101fe23727bcea33f7e4929c077f5702287f10" => :yosemite 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