I'd like to suggest the addition of a 'Release' variable to the Config. The conventions for RHEL, CentOS, and Fedora packages distinguish between Version and Release, so you have rpms such as haproxy17u-1.7.11-2.el7.x86_64.rpm
where the haproxy version is 1.7.11
but the package build is 2
. This is used to distinguish between builds where the source used to build the package hasn't changed but the build procedure has.
diff --git a/nfpm.go b/nfpm.go
index 4dc8015..4ebdc0f 100644
--- a/nfpm.go
+++ b/nfpm.go
@@ -106,6 +106,7 @@ type Info struct {
Arch string `yaml:"arch,omitempty"`
Platform string `yaml:"platform,omitempty"`
Version string `yaml:"version,omitempty"`
+ Release string `yaml:"release,omitempty"`
Section string `yaml:"section,omitempty"`
Priority string `yaml:"priority,omitempty"`
Maintainer string `yaml:"maintainer,omitempty"`
diff --git a/rpm/rpm.go b/rpm/rpm.go
index 675cf6f..18425db 100644
--- a/rpm/rpm.go
+++ b/rpm/rpm.go
@@ -47,6 +47,9 @@ func (*RPM) Package(info nfpm.Info, w io.Writer) error {
if err != nil {
return fmt.Errorf("rpmbuild not present in $PATH")
}
+ if info.Release == "" {
+ info.Release = "1"
+ }
temps, err := setupTempFiles(info)
if err != nil {
return err
@@ -215,7 +218,7 @@ func setupTempFiles(info nfpm.Info) (tempFiles, error) {
Folder: folder,
Source: filepath.Join(root, "SOURCES", folder+".tar.gz"),
Spec: filepath.Join(root, "SPECS", info.Name+".spec"),
- RPM: filepath.Join(root, "RPMS", info.Arch, fmt.Sprintf("%s-1.%s.rpm", folder, info.Arch)),
+ RPM: filepath.Join(root, "RPMS", info.Arch, fmt.Sprintf("%s-%s.%s.rpm", folder, info.Release, info.Arch)),
}, nil
}
@@ -309,7 +312,7 @@ const specTemplate = `
Name: {{ .Info.Name }}
Summary: {{ first_line .Info.Description }}
Version: {{ .Info.Version }}
-Release: 1
+Release: {{ .Info.Release }}
{{- with .Info.License }}
License: {{ . }}
{{- end }}