1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-31 01:53:50 +02:00

fix: properly translate mips arch (#2126)

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2021-03-20 15:16:26 -03:00 committed by GitHub
parent 57a69dbe47
commit 12c7d38eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 12 deletions

View File

@ -6,7 +6,10 @@ import "strings"
// Arch converts a goarch to a linux-compatible arch.
func Arch(key string) string {
// XXX: list of all linux arches: `go tool dist list | grep linux`
var arch = strings.TrimPrefix(key, "linux")
arch := strings.TrimPrefix(key, "linux")
for _, suffix := range []string{"hardfloat", "softfloat"} {
arch = strings.TrimSuffix(arch, suffix)
}
switch arch {
case "386":
return "i386"
@ -18,7 +21,10 @@ func Arch(key string) string {
return "armhf"
case "arm7": // GOARCH + GOARM
return "armhf"
default:
return arch
case "mips64le":
return "mips64el"
case "mipsle":
return "mipsel"
}
return arch
}

View File

@ -9,15 +9,19 @@ import (
func TestArch(t *testing.T) {
for from, to := range map[string]string{
"linuxamd64": "amd64",
"linux386": "i386",
"linuxarm64": "arm64",
"linuxarm5": "armel",
"linuxarm6": "armhf",
"linuxarm7": "armhf",
"linuxppc64": "ppc64",
"linuxppc64le": "ppc64le",
"linuxwhat": "what",
"linuxamd64": "amd64",
"linux386": "i386",
"linuxarm64": "arm64",
"linuxarm5": "armel",
"linuxarm6": "armhf",
"linuxarm7": "armhf",
"linuxppc64": "ppc64",
"linuxppc64le": "ppc64le",
"linuxwhat": "what",
"linuxmips64lesoftfloat": "mips64el",
"linuxmipslehardfloat": "mipsel",
"linuxmipssoftfloat": "mips",
"linuxmips64hardfloat": "mips64",
} {
t.Run(fmt.Sprintf("%s to %s", from, to), func(t *testing.T) {
require.Equal(t, to, Arch(from))