From 71eab55b4208293970175d16c64828e62bf6e6e2 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sun, 27 Aug 2017 13:18:23 -0300 Subject: [PATCH] fixed arm .deb --- internal/linux/arch.go | 19 +++++++++++++++++++ internal/linux/arch_test.go | 22 ++++++++++++++++++++++ pipeline/fpm/fpm.go | 10 ++-------- pipeline/snapcraft/snapcraft.go | 17 ++--------------- 4 files changed, 45 insertions(+), 23 deletions(-) create mode 100644 internal/linux/arch.go create mode 100644 internal/linux/arch_test.go diff --git a/internal/linux/arch.go b/internal/linux/arch.go new file mode 100644 index 000000000..04f7abf0b --- /dev/null +++ b/internal/linux/arch.go @@ -0,0 +1,19 @@ +// Package linux contains functions that are useful to generate linux packages. +package linux + +import "strings" + +// Arch converts a goarch to a linux-compatible arch +func Arch(key string) string { + switch { + case strings.Contains(key, "amd64"): + return "amd64" + case strings.Contains(key, "386"): + return "i386" + case strings.Contains(key, "arm64"): + return "arm64" + case strings.Contains(key, "arm6"): + return "armhf" + } + return key +} diff --git a/internal/linux/arch_test.go b/internal/linux/arch_test.go new file mode 100644 index 000000000..6193f9390 --- /dev/null +++ b/internal/linux/arch_test.go @@ -0,0 +1,22 @@ +package linux + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestArch(t *testing.T) { + for from, to := range map[string]string{ + "amd64": "amd64", + "386": "i386", + "arm64": "arm64", + "arm6": "armhf", + "what": "what", + } { + t.Run(fmt.Sprintf("%s to %s", from, to), func(t *testing.T) { + assert.Equal(t, to, Arch(from)) + }) + } +} diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index c1bcd7ce1..4618a4aec 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -10,6 +10,7 @@ import ( "github.com/apex/log" "github.com/goreleaser/goreleaser/context" + "github.com/goreleaser/goreleaser/internal/linux" "github.com/goreleaser/goreleaser/pipeline" "golang.org/x/sync/errgroup" ) @@ -43,7 +44,7 @@ func (Pipe) Run(ctx *context.Context) error { continue } format := format - arch := archFor(platform) + arch := linux.Arch(platform) for folder, binaries := range groups { g.Go(func() error { return create(ctx, format, folder, arch, binaries) @@ -54,13 +55,6 @@ func (Pipe) Run(ctx *context.Context) error { return g.Wait() } -func archFor(key string) string { - if strings.Contains(key, "386") { - return "i386" - } - return "x86_64" -} - func create(ctx *context.Context, format, folder, arch string, binaries []context.Binary) error { var path = filepath.Join(ctx.Config.Dist, folder) var file = path + "." + format diff --git a/pipeline/snapcraft/snapcraft.go b/pipeline/snapcraft/snapcraft.go index f5cd8a227..60ad0dc61 100644 --- a/pipeline/snapcraft/snapcraft.go +++ b/pipeline/snapcraft/snapcraft.go @@ -12,6 +12,7 @@ import ( "github.com/apex/log" "github.com/goreleaser/goreleaser/context" + "github.com/goreleaser/goreleaser/internal/linux" "github.com/goreleaser/goreleaser/pipeline" "golang.org/x/sync/errgroup" yaml "gopkg.in/yaml.v2" @@ -75,7 +76,7 @@ func (Pipe) Run(ctx *context.Context) error { log.WithField("platform", platform).Debug("skipped non-linux builds for snapcraft") continue } - arch := archFor(platform) + arch := linux.Arch(platform) for folder, binaries := range groups { g.Go(func() error { return create(ctx, folder, arch, binaries) @@ -85,20 +86,6 @@ func (Pipe) Run(ctx *context.Context) error { return g.Wait() } -func archFor(key string) string { - switch { - case strings.Contains(key, "amd64"): - return "amd64" - case strings.Contains(key, "386"): - return "i386" - case strings.Contains(key, "arm64"): - return "arm64" - case strings.Contains(key, "arm6"): - return "armhf" - } - return key -} - func create(ctx *context.Context, folder, arch string, binaries []context.Binary) error { var log = log.WithField("arch", arch) // prime is the directory that then will be compressed to make the .snap package.