Skip to content

Commit

Permalink
libpq@15 15.8 (new formula)
Browse files Browse the repository at this point in the history
The formula is based on libpq formula with version 15.4
  • Loading branch information
mkobel committed Oct 8, 2024
1 parent 90e82ba commit 8c1415b
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions Formula/lib/libpq@15.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
class LibpqAT15 < Formula
desc "Postgres C API library"
homepage "https://www.postgresql.org/docs/15/libpq.html"
url "https://ftp.postgresql.org/pub/source/v15.8/postgresql-15.8.tar.bz2"
sha256 "4403515f9a69eeb3efebc98f30b8c696122bfdf895e92b3b23f5b8e769edcb6a"
license "PostgreSQL"

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

keg_only "conflicts with postgres formula"
keg_only :versioned_formula

# GSSAPI provided by Kerberos.framework crashes when forked.
# See https://github.com/Homebrew/homebrew-core/issues/47494.
depends_on "krb5"

depends_on "openssl@3"

uses_from_macos "zlib"

on_linux do
depends_on "readline"
end

def install
system "./configure", "--disable-debug",
"--prefix=#{prefix}",
"--with-gssapi",
"--with-openssl",
"--libdir=#{opt_lib}",
"--includedir=#{opt_include}"
dirs = %W[
libdir=#{lib}
includedir=#{include}
pkgincludedir=#{include}/postgresql
includedir_server=#{include}/postgresql/server
includedir_internal=#{include}/postgresql/internal
]
system "make"
system "make", "-C", "src/bin", "install", *dirs
system "make", "-C", "src/include", "install", *dirs
system "make", "-C", "src/interfaces", "install", *dirs
system "make", "-C", "src/common", "install", *dirs
system "make", "-C", "src/port", "install", *dirs
system "make", "-C", "doc", "install", *dirs
end

test do
(testpath/"libpq.c").write <<~EOS
#include <stdlib.h>
#include <stdio.h>
#include <libpq-fe.h>
int main()
{
const char *conninfo;
PGconn *conn;
conninfo = "dbname = postgres";
conn = PQconnectdb(conninfo);
if (PQstatus(conn) != CONNECTION_OK) // This should always fail
{
printf("Connection to database attempted and failed");
PQfinish(conn);
exit(0);
}
return 0;
}
EOS
system ENV.cc, "libpq.c", "-L#{lib}", "-I#{include}", "-lpq", "-o", "libpqtest"
assert_equal "Connection to database attempted and failed", shell_output("./libpqtest")
end
end

0 comments on commit 8c1415b

Please sign in to comment.