feat: RiscV64 support (#1091)

* RiscV64 support

* Chore Cleanup RV64gc

* FIx a minor typo
This commit is contained in:
Akshanabha Chakraborty
2026-06-06 18:33:21 +05:30
committed by GitHub
parent d16d75f943
commit 5c2f7caebf
12 changed files with 147 additions and 91 deletions
+14 -13
View File
@@ -61,19 +61,20 @@ func init() {
// https://github.com/golang/go/blob/master/src/internal/syslist/syslist.go
// nolint: gochecknoglobals
var archToAlpine = map[string]string{
"all": "noarch",
"386": "x86",
"amd64": "x86_64",
"arm64": "aarch64",
"arm6": "armhf",
"arm7": "armv7",
"ppc64le": "ppc64le",
"s390": "s390x",
"loong64": "loongarch64",
"aarch64": "aarch64",
"x86_64": "x86_64",
"i386": "x86",
"i686": "x86",
"all": "noarch",
"386": "x86",
"amd64": "x86_64",
"arm64": "aarch64",
"arm6": "armhf",
"arm7": "armv7",
"ppc64le": "ppc64le",
"s390": "s390x",
"loong64": "loongarch64",
"aarch64": "aarch64",
"x86_64": "x86_64",
"i386": "x86",
"i686": "x86",
"riscv64": "riscv64",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
+1 -1
View File
@@ -138,7 +138,7 @@ func TestDefaultWithArch(t *testing.T) {
"etc/fake/fake2.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
"etc/fake/fake3.conf": "96c335dc28122b5f09a4cef74b156cd24c23784c",
}
for _, arch := range []string{"386", "amd64"} {
for _, arch := range []string{"386", "amd64", "riscv64"} {
t.Run(arch, func(t *testing.T) {
info := exampleInfo()
info.Arch = arch
+11 -10
View File
@@ -42,16 +42,17 @@ type ArchLinux struct{}
// nolint: gochecknoglobals
var archToArchLinux = map[string]string{
"all": "any",
"amd64": "x86_64",
"386": "i686",
"arm64": "aarch64",
"arm7": "armv7h",
"arm6": "armv6h",
"arm5": "arm",
"x86_64": "x86_64",
"aarch64": "aarch64",
"i386": "i686",
"all": "any",
"amd64": "x86_64",
"386": "i686",
"arm64": "aarch64",
"arm7": "armv7h",
"arm6": "armv6h",
"arm5": "arm",
"x86_64": "x86_64",
"aarch64": "aarch64",
"i386": "i686",
"riscv64": "riscv64",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
+2 -2
View File
@@ -94,7 +94,7 @@ func TestConventionalExtension(t *testing.T) {
}
func TestArch(t *testing.T) {
for _, arch := range []string{"386", "amd64", "arm64"} {
for _, arch := range []string{"386", "amd64", "arm64", "riscv64"} {
t.Run(arch, func(t *testing.T) {
info := exampleInfo()
info.Arch = arch
@@ -129,7 +129,7 @@ func TestArchNoInfo(t *testing.T) {
}
func TestArchConventionalFileName(t *testing.T) {
for _, arch := range []string{"386", "amd64", "arm64"} {
for _, arch := range []string{"386", "amd64", "arm64", "riscv64"} {
t.Run(arch, func(t *testing.T) {
info := exampleInfo()
info.Arch = arch
+12 -11
View File
@@ -43,17 +43,18 @@ func init() {
// https://wiki.debian.org/ArchitectureSpecificsMemo
// nolint: gochecknoglobals
var archToDebian = map[string]string{
"386": "i386",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "amd64",
"aarch64": "arm64",
"386": "i386",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "amd64",
"aarch64": "arm64",
"riscv64": "riscv64",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
+1 -1
View File
@@ -111,7 +111,7 @@ func TestConventionalExtension(t *testing.T) {
}
func TestDeb(t *testing.T) {
for _, arch := range []string{"386", "amd64"} {
for _, arch := range []string{"386", "amd64", "riscv64"} {
t.Run(arch, func(t *testing.T) {
info := exampleInfo()
info.Arch = arch
+14 -13
View File
@@ -32,19 +32,20 @@ func init() {
// nolint: gochecknoglobals
var archToIPK = map[string]string{
// all --> all
"386": "i386",
"amd64": "x86_64",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "x86_64",
"aarch64": "arm64",
"i386": "i386",
"386": "i386",
"amd64": "x86_64",
"arm64": "arm64",
"arm5": "armel",
"arm6": "armhf",
"arm7": "armhf",
"mips64le": "mips64el",
"mipsle": "mipsel",
"ppc64le": "ppc64el",
"s390": "s390x",
"x86_64": "x86_64",
"aarch64": "arm64",
"i386": "i386",
"riscv64": "riscv64_generic",
}
func ensureValidArch(info *nfpm.Info) *nfpm.Info {
+1 -1
View File
@@ -97,7 +97,7 @@ func TestConventionalExtension(t *testing.T) {
}
func TestIPK(t *testing.T) {
for _, arch := range []string{"386", "amd64"} {
for _, arch := range []string{"386", "amd64", "riscv64"} {
t.Run(arch, func(t *testing.T) {
info := exampleInfo()
info.Arch = arch
+12 -11
View File
@@ -77,17 +77,18 @@ type RPM struct {
// https://github.com/rpm-software-management/rpm/blob/4a9b7b5908d8b463a836b51322242677677bd8b7/lib/rpmrc.cc#L1167
// nolint: gochecknoglobals
var archToRPM = map[string]string{
"all": "noarch",
"amd64": "x86_64",
"386": "i386",
"arm64": "aarch64",
"arm5": "armv5tel",
"arm6": "armv6hl",
"arm7": "armv7hl",
"mips64le": "mips64el",
"mipsle": "mipsel",
"mips": "mips",
"loong64": "loongarch64",
"all": "noarch",
"amd64": "x86_64",
"386": "i386",
"arm64": "aarch64",
"arm5": "armv5tel",
"arm6": "armv6hl",
"arm7": "armv7hl",
"mips64le": "mips64el",
"mipsle": "mipsel",
"mips": "mips",
"loong64": "loongarch64",
"riscv64": "riscv64",
}
func setDefaults(info *nfpm.Info) *nfpm.Info {
+46
View File
@@ -154,6 +154,52 @@ func TestRPM(t *testing.T) {
require.Equal(t, "Foo does things", description)
}
func TestRPMRiscv64(t *testing.T) {
f, err := os.CreateTemp(t.TempDir(), "test-riscv.rpm")
require.NoError(t, err)
info := exampleInfo()
info.Arch = "riscv64"
require.NoError(t, DefaultRPM.Package(info, f))
file, err := os.OpenFile(f.Name(), os.O_RDONLY, 0o600) //nolint:gosec
require.NoError(t, err)
defer func() {
f.Close()
file.Close()
err = os.Remove(file.Name())
require.NoError(t, err)
}()
rpm, err := rpmutils.ReadRpm(file)
require.NoError(t, err)
arch, err := rpm.Header.GetString(rpmutils.ARCH)
require.NoError(t, err)
require.Equal(t, archToRPM["riscv64"], arch)
}
func TestSRPMRiscv64(t *testing.T) {
f, err := os.CreateTemp(t.TempDir(), "test-riscv.src.rpm")
require.NoError(t, err)
info := exampleInfo()
info.Arch = "riscv64"
require.NoError(t, DefaultSRPM.Package(info, f))
file, err := os.OpenFile(f.Name(), os.O_RDONLY, 0o600) //nolint:gosec
require.NoError(t, err)
defer func() {
f.Close()
file.Close()
err = os.Remove(file.Name())
require.NoError(t, err)
}()
rpm, err := rpmutils.ReadRpm(file)
require.NoError(t, err)
arch, err := rpm.Header.GetString(rpmutils.ARCH)
require.NoError(t, err)
require.Equal(t, archToRPM["riscv64"], arch)
}
func TestIssue952(t *testing.T) {
info := exampleInfo()
info.MTime = time.Time{}
+32 -27
View File
@@ -39,6 +39,7 @@ Thank you!
| `mips64le` | `mips64el` |
| `ppc64le` | `ppc64el` |
| `s390` | `s390x` |
| `riscv64` | `riscv64` |
{{< /tab >}}
@@ -56,6 +57,7 @@ Thank you!
| `mipsle` | `mipsel` |
| `mips64le` | `mips64el` |
| `loong64` | `loongarch64` |
| `riscv64` | `riscv64` |
{{< /tab >}}
@@ -75,6 +77,7 @@ Thank you!
| `ppc64le` | `ppc64le` |
| `s390` | `s390x` |
| `loong64` | `loongarch64` |
| `riscv64` | `riscv64` |
{{< /tab >}}
@@ -91,43 +94,45 @@ Thank you!
| `arm5` | `arm` |
| `arm6` | `armv6h` |
| `arm7` | `armv7h` |
| `riscv64` | `riscv64` |
{{< /tab >}}
{{< tab >}}
| Input | Value |
| :--------: | :--------: |
| `amd64` | `x86_64` |
| `x86_64` | `x86_64` |
| `386` | `i386` |
| `i386` | `i386` |
| `arm64` | `arm64` |
| `aarch64` | `arm64` |
| `arm5` | `armel` |
| `arm6` | `armhf` |
| `arm7` | `armhf` |
| `mipsle` | `mipsel` |
| `mips64le` | `mips64el` |
| `ppc64le` | `ppc64el` |
| `s390` | `s390x` |
| Input | Value |
| :--------: | :---------------: |
| `amd64` | `x86_64` |
| `x86_64` | `x86_64` |
| `386` | `i386` |
| `i386` | `i386` |
| `arm64` | `arm64` |
| `aarch64` | `arm64` |
| `arm5` | `armel` |
| `arm6` | `armhf` |
| `arm7` | `armhf` |
| `mipsle` | `mipsel` |
| `mips64le` | `mips64el` |
| `ppc64le` | `ppc64el` |
| `s390` | `s390x` |
| `riscv64` | `riscv64_generic` |
{{< /tab >}}
{{< tab >}}
| Input | Value |
| :--------: | :-------: |
| `amd64` | `x64` |
| `x86_64` | `x64` |
| `386` | `x86` |
| `i386` | `x86` |
| `i686` | `x86` |
| `arm64` | `arm64` |
| `aarch64` | `arm64` |
| `arm` | `arm` |
| `arm7` | `arm` |
| `all` | `neutral` |
| Input | Value |
| :-------: | :-------: |
| `amd64` | `x64` |
| `x86_64` | `x64` |
| `386` | `x86` |
| `i386` | `x86` |
| `i686` | `x86` |
| `arm64` | `arm64` |
| `aarch64` | `arm64` |
| `arm` | `arm` |
| `arm7` | `arm` |
| `all` | `neutral` |
{{< /tab >}}
+1 -1
View File
@@ -17,7 +17,7 @@ name: foo
# to the platform specific equivalent. In order to manually set the architecture
# to a platform specific value, set `{format}.arch`.
# Examples: `all`, `amd64`, `386`, `arm5`, `arm6`, `arm7`, `arm64`, `mips`,
# `mipsle`, `mips64le`, `ppc64le`, `s390`
# `mipsle`, `mips64le`, `ppc64le`, `s390`, `riscv64`
arch: amd64
# Platform.