From 8c1415bcbc15b06441a4eee7fc78d5782a4ffe82 Mon Sep 17 00:00:00 2001 From: Moritz Kobel Date: Tue, 8 Oct 2024 13:06:47 +0200 Subject: [PATCH] libpq@15 15.8 (new formula) The formula is based on libpq formula with version 15.4 --- Formula/lib/libpq@15.rb | 79 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Formula/lib/libpq@15.rb diff --git a/Formula/lib/libpq@15.rb b/Formula/lib/libpq@15.rb new file mode 100644 index 0000000000000..52ead8ca4017d --- /dev/null +++ b/Formula/lib/libpq@15.rb @@ -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 + #include + #include + + 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