From 77657d7cac1643cac7d8aa4a72f68b03f7c2bea0 Mon Sep 17 00:00:00 2001 From: Quentin Wentzler Date: Tue, 5 Oct 2021 16:04:37 +0200 Subject: [PATCH 1/3] postgresql: 13.4 --- Formula/postgresql@13.4.rb | 133 +++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Formula/postgresql@13.4.rb diff --git a/Formula/postgresql@13.4.rb b/Formula/postgresql@13.4.rb new file mode 100644 index 0000000..5924318 --- /dev/null +++ b/Formula/postgresql@13.4.rb @@ -0,0 +1,133 @@ +class PostgresqlAT134 < Formula + desc "Object-relational database system" + homepage "https://www.postgresql.org/" + url "https://ftp.postgresql.org/pub/source/v13.4/postgresql-13.4.tar.bz2" + sha256 "ea93e10390245f1ce461a54eb5f99a48d8cabd3a08ce4d652ec2169a357bc0cd" + license "PostgreSQL" + 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" + + # GSSAPI provided by Kerberos.framework crashes when forked. + # See https://github.com/Homebrew/homebrew-core/issues/47494. + depends_on "krb5" + + depends_on "openssl@1.1" + depends_on "readline" + + 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 + + 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=#{HOMEBREW_PREFIX}/share/postgresql + --libdir=#{HOMEBREW_PREFIX}/lib + --includedir=#{HOMEBREW_PREFIX}/include + --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" + system "make", "install-world", "datadir=#{pkgshare}", + "libdir=#{lib}", + "pkglibdir=#{lib}/postgresql", + "includedir=#{include}", + "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 + (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/"postgres" + end + + def postgresql_log_path + var/"log/postgres.log" + end + + def pg_version_exists? + (postgresql_datadir/"PG_VERSION").exist? + end + + def caveats + <<~EOS + To migrate existing data from a previous major version of PostgreSQL run: + brew postgresql-upgrade-database + + 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/"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["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 + end +end From 0af48e353595c11dfc235531ea8831343c397752 Mon Sep 17 00:00:00 2001 From: Quentin Wentzler Date: Tue, 5 Oct 2021 22:36:04 +0200 Subject: [PATCH 2/3] replace env ci usages it breaks homebrew rubocop rules --- Formula/postgresql@12.3.rb | 8 +++++--- Formula/postgresql@12.4.rb | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Formula/postgresql@12.3.rb b/Formula/postgresql@12.3.rb index 65e1f29..04b50b0 100644 --- a/Formula/postgresql@12.3.rb +++ b/Formula/postgresql@12.3.rb @@ -67,10 +67,12 @@ def install end def post_install - return if ENV["CI"] - (var/"log").mkpath (var/"postgres").mkpath + + # Don't initialize database, it clashes when testing other PostgreSQL versions. + return if ENV["HOMEBREW_GITHUB_ACTIONS"] + unless File.exist? "#{var}/postgres/PG_VERSION" system "#{bin}/initdb", "--locale=C", "-E", "UTF-8", "#{var}/postgres" end @@ -120,7 +122,7 @@ def plist 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 diff --git a/Formula/postgresql@12.4.rb b/Formula/postgresql@12.4.rb index fdb566b..28151fa 100644 --- a/Formula/postgresql@12.4.rb +++ b/Formula/postgresql@12.4.rb @@ -76,10 +76,12 @@ def install end def post_install - return if ENV["CI"] - (var/"log").mkpath (var/"postgres").mkpath + + # Don't initialize database, it clashes when testing other PostgreSQL versions. + return if ENV["HOMEBREW_GITHUB_ACTIONS"] + unless File.exist? "#{var}/postgres/PG_VERSION" system "#{bin}/initdb", "--locale=C", "-E", "UTF-8", "#{var}/postgres" end @@ -129,7 +131,7 @@ def plist 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 From 8487cfb2a912dc1c10a666f2f6b36aec60a51d81 Mon Sep 17 00:00:00 2001 From: Quentin Wentzler Date: Tue, 5 Oct 2021 23:05:52 +0200 Subject: [PATCH 3/3] remove postgresql 12 formulaes --- Formula/postgresql@12.3.rb | 130 ---------------------------------- Formula/postgresql@12.4.rb | 139 ------------------------------------- 2 files changed, 269 deletions(-) delete mode 100644 Formula/postgresql@12.3.rb delete mode 100644 Formula/postgresql@12.4.rb diff --git a/Formula/postgresql@12.3.rb b/Formula/postgresql@12.3.rb deleted file mode 100644 index 04b50b0..0000000 --- a/Formula/postgresql@12.3.rb +++ /dev/null @@ -1,130 +0,0 @@ -class PostgresqlAT123 < 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" - license "PostgreSQL" - revision 4 - head "https://github.com/postgres/postgres.git" - - depends_on "pkg-config" => :build - depends_on "icu4c" - - # GSSAPI provided by Kerberos.framework crashes when forked. - # See https://github.com/Homebrew/homebrew-core/issues/47494. - depends_on "krb5" - - depends_on "openssl@1.1" - depends_on "readline" - - uses_from_macos "libxml2" - uses_from_macos "libxslt" - uses_from_macos "perl" - - on_linux do - 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=#{HOMEBREW_PREFIX}/share/postgresql - --libdir=#{HOMEBREW_PREFIX}/lib - --includedir=#{HOMEBREW_PREFIX}/include - --sysconfdir=#{etc} - --docdir=#{doc} - --enable-thread-safety - --with-bonjour - --with-gssapi - --with-icu - --with-ldap - --with-libxml - --with-libxslt - --with-openssl - --with-pam - --with-perl - --with-tcl - --with-uuid=e2fs - ] - - # 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" - system "make", "install-world", "datadir=#{pkgshare}", - "libdir=#{lib}", - "pkglibdir=#{lib}/postgresql", - "includedir=#{include}", - "pkgincludedir=#{include}/postgresql", - "includedir_server=#{include}/postgresql/server", - "includedir_internal=#{include}/postgresql/internal" - end - - def post_install - (var/"log").mkpath - (var/"postgres").mkpath - - # Don't initialize database, it clashes when testing other PostgreSQL versions. - return if ENV["HOMEBREW_GITHUB_ACTIONS"] - - unless File.exist? "#{var}/postgres/PG_VERSION" - system "#{bin}/initdb", "--locale=C", "-E", "UTF-8", "#{var}/postgres" - end - end - - def caveats - <<~EOS - To migrate existing data from a previous major version of PostgreSQL run: - brew postgresql-upgrade-database - - This formula has created a default database cluster with: - initdb --locale=C -E UTF-8 #{var}/postgres - For more details, read: - https://www.postgresql.org/docs/#{version.to_s.slice(/\d+/)}/app-initdb.html - EOS - end - - plist_options manual: "pg_ctl -D #{HOMEBREW_PREFIX}/var/postgres start" - - def plist - <<~EOS - - - - - KeepAlive - - Label - #{plist_name} - ProgramArguments - - #{opt_bin}/postgres - -D - #{var}/postgres - - RunAtLoad - - WorkingDirectory - #{HOMEBREW_PREFIX} - StandardOutPath - #{var}/log/postgres.log - StandardErrorPath - #{var}/log/postgres.log - - - EOS - end - - test do - 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 - end -end diff --git a/Formula/postgresql@12.4.rb b/Formula/postgresql@12.4.rb deleted file mode 100644 index 28151fa..0000000 --- a/Formula/postgresql@12.4.rb +++ /dev/null @@ -1,139 +0,0 @@ -class PostgresqlAT124 < Formula - desc "Object-relational database system" - homepage "https://www.postgresql.org/" - url "https://ftp.postgresql.org/pub/source/v12.4/postgresql-12.4.tar.bz2" - sha256 "bee93fbe2c32f59419cb162bcc0145c58da9a8644ee154a30b9a5ce47de606cc" - license "PostgreSQL" - head "https://github.com/postgres/postgres.git" - - livecheck do - url "https://www.postgresql.org/docs/current/static/release.html" - regex(/Release v?(\d+(?:\.\d+)+)/i) - end - - bottle do - root_url "https://github.com/klaxit/homebrew-postgresql/releases/download/postgresql@12.4-12.4" - sha256 catalina: "fcf392a2f22280cf706650e6c83cc4cba714a44670c84f476f97388e168af576" - end - - depends_on "pkg-config" => :build - depends_on "icu4c" - - # GSSAPI provided by Kerberos.framework crashes when forked. - # See https://github.com/Homebrew/homebrew-core/issues/47494. - depends_on "krb5" - - depends_on "openssl@1.1" - depends_on "readline" - - uses_from_macos "libxml2" - uses_from_macos "libxslt" - uses_from_macos "perl" - - on_linux do - 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=#{HOMEBREW_PREFIX}/share/postgresql - --libdir=#{HOMEBREW_PREFIX}/lib - --includedir=#{HOMEBREW_PREFIX}/include - --sysconfdir=#{etc} - --docdir=#{doc} - --enable-thread-safety - --with-bonjour - --with-gssapi - --with-icu - --with-ldap - --with-libxml - --with-libxslt - --with-openssl - --with-pam - --with-perl - --with-tcl - --with-uuid=e2fs - ] - - # 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" - system "make", "install-world", "datadir=#{pkgshare}", - "libdir=#{lib}", - "pkglibdir=#{lib}/postgresql", - "includedir=#{include}", - "pkgincludedir=#{include}/postgresql", - "includedir_server=#{include}/postgresql/server", - "includedir_internal=#{include}/postgresql/internal" - end - - def post_install - (var/"log").mkpath - (var/"postgres").mkpath - - # Don't initialize database, it clashes when testing other PostgreSQL versions. - return if ENV["HOMEBREW_GITHUB_ACTIONS"] - - unless File.exist? "#{var}/postgres/PG_VERSION" - system "#{bin}/initdb", "--locale=C", "-E", "UTF-8", "#{var}/postgres" - end - end - - def caveats - <<~EOS - To migrate existing data from a previous major version of PostgreSQL run: - brew postgresql-upgrade-database - - This formula has created a default database cluster with: - initdb --locale=C -E UTF-8 #{var}/postgres - For more details, read: - 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 - - - - - KeepAlive - - Label - #{plist_name} - ProgramArguments - - #{opt_bin}/postgres - -D - #{var}/postgres - - RunAtLoad - - WorkingDirectory - #{HOMEBREW_PREFIX} - StandardOutPath - #{var}/log/postgres.log - StandardErrorPath - #{var}/log/postgres.log - - - EOS - end - - test do - 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 - end -end