homebrew-core/Formula/postgresql@11.rb

149 lines
4.5 KiB
Ruby

class PostgresqlAT11 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v11.11/postgresql-11.11.tar.bz2"
sha256 "40607b7fa15b7d63f5075a7277daf7b3412486aa5db3aedffdb7768b9298186c"
license "PostgreSQL"
revision 1
livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(11(?:\.\d+)*)/?["' >]}i)
end
bottle do
sha256 arm64_big_sur: "13273b530b4676aff62fe029c75c42e2807a239172ad6b1741e82ba86975c279"
sha256 big_sur: "ea91a1a975c8ddc11fab237adc0e38915eae9789ca6b6158270d20a355403ef3"
sha256 catalina: "3dbecb364cfb97f67a4268bff369fb6d8c5f575821743b9117d912fc7a320c9e"
sha256 mojave: "58721865e436ac9177d52b69e53d3334a19c3a0db387a4205526f828aeda32f6"
end
keg_only :versioned_formula
# https://www.postgresql.org/support/versioning/
deprecate! date: "2023-11-09", because: :unsupported
depends_on "pkg-config" => :build
depends_on "icu4c"
depends_on "openssl@1.1"
depends_on "readline"
uses_from_macos "libxml2"
uses_from_macos "libxslt"
uses_from_macos "perl"
on_linux do
depends_on "util-linux"
end
def install
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 = %W[
--disable-debug
--prefix=#{prefix}
--datadir=#{opt_pkgshare}
--libdir=#{opt_lib}
--includedir=#{opt_include}
--sysconfdir=#{etc}
--docdir=#{doc}
--enable-thread-safety
--with-bonjour
--with-gssapi
--with-icu
--with-ldap
--with-libxml
--with-libxslt
--with-openssl
--with-pam
--with-perl
--with-tcl
--with-uuid=e2fs
]
# 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
system "make"
system "make", "install-world", "datadir=#{pkgshare}",
"libdir=#{lib}",
"pkglibdir=#{lib}",
"includedir=#{include}",
"pkgincludedir=#{include}",
"includedir_server=#{include}/server",
"includedir_internal=#{include}/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}
For more details, read:
https://www.postgresql.org/docs/#{version.major}/app-initdb.html
EOS
end
plist_options manual: "pg_ctl -D #{HOMEBREW_PREFIX}/var/postgresql@11 start"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/postgres</string>
<string>-D</string>
<string>#{postgresql_datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardOutPath</key>
<string>#{postgresql_log_path}</string>
<key>StandardErrorPath</key>
<string>#{postgresql_log_path}</string>
</dict>
</plist>
EOS
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.to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
end
end