140 lines
4.3 KiB
Ruby
140 lines
4.3 KiB
Ruby
class PostgresqlAT11 < Formula
|
|
desc "Object-relational database system"
|
|
homepage "https://www.postgresql.org/"
|
|
url "https://ftp.postgresql.org/pub/source/v11.16/postgresql-11.16.tar.bz2"
|
|
sha256 "2dd9e111f0a5949ee7cacc065cea0fb21092929bae310ce05bf01b4ffc5103a5"
|
|
license "PostgreSQL"
|
|
|
|
livecheck do
|
|
url "https://ftp.postgresql.org/pub/source/"
|
|
regex(%r{href=["']?v?(11(?:\.\d+)+)/?["' >]}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "e9880842d1dc9dde2fa3f4032fef8ce5a86804c0753162ed4445243b17100ad3"
|
|
sha256 arm64_big_sur: "30b6a8cc7f60250cddd6506f36c7d3485d3679079f229d0862611345588d3f04"
|
|
sha256 monterey: "4983f232df32b431ee7b6c7ecdb2c3539b4164a2a162daadc5b8c2676d0738ee"
|
|
sha256 big_sur: "f1cc7a6285b5ba348a80cb38e4850fb1a9f86221f739a0d5e3b6d295aecdd724"
|
|
sha256 catalina: "0ad90d806ebbe33b95cbcaea55d487435357097ee1b01d30fb082a28e048746d"
|
|
sha256 x86_64_linux: "da43272592d7ae0df187f19439076b709f641697c4dcaef6b8c87545d448c14e"
|
|
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 "krb5"
|
|
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=#{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
|
|
system "make"
|
|
system "make", "install-world", "datadir=#{pkgshare}",
|
|
"libdir=#{lib}",
|
|
"pkglibdir=#{lib}",
|
|
"includedir=#{include}",
|
|
"pkgincludedir=#{include}",
|
|
"includedir_server=#{include}/server",
|
|
"includedir_internal=#{include}/internal"
|
|
|
|
if OS.linux?
|
|
inreplace lib/"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", var/"postgresql@11"]
|
|
keep_alive true
|
|
log_path var/"log/postgresql@11.log"
|
|
error_log_path var/"log/postgresql@11.log"
|
|
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.to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
|
|
end
|
|
end
|