homebrew-core/Formula/postgresql@10.rb

156 lines
5.0 KiB
Ruby

class PostgresqlAT10 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v10.22/postgresql-10.22.tar.bz2"
sha256 "955977555c69df1a64f44b81d4a1987eb74abbd1870579f5ad9d946133dd8e4d"
license "PostgreSQL"
revision 3
livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(10(?:\.\d+)+)/?["' >]}i)
end
bottle do
sha256 arm64_ventura: "12a23aa3da4c20fe27d7d2cf7e68a31f8072b8e5e1356e95e0918d7d528a6faa"
sha256 arm64_monterey: "95ff39fa2a308b2ba32569df5da563911664d447ab160cf9e7a4e0dc81cd46c1"
sha256 arm64_big_sur: "ce82c9858b89a210fe816495af9072c57e4a2102007dbd481bb6055ac3ab37a5"
sha256 ventura: "e192b534805c7bc6d03af8e3bbfbd5bccdac4f33a1901dfddc0f5532ea125458"
sha256 monterey: "56d578ffafd4651d48ea24c65c2821d5eab5c4308dc83ec0b13a7aa069a8dfe1"
sha256 big_sur: "0709771101fc5c98748b905b4687b19275fa196169a12f2b882ba4c14fc0668e"
sha256 catalina: "a8fdf9b8cc39eb124cf9006ba21d13b9b47aea401f4916a9159db27877029bdc"
sha256 x86_64_linux: "ba4d03256d2b7217953fa653505d053f12d71af9291f3b6adb16bc0a5a665b4f"
end
keg_only :versioned_formula
# https://www.postgresql.org/support/versioning/
deprecate! date: "2022-11-10", 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 "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=#{pkgshare}
--libdir=#{lib}
--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"
# pkglibdir=#{lib}/postgresql
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 OS.mac?
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
else
system "make", "all"
system "make", "-C", "contrib", "install", "all", *dirs
system "make", "install", "all", *dirs
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@10"]
keep_alive true
log_path var/"log/postgresql@10.log"
error_log_path var/"log/postgresql@10.log"
working_dir HOMEBREW_PREFIX
end
test do
system "#{bin}/initdb", testpath/"test" unless ENV["HOMEBREW_GITHUB_ACTIONS"]
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