2017-07-16 20:06:32 +02:00
|
|
|
package brew
|
|
|
|
|
|
|
|
type templateData struct {
|
2018-06-20 14:46:42 +02:00
|
|
|
Name string
|
|
|
|
Desc string
|
|
|
|
Homepage string
|
|
|
|
Version string
|
|
|
|
Caveats []string
|
|
|
|
Plist string
|
|
|
|
DownloadStrategy string
|
|
|
|
Install []string
|
|
|
|
Dependencies []string
|
|
|
|
Conflicts []string
|
|
|
|
Tests []string
|
2018-11-21 17:57:44 +02:00
|
|
|
CustomRequire string
|
2018-12-30 04:06:54 +02:00
|
|
|
CustomBlock []string
|
2019-06-10 15:35:19 +02:00
|
|
|
MacOS downloadable
|
|
|
|
Linux downloadable
|
2019-08-13 18:37:11 +02:00
|
|
|
Arm downloadable
|
|
|
|
Arm64 downloadable
|
2019-06-10 15:35:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type downloadable struct {
|
|
|
|
DownloadURL string
|
|
|
|
SHA256 string
|
2017-07-16 20:06:32 +02:00
|
|
|
}
|
|
|
|
|
2019-01-27 20:37:32 +02:00
|
|
|
const formulaTemplate = `# This file was generated by GoReleaser. DO NOT EDIT.
|
|
|
|
{{ if .CustomRequire -}}
|
2018-11-21 17:57:44 +02:00
|
|
|
require_relative "{{ .CustomRequire }}"
|
|
|
|
{{ end -}}
|
|
|
|
class {{ .Name }} < Formula
|
2017-07-16 20:06:32 +02:00
|
|
|
desc "{{ .Desc }}"
|
|
|
|
homepage "{{ .Homepage }}"
|
|
|
|
version "{{ .Version }}"
|
2019-07-20 19:27:25 +02:00
|
|
|
bottle :unneeded
|
2019-06-10 15:35:19 +02:00
|
|
|
|
|
|
|
if OS.mac?
|
|
|
|
{{- if .MacOS.DownloadURL }}
|
|
|
|
url "{{ .MacOS.DownloadURL }}"
|
2019-08-13 18:37:11 +02:00
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
2019-06-10 15:35:19 +02:00
|
|
|
sha256 "{{ .MacOS.SHA256 }}"
|
|
|
|
{{- end }}
|
|
|
|
elsif OS.linux?
|
|
|
|
{{- if .Linux.DownloadURL }}
|
2019-08-13 18:37:11 +02:00
|
|
|
if Hardware::CPU.intel?
|
|
|
|
url "{{ .Linux.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ .Linux.SHA256 }}"
|
|
|
|
end
|
2019-06-10 15:35:19 +02:00
|
|
|
{{- end }}
|
2019-08-13 18:37:11 +02:00
|
|
|
{{- if or .Arm.DownloadURL .Arm64.DownloadURL }}
|
|
|
|
if Hardware::CPU.arm?
|
|
|
|
if Hardware::CPU.is_64_bit?
|
|
|
|
{{- if .Arm64.DownloadURL }}
|
|
|
|
url "{{ .Arm64.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ .Arm64.SHA256 }}"
|
|
|
|
{{- end }}
|
|
|
|
else
|
|
|
|
{{- if .Arm.DownloadURL }}
|
|
|
|
url "{{ .Arm.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ .Arm.SHA256 }}"
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
{{- end }}
|
2019-06-10 15:35:19 +02:00
|
|
|
end
|
|
|
|
|
2018-12-30 04:06:54 +02:00
|
|
|
{{- with .CustomBlock }}
|
|
|
|
{{ range $index, $element := . }}
|
|
|
|
{{ . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
2018-04-04 02:13:17 +02:00
|
|
|
{{- with .Dependencies }}
|
|
|
|
{{ range $index, $element := . }}
|
2018-04-01 20:07:28 +02:00
|
|
|
depends_on "{{ . }}"
|
2018-03-28 16:14:27 +02:00
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
2017-07-16 20:06:32 +02:00
|
|
|
|
2018-04-01 19:25:04 +02:00
|
|
|
{{- with .Conflicts }}
|
|
|
|
{{ range $index, $element := . }}
|
2017-07-16 20:06:32 +02:00
|
|
|
conflicts_with "{{ . }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
|
2018-04-01 19:25:04 +02:00
|
|
|
{{- with .Caveats }}
|
2017-07-16 20:06:32 +02:00
|
|
|
|
2018-04-05 22:38:32 +02:00
|
|
|
def caveats; <<~EOS
|
2018-04-01 19:25:04 +02:00
|
|
|
{{- range $index, $element := . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
EOS
|
2017-07-16 20:06:32 +02:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2018-04-01 19:25:04 +02:00
|
|
|
{{- with .Plist }}
|
2017-07-16 20:06:32 +02:00
|
|
|
|
|
|
|
plist_options :startup => false
|
|
|
|
|
2018-02-06 20:08:20 +02:00
|
|
|
def plist; <<~EOS
|
2018-04-01 19:25:04 +02:00
|
|
|
{{ . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
EOS
|
2017-07-16 20:06:32 +02:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
|
|
|
{{- if .Tests }}
|
|
|
|
|
|
|
|
test do
|
|
|
|
{{- range $index, $element := .Tests }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
`
|