Repository: goreleaser/nfpm
Pull request #58 (2019-06-24 15:55:29)

Added Packager and Epoch tags
See #57 

codecov-io: # [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/58?src=pr&el=h1) Report
> Merging [#58](https://codecov.io/gh/goreleaser/nfpm/pull/58?src=pr&el=desc) into [master](https://codecov.io/gh/goreleaser/nfpm/commit/8fedf987c4eed529bc8a216ca2a0193e4da480c0?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/nfpm/pull/58/graphs/tree.svg?width=650&token=9QKGIxn7wg&height=150&src=pr)](https://codecov.io/gh/goreleaser/nfpm/pull/58?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master      #58   +/-   ##
=======================================
  Coverage   71.39%   71.39%           
=======================================
  Files           5        5           
  Lines         493      493           
=======================================
  Hits          352      352           
  Misses         87       87           
  Partials       54       54
```


| [Impacted Files](https://codecov.io/gh/goreleaser/nfpm/pull/58?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [nfpm.go](https://codecov.io/gh/goreleaser/nfpm/pull/58/diff?src=pr&el=tree#diff-bmZwbS5nbw==) | `89.65% <ø> (ø)` | :arrow_up: |
| [deb/deb.go](https://codecov.io/gh/goreleaser/nfpm/pull/58/diff?src=pr&el=tree#diff-ZGViL2RlYi5nbw==) | `72.72% <ø> (ø)` | :arrow_up: |
| [rpm/rpm.go](https://codecov.io/gh/goreleaser/nfpm/pull/58/diff?src=pr&el=tree#diff-cnBtL3JwbS5nbw==) | `72.61% <ø> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/58?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/58?src=pr&el=footer). Last update [8fedf98...402d907](https://codecov.io/gh/goreleaser/nfpm/pull/58?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

AdrianWennberg: Thanks for the heads up! I'm new to the template system, and I see where I went wrong now. It's tested and fixed now!
caarlos0: awesome, thanks!

Patch:
diff --git a/deb/deb.go b/deb/deb.go
index f9ffbf3..ff067e3 100644
--- a/deb/deb.go
+++ b/deb/deb.go
@@ -334,7 +334,11 @@ func conffiles(info nfpm.Info) []byte {
 const controlTemplate = `
 {{- /* Mandatory fields */ -}}
 Package: {{.Info.Name}}
+{{- if .Info.Epoch}}
+Version: {{ .Info.Epoch }}:{{.Info.Version}}
+{{- else }}
 Version: {{.Info.Version}}
+{{- end }}
 Section: {{.Info.Section}}
 Priority: {{.Info.Priority}}
 Architecture: {{.Info.Arch}}
@@ -345,7 +349,7 @@ Maintainer: {{.Info.Maintainer}}
 {{- if .Info.Vendor}}
 Vendor: {{.Info.Vendor}}
 {{- end }}
-Installed-Size: {{.InstalledSize}}
+Installed-Size: {{.InstalledSize}}	
 {{- with .Info.Replaces}}
 Replaces: {{join .}}
 {{- end }}
diff --git a/nfpm.go b/nfpm.go
index fb81b21..156f0b5 100644
--- a/nfpm.go
+++ b/nfpm.go
@@ -106,6 +106,7 @@ type Info struct {
 	Name         string `yaml:"name,omitempty"`
 	Arch         string `yaml:"arch,omitempty"`
 	Platform     string `yaml:"platform,omitempty"`
+	Epoch        string `yaml:"epoch,omitempty"`
 	Version      string `yaml:"version,omitempty"`
 	Section      string `yaml:"section,omitempty"`
 	Priority     string `yaml:"priority,omitempty"`
diff --git a/rpm/rpm.go b/rpm/rpm.go
index 08d5353..7331782 100644
--- a/rpm/rpm.go
+++ b/rpm/rpm.go
@@ -314,6 +314,9 @@ const specTemplate = `
 
 Name: {{ .Info.Name }}
 Summary: {{ first_line .Info.Description }}
+{{- with .Info.Epoch}}
+Epoch: {{ . }}
+{{- end }}
 Version: {{ .Info.Version }}
 Release: 1
 {{- with .Info.License }}
@@ -324,6 +327,9 @@ SOURCE0 : %{name}-%{version}.tar.gz
 {{- with .Info.Homepage }}
 URL: {{ . }}
 {{- end }}
+{{- with .Info.Maintainer}}
+Packager: {{ . }}
+{{- end }}
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 {{ range $index, $element := .Info.Replaces }}


Test patch:
diff --git a/deb/deb_test.go b/deb/deb_test.go
index 33fa024..49ac53d 100644
--- a/deb/deb_test.go
+++ b/deb/deb_test.go
@@ -253,3 +253,25 @@ func TestMinimalFields(t *testing.T) {
 	assert.NoError(t, err)
 	assert.Equal(t, string(bts), w.String())
 }
+
+func TestDebEpoch(t *testing.T) {
+	var w bytes.Buffer
+	assert.NoError(t, writeControl(&w, controlData{
+		Info: nfpm.WithDefaults(nfpm.Info{
+			Name:        "withepoch",
+			Arch:        "arm64",
+			Description: "Has an epoch added to it's version",
+			Priority:    "extra",
+			Epoch:       "2",
+			Version:     "1.0.0",
+			Section:     "default",
+		}),
+	}))
+	var golden = "testdata/withepoch.golden"
+	if *update {
+		require.NoError(t, ioutil.WriteFile(golden, w.Bytes(), 0655))
+	}
+	bts, err := ioutil.ReadFile(golden) //nolint:gosec
+	assert.NoError(t, err)
+	assert.Equal(t, string(bts), w.String())
+}
diff --git a/deb/testdata/withepoch.golden b/deb/testdata/withepoch.golden
new file mode 100644
index 0000000..15612a7
--- /dev/null
+++ b/deb/testdata/withepoch.golden
@@ -0,0 +1,7 @@
+Package: withepoch
+Version: 2:1.0.0
+Section: default
+Priority: extra
+Architecture: arm64
+Installed-Size: 0
+Description: Has an epoch added to it's version
diff --git a/rpm/testdata/spec_4.12.x.golden b/rpm/testdata/spec_4.12.x.golden
index c32bd11..57ec967 100644
--- a/rpm/testdata/spec_4.12.x.golden
+++ b/rpm/testdata/spec_4.12.x.golden
@@ -13,6 +13,7 @@ License: MIT
 Group: Development/Tools
 SOURCE0 : %{name}-%{version}.tar.gz
 URL: http://carlosbecker.com
+Packager: Carlos A Becker <pkg@carlosbecker.com>
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 
diff --git a/rpm/testdata/spec_4.13.x.golden b/rpm/testdata/spec_4.13.x.golden
index 0a78508..4c110a1 100644
--- a/rpm/testdata/spec_4.13.x.golden
+++ b/rpm/testdata/spec_4.13.x.golden
@@ -13,6 +13,7 @@ License: MIT
 Group: Development/Tools
 SOURCE0 : %{name}-%{version}.tar.gz
 URL: http://carlosbecker.com
+Packager: Carlos A Becker <pkg@carlosbecker.com>
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
 
 
diff --git a/rpm/testdata/spec_4.14.x.golden b/rpm/testdata/spec_4.14.x.golden
index 0a78508..4c110a1 100644
--- a/rpm/testdata/spec_4.14.x.golden
+++ b/rpm/testdata/spec_4.14.x.golden
@@ -13,6 +13,7 @@ License: MIT
 Group: Development/Tools
 SOURCE0 : %{name}-%{version}.tar.gz
 URL: http://carlosbecker.com
+Packager: Carlos A Becker <pkg@carlosbecker.com>
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root