-
Notifications
You must be signed in to change notification settings - Fork 3
/
homebrew_formula.yml
81 lines (70 loc) · 2.83 KB
/
homebrew_formula.yml
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
#@ load("@ytt:data", "data")
#@ load("@ytt:assert", "assert")
#@ def get_shasum(os, arch):
#@ assets = data.values.assets
#@ for i in range(len(assets)):
#@ if assets[i].os == os and assets[i].arch == arch:
#@ return assets[i].shasum
#@ end
#@ end
#@ assert.fail('did not find os/arch')
#@ end
#@ def has(os, arch):
#@ assets = data.values.assets
#@ for i in range(len(assets)):
#@ if assets[i].os == os and assets[i].arch == arch:
#@ return True
#@ end
#@ end
#@ return False
#@ end
#@ def download_info(os, arch, product, version, github_url):
#@ if has(os, arch):
#@ sha256 = get_shasum(os, arch)
#@ return 'url "https://{github_url}/releases/download/{version}/{product}-{os}-{arch}"\n sha256 "{sha256}"'.format(product=product, version=version, sha256=sha256, os=os, arch=arch, github_url=github_url)
#@ else:
#@ return 'odie "{os}/{arch} is not supported. If you would like support please raise an issue upstream to {github_url}"'.format(os=os, arch=arch, github_url=github_url)
#@ end
#@ end
#@ def homepage(product):
#@ if product == "kctrl":
#@ return "https://carvel.dev/kapp-controller/"
#@ else:
#@ return "https://carvel.dev/{product}/".format(product=product)
#@ end
#@ end
#@yaml/text-templated-strings
output: |
class (@= data.values.product.capitalize() @) < Formula
desc "(@= data.values.product.capitalize() @)"
homepage "(@= homepage(data.values.product) @)"
version "(@= data.values.version @)"
if OS.mac?
if Hardware::CPU.arm?
(@= download_info('darwin', 'arm64', data.values.product, data.values.version, data.values.github.url) @)
else
(@= download_info('darwin', 'amd64', data.values.product, data.values.version, data.values.github.url) @)
end
elsif OS.linux?
if Hardware::CPU.arm?
(@= download_info('linux', 'arm64', data.values.product, data.values.version, data.values.github.url) @)
else
(@= download_info('linux', 'amd64', data.values.product, data.values.version, data.values.github.url) @)
end
end
def install
bin.install stable.url.split("/")[-1] => "(@= data.values.product @)"
(@ if data.values.product == "ytt": @)
chmod 0755, bin/"(@= data.values.product @)"
bash_output = Utils.safe_popen_read(bin/"(@= data.values.product @)", "completion", "bash")
(bash_completion/"(@= data.values.product @)").write bash_output
zsh_output = Utils.safe_popen_read(bin/"(@= data.values.product @)", "completion", "zsh")
(zsh_completion/"_(@= data.values.product @)").write zsh_output
fish_output = Utils.safe_popen_read(bin/"(@= data.values.product @)", "completion", "fish")
(fish_completion/"(@= data.values.product @).fish").write fish_output
(@ end @)
end
test do
system "#{bin}/(@= data.values.product @)", "version"
end
end