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

neon-* 3916 #42

Closed
wants to merge 4 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
25 changes: 15 additions & 10 deletions Formula/neon-extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class NeonExtension < Formula
desc "Extension enabling storage manager API and Pageserver communication"
homepage "https://github.com/neondatabase/neon"
url "https://github.com/neondatabase/neon.git",
tag: "release-3898",
revision: "0e6fdc8a587aacbc598afb9232eb81484ed3494e"
tag: "release-3916",
revision: "dce91b33a4ce24b1526ef1c39a95761cb0d7da2b"
license "Apache-2.0"
head "https://github.com/neondatabase/neon.git", branch: "main"

Expand All @@ -17,21 +17,24 @@ class NeonExtension < Formula
depends_on "bayandin/tap/neon-postgres"

def extensions
%w[neon neon_utils neon_walredo]
%w[neon_walredo neon neon_rmgr neon_utils]
end

def neon_postgres
Formula["bayandin/tap/neon-postgres"]
end

def install
neon_postgres.pg_versions.each do |v|
neon_postgres.pg_versions_internal.each do |v|
# Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a
dlsuffix = (OS.linux? || "v14 v15".include?(v)) ? "so" : "dylib"

cp_r "pgxn", "build-#{v}"
extensions.each do |ext|
cp_r "pgxn/#{ext}", "build-#{ext}-#{v}"
cd "build-#{ext}-#{v}" do
cd "build-#{v}/#{ext}" do
system "make", "PG_CONFIG=#{neon_postgres.pg_bin_for(v)}/pg_config"

(lib/neon_postgres.name/v).install "#{ext}.so"
(lib/neon_postgres.name/v).install "#{ext}.#{dlsuffix}"
(share/neon_postgres.name/v/"extension").install "#{ext}.control" if File.exist?("#{ext}.control")
(share/neon_postgres.name/v/"extension").install Dir["#{ext}--*.sql"]
end
Expand All @@ -40,20 +43,22 @@ def install
end

test do
neon_postgres.pg_versions.each do |v|
neon_postgres.pg_versions_internal.each do |v|
pg_ctl = neon_postgres.pg_bin_for(v)/"pg_ctl"
psql = neon_postgres.pg_bin_for(v)/"psql"
port = free_port

system pg_ctl, "initdb", "-D", testpath/"test-#{v}"
(testpath/"test-#{v}/postgresql.conf").write <<~EOS, mode: "a+"

shared_preload_libraries = 'neon'
#{"v14 v15".include?(v) ? "shared_preload_libraries = 'neon'": ""}
port = #{port}
EOS
system pg_ctl, "start", "-D", testpath/"test-#{v}", "-l", testpath/"log-#{v}"
begin
(extensions - %w[neon_walredo]).each do |ext|
(extensions - %w[neon_walredo neon_rmgr]).each do |ext|
next if "v14 v15".exclude?(v) && ext == "neon"

system psql, "-p", port.to_s, "-c", "CREATE EXTENSION \"#{ext}\";", "postgres"
end
ensure
Expand Down
6 changes: 3 additions & 3 deletions Formula/neon-local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class NeonLocal < Formula
desc "CLI for running Neon locally"
homepage "https://github.com/neondatabase/neon"
url "https://github.com/neondatabase/neon.git",
tag: "release-3898",
revision: "0e6fdc8a587aacbc598afb9232eb81484ed3494e"
tag: "release-3916",
revision: "dce91b33a4ce24b1526ef1c39a95761cb0d7da2b"
license "Apache-2.0"
head "https://github.com/neondatabase/neon.git", branch: "main"

Expand Down Expand Up @@ -76,7 +76,7 @@ def post_install
end

system bin/"neon_local", "start"
neon_postgres.pg_versions.each do |v|
neon_postgres.pg_versions_internal.each do |v|
vv = v.delete_prefix("v")

output = shell_output("#{bin}/neon_local tenant create --pg-version #{vv}")
Expand Down
15 changes: 10 additions & 5 deletions Formula/neon-postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class NeonPostgres < Formula
desc "Neon's fork of PostgreSQL"
homepage "https://github.com/neondatabase/postgres"
url "https://github.com/neondatabase/neon.git",
tag: "release-3898",
revision: "0e6fdc8a587aacbc598afb9232eb81484ed3494e"
tag: "release-3916",
revision: "dce91b33a4ce24b1526ef1c39a95761cb0d7da2b"
license "Apache-2.0"
head "https://github.com/neondatabase/neon.git", branch: "main"

Expand Down Expand Up @@ -31,12 +31,16 @@ class NeonPostgres < Formula
depends_on "libseccomp"
end

def pg_versions_internal
%w[v14 v15 v16]
end

def pg_versions
%w[v14 v15]
end

def pg_bin_for(version)
pg_versions.to_h { |v| [v, opt_libexec/v/"bin"] }.fetch(version)
pg_versions_internal.to_h { |v| [v, opt_libexec/v/"bin"] }.fetch(version)
end

def install
Expand All @@ -50,7 +54,7 @@ def install
ENV.prepend "CPPFLAGS", "-I#{Formula["curl"].opt_include}"
end

pg_versions.each do |v|
pg_versions_internal.each do |v|
cd "vendor/postgres-#{v}" do
args = %W[
--prefix=#{libexec}/#{v}
Expand Down Expand Up @@ -84,6 +88,7 @@ def install
ln_s include/name/v/"server", libexec/v/"include/server"

next unless OS.linux?
next unless "v14 v15".include?(v)

inreplace libexec/v/"lib/pgxs/src/Makefile.global",
"LD = #{HOMEBREW_PREFIX}/Homebrew/Library/Homebrew/shims/linux/super/ld",
Expand All @@ -92,7 +97,7 @@ def install
end

test do
pg_versions.each do |v|
pg_versions_internal.each do |v|
system "#{pg_bin_for(v)}/initdb", testpath/"test-#{v}"

pg_config = pg_bin_for(v)/"pg_config"
Expand Down
4 changes: 2 additions & 2 deletions Formula/neon-storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class NeonStorage < Formula
desc "Storage components for Neon"
homepage "https://github.com/neondatabase/neon"
url "https://github.com/neondatabase/neon.git",
tag: "release-3898",
revision: "0e6fdc8a587aacbc598afb9232eb81484ed3494e"
tag: "release-3916",
revision: "dce91b33a4ce24b1526ef1c39a95761cb0d7da2b"
license "Apache-2.0"
head "https://github.com/neondatabase/neon.git", branch: "main"

Expand Down