156 lines
4.7 KiB
Ruby
156 lines
4.7 KiB
Ruby
class PostgresqlAT96 < Formula
|
|
desc "Object-relational database system"
|
|
homepage "https://www.postgresql.org/"
|
|
url "https://ftp.postgresql.org/pub/source/v9.6.20/postgresql-9.6.20.tar.bz2"
|
|
sha256 "3d08cba409d45ab62d42b24431a0d55e7537bcd1db2d979f5f2eefe34d487bb6"
|
|
license "PostgreSQL"
|
|
|
|
livecheck do
|
|
url "https://www.postgresql.org/docs/9.6/static/release.html"
|
|
regex(/Release v?(\d+(?:\.\d+)+)/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 "1d2e78a45b69aa887935849a2b2a663825ef1e78e6eb8df2692f1642d51fb073" => :big_sur
|
|
sha256 "1406b0e42667227867dc5cdb4ecf316387b7ade1789837969f8aa2295afe22b4" => :catalina
|
|
sha256 "e0d93fe31b16a638b34c4e381e4d631f3cba32abbc9728f447e2960a829d235d" => :mojave
|
|
end
|
|
|
|
keg_only :versioned_formula
|
|
|
|
# https://www.postgresql.org/support/versioning/
|
|
deprecate! date: "2021-11-11", because: :unsupported
|
|
|
|
depends_on "openssl@1.1"
|
|
depends_on "readline"
|
|
|
|
uses_from_macos "libxslt"
|
|
uses_from_macos "perl"
|
|
|
|
on_linux do
|
|
depends_on "util-linux"
|
|
end
|
|
|
|
def install
|
|
# avoid adding the SDK library directory to the linker search path
|
|
ENV["XML2_CONFIG"] = "xml2-config --exec-prefix=/usr"
|
|
|
|
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=#{pkgshare}
|
|
--libdir=#{lib}
|
|
--sysconfdir=#{prefix}/etc
|
|
--docdir=#{doc}
|
|
--enable-thread-safety
|
|
--with-bonjour
|
|
--with-gssapi
|
|
--with-ldap
|
|
--with-openssl
|
|
--with-pam
|
|
--with-libxml
|
|
--with-libxslt
|
|
--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"
|
|
|
|
dirs = %W[datadir=#{pkgshare} libdir=#{lib} pkglibdir=#{lib}]
|
|
|
|
# Temporarily disable building/installing the documentation.
|
|
# Postgresql seems to "know" the build system has been altered and
|
|
# tries to regenerate the documentation when using `install-world`.
|
|
# This results in the build failing:
|
|
# `ERROR: `osx' is missing on your system.`
|
|
# Attempting to fix that by adding a dependency on `open-sp` doesn't
|
|
# work and the build errors out on generating the documentation, so
|
|
# for now let's simply omit it so we can package Postgresql for Mojave.
|
|
if DevelopmentTools.clang_build_version >= 1000
|
|
system "make", "all"
|
|
system "make", "-C", "contrib", "install", "all", *dirs
|
|
system "make", "install", "all", *dirs
|
|
else
|
|
system "make", "install-world", *dirs
|
|
end
|
|
end
|
|
|
|
def post_install
|
|
return if ENV["CI"]
|
|
|
|
(var/"log").mkpath
|
|
postgresql_datadir.mkpath
|
|
system "#{bin}/initdb", 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
|
|
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
|
|
you may need to remove the previous version first. See:
|
|
https://github.com/Homebrew/legacy-homebrew/issues/2510
|
|
|
|
This formula has created a default database cluster with:
|
|
initdb #{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@9.6 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>StandardErrorPath</key>
|
|
<string>#{postgresql_log_path}</string>
|
|
</dict>
|
|
</plist>
|
|
EOS
|
|
end
|
|
|
|
test do
|
|
system "#{bin}/initdb", testpath/"test" unless ENV["CI"]
|
|
assert_equal pkgshare.to_s, shell_output("#{bin}/pg_config --sharedir").chomp
|
|
assert_equal lib.to_s, shell_output("#{bin}/pg_config --libdir").chomp
|
|
assert_equal lib.to_s, shell_output("#{bin}/pg_config --pkglibdir").chomp
|
|
end
|
|
end
|