-
-
Notifications
You must be signed in to change notification settings - Fork 12.5k
159 lines (134 loc) · 5.58 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
class PostgresqlAT16 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v16.6/postgresql-16.6.tar.bz2"
sha256 "23369cdaccd45270ac5dcc30fa9da205d5be33fa505e1f17a0418d2caeca477b"
license "PostgreSQL"
livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(16(?:\.\d+)+)/?["' >]}i)
end
bottle do
rebuild 1
sha256 arm64_sequoia: "a125571f9fef1986bedf7300e3d99ad0b9c7b1f7d2798adcc7dc84af7f8b6173"
sha256 arm64_sonoma: "cba3ec296592f3a10b8f9c412524610aa56eaf7d9cab8f498cd9a1264d5f1adf"
sha256 arm64_ventura: "a36cab1b111803ca1ad88fec990d5a5d3d5a6d5f20667d1322217e2ac2072c6c"
sha256 sonoma: "17ce2aafc8b68a7560e6650240466cc0d5a83df0eca998f8420cc6d818acc79d"
sha256 ventura: "da6354aa893f7de19811cca70816556df8257011bc1e9b16f4eb0ad447d3ed47"
sha256 x86_64_linux: "50858f007990ab7356c183b6b1d02dffabc4fa058321a44e71de67efe33a8d95"
end
keg_only :versioned_formula
# https://www.postgresql.org/support/versioning/
deprecate! date: "2028-11-09", because: :unsupported
depends_on "gettext" => :build
depends_on "pkgconf" => :build
depends_on "icu4c@76"
# GSSAPI provided by Kerberos.framework crashes when forked.
# See https://github.com/Homebrew/homebrew-core/issues/47494.
depends_on "krb5"
depends_on "lz4"
depends_on "openssl@3"
depends_on "readline"
depends_on "zstd"
uses_from_macos "libxml2"
uses_from_macos "libxslt"
uses_from_macos "openldap"
uses_from_macos "perl"
uses_from_macos "zlib"
on_macos do
depends_on "gettext"
end
on_linux do
depends_on "linux-pam"
depends_on "util-linux"
end
def install
ENV.delete "PKG_CONFIG_LIBDIR"
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}"
# Fix 'libintl.h' file not found for extensions
# Update config to fix `error: could not find function 'gss_store_cred_into' required for GSSAPI`
if OS.mac?
ENV.prepend "LDFLAGS", "-L#{Formula["gettext"].opt_lib} -L#{Formula["krb5"].opt_lib}"
ENV.prepend "CPPFLAGS", "-I#{Formula["gettext"].opt_include} -I#{Formula["krb5"].opt_include}"
end
args = %W[
--datadir=#{opt_pkgshare}
--includedir=#{opt_include}
--sysconfdir=#{etc}
--docdir=#{doc}
--enable-nls
--enable-thread-safety
--with-gssapi
--with-icu
--with-ldap
--with-libxml
--with-libxslt
--with-lz4
--with-zstd
--with-openssl
--with-pam
--with-perl
--with-uuid=e2fs
]
args << "--with-extra-version= (#{tap.user})" if tap
args += %w[--with-bonjour --with-tcl] if OS.mac?
# 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, *std_configure_args(libdir: opt_lib)
# 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"
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 caveats
<<~EOS
This formula has created a default database cluster with:
initdb --locale=C -E UTF-8 #{postgresql_datadir}
EOS
end
service do
run [opt_bin/"postgres", "-D", f.postgresql_datadir]
environment_variables LC_ALL: "C"
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
assert_match "-I#{Formula["gettext"].opt_include}", shell_output("#{bin}/pg_config --cppflags") if OS.mac?
end
end