mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-10 03:47:03 +02:00
commit
e62756a5ae
19
internal/linux/arch.go
Normal file
19
internal/linux/arch.go
Normal 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
|
||||
}
|
22
internal/linux/arch_test.go
Normal file
22
internal/linux/arch_test.go
Normal 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))
|
||||
})
|
||||
}
|
||||
}
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user