-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneon-extension.rb
83 lines (71 loc) · 2.95 KB
/
neon-extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
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-7381",
revision: "671889b0e959a6520337ba3c56d645d6ff2ec1c1"
license "Apache-2.0"
head "https://github.com/neondatabase/neon.git", branch: "main"
livecheck do
url :head
regex(/^release-(\d+)$/i)
end
bottle do
root_url "https://ghcr.io/v2/bayandin/tap"
sha256 cellar: :any, arm64_sequoia: "75c4e3cee2897a35b670240bed25131fc8c78ba1ea349ee3480336a31549709f"
sha256 cellar: :any, arm64_sonoma: "f3c6e4f358342703eda1c76e23176e6ef1d053e3f4cc9ef06929f2049216a021"
sha256 cellar: :any, ventura: "d93d08d89267db70aab39a2d02e5553f02c06b8f3fa571c3dc8826209c8cee41"
sha256 cellar: :any_skip_relocation, x86_64_linux: "6b5b88d6e534bb9fcd172019fc91d4cd1729bbba8914f1f953a632ea6bedccb9"
end
depends_on "bayandin/tap/neon-postgres"
uses_from_macos "curl"
def extensions
%w[neon_walredo neon neon_rmgr neon_utils]
end
def neon_postgres
Formula["bayandin/tap/neon-postgres"]
end
def pg_versions
neon_postgres.pg_versions
end
def install
pg_versions.each do |v|
cp_r "pgxn", "build-#{v}"
extensions.each do |ext|
cd "build-#{v}/#{ext}" do
system "make", "install", "PG_CONFIG=#{neon_postgres.pg_bin_for(v)}/pg_config",
"DESTDIR=#{buildpath}/stage-#{v}-#{ext}"
stage_dir = buildpath/"stage-#{v}-#{ext}#{HOMEBREW_PREFIX}"
share_dir = share/neon_postgres.name/v
lib_dir = lib/neon_postgres.name/v
lib_dir.install stage_dir/"lib"/neon_postgres.name/v/"#{ext}.#{neon_postgres.dlsuffix(v)}"
if File.exist?(stage_dir/"share"/neon_postgres.name/v/"extension/#{ext}.control")
(share_dir/"extension").install stage_dir/"share"/neon_postgres.name/v/"extension/#{ext}.control"
end
(share_dir/"extension").install Dir[stage_dir/"share"/neon_postgres.name/v/"extension/#{ext}--*.sql"]
end
end
end
end
test do
pg_versions.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+"
#{"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 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
system pg_ctl, "stop", "-D", testpath/"test-#{v}"
end
end
end
end