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

Merge pull request #346 from goreleaser/arm-deb

fixed arm .deb
This commit is contained in:
Carlos Alexandro Becker 2017-08-27 13:29:52 -03:00 committed by GitHub
commit e62756a5ae
4 changed files with 45 additions and 23 deletions

19
internal/linux/arch.go Normal file
View File

@ -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
}

View File

@ -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))
})
}
}

View File

@ -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

View File

@ -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.