Repository: goreleaser/nfpm
Pull request #398 (2021-11-07 13:52:22)

fix: added more arches
added more arches, improved test coverage a bit

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/398?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#398](https://codecov.io/gh/goreleaser/nfpm/pull/398?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (4fb789d) into [master](https://codecov.io/gh/goreleaser/nfpm/commit/2e30111d868d2451660e08277cdf03e9dd43edcf?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (2e30111) will **increase** coverage by `0.49%`.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/nfpm/pull/398/graphs/tree.svg?width=650&height=150&src=pr&token=9QKGIxn7wg&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)](https://codecov.io/gh/goreleaser/nfpm/pull/398?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)

```diff
@@            Coverage Diff             @@
##           master     #398      +/-   ##
==========================================
+ Coverage   64.22%   64.71%   +0.49%     
==========================================
  Files          14       14              
  Lines        1828     1828              
==========================================
+ Hits         1174     1183       +9     
+ Misses        512      509       -3     
+ Partials      142      136       -6     
```


| [Impacted Files](https://codecov.io/gh/goreleaser/nfpm/pull/398?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) | Coverage Δ | |
|---|---|---|
| [apk/apk.go](https://codecov.io/gh/goreleaser/nfpm/pull/398/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-YXBrL2Fway5nbw==) | `68.51% <ø> (+0.87%)` | :arrow_up: |
| [rpm/rpm.go](https://codecov.io/gh/goreleaser/nfpm/pull/398/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-cnBtL3JwbS5nbw==) | `70.07% <ø> (+1.09%)` | :arrow_up: |
| [deb/deb.go](https://codecov.io/gh/goreleaser/nfpm/pull/398/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-ZGViL2RlYi5nbw==) | `66.25% <0.00%> (+0.62%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/398?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/398?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Last update [2e30111...4fb789d](https://codecov.io/gh/goreleaser/nfpm/pull/398?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser).


Patch:
diff --git a/apk/apk.go b/apk/apk.go
index 61c6f9c..b466df2 100644
--- a/apk/apk.go
+++ b/apk/apk.go
@@ -58,15 +58,16 @@ func init() {
 	nfpm.RegisterPackager(packagerName, Default)
 }
 
+// https://wiki.alpinelinux.org/wiki/Architecture
 // nolint: gochecknoglobals
 var archToAlpine = map[string]string{
-	"386":   "x86",
-	"amd64": "x86_64",
-	"arm":   "armhf",
-	"arm6":  "armhf",
-	"arm7":  "armhf",
-	"arm64": "aarch64",
-	// TODO: other arches
+	"386":     "x86",
+	"amd64":   "x86_64",
+	"arm":     "armhf",
+	"arm6":    "armhf",
+	"arm7":    "armv7",
+	"arm64":   "aarch64",
+	"ppc64le": "ppc64le",
 }
 
 func ensureValidArch(info *nfpm.Info) *nfpm.Info {
diff --git a/rpm/rpm.go b/rpm/rpm.go
index d6b6015..5c38231 100644
--- a/rpm/rpm.go
+++ b/rpm/rpm.go
@@ -52,12 +52,17 @@ var Default = &RPM{}
 // RPM is a RPM packager implementation.
 type RPM struct{}
 
+// https://docs.fedoraproject.org/ro/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch01s03.html
 // nolint: gochecknoglobals
 var archToRPM = map[string]string{
-	"all":   "noarch",
-	"amd64": "x86_64",
-	"386":   "i386",
-	"arm64": "aarch64",
+	"all":    "noarch",
+	"amd64":  "x86_64",
+	"386":    "i386",
+	"arm64":  "aarch64",
+	"arm6":   "arm6l",
+	"arm7":   "arm7l",
+	"mips":   "mips",
+	"mipsle": "mipsel",
 	// TODO: other arches
 }
 


Test patch:
diff --git a/apk/apk_test.go b/apk/apk_test.go
index 62fea3d..c159973 100644
--- a/apk/apk_test.go
+++ b/apk/apk_test.go
@@ -83,25 +83,6 @@ func exampleInfo() *nfpm.Info {
 	})
 }
 
-func TestArchToAlpine(t *testing.T) {
-	verifyArch(t, "abc", "abc")
-	verifyArch(t, "386", "x86")
-	verifyArch(t, "amd64", "x86_64")
-	verifyArch(t, "arm", "armhf")
-	verifyArch(t, "arm6", "armhf")
-	verifyArch(t, "arm7", "armhf")
-	verifyArch(t, "arm64", "aarch64")
-}
-
-func verifyArch(t *testing.T, nfpmArch, expectedArch string) {
-	t.Helper()
-	info := exampleInfo()
-	info.Arch = nfpmArch
-
-	require.NoError(t, Default.Package(info, ioutil.Discard))
-	require.Equal(t, expectedArch, info.Arch)
-}
-
 func TestCreateBuilderData(t *testing.T) {
 	info := exampleInfo()
 	err := info.Validate()
@@ -480,3 +461,21 @@ func TestPackageSymlinks(t *testing.T) {
 	}
 	require.NoError(t, Default.Package(info, ioutil.Discard))
 }
+
+func TestArches(t *testing.T) {
+	for k := range archToAlpine {
+		t.Run(k, func(t *testing.T) {
+			info := exampleInfo()
+			info.Arch = k
+			info = ensureValidArch(info)
+			require.Equal(t, archToAlpine[k], info.Arch)
+		})
+	}
+
+	t.Run("override", func(t *testing.T) {
+		info := exampleInfo()
+		info.APK.Arch = "foo64"
+		info = ensureValidArch(info)
+		require.Equal(t, "foo64", info.Arch)
+	})
+}
diff --git a/deb/deb_test.go b/deb/deb_test.go
index 0284c0a..6e49902 100644
--- a/deb/deb_test.go
+++ b/deb/deb_test.go
@@ -1084,3 +1084,21 @@ func TestEmptyButRequiredDebFields(t *testing.T) {
 	err := Default.Package(item, &deb)
 	require.NoError(t, err)
 }
+
+func TestArches(t *testing.T) {
+	for k := range archToDebian {
+		t.Run(k, func(t *testing.T) {
+			info := exampleInfo()
+			info.Arch = k
+			info = ensureValidArch(info)
+			require.Equal(t, archToDebian[k], info.Arch)
+		})
+	}
+
+	t.Run("override", func(t *testing.T) {
+		info := exampleInfo()
+		info.Deb.Arch = "foo64"
+		info = ensureValidArch(info)
+		require.Equal(t, "foo64", info.Arch)
+	})
+}
diff --git a/rpm/rpm_test.go b/rpm/rpm_test.go
index d40a095..1bf9f6e 100644
--- a/rpm/rpm_test.go
+++ b/rpm/rpm_test.go
@@ -407,14 +407,22 @@ func TestRPMFileDoesNotExist(t *testing.T) {
 	require.EqualError(t, err, fmt.Sprintf("matching \"%s\": file does not exist", filepath.ToSlash(abs)))
 }
 
-func TestRPMMultiArch(t *testing.T) {
-	info := exampleInfo()
-
+func TestArches(t *testing.T) {
 	for k := range archToRPM {
-		info.Arch = k
-		info = ensureValidArch(info)
-		require.Equal(t, archToRPM[k], info.Arch)
+		t.Run(k, func(t *testing.T) {
+			info := exampleInfo()
+			info.Arch = k
+			info = ensureValidArch(info)
+			require.Equal(t, archToRPM[k], info.Arch)
+		})
 	}
+
+	t.Run("override", func(t *testing.T) {
+		info := exampleInfo()
+		info.RPM.Arch = "foo64"
+		info = ensureValidArch(info)
+		require.Equal(t, "foo64", info.Arch)
+	})
 }
 
 func TestConfigNoReplace(t *testing.T) {