1
1
Fork 0
mirror of https://github.com/goreleaser/nfpm synced 2024-06-28 19:00:47 +02:00

Added Packager and Epoch tags (#58)

* feat: Add optional packager tag to rpm spec

Using the `Maintainer` tag from deb as the `Packager` tag for rpm

See #57

* feat: Optional epoch field added to both rpm and dep packages

See #57

* test: Adding test for deb epoch field

Adding a unit test for the epoch field and fixing the implementation
of version number with epoch for deb packager.

See #57
This commit is contained in:
Adrian Wennberg 2019-06-25 13:56:32 +01:00 committed by Carlos Alexandro Becker
parent 8fedf987c4
commit 75cf0f6b4e
8 changed files with 44 additions and 1 deletions

View File

@ -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 }}

View File

@ -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())
}

7
deb/testdata/withepoch.golden vendored Normal file
View File

@ -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

View File

@ -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"`

View File

@ -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 }}

View File

@ -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

View File

@ -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

View File

@ -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