homebrew-core/Formula/postgresql@15.rb

157 lines
5.4 KiB
Ruby

class PostgresqlAT15 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.bz2"
sha256 "64fdf23d734afad0dfe4077daca96ac51dcd697e68ae2d3d4ca6c45cb14e21ae"
license "PostgreSQL"
livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(15(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 arm64_ventura: "3bea87c03889cf4749d85132aac11be2c868d81a968654842fa9c68d224d9a12"
sha256 arm64_monterey: "143bca5a98b5dee40179cf8db8fb2b9966e361e3c725bd23e9834903d8c75715"
sha256 arm64_big_sur: "f494ffa19149d41d0153149068b2ef129c6eb4dd3aaa6abf5e13f71c39547bd6"
sha256 ventura: "d3bca414d1ebbfeac83b9d794d68536d6bee0d4f5fac21b75153a57b20caf64c"
sha256 monterey: "a04be472c9d417579453b2a0e0cb743541279a10115f854105f7f8dfc246fda6"
sha256 big_sur: "544b5cc351f97290a9b283f3f26ad157b9867f81835c5751ffa92bc2f2931bc2"
sha256 catalina: "03e46b6d3c06e056e91def58377ce11b1d7823deef5b1a572c5e1e0d8bcc70e8"
sha256 x86_64_linux: "11e7c99da3f638663acc1ad27c5d22faffabafee78952fd579a41c5e73a6b97a"
end
keg_only :versioned_formula
# https://www.postgresql.org/support/versioning/
deprecate! date: "2027-11-11", 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 "lz4"
depends_on "openssl@1.1"
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
def install
ENV.delete "PKG_CONFIG_LIBDIR"
ENV.prepend "LDFLAGS", "-L#{Formula["openssl@1.1"].opt_lib} -L#{Formula["readline"].opt_lib}"
ENV.prepend "CPPFLAGS", "-I#{Formula["openssl@1.1"].opt_include} -I#{Formula["readline"].opt_include}"
args = std_configure_args + %W[
--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-lz4
--with-openssl
--with-pam
--with-perl
--with-uuid=e2fs
--with-extra-version=\ (#{tap.user})
]
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 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 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
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