-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
277 lines (231 loc) · 8.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
class PostgresqlAT13 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v13.13/postgresql-13.13.tar.bz2"
sha256 "8af69c2599047a2ad246567d68ec4131aef116954d8c3e469e9789080b37a474"
license "PostgreSQL"
revision 1
livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(13(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 arm64_sonoma: "3f5726702af2f5445bb2a5aa275fff8a3af9ce95ce5a0d522987cd5f7c3a0fe8"
sha256 arm64_ventura: "9d12d6a9a2badd16851b66b2518d0ac6f0b6645cc2a823da180fcef99cdb8215"
sha256 arm64_monterey: "b699aa5abdc5bbf6927bafc45299be5c247517d65236ae8e3400fd8a69f1d8ec"
sha256 sonoma: "24b6e70b0fdf274c4ab0d1d050786d18ef86458fcbb869690fe3a101d14ea413"
sha256 ventura: "2ba0f422a2f9ad6f97518614893fe62770cd29b9a45d09b32548f46c3b1f678d"
sha256 monterey: "76d344edc661da3fb57d08b089a648803d8d5b58bf37d7e34e48869c27515481"
sha256 x86_64_linux: "a431b819d9d09707e5ca0b507000b77462af7091a5fbdd0bb40b1e7e5a20b2a6"
end
keg_only :versioned_formula
# https://www.postgresql.org/support/versioning/
deprecate! date: "2025-11-13", because: :unsupported
depends_on "pkg-config" => :build
depends_on "icu4c"
# GSSAPI provided by Kerberos.framework crashes when forked.
# See https://github.com/Homebrew/homebrew-core/issues/47494.
depends_on "krb5"
depends_on "openssl@3"
depends_on "readline"
uses_from_macos "libxml2"
uses_from_macos "libxslt"
uses_from_macos "openldap"
uses_from_macos "perl"
on_linux do
depends_on "linux-pam"
depends_on "util-linux"
end
# Fix compatibility with OpenSSL 3.2
# Remove once merged
# Ref https://www.postgresql.org/message-id/CX9SU44GH3P4.17X6ZZUJ5D40N%40neon.tech
patch :DATA
def install
ENV.delete "PKG_CONFIG_LIBDIR" if OS.mac? && version == :catalina
ENV.prepend "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib} -L#{Formula["readline"].opt_lib}"
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl@3"].opt_include} -I#{Formula["readline"].opt_include}"
args = %W[
--disable-debug
--prefix=#{prefix}
--datadir=#{opt_pkgshare}
--libdir=#{opt_lib}
--includedir=#{opt_include}
--sysconfdir=#{etc}
--docdir=#{doc}
--enable-thread-safety
--with-gssapi
--with-icu
--with-ldap
--with-libxml
--with-libxslt
--with-openssl
--with-pam
--with-perl
--with-uuid=e2fs
]
if OS.mac?
args += %w[
--with-bonjour
--with-tcl
]
end
# PostgreSQL by default uses xcodebuild internally to determine this,
# which does not work on CLT-only installs.
args << "PG_SYSROOT=#{MacOS.sdk_path}" if OS.mac? && MacOS.sdk_root_needed?
system "./configure", *args
# Work around busted path magic in Makefile.global.in. This can't be specified
# in ./configure, but needs to be set here otherwise install prefixes containing
# the string "postgres" will get an incorrect pkglibdir.
# See https://github.com/Homebrew/homebrew-core/issues/62930#issuecomment-709411789
system "make", "pkglibdir=#{opt_lib}/postgresql",
"pkgincludedir=#{opt_include}/postgresql",
"includedir_server=#{opt_include}/postgresql/server"
system "make", "install-world", "datadir=#{pkgshare}",
"libdir=#{lib}",
"pkglibdir=#{lib}/postgresql",
"includedir=#{include}",
"pkgincludedir=#{include}/postgresql",
"includedir_server=#{include}/postgresql/server",
"includedir_internal=#{include}/postgresql/internal"
if OS.linux?
inreplace lib/"postgresql/pgxs/src/Makefile.global",
"LD = #{HOMEBREW_PREFIX}/Homebrew/Library/Homebrew/shims/linux/super/ld",
"LD = #{HOMEBREW_PREFIX}/bin/ld"
end
end
def post_install
(var/"log").mkpath
postgresql_datadir.mkpath
# Don't initialize database, it clashes when testing other PostgreSQL versions.
return if ENV["HOMEBREW_GITHUB_ACTIONS"]
system "#{bin}/initdb", "--locale=C", "-E", "UTF-8", postgresql_datadir unless pg_version_exists?
end
def postgresql_datadir
var/name
end
def postgresql_log_path
var/"log/#{name}.log"
end
def pg_version_exists?
(postgresql_datadir/"PG_VERSION").exist?
end
def old_postgres_data_dir
var/"postgres"
end
# Figure out what version of PostgreSQL the old data dir is
# using
def old_postgresql_datadir_version
pg_version = old_postgres_data_dir/"PG_VERSION"
pg_version.exist? && pg_version.read.chomp
end
def caveats
caveats = ""
# Extract the version from the formula name
pg_formula_version = version.major.to_s
# ... and check it against the old data dir postgres version number
# to see if we need to print a warning re: data dir
if old_postgresql_datadir_version == pg_formula_version
caveats += <<~EOS
Previous versions of postgresql shared the same data directory.
You can migrate to a versioned data directory by running:
mv -v "#{old_postgres_data_dir}" "#{postgresql_datadir}"
(Make sure PostgreSQL is stopped before executing this command)
EOS
end
caveats += <<~EOS
This formula has created a default database cluster with:
initdb --locale=C -E UTF-8 #{postgresql_datadir}
For more details, read:
https://www.postgresql.org/docs/#{version.major}/app-initdb.html
EOS
caveats
end
service do
run [opt_bin/"postgres", "-D", f.postgresql_datadir]
keep_alive true
log_path f.postgresql_log_path
error_log_path f.postgresql_log_path
working_dir HOMEBREW_PREFIX
end
test do
system "#{bin}/initdb", testpath/"test" unless ENV["HOMEBREW_GITHUB_ACTIONS"]
assert_equal opt_pkgshare.to_s, shell_output("#{bin}/pg_config --sharedir").chomp
assert_equal opt_lib.to_s, shell_output("#{bin}/pg_config --libdir").chomp
assert_equal (opt_lib/"postgresql").to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
assert_equal (opt_include/"postgresql").to_s, shell_output("#{bin}/pg_config --pkgincludedir").chomp
assert_equal (opt_include/"postgresql/server").to_s, shell_output("#{bin}/pg_config --includedir-server").chomp
end
end
__END__
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index 55fe59276a..76ef7afd77 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -748,10 +748,6 @@ be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
* to retry; do we need to adopt their logic for that?
*/
-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif
static BIO_METHOD *my_bio_methods = NULL;
@@ -762,7 +758,7 @@ my_sock_read(BIO *h, char *buf, int size)
if (buf != NULL)
{
- res = secure_raw_read(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_read(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -782,7 +778,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res = 0;
- res = secure_raw_write(((Port *) BIO_get_data(h)), buf, size);
+ res = secure_raw_write(((Port *) BIO_get_app_data(h)), buf, size);
BIO_clear_retry_flags(h);
if (res <= 0)
{
@@ -858,7 +854,7 @@ my_SSL_set_fd(Port *port, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, port);
+ BIO_set_app_data(bio, port);
BIO_set_fd(bio, fd, BIO_NOCLOSE);
SSL_set_bio(port->ssl, bio, bio);
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 07d5daf4d9..1eb17dd280 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -1602,10 +1602,6 @@ PQsslAttribute(PGconn *conn, const char *attribute_name)
* to retry; do we need to adopt their logic for that?
*/
-#ifndef HAVE_BIO_GET_DATA
-#define BIO_get_data(bio) (bio->ptr)
-#define BIO_set_data(bio, data) (bio->ptr = data)
-#endif
static BIO_METHOD *my_bio_methods;
@@ -1614,7 +1610,7 @@ my_sock_read(BIO *h, char *buf, int size)
{
int res;
- res = pqsecure_raw_read((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_read((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{
@@ -1644,7 +1640,7 @@ my_sock_write(BIO *h, const char *buf, int size)
{
int res;
- res = pqsecure_raw_write((PGconn *) BIO_get_data(h), buf, size);
+ res = pqsecure_raw_write((PGconn *) BIO_get_app_data(h), buf, size);
BIO_clear_retry_flags(h);
if (res < 0)
{
@@ -1735,7 +1731,7 @@ my_SSL_set_fd(PGconn *conn, int fd)
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
- BIO_set_data(bio, conn);
+ BIO_set_app_data(bio, conn);
SSL_set_bio(conn->ssl, bio, bio);
BIO_set_fd(bio, fd, BIO_NOCLOSE);