Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresql: 13.4 #2

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 0 additions & 137 deletions Formula/[email protected]

This file was deleted.

95 changes: 50 additions & 45 deletions Formula/[email protected] → Formula/[email protected]
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
class PostgresqlAT123 < Formula
class PostgresqlAT134 < Formula
desc "Object-relational database system"
homepage "https://www.postgresql.org/"
url "https://ftp.postgresql.org/pub/source/v12.3/postgresql-12.3.tar.bz2"
sha256 "94ed64a6179048190695c86ec707cc25d016056ce10fc9d229267d9a8f1dcf41"
url "https://ftp.postgresql.org/pub/source/v13.4/postgresql-13.4.tar.bz2"
sha256 "ea93e10390245f1ce461a54eb5f99a48d8cabd3a08ce4d652ec2169a357bc0cd"
license "PostgreSQL"
revision 4
head "https://github.com/postgres/postgres.git"
head "https://github.com/postgres/postgres.git", branch: "master"

livecheck do
url "https://ftp.postgresql.org/pub/source/"
regex(%r{href=["']?v?(\d+(?:\.\d+)+)/?["' >]}i)
end

depends_on "pkg-config" => :build
depends_on "icu4c"
Expand All @@ -19,9 +23,11 @@ class PostgresqlAT123 < Formula

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

Expand All @@ -38,7 +44,6 @@ def install
--sysconfdir=#{etc}
--docdir=#{doc}
--enable-thread-safety
--with-bonjour
--with-gssapi
--with-icu
--with-ldap
Expand All @@ -47,9 +52,14 @@ def install
--with-openssl
--with-pam
--with-perl
--with-tcl
--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.
Expand All @@ -64,16 +74,34 @@ def install
"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
return if ENV["CI"]

(var/"log").mkpath
(var/"postgres").mkpath
unless File.exist? "#{var}/postgres/PG_VERSION"
system "#{bin}/initdb", "--locale=C", "-E", "UTF-8", "#{var}/postgres"
end
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/"postgres"
end

def postgresql_log_path
var/"log/postgres.log"
end

def pg_version_exists?
(postgresql_datadir/"PG_VERSION").exist?
end

def caveats
Expand All @@ -82,45 +110,22 @@ def caveats
brew postgresql-upgrade-database

This formula has created a default database cluster with:
initdb --locale=C -E UTF-8 #{var}/postgres
initdb --locale=C -E UTF-8 #{postgresql_datadir}
For more details, read:
https://www.postgresql.org/docs/#{version.to_s.slice(/\d+/)}/app-initdb.html
https://www.postgresql.org/docs/#{version.major}/app-initdb.html
EOS
end

plist_options manual: "pg_ctl -D #{HOMEBREW_PREFIX}/var/postgres 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>#{var}/postgres</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardOutPath</key>
<string>#{var}/log/postgres.log</string>
<key>StandardErrorPath</key>
<string>#{var}/log/postgres.log</string>
</dict>
</plist>
EOS
service do
run [opt_bin/"postgres", "-D", var/"postgres"]
keep_alive true
log_path var/"log/postgres.log"
error_log_path var/"log/postgres.log"
working_dir HOMEBREW_PREFIX
end

test do
system "#{bin}/initdb", testpath/"test" unless ENV["CI"]
system "#{bin}/initdb", testpath/"test" unless ENV["HOMEBREW_GITHUB_ACTIONS"]
assert_equal "#{HOMEBREW_PREFIX}/share/postgresql", shell_output("#{bin}/pg_config --sharedir").chomp
assert_equal "#{HOMEBREW_PREFIX}/lib", shell_output("#{bin}/pg_config --libdir").chomp
assert_equal "#{HOMEBREW_PREFIX}/lib/postgresql", shell_output("#{bin}/pg_config --pkglibdir").chomp
Expand Down