homebrew-core/Formula/minio.rb

96 lines
3.1 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.2021-05-26T00-22-46Z",
revision: "3fff50120bb17700fc9b8d88ce6fe4a71fcbc3f0"
version "20210526002246"
license "AGPL-3.0-or-later"
head "https://github.com/minio/minio.git"
livecheck do
url :stable
regex(%r{href=.*?/tag/(?:RELEASE[._-]?)?([\d\-TZ]+)["' >]}i)
strategy :github_latest do |page, regex|
page.scan(regex).map { |match| match&.first&.gsub(/\D/, "") }
end
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "fba09908f92d37b1bcbf7c84b05d8505eae6fa1aec6d5e39020080fda9a45b31"
sha256 cellar: :any_skip_relocation, big_sur: "4cecbed5d70b01f45dc7db33fe5aa7260713fb12d8d30de335ee5fab1f92ce10"
sha256 cellar: :any_skip_relocation, catalina: "d732e0b3b7c7945d9e2e8eb3e5c7b90ed14efc80fc4dbe2d23b9eeef035550a3"
sha256 cellar: :any_skip_relocation, mojave: "6c79f916f2ae20c4f537015bcc8cf6f43cad4fe6dd2af434267ea240b148410c"
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')
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=#{Utils.git_head}
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