1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-09 13:36:56 +02:00

fix: use gnu-tar on macOS

closes #409
This commit is contained in:
Carlos Alexandro Becker 2017-12-26 22:13:58 -02:00
parent cd03056dca
commit a7a290fb63
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 17 additions and 2 deletions

View File

@ -4,6 +4,7 @@ package fpm
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@ -21,6 +22,9 @@ import (
// ErrNoFPM is shown when fpm cannot be found in $PATH
var ErrNoFPM = errors.New("fpm not present in $PATH")
// path to gnu-tar on macOS when installed with homebrew
const gnuTarPath = "/usr/local/opt/gnu-tar/libexec/gnubin"
// Pipe for fpm packaging
type Pipe struct{}
@ -114,8 +118,7 @@ func create(ctx *context.Context, format, arch string, binaries []artifact.Artif
}
log.WithField("args", options).Debug("creating fpm package")
/* #nosec */
if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
if out, err := cmd(options).CombinedOutput(); err != nil {
return errors.Wrap(err, string(out))
}
ctx.Artifacts.Add(artifact.Artifact{
@ -129,6 +132,13 @@ func create(ctx *context.Context, format, arch string, binaries []artifact.Artif
return nil
}
func cmd(options []string) *exec.Cmd {
/* #nosec */
var cmd = exec.Command("fpm", options...)
cmd.Env = []string{fmt.Sprintf("PATH=%s:%s", gnuTarPath, os.Getenv("PATH"))}
return cmd
}
func basicOptions(ctx *context.Context, workdir, format, arch, file string) []string {
var options = []string{
"--input-type", "dir",

View File

@ -122,6 +122,11 @@ func TestCreateFileDoesntExist(t *testing.T) {
assert.Error(t, Pipe{}.Run(ctx))
}
func TestCmd(t *testing.T) {
cmd := cmd([]string{"--help"})
assert.NotEmpty(t, cmd.Env)
}
func TestDefault(t *testing.T) {
var ctx = &context.Context{
Config: config.Project{