181 lines
5.8 KiB
Ruby
181 lines
5.8 KiB
Ruby
class PostgresqlAT14 < Formula
|
|
desc "Object-relational database system"
|
|
homepage "https://www.postgresql.org/"
|
|
url "https://ftp.postgresql.org/pub/source/v14.6/postgresql-14.6.tar.bz2"
|
|
sha256 "508840fc1809d39ab72274d5f137dabb9fd7fb4f933da4168aeebb20069edf22"
|
|
license "PostgreSQL"
|
|
|
|
livecheck do
|
|
url "https://ftp.postgresql.org/pub/source/"
|
|
regex(%r{href=["']?v?(14+(?:\.\d+)+)/?["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_ventura: "c0eed89483a97caebed69f65e290d8df24783deaecd9bff8ec4899484a7b9382"
|
|
sha256 arm64_monterey: "b51594b121714379dc2f0edd307e8edc7e074125492e0615dd96987dfc33fb63"
|
|
sha256 arm64_big_sur: "81c6b2bba599cd87da49437eda8438638562d99e424a6d9001071b6f4c4fc405"
|
|
sha256 ventura: "9cb2ecc8403338130359fe676928a409cd814a86f77e5c4f651e94198b569d0f"
|
|
sha256 monterey: "97ff5dda0a2e50654fd99e8d1b4a6d3b62abe63283ebcbb3fcacbc2477100fe0"
|
|
sha256 big_sur: "a5100cbb30a8e1d016246ae2d587b062c5ba0694164478048193810e9967997a"
|
|
sha256 catalina: "8072b65841307d16423b61d0b5232640d63519572553fd60d2dd81078b92e558"
|
|
sha256 x86_64_linux: "f79a5cd043c8f9e500a4f77c7b358f8e002983a0bf7710a4c3393f6c5a3dda17"
|
|
end
|
|
|
|
# https://www.postgresql.org/support/versioning/
|
|
deprecate! date: "2026-11-12", 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.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=#{HOMEBREW_PREFIX}/share/#{name}
|
|
--libdir=#{HOMEBREW_PREFIX}/lib/#{name}
|
|
--includedir=#{HOMEBREW_PREFIX}/include/#{name}
|
|
--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
|
|
system "make"
|
|
system "make", "install-world", "datadir=#{pkgshare}",
|
|
"libdir=#{lib}/#{name}",
|
|
"pkglibdir=#{lib}/#{name}",
|
|
"includedir=#{include}/#{name}",
|
|
"pkgincludedir=#{include}/#{name}",
|
|
"includedir_server=#{include}/#{name}/server",
|
|
"includedir_internal=#{include}/#{name}/internal"
|
|
|
|
if OS.linux?
|
|
inreplace lib/name/"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
|
|
if old_postgres_data_dir.exist?
|
|
old_postgres_data_dir
|
|
else
|
|
var/name
|
|
end
|
|
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}" "#{var/name}"
|
|
|
|
(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 "#{HOMEBREW_PREFIX}/share/#{name}", shell_output("#{bin}/pg_config --sharedir").chomp
|
|
assert_equal "#{HOMEBREW_PREFIX}/lib/#{name}", shell_output("#{bin}/pg_config --libdir").chomp
|
|
assert_equal "#{HOMEBREW_PREFIX}/lib/#{name}", shell_output("#{bin}/pg_config --pkglibdir").chomp
|
|
assert_equal "#{HOMEBREW_PREFIX}/include/#{name}", shell_output("#{bin}/pg_config --includedir").chomp
|
|
end
|
|
end
|