/
doctl.rb
38 lines (32 loc) 路 1.33 KB
/
doctl.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
class Doctl < Formula
desc "Command-line tool for DigitalOcean"
homepage "https://github.com/digitalocean/doctl"
url "https://github.com/digitalocean/doctl/archive/v1.3.1.tar.gz"
sha256 "3b83173a00a6f0e94e250cf5e77845d70cacd02529b7791076a5c7e24320c394"
head "https://github.com/digitalocean/doctl.git"
bottle do
cellar :any_skip_relocation
sha256 "533905ad448a8288e8b119e78c6686672e64f2bc27c11a17a38d573671b5c8ee" => :el_capitan
sha256 "95e20a1b330b8ef853d7292e905b7198afb2a184aefb35ace8ea859f140a24b9" => :yosemite
sha256 "4e699d213de14dfaee7e45342b06f5c34ff5bcb01551f44c0b027a76d848d4ed" => :mavericks
end
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
mkdir_p buildpath/"src/github.com/digitalocean/"
ln_sf buildpath, buildpath/"src/github.com/digitalocean/doctl"
doctl_version = version.to_s.split(/\./)
base_flag = "-X github.com/digitalocean/doctl"
ldflags = %W[
#{base_flag}.Major=#{doctl_version[0]}
#{base_flag}.Minor=#{doctl_version[1]}
#{base_flag}.Patch=#{doctl_version[2]}
#{base_flag}.Label=release
].join(" ")
system "go", "build", "-ldflags", ldflags, "github.com/digitalocean/doctl/cmd/doctl"
bin.install "doctl"
end
test do
assert_match "doctl version #{version}-release", shell_output("#{bin}/doctl version")
end
end