From 3b97cd712d5447d1af6ed828bd70a715925a251a Mon Sep 17 00:00:00 2001 From: Michael Cho Date: Sat, 28 Sep 2024 16:17:12 -0400 Subject: [PATCH 1/2] pg_cron: add support for `postgresql@17` by linking to `libpq` pg_cron: fix shared_library usage pg_cron: more efficient deps lookup Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> --- Formula/p/pg_cron.rb | 55 +++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/Formula/p/pg_cron.rb b/Formula/p/pg_cron.rb index caa81efabd5f..f5b6672f648b 100644 --- a/Formula/p/pg_cron.rb +++ b/Formula/p/pg_cron.rb @@ -16,14 +16,17 @@ class PgCron < Formula sha256 cellar: :any_skip_relocation, x86_64_linux: "e6fe3792c2ab79fc559a08b92f858d6ba3cab54073a2861c3a5eb5ea81013df1" end - depends_on "postgresql@14" + depends_on "postgresql@14" => [:build, :test] + depends_on "postgresql@17" => [:build, :test] + depends_on "libpq" on_macos do depends_on "gettext" # for libintl end - def postgresql - Formula["postgresql@14"] + def postgresqls + deps.filter_map { |f| f.to_formula if f.name.start_with?("postgresql@") } + .sort_by(&:version) end def install @@ -31,28 +34,38 @@ def install # Issue ref: https://github.com/citusdata/pg_cron/issues/269 ENV["PG_LDFLAGS"] = "-lintl" if OS.mac? - system "make", "install", "PG_CONFIG=#{postgresql.opt_bin}/pg_config", - "pkglibdir=#{lib/postgresql.name}", - "datadir=#{share/postgresql.name}" + postgresqls.each do |postgresql| + ENV["PG_CONFIG"] = postgresql.opt_bin/"pg_config" + # We force linkage to `libpq` to allow building for multiple `postgresql@X` formulae. + # The major soversion is hardcoded to at least make sure compatibility version hasn't changed. + # If it does change, then need to confirm if API/ABI change impacts running on older PostgreSQL. + system "make", "install", "libpq=#{Formula["libpq"].opt_lib/shared_library("libpq", 5)}", + "pkglibdir=#{lib/postgresql.name}", + "datadir=#{share/postgresql.name}" + system "make", "clean" + end end test do ENV["LC_ALL"] = "C" - pg_ctl = postgresql.opt_bin/"pg_ctl" - psql = postgresql.opt_bin/"psql" - port = free_port - - system pg_ctl, "initdb", "-D", testpath/"test" - (testpath/"test/postgresql.conf").write <<~EOS, mode: "a+" - - shared_preload_libraries = 'pg_cron' - port = #{port} - EOS - system pg_ctl, "start", "-D", testpath/"test", "-l", testpath/"log" - begin - system psql, "-p", port.to_s, "-c", "CREATE EXTENSION \"pg_cron\";", "postgres" - ensure - system pg_ctl, "stop", "-D", testpath/"test" + postgresqls.each do |postgresql| + pg_ctl = postgresql.opt_bin/"pg_ctl" + psql = postgresql.opt_bin/"psql" + port = free_port + + datadir = testpath/postgresql.name + system pg_ctl, "initdb", "-D", datadir + (datadir/"postgresql.conf").write <<~EOS, mode: "a+" + + shared_preload_libraries = 'pg_cron' + port = #{port} + EOS + system pg_ctl, "start", "-D", datadir, "-l", testpath/"log-#{postgresql.name}" + begin + system psql, "-p", port.to_s, "-c", "CREATE EXTENSION \"pg_cron\";", "postgres" + ensure + system pg_ctl, "stop", "-D", datadir + end end end end From 07cc10a7fcb1cd13de46a0c1708d561b9aacbc24 Mon Sep 17 00:00:00 2001 From: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com> Date: Sun, 29 Sep 2024 00:10:20 +0000 Subject: [PATCH 2/2] pg_cron: update 1.6.4 bottle. --- Formula/p/pg_cron.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Formula/p/pg_cron.rb b/Formula/p/pg_cron.rb index f5b6672f648b..21eb26658542 100644 --- a/Formula/p/pg_cron.rb +++ b/Formula/p/pg_cron.rb @@ -6,14 +6,13 @@ class PgCron < Formula license "PostgreSQL" bottle do - sha256 cellar: :any, arm64_sequoia: "1d02a68df87ccb9230b012df1156d13871d0cef491654456c87f67d36a3f3d16" - sha256 cellar: :any, arm64_sonoma: "a4000e880882f55b3d67500e5af3136ec503352ec0ff5149820ddf7c2a956ed3" - sha256 cellar: :any, arm64_ventura: "a4c5ceb4fd4dc0f48b2467a973c9da39c035310ccd9f9e7b33a292946af1a8c9" - sha256 cellar: :any, arm64_monterey: "bf81b4a0c65c288a78144458945bfb43f9b4b6ec58f91a95534fa226b85125d4" - sha256 cellar: :any, sonoma: "9c26f60cc911b2dbff41be7fa52bab1169d0196f76a02ff5189f06a2424b1ae9" - sha256 cellar: :any, ventura: "24ea0207cb01a894dde9759e16cbc251f0c208a116a954a1db3a34aab5c36acf" - sha256 cellar: :any, monterey: "ccf9d396b36b9f7273ed532f9cf7b7ff397c16dadac70ba6466dba564240ca80" - sha256 cellar: :any_skip_relocation, x86_64_linux: "e6fe3792c2ab79fc559a08b92f858d6ba3cab54073a2861c3a5eb5ea81013df1" + rebuild 1 + sha256 cellar: :any, arm64_sequoia: "761f569a42613c25ad934f27d9a33700bee8fae46611cf65afeb44c2e94e7490" + sha256 cellar: :any, arm64_sonoma: "37b2a1792f507b0c9056330b9692b020c051990c267796206d9a49e323e434cd" + sha256 cellar: :any, arm64_ventura: "7cbf1d31f5e7b621db839a14a0769870dbb9f438b3b435bb5346976909f41974" + sha256 cellar: :any, sonoma: "0ee4c33e3afc5c2938a29a01f7e1c1796d004799c85e916a02e68caa9f75631d" + sha256 cellar: :any, ventura: "b661444235d90028484e30f5c2c5482f2ffb37c411589e2b47cc2d29f5f57361" + sha256 cellar: :any_skip_relocation, x86_64_linux: "716af477c814e3dc4fda5bbaf25b11a278b0ae93fdda8d5ebd37e1c0c12e5bb8" end depends_on "postgresql@14" => [:build, :test]