Skip to content

Commit

Permalink
fix: mips softfloat/hardfloat handling
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed May 24, 2023
1 parent a8c1674 commit 9524bb8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
7 changes: 0 additions & 7 deletions deb/deb.go
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions nfpm.go
Expand Up @@ -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"
}
Expand Down
22 changes: 22 additions & 0 deletions nfpm_test.go
Expand Up @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions rpm/rpm.go
Expand Up @@ -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
Expand Down

0 comments on commit 9524bb8

Please sign in to comment.