mirror of
https://github.com/goreleaser/nfpm
synced 2024-09-29 21:11:15 +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:
parent
8fedf987c4
commit
75cf0f6b4e
@ -334,7 +334,11 @@ func conffiles(info nfpm.Info) []byte {
|
|||||||
const controlTemplate = `
|
const controlTemplate = `
|
||||||
{{- /* Mandatory fields */ -}}
|
{{- /* Mandatory fields */ -}}
|
||||||
Package: {{.Info.Name}}
|
Package: {{.Info.Name}}
|
||||||
|
{{- if .Info.Epoch}}
|
||||||
|
Version: {{ .Info.Epoch }}:{{.Info.Version}}
|
||||||
|
{{- else }}
|
||||||
Version: {{.Info.Version}}
|
Version: {{.Info.Version}}
|
||||||
|
{{- end }}
|
||||||
Section: {{.Info.Section}}
|
Section: {{.Info.Section}}
|
||||||
Priority: {{.Info.Priority}}
|
Priority: {{.Info.Priority}}
|
||||||
Architecture: {{.Info.Arch}}
|
Architecture: {{.Info.Arch}}
|
||||||
@ -345,7 +349,7 @@ Maintainer: {{.Info.Maintainer}}
|
|||||||
{{- if .Info.Vendor}}
|
{{- if .Info.Vendor}}
|
||||||
Vendor: {{.Info.Vendor}}
|
Vendor: {{.Info.Vendor}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
Installed-Size: {{.InstalledSize}}
|
Installed-Size: {{.InstalledSize}}
|
||||||
{{- with .Info.Replaces}}
|
{{- with .Info.Replaces}}
|
||||||
Replaces: {{join .}}
|
Replaces: {{join .}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -253,3 +253,25 @@ func TestMinimalFields(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, string(bts), w.String())
|
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
7
deb/testdata/withepoch.golden
vendored
Normal 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
|
1
nfpm.go
1
nfpm.go
@ -106,6 +106,7 @@ type Info struct {
|
|||||||
Name string `yaml:"name,omitempty"`
|
Name string `yaml:"name,omitempty"`
|
||||||
Arch string `yaml:"arch,omitempty"`
|
Arch string `yaml:"arch,omitempty"`
|
||||||
Platform string `yaml:"platform,omitempty"`
|
Platform string `yaml:"platform,omitempty"`
|
||||||
|
Epoch string `yaml:"epoch,omitempty"`
|
||||||
Version string `yaml:"version,omitempty"`
|
Version string `yaml:"version,omitempty"`
|
||||||
Section string `yaml:"section,omitempty"`
|
Section string `yaml:"section,omitempty"`
|
||||||
Priority string `yaml:"priority,omitempty"`
|
Priority string `yaml:"priority,omitempty"`
|
||||||
|
@ -314,6 +314,9 @@ const specTemplate = `
|
|||||||
|
|
||||||
Name: {{ .Info.Name }}
|
Name: {{ .Info.Name }}
|
||||||
Summary: {{ first_line .Info.Description }}
|
Summary: {{ first_line .Info.Description }}
|
||||||
|
{{- with .Info.Epoch}}
|
||||||
|
Epoch: {{ . }}
|
||||||
|
{{- end }}
|
||||||
Version: {{ .Info.Version }}
|
Version: {{ .Info.Version }}
|
||||||
Release: 1
|
Release: 1
|
||||||
{{- with .Info.License }}
|
{{- with .Info.License }}
|
||||||
@ -324,6 +327,9 @@ SOURCE0 : %{name}-%{version}.tar.gz
|
|||||||
{{- with .Info.Homepage }}
|
{{- with .Info.Homepage }}
|
||||||
URL: {{ . }}
|
URL: {{ . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- with .Info.Maintainer}}
|
||||||
|
Packager: {{ . }}
|
||||||
|
{{- end }}
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
{{ range $index, $element := .Info.Replaces }}
|
{{ range $index, $element := .Info.Replaces }}
|
||||||
|
1
rpm/testdata/spec_4.12.x.golden
vendored
1
rpm/testdata/spec_4.12.x.golden
vendored
@ -13,6 +13,7 @@ License: MIT
|
|||||||
Group: Development/Tools
|
Group: Development/Tools
|
||||||
SOURCE0 : %{name}-%{version}.tar.gz
|
SOURCE0 : %{name}-%{version}.tar.gz
|
||||||
URL: http://carlosbecker.com
|
URL: http://carlosbecker.com
|
||||||
|
Packager: Carlos A Becker <pkg@carlosbecker.com>
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
|
|
||||||
|
1
rpm/testdata/spec_4.13.x.golden
vendored
1
rpm/testdata/spec_4.13.x.golden
vendored
@ -13,6 +13,7 @@ License: MIT
|
|||||||
Group: Development/Tools
|
Group: Development/Tools
|
||||||
SOURCE0 : %{name}-%{version}.tar.gz
|
SOURCE0 : %{name}-%{version}.tar.gz
|
||||||
URL: http://carlosbecker.com
|
URL: http://carlosbecker.com
|
||||||
|
Packager: Carlos A Becker <pkg@carlosbecker.com>
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
|
|
||||||
|
1
rpm/testdata/spec_4.14.x.golden
vendored
1
rpm/testdata/spec_4.14.x.golden
vendored
@ -13,6 +13,7 @@ License: MIT
|
|||||||
Group: Development/Tools
|
Group: Development/Tools
|
||||||
SOURCE0 : %{name}-%{version}.tar.gz
|
SOURCE0 : %{name}-%{version}.tar.gz
|
||||||
URL: http://carlosbecker.com
|
URL: http://carlosbecker.com
|
||||||
|
Packager: Carlos A Becker <pkg@carlosbecker.com>
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user