-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
mariadb@11.2.rb
198 lines (167 loc) 路 6.41 KB
/
mariadb@11.2.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
class MariadbAT112 < Formula
desc "Drop-in replacement for MySQL"
homepage "https://mariadb.org/"
url "https://archive.mariadb.org/mariadb-11.2.4/source/mariadb-11.2.4.tar.gz"
sha256 "e16f152a6b60bec0938051a8340e410d33e0708d1f84a2cf38f1b04e4133bf19"
license "GPL-2.0-only"
livecheck do
url "https://downloads.mariadb.org/rest-api/mariadb/all-releases/?olderReleases=false"
strategy :json do |json|
json["releases"]&.map do |release|
next unless release["release_number"]&.start_with?(version.major_minor)
next if release["status"] != "stable"
release["release_number"]
end
end
end
bottle do
sha256 arm64_sonoma: "469774894a1d0b5d541c8f8f69f72e3ba93853c04acd56a8e4e314f8e56d7ec3"
sha256 arm64_ventura: "f38825629f1343c7f8035f6e698881b82864c85af7ac3c02e95cb72e6b319d0c"
sha256 arm64_monterey: "6a7ec6bec3a724fd3ce647a32dcdfa8c342f95db5ab7bffc61d4f707db81d755"
sha256 sonoma: "2e9a39094ccdaea04be094b815e7a7d8ceb4f3d95c4e5756f1839d12358ac26d"
sha256 ventura: "2c205a7ced7ff07db00a64bda70d87d74232377c62641a6161b79212efde61de"
sha256 monterey: "91dfd2a75cc471e2c7ac865e34a33f1ae8964e40e6984afb9b27e8c70d1505f4"
sha256 x86_64_linux: "294e1d04bae98dece5a291061d89e3cca5cc78611d28251d5026508523b5941b"
end
keg_only :versioned_formula
# See: https://mariadb.com/kb/en/changes-improvements-in-mariadb-11-2/
# End-of-life on 2024-11-21: https://mariadb.org/about/#maintenance-policy
disable! date: "2024-11-21", because: :unsupported
depends_on "bison" => :build
depends_on "cmake" => :build
depends_on "fmt" => :build
depends_on "pkg-config" => :build
depends_on "groonga"
depends_on "lz4"
depends_on "openssl@3"
depends_on "pcre2"
depends_on "xz"
depends_on "zstd"
uses_from_macos "bzip2"
uses_from_macos "krb5"
uses_from_macos "libedit"
uses_from_macos "libxcrypt"
uses_from_macos "libxml2"
uses_from_macos "ncurses"
uses_from_macos "zlib"
on_linux do
depends_on "linux-pam"
depends_on "readline" # uses libedit on macOS
end
fails_with gcc: "5"
def install
ENV.cxx11
# Set basedir and ldata so that mysql_install_db can find the server
# without needing an explicit path to be set. This can still
# be overridden by calling --basedir= when calling.
inreplace "scripts/mysql_install_db.sh" do |s|
s.change_make_var! "basedir", "\"#{prefix}\""
s.change_make_var! "ldata", "\"#{var}/mysql\""
end
# Use brew groonga
rm_r "storage/mroonga/vendor/groonga"
# -DINSTALL_* are relative to prefix
args = %W[
-DMYSQL_DATADIR=#{var}/mysql
-DINSTALL_INCLUDEDIR=include/mysql
-DINSTALL_MANDIR=share/man
-DINSTALL_DOCDIR=share/doc/#{name}
-DINSTALL_INFODIR=share/info
-DINSTALL_MYSQLSHAREDIR=share/mysql
-DWITH_LIBFMT=system
-DWITH_SSL=system
-DWITH_UNIT_TESTS=OFF
-DDEFAULT_CHARSET=utf8mb4
-DDEFAULT_COLLATION=utf8mb4_general_ci
-DINSTALL_SYSCONFDIR=#{etc}
-DCOMPILATION_COMMENT=#{tap.user}
]
if OS.linux?
args << "-DWITH_NUMA=OFF"
args << "-DENABLE_DTRACE=NO"
args << "-DCONNECT_WITH_JDBC=OFF"
end
# Disable RocksDB on Apple Silicon (currently not supported)
args << "-DPLUGIN_ROCKSDB=NO" if Hardware::CPU.arm?
system "cmake", "-S", ".", "-B", "_build", *std_cmake_args, *args
system "cmake", "--build", "_build"
system "cmake", "--install", "_build"
# Fix my.cnf to point to #{etc} instead of /etc
(etc/"my.cnf.d").mkpath
inreplace "#{etc}/my.cnf", "!includedir /etc/my.cnf.d",
"!includedir #{etc}/my.cnf.d"
touch etc/"my.cnf.d/.homebrew_dont_prune_me"
# Don't create databases inside of the prefix!
# See: https://github.com/Homebrew/homebrew/issues/4975
rm_rf prefix/"data"
# Save space
(prefix/"mariadb-test").rmtree
(prefix/"sql-bench").rmtree
# Link the setup scripts into bin
bin.install_symlink [
prefix/"scripts/mariadb-install-db",
prefix/"scripts/mysql_install_db",
]
# Fix up the control script and link into bin
inreplace "#{prefix}/support-files/mysql.server", /^(PATH=".*)(")/, "\\1:#{HOMEBREW_PREFIX}/bin\\2"
bin.install_symlink prefix/"support-files/mysql.server"
# Move sourced non-executable out of bin into libexec
libexec.install "#{bin}/wsrep_sst_common"
# Fix up references to wsrep_sst_common
%w[
wsrep_sst_mysqldump
wsrep_sst_rsync
wsrep_sst_mariabackup
].each do |f|
inreplace "#{bin}/#{f}", "$(dirname \"$0\")/wsrep_sst_common",
"#{libexec}/wsrep_sst_common"
end
# Install my.cnf that binds to 127.0.0.1 by default
(buildpath/"my.cnf").write <<~EOS
# Default Homebrew MySQL server config
[mysqld]
# Only allow connections from localhost
bind-address = 127.0.0.1
EOS
etc.install "my.cnf"
end
def post_install
# Make sure the var/mysql directory exists
(var/"mysql").mkpath
# Don't initialize database, it clashes when testing other MySQL-like implementations.
return if ENV["HOMEBREW_GITHUB_ACTIONS"]
unless File.exist? "#{var}/mysql/mysql/user.frm"
ENV["TMPDIR"] = nil
system "#{bin}/mysql_install_db", "--verbose", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{var}/mysql", "--tmpdir=/tmp"
end
end
def caveats
<<~EOS
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
MySQL is configured to only allow connections from localhost by default
EOS
end
service do
run [opt_bin/"mysqld_safe", "--datadir=#{var}/mysql"]
keep_alive true
working_dir var
end
test do
(testpath/"mysql").mkpath
(testpath/"tmp").mkpath
system bin/"mysql_install_db", "--no-defaults", "--user=#{ENV["USER"]}",
"--basedir=#{prefix}", "--datadir=#{testpath}/mysql", "--tmpdir=#{testpath}/tmp",
"--auth-root-authentication-method=normal"
port = free_port
fork do
system "#{bin}/mysqld", "--no-defaults", "--user=#{ENV["USER"]}",
"--datadir=#{testpath}/mysql", "--port=#{port}", "--tmpdir=#{testpath}/tmp"
end
sleep 5
assert_match "information_schema",
shell_output("#{bin}/mysql --port=#{port} --user=root --password= --execute='show databases;'")
system "#{bin}/mysqladmin", "--port=#{port}", "--user=root", "--password=", "shutdown"
end
end