homebrew-core/Formula/minio.rb

95 lines
3.0 KiB
Ruby

class Minio < Formula
desc "High Performance, Kubernetes Native Object Storage"
homepage "https://min.io"
url "https://github.com/minio/minio.git",
tag: "RELEASE.2020-11-10T21-02-24Z",
revision: "4683a623dcbd539d93e7dd1cf11db609b3121ebc"
version "20201110210224"
license "Apache-2.0"
head "https://github.com/minio/minio.git"
livecheck do
url "https://github.com/minio/minio/releases/latest"
regex(%r{href=.*?/tag/(?:RELEASE[._-]?)?([^"' >]+)["' >]}i)
end
bottle do
cellar :any_skip_relocation
sha256 "9b3203380f58fa329b1104dd214ca03dbfb70ebf2d4f9f5f319f000c3afdbf4b" => :big_sur
sha256 "683225d7b4226cb85590b002bf58aecb68deae94933df531e09d4120ce8b6893" => :catalina
sha256 "b42a713ba168c2cf4fa1dae21bbf99f263e3529c3216724a271e8bad0723ef67" => :mojave
sha256 "59b5e4c362aac3321bf45e36c22cb6d8a6508f6a4bfddb4fc9afdefdf7f8eb31" => :high_sierra
end
depends_on "go" => :build
def install
if build.head?
system "go", "build", *std_go_args
else
release = `git tag --points-at HEAD`.chomp
version = release.gsub(/RELEASE\./, "").chomp.gsub(/T(\d+)-(\d+)-(\d+)Z/, 'T\1:\2:\3Z')
commit = `git rev-parse HEAD`.chomp
proj = "github.com/minio/minio"
system "go", "build", *std_go_args, "-ldflags", <<~EOS
-X #{proj}/cmd.Version=#{version}
-X #{proj}/cmd.ReleaseTag=#{release}
-X #{proj}/cmd.CommitID=#{commit}
EOS
end
end
def post_install
(var/"minio").mkpath
(etc/"minio").mkpath
end
plist_options manual: "minio server"
def plist
<<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{opt_bin}/minio</string>
<string>server</string>
<string>--config-dir=#{etc}/minio</string>
<string>--address=:9000</string>
<string>#{var}/minio</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/minio.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/minio.log</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
EOS
end
test do
assert_match "minio server - start object storage server",
shell_output("#{bin}/minio server --help 2>&1")
assert_match "minio gateway - start object storage gateway",
shell_output("#{bin}/minio gateway 2>&1")
assert_match "ERROR Unable to validate credentials",
shell_output("#{bin}/minio gateway s3 2>&1", 1)
end
end