1
1
mirror of https://github.com/goreleaser/nfpm synced 2024-11-18 19:04:07 +01:00

fix: mips softfloat/hardfloat handling

This commit is contained in:
Carlos Alexandro Becker 2023-05-24 02:34:03 +00:00
parent a8c16744a1
commit 9524bb8a26
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 28 additions and 14 deletions

@ -51,13 +51,6 @@ func ensureValidArch(info *nfpm.Info) *nfpm.Info {
info.Arch = info.Deb.Arch
} else if arch, ok := archToDebian[info.Arch]; ok {
info.Arch = arch
} else {
for k, v := range archToDebian {
if strings.HasPrefix(info.Arch, k) {
info.Arch = v
break
}
}
}
return info

@ -479,6 +479,12 @@ func WithDefaults(info *Info) *Info {
if info.Arch == "" {
info.Arch = "amd64"
}
if strings.HasPrefix(info.Arch, "mips") {
info.Arch = strings.NewReplacer(
"softfloat", "",
"hardfloat", "",
).Replace(info.Arch)
}
if info.Version == "" {
info.Version = "v0.0.0-rc0"
}

@ -119,6 +119,28 @@ func TestDefaults(t *testing.T) {
},
}, *got)
})
t.Run("mips softfloat", func(t *testing.T) {
makeinfo := func() nfpm.Info {
return nfpm.Info{
Platform: "linux",
Arch: "mips64softfloat",
}
}
info := makeinfo()
nfpm.WithDefaults(&info)
require.Equal(t, "mips64", info.Arch)
})
t.Run("mips softfloat", func(t *testing.T) {
makeinfo := func() nfpm.Info {
return nfpm.Info{
Platform: "linux",
Arch: "mips64hardfloat",
}
}
info := makeinfo()
nfpm.WithDefaults(&info)
require.Equal(t, "mips64", info.Arch)
})
}
func TestPrepareForPackager(t *testing.T) {

@ -75,13 +75,6 @@ func ensureValidArch(info *nfpm.Info) *nfpm.Info {
info.Arch = info.RPM.Arch
} else if arch, ok := archToRPM[info.Arch]; ok {
info.Arch = arch
} else {
for k, v := range archToRPM {
if strings.HasPrefix(info.Arch, k) {
info.Arch = v
break
}
}
}
return info