Skip to content

Commit

Permalink
Merge pull request #192233 from Homebrew/pg_cron-pg17
Browse files Browse the repository at this point in the history
pg_cron: add support for `postgresql@17` by linking to `libpq`
  • Loading branch information
BrewTestBot authored Sep 29, 2024
2 parents 35e0d63 + 07cc10a commit f6aba97
Showing 1 changed file with 41 additions and 29 deletions.
70 changes: 41 additions & 29 deletions Formula/p/pg_cron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,65 @@ 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"
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
# Work around for ld: Undefined symbols: _libintl_ngettext
# 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

0 comments on commit f6aba97

Please sign in to comment.