Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Release to Config? #46

Closed
jimrobinson opened this issue Mar 12, 2019 · 2 comments
Closed

Add Release to Config? #46

jimrobinson opened this issue Mar 12, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@jimrobinson
Copy link
Contributor

jimrobinson commented Mar 12, 2019

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 }}
@jimrobinson jimrobinson changed the title Add Build to Config? Add Release to Config? Mar 12, 2019
@jimrobinson
Copy link
Contributor Author

#52

@caarlos0 caarlos0 added the enhancement New feature or request label Jun 25, 2019
@caarlos0
Copy link
Member

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@goreleaser goreleaser locked as resolved and limited conversation to collaborators Nov 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants