From ec391a4a791d8a30d40225bc8a35b36f266ad588 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 1 Feb 2017 15:40:27 -0200 Subject: [PATCH] adds conflicts_with for fpm and brew --- config/config.go | 2 ++ pipeline/brew/brew.go | 8 ++++++++ pipeline/brew/brew_test.go | 4 +++- pipeline/fpm/fpm.go | 23 +++++++++++++---------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index 43563482a..2ecfbad75 100644 --- a/config/config.go +++ b/config/config.go @@ -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 diff --git a/pipeline/brew/brew.go b/pipeline/brew/brew.go index 2236fe256..069d84fd2 100644 --- a/pipeline/brew/brew.go +++ b/pipeline/brew/brew.go @@ -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 } diff --git a/pipeline/brew/brew_test.go b/pipeline/brew/brew_test.go index e9ada50af..628b760ca 100644 --- a/pipeline/brew/brew_test.go +++ b/pipeline/brew/brew_test.go @@ -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) diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 7e2681a65..3ea768c50 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -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