From a4abb456bb59b3a64b21a99a1071a23c97ac25d6 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Tue, 8 Oct 2024 13:59:51 -0400 Subject: [PATCH] postgresql 17 --- Formula/postgresql_plpy@17.rb | 121 ++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 Formula/postgresql_plpy@17.rb diff --git a/Formula/postgresql_plpy@17.rb b/Formula/postgresql_plpy@17.rb new file mode 100644 index 0000000..88b1f3d --- /dev/null +++ b/Formula/postgresql_plpy@17.rb @@ -0,0 +1,121 @@ +class PostgresqlPlpyAT17 < Formula + desc "Python3 as procedural language for Postgres" + homepage "https://www.postgresql.org/" + url "https://ftp.postgresql.org/pub/source/v17.0/postgresql-17.0.tar.bz2" + sha256 "7e276131c0fdd6b62588dbad9b3bb24b8c3498d5009328dba59af16e819109de" + license "PostgreSQL" + + livecheck do + url "https://ftp.postgresql.org/pub/source/" + regex(%r{href=["']?v?(17(?:\.\d+)+)/?["' >]}i) + end + + keg_only :versioned_formula + + # https://www.postgresql.org/support/versioning/ + deprecate! date: "2029-11-08", because: :unsupported + + depends_on "postgresql@17" + depends_on "python@3.12" + + def install + print "#{buildpath}/stage" + # Modify Makefile to link macOS binaries using Cellar path. Otherwise, binaries are linked + # using #{HOMEBREW_PREFIX}/lib path set during ./configure, which will cause audit failures + # for broken linkage as the paths are not created until post-install step. + + inreplace "src/Makefile.shlib", "-install_name '$(libdir)/", "-install_name '#{lib}/postgresql/" + + ENV["XML_CATALOG_FILES"] = etc/"xml/catalog" + ENV.delete "PKG_CONFIG_LIBDIR" + ENV.prepend "LDFLAGS", "-L#{Formula["openssl@3"].opt_lib} -L#{Formula["readline"].opt_lib}" + ENV.prepend "CPPFLAGS", "-I#{Formula["openssl@3"].opt_include} -I#{Formula["readline"].opt_include}" + ENV.prepend "PYTHON", "#{HOMEBREW_PREFIX}/opt/python@3.12/bin/python3.12" + + # Fix 'libintl.h' file not found for extensions + if OS.mac? + ENV.prepend "LDFLAGS", "-L#{Formula["gettext"].opt_lib}" + ENV.prepend "CPPFLAGS", "-I#{Formula["gettext"].opt_include}" + end + + args = std_configure_args + %W[ + --datadir=#{HOMEBREW_PREFIX}/share/postgresql@17 + --libdir=#{HOMEBREW_PREFIX}/lib/postgresql@17 + --includedir=#{HOMEBREW_PREFIX}/include/postgresql@17 + --sysconfdir=#{etc} + --docdir=#{doc} + --enable-nls + --enable-thread-safety + --with-gssapi + --with-icu + --with-ldap + --with-libxml + --with-libxslt + --with-lz4 + --with-zstd + --with-openssl + --with-pam + --with-python + --with-uuid=e2fs + --with-extra-version=\ (#{tap.user}) + ] + args += %w[--with-bonjour --with-tcl] if OS.mac? + + # PostgreSQL by default uses xcodebuild internally to determine this, + # which does not work on CLT-only installs. + args << "PG_SYSROOT=#{MacOS.sdk_path}" if OS.mac? && MacOS.sdk_root_needed? + + system "./configure", *args + system "make" + chdir "src/pl/plpython" do + system "make", "install", "datadir=#{share}/postgresql", + "libdir=#{lib}/postgresql", + "includedir=#{include}/postgresql" + end + chdir "contrib/hstore_plpython" do + system "make", "install", "datadir=#{share}/postgresql", + "libdir=#{lib}/postgresql", + "includedir=#{include}/postgresql" + end + chdir "contrib/ltree_plpython" do + system "make", "install", "datadir=#{share}/postgresql", + "libdir=#{lib}/postgresql", + "includedir=#{include}/postgresql" + end + chdir "contrib/jsonb_plpython" do + system "make", "install", "datadir=#{share}/postgresql", + "libdir=#{lib}/postgresql", + "includedir=#{include}/postgresql" + end + end + + def post_install + + # Manually link files from keg to non-conflicting versioned directories in HOMEBREW_PREFIX. + %w[include lib share locale].each do |dir| + dst_dir = HOMEBREW_PREFIX/dir/"postgresql@17" + src_dir = prefix/dir/"postgresql" + src_dir.find do |src| + dst = dst_dir/src.relative_path_from(src_dir) + + # Retain existing real directories for extensions if directory structure matches + next if dst.directory? && !dst.symlink? && src.directory? && !src.symlink? + + rm_r(dst) if dst.exist? || dst.symlink? + if src.symlink? || src.file? + Find.prune if src.basename.to_s == ".DS_Store" + dst.parent.install_symlink src + print(src, " -> ",dst,"\n") + elsif src.directory? + dst.mkpath + end + end + end + end + + def postgresql_datadir + var/name + end + + +end