1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

adds conflicts_with for fpm and brew

This commit is contained in:
Carlos Alexandro Becker 2017-02-01 15:40:27 -02:00
parent 80b6b141bc
commit ec391a4a79
4 changed files with 26 additions and 11 deletions

View File

@ -12,6 +12,7 @@ type Homebrew struct {
Folder string
Caveats string
Dependencies []string
Conflicts []string
}
// Hooks define actions to run before and/or after something
@ -47,6 +48,7 @@ type Release struct {
type FPM struct {
Formats []string
Dependencies []string
Conflicts []string
}
// Project includes all project configuration

View File

@ -31,6 +31,12 @@ const formula = `class {{ .Name }} < Formula
{{- end }}
{{- end }}
{{- if .Conflicts }}
{{ range $index, $element := .Conflicts }}
conflicts_with "{{ . }}"
{{- end }}
{{- end }}
def install
bin.install "{{ .BinaryName }}"
end
@ -57,6 +63,7 @@ type templateData struct {
Format string
SHA256 string
Dependencies []string
Conflicts []string
}
// Pipe for brew deployment
@ -164,6 +171,7 @@ func dataFor(ctx *context.Context, client *github.Client) (result templateData,
Format: ctx.Config.Archive.Format,
SHA256: sum,
Dependencies: ctx.Config.Brew.Dependencies,
Conflicts: ctx.Config.Brew.Conflicts,
}, err
}

View File

@ -46,6 +46,7 @@ func TestFullFormulae(t *testing.T) {
data := defaultTemplateData
data.Caveats = "Here are some caveats"
data.Dependencies = []string{"gtk", "git"}
data.Conflicts = []string{"conflicting_dep"}
out, err := doBuildFormula(data)
assert.NoError(err)
formulae := out.String()
@ -54,9 +55,10 @@ func TestFullFormulae(t *testing.T) {
assert.Contains(formulae, "Here are some caveats")
assert.Contains(formulae, "depends_on \"gtk\"")
assert.Contains(formulae, "depends_on \"git\"")
assert.Contains(formulae, "conflicts_with \"conflicting_dep\"")
}
func TestFormulaeNoCaveats(t *testing.T) {
func TestFormulaeSimple(t *testing.T) {
assert := assert.New(t)
out, err := doBuildFormula(defaultTemplateData)
assert.NoError(err)

View File

@ -60,24 +60,27 @@ func create(ctx *context.Context, format, archive, arch string) error {
log.Println("Creating", file)
var options = []string{
"-s", "dir",
"-t", format,
"-n", name,
"-v", ctx.Version,
"-a", arch,
"-C", path,
"-p", file,
"--input-type", "dir",
"--output-type", format,
"--name", name,
"--version", ctx.Version,
"--architecture", arch,
"--chdir", path,
"--package", file,
"--force",
}
for _, dep := range ctx.Config.FPM.Dependencies {
options = append(options, "-d", dep)
options = append(options, "--depends", dep)
}
for _, conflict := range ctx.Config.FPM.Conflicts {
options = append(options, "--conflicts", conflict)
}
// This basically tells fpm to put the binary in the /usr/local/bin
// binary=/usr/local/bin/binary
options = append(options, name+"="+filepath.Join("/usr/local/bin", name))
cmd := exec.Command("fpm", options...)
if out, err := cmd.CombinedOutput(); err != nil {
if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
return errors.New(string(out))
}
return nil