187 lines
6.2 KiB
Ruby
187 lines
6.2 KiB
Ruby
class PostgresqlAT12 < Formula
|
|
desc "Object-relational database system"
|
|
homepage "https://www.postgresql.org/"
|
|
url "https://ftp.postgresql.org/pub/source/v12.12/postgresql-12.12.tar.bz2"
|
|
sha256 "34b3f1c69408e22068c0c71b1827691f1c89153b0ad576c1a44f8920a858039c"
|
|
license "PostgreSQL"
|
|
revision 4
|
|
|
|
livecheck do
|
|
url "https://ftp.postgresql.org/pub/source/"
|
|
regex(%r{href=["']?v?(12(?:\.\d+)+)/?["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_ventura: "feae9eaf1c2676c2ec70edb12ff8314ea23b2030781b1736053eadec5e26e629"
|
|
sha256 arm64_monterey: "4a998174e1ba229f7b823c1e263de50b109b33f8298b643d7869e6a334a5067a"
|
|
sha256 arm64_big_sur: "50cfd67b66a438bc0de9245d968c898f69b785ca4702e1b4e43f3936d972027f"
|
|
sha256 monterey: "fa647bcc8edf48959506858bde291bfc0e4b88731c9d4c126f0f0f7728554fd4"
|
|
sha256 big_sur: "9930ff1fb182d708ea397270e95a88c4d3c1a134a0b814ba6dc3c94c2f3b39fe"
|
|
sha256 catalina: "d2961ad3055ae8cd560fc9c6c87ed9730cda0bd132d9f73ccb955c5ea3823ed4"
|
|
sha256 x86_64_linux: "e5edef76554d3b3c4e7c7b471f0cd57f0e3048d7e848b6a810e8a3ce3e76f130"
|
|
end
|
|
|
|
keg_only :versioned_formula
|
|
|
|
# https://www.postgresql.org/support/versioning/
|
|
deprecate! date: "2024-11-14", 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@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" if MacOS.version == :catalina
|
|
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-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 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
|