2017-07-16 15:06:32 -03:00
|
|
|
package brew
|
|
|
|
|
2020-05-24 18:10:25 +03:00
|
|
|
import "github.com/goreleaser/goreleaser/pkg/config"
|
|
|
|
|
2017-07-16 15:06:32 -03:00
|
|
|
type templateData struct {
|
2022-02-25 19:57:46 -05:00
|
|
|
Name string
|
|
|
|
Desc string
|
|
|
|
Homepage string
|
|
|
|
Version string
|
|
|
|
License string
|
|
|
|
Caveats []string
|
|
|
|
Plist string
|
2022-03-16 21:40:25 -03:00
|
|
|
PostInstall []string
|
2022-02-25 19:57:46 -05:00
|
|
|
Dependencies []config.HomebrewDependency
|
|
|
|
Conflicts []string
|
|
|
|
Tests []string
|
|
|
|
CustomRequire string
|
|
|
|
CustomBlock []string
|
|
|
|
LinuxPackages []releasePackage
|
|
|
|
MacOSPackages []releasePackage
|
2022-03-16 21:12:57 -03:00
|
|
|
Service []string
|
2022-02-25 19:57:46 -05:00
|
|
|
HasOnlyAmd64MacOsPkg bool
|
2019-06-10 10:35:19 -03:00
|
|
|
}
|
|
|
|
|
2021-09-28 21:34:35 -03:00
|
|
|
type releasePackage struct {
|
|
|
|
DownloadURL string
|
|
|
|
SHA256 string
|
|
|
|
OS string
|
|
|
|
Arch string
|
|
|
|
DownloadStrategy string
|
2021-10-18 09:31:20 -03:00
|
|
|
Install []string
|
2017-07-16 15:06:32 -03:00
|
|
|
}
|
|
|
|
|
2021-01-07 05:14:50 -07:00
|
|
|
const formulaTemplate = `# typed: false
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# This file was generated by GoReleaser. DO NOT EDIT.
|
2019-01-27 16:37:32 -02:00
|
|
|
{{ if .CustomRequire -}}
|
2018-11-21 15:57:44 +00:00
|
|
|
require_relative "{{ .CustomRequire }}"
|
|
|
|
{{ end -}}
|
|
|
|
class {{ .Name }} < Formula
|
2017-07-16 15:06:32 -03:00
|
|
|
desc "{{ .Desc }}"
|
|
|
|
homepage "{{ .Homepage }}"
|
|
|
|
version "{{ .Version }}"
|
2021-10-19 16:28:23 -04:00
|
|
|
{{- if .License }}
|
2020-11-26 14:06:47 +01:00
|
|
|
license "{{ .License }}"
|
2021-10-19 16:28:23 -04:00
|
|
|
{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if and (not .LinuxPackages) .MacOSPackages }}
|
2021-05-30 14:25:25 -03:00
|
|
|
depends_on :macos
|
|
|
|
{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if and (not .MacOSPackages) .LinuxPackages }}
|
2020-11-16 09:16:50 -03:00
|
|
|
depends_on :linux
|
|
|
|
{{- end }}
|
|
|
|
{{- printf "\n" }}
|
|
|
|
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if .MacOSPackages }}
|
2021-05-30 14:25:25 -03:00
|
|
|
on_macos do
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- range $element := .MacOSPackages }}
|
2021-10-12 14:55:43 -03:00
|
|
|
{{- if eq $element.Arch "all" }}
|
|
|
|
url "{{ $element.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ $element.SHA256 }}"
|
2021-10-18 09:31:20 -03:00
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
2022-02-25 19:57:46 -05:00
|
|
|
{{- else if $.HasOnlyAmd64MacOsPkg }}
|
|
|
|
url "{{ $element.DownloadURL }}"
|
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
|
|
|
sha256 "{{ $element.SHA256 }}"
|
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
|
|
|
|
if Hardware::CPU.arm?
|
|
|
|
def caveats
|
|
|
|
<<~EOS
|
|
|
|
The darwin_arm64 architecture is not supported for the {{ $.Name }}
|
|
|
|
formula at this time. The darwin_amd64 binary may work in compatibility
|
|
|
|
mode, but it might not be fully supported.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
2021-10-12 14:55:43 -03:00
|
|
|
{{- else }}
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if eq $element.Arch "amd64" }}
|
2021-05-30 14:25:25 -03:00
|
|
|
if Hardware::CPU.intel?
|
|
|
|
{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if eq $element.Arch "arm64" }}
|
2021-05-30 14:25:25 -03:00
|
|
|
if Hardware::CPU.arm?
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- end}}
|
|
|
|
url "{{ $element.DownloadURL }}"
|
2021-05-30 14:25:25 -03:00
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
sha256 "{{ $element.SHA256 }}"
|
2021-10-18 09:31:20 -03:00
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
2021-05-30 14:25:25 -03:00
|
|
|
end
|
2021-10-12 14:55:43 -03:00
|
|
|
{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- end }}
|
2020-11-16 09:16:50 -03:00
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if and .MacOSPackages .LinuxPackages }}{{ printf "\n" }}{{ end }}
|
2021-05-30 14:25:25 -03:00
|
|
|
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if .LinuxPackages }}
|
2021-05-30 14:25:25 -03:00
|
|
|
on_linux do
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- range $element := .LinuxPackages }}
|
|
|
|
{{- if eq $element.Arch "amd64" }}
|
2021-05-30 14:25:25 -03:00
|
|
|
if Hardware::CPU.intel?
|
|
|
|
{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if eq $element.Arch "arm" }}
|
2021-05-30 14:25:25 -03:00
|
|
|
if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
|
|
|
|
{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- if eq $element.Arch "arm64" }}
|
2021-05-30 14:25:25 -03:00
|
|
|
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- end }}
|
|
|
|
url "{{ $element.DownloadURL }}"
|
2021-05-30 14:25:25 -03:00
|
|
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
2021-09-28 21:34:35 -03:00
|
|
|
sha256 "{{ $element.SHA256 }}"
|
2021-10-18 09:31:20 -03:00
|
|
|
|
|
|
|
def install
|
|
|
|
{{- range $index, $element := .Install }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
2021-05-30 14:25:25 -03:00
|
|
|
end
|
2021-09-28 21:34:35 -03:00
|
|
|
{{- end }}
|
2020-11-16 09:16:50 -03:00
|
|
|
end
|
|
|
|
{{- end }}
|
2019-06-10 10:35:19 -03:00
|
|
|
|
2018-12-30 02:06:54 +00:00
|
|
|
{{- with .CustomBlock }}
|
|
|
|
{{ range $index, $element := . }}
|
|
|
|
{{ . }}
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
2018-04-03 21:13:17 -03:00
|
|
|
{{- with .Dependencies }}
|
|
|
|
{{ range $index, $element := . }}
|
2020-05-24 18:10:25 +03:00
|
|
|
depends_on "{{ .Name }}"
|
|
|
|
{{- if .Type }} => :{{ .Type }}{{- end }}
|
2018-03-28 16:14:27 +02:00
|
|
|
{{- end }}
|
|
|
|
{{- end -}}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Conflicts }}
|
|
|
|
{{ range $index, $element := . }}
|
2017-07-16 15:06:32 -03:00
|
|
|
conflicts_with "{{ . }}"
|
|
|
|
{{- end }}
|
|
|
|
{{- end }}
|
|
|
|
|
2020-09-18 10:42:52 -03:00
|
|
|
{{- with .PostInstall }}
|
|
|
|
|
|
|
|
def post_install
|
2022-03-16 21:40:25 -03:00
|
|
|
{{- range . }}
|
2020-09-18 10:42:52 -03:00
|
|
|
{{ . }}
|
2022-03-16 21:40:25 -03:00
|
|
|
{{- end }}
|
2020-09-18 10:42:52 -03:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Caveats }}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
2018-04-05 13:38:32 -07:00
|
|
|
def caveats; <<~EOS
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- range $index, $element := . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
EOS
|
2017-07-16 15:06:32 -03:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2018-04-01 14:25:04 -03:00
|
|
|
{{- with .Plist }}
|
2017-07-16 15:06:32 -03:00
|
|
|
|
|
|
|
plist_options :startup => false
|
|
|
|
|
2018-02-06 10:08:20 -08:00
|
|
|
def plist; <<~EOS
|
2018-04-01 14:25:04 -03:00
|
|
|
{{ . }}
|
2018-03-28 16:14:27 +02:00
|
|
|
EOS
|
2017-07-16 15:06:32 -03:00
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2022-03-16 21:12:57 -03:00
|
|
|
{{- with .Service }}
|
2022-03-16 21:40:25 -03:00
|
|
|
|
2022-03-16 21:12:57 -03:00
|
|
|
service do
|
|
|
|
{{- range . }}
|
2022-03-16 21:40:25 -03:00
|
|
|
{{ . }}
|
2022-03-16 21:12:57 -03:00
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
{{- end -}}
|
|
|
|
|
2017-07-16 15:06:32 -03:00
|
|
|
{{- if .Tests }}
|
|
|
|
|
|
|
|
test do
|
|
|
|
{{- range $index, $element := .Tests }}
|
|
|
|
{{ . -}}
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
{{- end }}
|
|
|
|
end
|
|
|
|
`
|