homebrew-core/Formula/minio-mc.rb
2019-05-18 10:58:48 +02:00

50 lines
1.6 KiB
Ruby

class MinioMc < Formula
desc "Replacement for ls, cp and other commands for object storage"
homepage "https://github.com/minio/mc"
url "https://github.com/minio/mc.git",
:tag => "RELEASE.2019-05-01T23-27-44Z",
:revision => "b1aa2232ef3babc5f06bacb1b0044022185457ca"
version "20190501232744"
bottle do
cellar :any_skip_relocation
sha256 "f3802702ce2a78282c560849c328c3ffd5f2cee62ed414d258dcb4ca5eab33b6" => :mojave
sha256 "09d9a5b383fe58ce579facb9328d0c0b27395329f9da2953fa9685efcc629d4d" => :high_sierra
sha256 "4463b10138ae750aad9f958017944c942a532b49ae67699d56d8295cc0eb56e9" => :sierra
end
depends_on "go" => :build
conflicts_with "midnight-commander", :because => "Both install a `mc` binary"
def install
ENV["GOPATH"] = buildpath
ENV["GO111MODULE"] = "on"
src = buildpath/"src/github.com/minio/mc"
src.install buildpath.children
src.cd do
if build.head?
system "go", "build", "-o", buildpath/"mc"
else
minio_release = `git tag --points-at HEAD`.chomp
minio_version = minio_release.gsub(/RELEASE\./, "").chomp.gsub(/T(\d+)\-(\d+)\-(\d+)Z/, 'T\1:\2:\3Z')
minio_commit = `git rev-parse HEAD`.chomp
proj = "github.com/minio/mc"
system "go", "build", "-o", buildpath/"mc", "-ldflags", <<~EOS
-X #{proj}/cmd.Version=#{minio_version}
-X #{proj}/cmd.ReleaseTag=#{minio_release}
-X #{proj}/cmd.CommitID=#{minio_commit}
EOS
end
end
bin.install buildpath/"mc"
prefix.install_metafiles
end
test do
system bin/"mc", "mb", testpath/"test"
assert_predicate testpath/"test", :exist?
end
end