Skip to content

Commit 38a63f1

Browse files
authored
Merge pull request Homebrew#181862 from Homebrew/postgresql@17
postgresql@17 17.0 (new formula)
2 parents 5121487 + 3c6b533 commit 38a63f1

File tree

5 files changed

+329
-118
lines changed

5 files changed

+329
-118
lines changed

Formula/p/pg_partman.rb

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,55 @@ class PgPartman < Formula
66
license "PostgreSQL"
77

88
bottle do
9-
sha256 cellar: :any_skip_relocation, arm64_sequoia: "fde075f32db1d1f8f7b3d954cd30ecb1bec6bcbf6fc838084ec468864b5f3bab"
10-
sha256 cellar: :any_skip_relocation, arm64_sonoma: "c56840f6d344008d864863de5feff7b47c2bd0c521083d07e5ef49b4924a3809"
11-
sha256 cellar: :any_skip_relocation, arm64_ventura: "bf48c9c38dcb45a5646e2148c49d0de6a7099ed316e52b9a3cca5faac1500b5e"
12-
sha256 cellar: :any_skip_relocation, arm64_monterey: "eda23266bd52c4628e3882d906aa9dad2a7db08d862040c55ad8c946c4e29975"
13-
sha256 cellar: :any_skip_relocation, sonoma: "c1dbe58ee7d246699775795b63ef8163b9e0ee89b5b39ea8569872f0321b9413"
14-
sha256 cellar: :any_skip_relocation, ventura: "b97109681a98ef37ca016346f8a3133d1ed87d8da0fe55086a6001ff2b5996e5"
15-
sha256 cellar: :any_skip_relocation, monterey: "583ba02efc0220db153efbbbd30e8fea14310a60513056db634b5516ecb8309f"
16-
sha256 cellar: :any_skip_relocation, x86_64_linux: "4fafe8ac83d791278343a73cd2d41511738305e51c099ada727d149481ededdd"
9+
rebuild 1
10+
sha256 cellar: :any_skip_relocation, arm64_sequoia: "995615e05892a4a62213fd7248beaef88fdd345b3a386b6378f93f28e42112de"
11+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "2c2e05b74290971c37bb8cd1af765a95e1b9f3241cdd73373a74b125619a74da"
12+
sha256 cellar: :any_skip_relocation, arm64_ventura: "f44f771ad70e19ef41072b2a1465ce0aa1019cd77c475d6a9583484c284eaa0b"
13+
sha256 cellar: :any_skip_relocation, sonoma: "1c474f3a11de006f0c84e159dc21971c5da027b0138f52d5f31689baad2afa53"
14+
sha256 cellar: :any_skip_relocation, ventura: "a9ce480d5188be5afa9ab08a75c12f2fc1f6993fa948d1350b2528c9d7687128"
15+
sha256 cellar: :any_skip_relocation, x86_64_linux: "61a6d1327005efb276aa8487952bd916293aa83a33efc96307334faa2bbfa2d9"
1716
end
1817

19-
depends_on "postgresql@14"
18+
depends_on "postgresql@14" => [:build, :test]
19+
depends_on "postgresql@17" => [:build, :test]
2020

21-
def postgresql
22-
Formula["postgresql@14"]
21+
def postgresqls
22+
deps.map(&:to_formula).sort_by(&:version).filter { |f| f.name.start_with?("postgresql@") }
2323
end
2424

2525
def install
26-
ENV["PG_CONFIG"] = postgresql.opt_bin/"pg_config"
27-
28-
system "make"
29-
system "make", "install", "bindir=#{bin}",
30-
"docdir=#{doc}",
31-
"datadir=#{share/postgresql.name}",
32-
"pkglibdir=#{lib/postgresql.name}"
26+
postgresqls.each do |postgresql|
27+
ENV["PG_CONFIG"] = postgresql.opt_bin/"pg_config"
28+
29+
system "make"
30+
system "make", "install", "bindir=#{bin}",
31+
"docdir=#{doc}",
32+
"datadir=#{share/postgresql.name}",
33+
"pkglibdir=#{lib/postgresql.name}"
34+
system "make", "clean"
35+
end
3336
end
3437

3538
test do
3639
ENV["LC_ALL"] = "C"
37-
pg_ctl = postgresql.opt_bin/"pg_ctl"
38-
psql = postgresql.opt_bin/"psql"
39-
port = free_port
40-
41-
system pg_ctl, "initdb", "-D", testpath/"test"
42-
(testpath/"test/postgresql.conf").write <<~EOS, mode: "a+"
43-
44-
shared_preload_libraries = 'pg_partman_bgw'
45-
port = #{port}
46-
EOS
47-
system pg_ctl, "start", "-D", testpath/"test", "-l", testpath/"log"
48-
begin
49-
system psql, "-p", port.to_s, "-c", "CREATE EXTENSION \"pg_partman\";", "postgres"
50-
ensure
51-
system pg_ctl, "stop", "-D", testpath/"test"
40+
postgresqls.each do |postgresql|
41+
pg_ctl = postgresql.opt_bin/"pg_ctl"
42+
psql = postgresql.opt_bin/"psql"
43+
port = free_port
44+
45+
datadir = testpath/postgresql.name
46+
system pg_ctl, "initdb", "-D", datadir
47+
(datadir/"postgresql.conf").write <<~EOS, mode: "a+"
48+
49+
shared_preload_libraries = 'pg_partman_bgw'
50+
port = #{port}
51+
EOS
52+
system pg_ctl, "start", "-D", datadir, "-l", testpath/"log-#{postgresql.name}"
53+
begin
54+
system psql, "-p", port.to_s, "-c", "CREATE EXTENSION \"pg_partman\";", "postgres"
55+
ensure
56+
system pg_ctl, "stop", "-D", datadir
57+
end
5258
end
5359
end
5460
end

Formula/p/pgvector.rb

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,51 @@ class Pgvector < Formula
66
license "PostgreSQL"
77

88
bottle do
9-
sha256 cellar: :any_skip_relocation, arm64_sequoia: "0e6c2f42cc9d8809cd5fb64ad32bbbc31039b7eed55a025206bc4bcc1f3f0c8d"
10-
sha256 cellar: :any_skip_relocation, arm64_sonoma: "a251bbc3992e58169aa83d7a2753c9ddbad8d0dedd65929e386e6ed2034a2305"
11-
sha256 cellar: :any_skip_relocation, arm64_ventura: "2360d6c6185c21e7928d24c393aebce0568a8ce3c5f5d5af40a4e84283b5bd5f"
12-
sha256 cellar: :any_skip_relocation, arm64_monterey: "56be02b9338ff682781ab0f371f5ccbf45907eab6cfc4c60eddaa140e73c2477"
13-
sha256 cellar: :any_skip_relocation, sonoma: "11938beccda5271a79a663f261484d3f813f275ae82b5911ba83bdcbadf1f02c"
14-
sha256 cellar: :any_skip_relocation, ventura: "45cab40694323e8e7544530a78898fa0501dd7123ac72019bbf9bcc1b7e2d1e7"
15-
sha256 cellar: :any_skip_relocation, monterey: "5485765a2bc9c645504369b020049462c4c5d59350d215e89a3b840b4df70a61"
16-
sha256 cellar: :any_skip_relocation, x86_64_linux: "dbff5b6c43f5d6f90446c96d65b34b26227a74a848abc9fe0ad73839cfb4121d"
9+
rebuild 1
10+
sha256 cellar: :any_skip_relocation, arm64_sequoia: "6c15fe20140648ded883016f6edcf606926b1654ecb2b82b73e035c0dfc7bf50"
11+
sha256 cellar: :any_skip_relocation, arm64_sonoma: "fe198adaaa6588303ae2032c61cf8dd535ad06e9860780335dfacd4396ed19a3"
12+
sha256 cellar: :any_skip_relocation, arm64_ventura: "8c7f23fe6998cf78b81613cbe4c0378fae3ce4ef486e10c3bf7eed6323d6b337"
13+
sha256 cellar: :any_skip_relocation, sonoma: "e9f6ed112975cb8a21208609fa5773c37bb74ca6ea112159b4a7f33ca2238c18"
14+
sha256 cellar: :any_skip_relocation, ventura: "b8058a3a989357e9e6ac1bd7784b6bd77f107c960d088da487e716cf1dee2ddb"
15+
sha256 cellar: :any_skip_relocation, x86_64_linux: "e5020858a996ba215f18234bc25e7552edae986911cfe0206980c5c8d0affc45"
1716
end
1817

19-
depends_on "postgresql@14"
18+
depends_on "postgresql@14" => [:build, :test]
19+
depends_on "postgresql@17" => [:build, :test]
2020

21-
def postgresql
22-
Formula["postgresql@14"]
21+
def postgresqls
22+
deps.map(&:to_formula).sort_by(&:version).filter { |f| f.name.start_with?("postgresql@") }
2323
end
2424

2525
def install
26-
ENV["PG_CONFIG"] = postgresql.opt_bin/"pg_config"
27-
system "make"
28-
system "make", "install", "pkglibdir=#{lib/postgresql.name}",
29-
"datadir=#{share/postgresql.name}",
30-
"pkgincludedir=#{include/postgresql.name}"
26+
postgresqls.each do |postgresql|
27+
ENV["PG_CONFIG"] = postgresql.opt_bin/"pg_config"
28+
system "make"
29+
system "make", "install", "pkglibdir=#{lib/postgresql.name}",
30+
"datadir=#{share/postgresql.name}",
31+
"pkgincludedir=#{include/postgresql.name}"
32+
system "make", "clean"
33+
end
3134
end
3235

3336
test do
3437
ENV["LC_ALL"] = "C"
35-
pg_ctl = postgresql.opt_bin/"pg_ctl"
36-
psql = postgresql.opt_bin/"psql"
37-
datadir = testpath/postgresql.name
38-
port = free_port
38+
postgresqls.each do |postgresql|
39+
pg_ctl = postgresql.opt_bin/"pg_ctl"
40+
psql = postgresql.opt_bin/"psql"
41+
port = free_port
3942

40-
system pg_ctl, "initdb", "-D", datadir
41-
(datadir/"postgresql.conf").write <<~EOS, mode: "a+"
42-
port = #{port}
43-
EOS
44-
system pg_ctl, "start", "-D", datadir, "-l", testpath/"log"
45-
begin
46-
system psql, "-p", port.to_s, "-c", "CREATE EXTENSION vector;", "postgres"
47-
ensure
48-
system pg_ctl, "stop", "-D", datadir
43+
datadir = testpath/postgresql.name
44+
system pg_ctl, "initdb", "-D", datadir
45+
(datadir/"postgresql.conf").write <<~EOS, mode: "a+"
46+
port = #{port}
47+
EOS
48+
system pg_ctl, "start", "-D", datadir, "-l", testpath/"log-#{postgresql.name}"
49+
begin
50+
system psql, "-p", port.to_s, "-c", "CREATE EXTENSION vector;", "postgres"
51+
ensure
52+
system pg_ctl, "stop", "-D", datadir
53+
end
4954
end
5055
end
5156
end

Formula/p/[email protected]

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
class PostgresqlAT17 < Formula
2+
desc "Object-relational database system"
3+
homepage "https://www.postgresql.org/"
4+
url "https://ftp.postgresql.org/pub/source/v17.0/postgresql-17.0.tar.bz2"
5+
sha256 "7e276131c0fdd6b62588dbad9b3bb24b8c3498d5009328dba59af16e819109de"
6+
license "PostgreSQL"
7+
8+
livecheck do
9+
url "https://ftp.postgresql.org/pub/source/"
10+
regex(%r{href=["']?v?(17(?:\.\d+)+)/?["' >]}i)
11+
end
12+
13+
bottle do
14+
sha256 arm64_sequoia: "7345b4a703b655b5ef7bcb37a3dbc90b5406e4d06e7c4b8d30f8bd43f8499974"
15+
sha256 arm64_sonoma: "34876e4d4b26909d79f757d60f7cb34c6e2531c03120f103f5063a6cf62facd3"
16+
sha256 arm64_ventura: "f2facfda470d494aea051eb64ba54c60171e5866fa032ef7c3fba3b488a69f13"
17+
sha256 sonoma: "a5258e4c8218b8ba6d91bb368581548042dc618e07a788e19d0fdf6b7297d7fd"
18+
sha256 ventura: "e25fa2f7a5dc496172f262913071f1a85ce03711b1edfd41a8e9f4a38d2c0b2e"
19+
sha256 x86_64_linux: "3a5e1daf6f1cef652cb39b869e0d8490c3bf29fcadc1869fbe7c92a7f37d6810"
20+
end
21+
22+
keg_only :versioned_formula
23+
24+
# https://www.postgresql.org/support/versioning/
25+
deprecate! date: "2029-11-08", because: :unsupported
26+
27+
depends_on "docbook" => :build
28+
depends_on "docbook-xsl" => :build
29+
depends_on "gettext" => :build
30+
depends_on "pkg-config" => :build
31+
depends_on "icu4c"
32+
# GSSAPI provided by Kerberos.framework crashes when forked.
33+
# See https://github.com/Homebrew/homebrew-core/issues/47494.
34+
depends_on "krb5"
35+
depends_on "lz4"
36+
depends_on "openssl@3"
37+
depends_on "readline"
38+
depends_on "zstd"
39+
40+
uses_from_macos "bison" => :build
41+
uses_from_macos "flex" => :build
42+
uses_from_macos "libxml2"
43+
uses_from_macos "libxslt"
44+
uses_from_macos "openldap"
45+
uses_from_macos "perl"
46+
uses_from_macos "zlib"
47+
48+
on_macos do
49+
depends_on "gettext"
50+
end
51+
52+
on_linux do
53+
depends_on "linux-pam"
54+
depends_on "util-linux"
55+
end
56+
57+
def install
58+
# Modify Makefile to link macOS binaries using Cellar path. Otherwise, binaries are linked
59+
# using #{HOMEBREW_PREFIX}/lib path set during ./configure, which will cause audit failures
60+
# for broken linkage as the paths are not created until post-install step.
61+
inreplace "src/Makefile.shlib", "-install_name '$(libdir)/", "-install_name '#{lib}/postgresql/"
62+
63+
ENV["XML_CATALOG_FILES"] = etc/"xml/catalog"
64+
ENV.delete "PKG_CONFIG_LIBDIR"
65+
ENV.prepend "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib} -L#{Formula["readline"].opt_lib}"
66+
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl@3"].opt_include} -I#{Formula["readline"].opt_include}"
67+
68+
# Fix 'libintl.h' file not found for extensions
69+
if OS.mac?
70+
ENV.prepend "LDFLAGS", "-L#{Formula["gettext"].opt_lib}"
71+
ENV.prepend "CPPFLAGS", "-I#{Formula["gettext"].opt_include}"
72+
end
73+
74+
args = std_configure_args + %W[
75+
--datadir=#{HOMEBREW_PREFIX}/share/#{name}
76+
--libdir=#{HOMEBREW_PREFIX}/lib/#{name}
77+
--includedir=#{HOMEBREW_PREFIX}/include/#{name}
78+
--sysconfdir=#{etc}
79+
--docdir=#{doc}
80+
--enable-nls
81+
--enable-thread-safety
82+
--with-gssapi
83+
--with-icu
84+
--with-ldap
85+
--with-libxml
86+
--with-libxslt
87+
--with-lz4
88+
--with-zstd
89+
--with-openssl
90+
--with-pam
91+
--with-perl
92+
--with-uuid=e2fs
93+
--with-extra-version=\ (#{tap.user})
94+
]
95+
args += %w[--with-bonjour --with-tcl] if OS.mac?
96+
97+
# PostgreSQL by default uses xcodebuild internally to determine this,
98+
# which does not work on CLT-only installs.
99+
args << "PG_SYSROOT=#{MacOS.sdk_path}" if OS.mac? && MacOS.sdk_root_needed?
100+
101+
system "./configure", *args
102+
system "make"
103+
# We use an unversioned `postgresql` subdirectory rather than `#{name}` so that the
104+
# post-installed symlinks can use non-conflicting `#{name}` and be retained on `brew unlink`.
105+
# Removing symlinks may break PostgreSQL as its binaries expect paths from ./configure step.
106+
system "make", "install-world", "datadir=#{share}/postgresql",
107+
"libdir=#{lib}/postgresql",
108+
"includedir=#{include}/postgresql"
109+
110+
# Modify the Makefile back so dependents pick up common path
111+
makefile = lib/"postgresql/pgxs/src/Makefile.shlib"
112+
inreplace makefile, "-install_name '#{lib}/postgresql/", "-install_name '$(libdir)/"
113+
end
114+
115+
def post_install
116+
(var/"log").mkpath
117+
postgresql_datadir.mkpath
118+
119+
# Manually link files from keg to non-conflicting versioned directories in HOMEBREW_PREFIX.
120+
%w[include lib share].each do |dir|
121+
dst_dir = HOMEBREW_PREFIX/dir/name
122+
src_dir = prefix/dir/"postgresql"
123+
src_dir.find do |src|
124+
dst = dst_dir/src.relative_path_from(src_dir)
125+
126+
# Retain existing real directories for extensions if directory structure matches
127+
next if dst.directory? && !dst.symlink? && src.directory? && !src.symlink?
128+
129+
rm_r(dst) if dst.exist? || dst.symlink?
130+
if src.symlink? || src.file?
131+
Find.prune if src.basename.to_s == ".DS_Store"
132+
dst.parent.install_symlink src
133+
elsif src.directory?
134+
dst.mkpath
135+
end
136+
end
137+
end
138+
139+
# Also link versioned executables
140+
bin.each_child { |f| (HOMEBREW_PREFIX/"bin").install_symlink f => "#{f.basename}-#{version.major}" }
141+
142+
# Don't initialize database, it clashes when testing other PostgreSQL versions.
143+
return if ENV["HOMEBREW_GITHUB_ACTIONS"]
144+
145+
system bin/"initdb", "--locale=C", "-E", "UTF-8", postgresql_datadir unless pg_version_exists?
146+
end
147+
148+
def postgresql_datadir
149+
var/name
150+
end
151+
152+
def postgresql_log_path
153+
var/"log/#{name}.log"
154+
end
155+
156+
def pg_version_exists?
157+
(postgresql_datadir/"PG_VERSION").exist?
158+
end
159+
160+
def caveats
161+
<<~EOS
162+
This formula has created a default database cluster with:
163+
initdb --locale=C -E UTF-8 #{postgresql_datadir}
164+
For more details, read:
165+
https://www.postgresql.org/docs/#{version.major}/app-initdb.html
166+
EOS
167+
end
168+
169+
service do
170+
run [opt_bin/"postgres", "-D", f.postgresql_datadir]
171+
environment_variables LC_ALL: "C"
172+
keep_alive true
173+
log_path f.postgresql_log_path
174+
error_log_path f.postgresql_log_path
175+
working_dir HOMEBREW_PREFIX
176+
end
177+
178+
test do
179+
system bin/"initdb", testpath/"test" unless ENV["HOMEBREW_GITHUB_ACTIONS"]
180+
[bin/"pg_config", HOMEBREW_PREFIX/"bin/pg_config-#{version.major}"].each do |pg_config|
181+
assert_equal "#{HOMEBREW_PREFIX}/share/#{name}", shell_output("#{pg_config} --sharedir").chomp
182+
assert_equal "#{HOMEBREW_PREFIX}/lib/#{name}", shell_output("#{pg_config} --libdir").chomp
183+
assert_equal "#{HOMEBREW_PREFIX}/lib/#{name}", shell_output("#{pg_config} --pkglibdir").chomp
184+
assert_equal "#{HOMEBREW_PREFIX}/include/#{name}", shell_output("#{pg_config} --pkgincludedir").chomp
185+
assert_equal "#{HOMEBREW_PREFIX}/include/#{name}/server", shell_output("#{pg_config} --includedir-server").chomp
186+
assert_match "-I#{Formula["gettext"].opt_include}", shell_output("#{pg_config} --cppflags") if OS.mac?
187+
end
188+
end
189+
end

0 commit comments

Comments
 (0)