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