mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-05 13:15:26 +02:00
fix: improve linux.Arch
should affect snapcraft and nfpm
This commit is contained in:
parent
486d5303fd
commit
3395bf1719
@ -4,22 +4,19 @@ package linux
|
||||
import "strings"
|
||||
|
||||
// Arch converts a goarch to a linux-compatible arch
|
||||
//
|
||||
// list of all linux arches: `go tool dist list | grep linux`
|
||||
func Arch(key string) string {
|
||||
switch {
|
||||
case strings.Contains(key, "amd64"):
|
||||
return "amd64"
|
||||
case strings.Contains(key, "386"):
|
||||
var arch = strings.TrimPrefix(key, "linux")
|
||||
switch arch {
|
||||
case "386":
|
||||
return "i386"
|
||||
case strings.Contains(key, "arm64"):
|
||||
return "arm64"
|
||||
case strings.Contains(key, "arm6"):
|
||||
case "amd64":
|
||||
return "amd64"
|
||||
case "arm6": // GOARCH + GOARM
|
||||
return "armel"
|
||||
case strings.Contains(key, "arm7"):
|
||||
case "arm7": // GOARCH + GOARM
|
||||
return "armhf"
|
||||
case strings.Contains(key, "ppc64le"):
|
||||
return "ppc64le"
|
||||
case strings.Contains(key, "ppc64"):
|
||||
return "ppc64"
|
||||
}
|
||||
return key
|
||||
return arch
|
||||
}
|
||||
|
@ -9,12 +9,12 @@ import (
|
||||
|
||||
func TestArch(t *testing.T) {
|
||||
for from, to := range map[string]string{
|
||||
"amd64": "amd64",
|
||||
"386": "i386",
|
||||
"arm64": "arm64",
|
||||
"arm6": "armel",
|
||||
"arm7": "armhf",
|
||||
"what": "what",
|
||||
"linuxamd64": "amd64",
|
||||
"linux386": "i386",
|
||||
"linuxarm64": "arm64",
|
||||
"linuxarm6": "armel",
|
||||
"linuxarm7": "armhf",
|
||||
"linuxwhat": "what",
|
||||
} {
|
||||
t.Run(fmt.Sprintf("%s to %s", from, to), func(t *testing.T) {
|
||||
assert.Equal(t, to, Arch(from))
|
||||
|
Loading…
x
Reference in New Issue
Block a user