Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(brew): improve handling of single os (#4562)
- refactors brew template into separated files using embed.FS - moves the macos and linux packages to different template files - includes and indent those accordingly to which OSes are supported closes #4561 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
- Loading branch information
Showing
13 changed files
with
272 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
# This file was generated by GoReleaser. DO NOT EDIT. | ||
{{ if .CustomRequire -}} | ||
require_relative "{{ .CustomRequire }}" | ||
{{ end -}} | ||
class {{ .Name }} < Formula | ||
desc "{{ .Desc }}" | ||
homepage "{{ .Homepage }}" | ||
version "{{ .Version }}" | ||
{{- if .License }} | ||
license "{{ .License }}" | ||
{{- end }} | ||
{{- with .Dependencies }} | ||
{{ range $index, $element := . }} | ||
depends_on "{{ .Name }}" | ||
{{- if .Type }} => :{{ .Type }}{{- else if .Version }} => "{{ .Version }}"{{- end }} | ||
{{- with .OS }} if OS.{{ . }}?{{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{- if and (not .LinuxPackages) .MacOSPackages }} | ||
depends_on :macos | ||
{{- end }} | ||
{{- if and (not .MacOSPackages) .LinuxPackages }} | ||
depends_on :linux | ||
{{- end }} | ||
{{- printf "\n" }} | ||
|
||
{{- if and .MacOSPackages .LinuxPackages }} | ||
on_macos do | ||
{{- include "macos_packages" . | indent 2 }} | ||
end | ||
|
||
on_linux do | ||
{{- include "linux_packages" . | indent 2 }} | ||
end | ||
{{- end }} | ||
|
||
{{- if and (.MacOSPackages) (not .LinuxPackages) }} | ||
{{- template "macos_packages" . }} | ||
{{- end }} | ||
|
||
{{- if and (not .MacOSPackages) (.LinuxPackages) }} | ||
{{- template "linux_packages" . }} | ||
{{- end }} | ||
|
||
{{- with .Conflicts }} | ||
{{ range $index, $element := . }} | ||
conflicts_with "{{ . }}" | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- with .CustomBlock }} | ||
{{ range $index, $element := . }} | ||
{{ . }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{- with .PostInstall }} | ||
|
||
def post_install | ||
{{- range . }} | ||
{{ . }} | ||
{{- end }} | ||
end | ||
{{- end -}} | ||
|
||
{{- with .Caveats }} | ||
|
||
def caveats | ||
<<~EOS | ||
{{- range $index, $element := . }} | ||
{{ . -}} | ||
{{- end }} | ||
EOS | ||
end | ||
{{- end -}} | ||
|
||
{{- with .Plist }} | ||
|
||
plist_options startup: false | ||
|
||
def plist | ||
<<~EOS | ||
{{ . }} | ||
EOS | ||
end | ||
{{- end -}} | ||
|
||
{{- with .Service }} | ||
|
||
service do | ||
{{- range . }} | ||
{{ . }} | ||
{{- end }} | ||
end | ||
{{- end -}} | ||
|
||
{{- if .Tests }} | ||
|
||
test do | ||
{{- range $index, $element := .Tests }} | ||
{{ . -}} | ||
{{- end }} | ||
end | ||
{{- end }} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- define "linux_packages" }} | ||
{{- range $element := .LinuxPackages }} | ||
{{- if eq $element.Arch "amd64" }} | ||
if Hardware::CPU.intel? | ||
{{- end }} | ||
{{- if eq $element.Arch "arm" }} | ||
if Hardware::CPU.arm? && !Hardware::CPU.is_64_bit? | ||
{{- end }} | ||
{{- if eq $element.Arch "arm64" }} | ||
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? | ||
{{- end }} | ||
url "{{ $element.DownloadURL }}" | ||
{{- if .DownloadStrategy }}, using: {{ .DownloadStrategy }}{{- end }} | ||
sha256 "{{ $element.SHA256 }}" | ||
|
||
def install | ||
{{- range $index, $element := .Install }} | ||
{{ . -}} | ||
{{- end }} | ||
end | ||
end | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.