-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneon-postgres.rb
123 lines (106 loc) · 4.23 KB
/
neon-postgres.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class NeonPostgres < Formula
desc "Neon's fork of PostgreSQL"
homepage "https://github.com/neondatabase/postgres"
url "https://github.com/neondatabase/neon.git",
tag: "release-compute-7685",
revision: "dd04e3eb1198eef722773240d79a40f36c57c726"
license "Apache-2.0"
head "https://github.com/neondatabase/neon.git", branch: "main"
livecheck do
url :head
regex(/^release-compute-(\d+)$/i)
end
bottle do
root_url "https://ghcr.io/v2/bayandin/tap"
sha256 arm64_sequoia: "cce348a4f9a06a4f679c0586d7a4681de28b77ecb49bef7f83c67eeea57e2559"
sha256 arm64_sonoma: "ba4750c30d49cea1452666b3b9a5e621d8f5f195693a58e56a1e002b581869c4"
sha256 ventura: "4664d84d563464aaa47c479b366eb1a58709a58172d6d0d2b74566e6648faf75"
sha256 x86_64_linux: "501f51044ea91e6eb02fab98a4fe4cf3087bb15fc65079fa92408cfe066d9f80"
end
depends_on "docbook" => :build
depends_on "docbook-xsl" => :build
depends_on "pkg-config" => :build
depends_on "icu4c@76"
depends_on "lz4"
depends_on "openssl@3"
depends_on "readline"
depends_on "zstd"
uses_from_macos "bison" => :build
uses_from_macos "flex" => :build
uses_from_macos "libxml2"
uses_from_macos "libxslt"
uses_from_macos "zlib"
on_linux do
depends_on "libseccomp"
depends_on "util-linux"
end
def pg_versions(with: nil, without: nil)
versions = Set.new(%w[v14 v15 v16 v17])
versions.merge(Array(with))
versions.subtract(Array(without))
versions.to_a.sort
end
def pg_bin_for(version)
opt_libexec/version/"bin"
end
def pg_lib_for(version)
opt_libexec/version/"lib"
end
def dlsuffix(version)
# Ref https://github.com/postgres/postgres/commit/b55f62abb2c2e07dfae99e19a2b3d7ca9e58dc1a
(OS.linux? || "v14 v15".include?(version)) ? "so" : "dylib"
end
def install
ENV["XML_CATALOG_FILES"] = etc/"xml/catalog"
ENV.append_to_cflags "-DUSE_PREFETCH" if OS.mac?
deps = %w[openssl@3 readline]
pg_versions.each do |v|
cd "vendor/postgres-#{v}" do
args = %W[
--prefix=#{libexec}/#{v}
--datadir=#{HOMEBREW_PREFIX}/share/#{name}/#{v}
--libdir=#{HOMEBREW_PREFIX}/lib/#{name}/#{v}
--includedir=#{HOMEBREW_PREFIX}/include/#{name}/#{v}
--with-includes=#{deps.map { |d| Formula[d].opt_include }.join(" ")}
--with-libraries=#{deps.map { |d| Formula[d].opt_lib }.join(" ")}
--enable-debug
--with-icu
--with-libxml
--with-libxslt
--with-lz4
--with-ssl=openssl
--with-uuid=e2fs
]
args << "--with-zstd" if v != "v14"
args << "PG_SYSROOT=#{MacOS.sdk_path}" if OS.mac? && MacOS.sdk_root_needed?
system "./configure", *args
system "make"
system "make", "install-world", "datadir=#{pkgshare}/#{v}",
"includedir_internal=#{include/name/v}/internal",
"includedir_server=#{include/name/v}/server",
"includedir=#{include/name/v}",
"libdir=#{lib/name/v}",
"pkgincludedir=#{include/name/v}",
"pkglibdir=#{lib/name/v}"
end
ln_s lib/name/v, libexec/v/"lib"
ln_s include/name/v, libexec/v/"include"
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",
"LD = #{HOMEBREW_PREFIX}/bin/ld"
end
end
test do
pg_versions.each do |v|
system "#{pg_bin_for(v)}/initdb", testpath/"test-#{v}"
pg_config = pg_bin_for(v)/"pg_config"
assert_equal "#{HOMEBREW_PREFIX}/share/#{name}/#{v}", shell_output("#{pg_config} --sharedir").chomp
assert_equal "#{HOMEBREW_PREFIX}/lib/#{name}/#{v}", shell_output("#{pg_config} --libdir").chomp
assert_equal "#{HOMEBREW_PREFIX}/lib/#{name}/#{v}", shell_output("#{pg_config} --pkglibdir").chomp
assert_equal "#{HOMEBREW_PREFIX}/include/#{name}/#{v}", shell_output("#{pg_config} --includedir").chomp
end
end
end