From 9935b87100b6f3e286e90614d22ee1bf169a2d9b Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 6 Nov 2020 15:17:08 -0300 Subject: [PATCH] feat: support replaces on nfpm (#1888) * feat: support replaces on nfpm Signed-off-by: Carlos Alexandro Becker * Update www/docs/customization/nfpm.md --- internal/pipe/nfpm/nfpm.go | 1 + internal/pipe/nfpm/nfpm_test.go | 2 ++ pkg/config/config.go | 1 + www/docs/customization/nfpm.md | 8 +++++++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/pipe/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go index c507cafa46f..babc6216be2 100644 --- a/internal/pipe/nfpm/nfpm.go +++ b/internal/pipe/nfpm/nfpm.go @@ -165,6 +165,7 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries Depends: overridden.Dependencies, Recommends: overridden.Recommends, Suggests: overridden.Suggests, + Replaces: overridden.Replaces, EmptyFolders: overridden.EmptyFolders, Files: files, ConfigFiles: overridden.ConfigFiles, diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go index f99ef426375..023305207ea 100644 --- a/internal/pipe/nfpm/nfpm_test.go +++ b/internal/pipe/nfpm/nfpm_test.go @@ -101,6 +101,7 @@ func TestRunPipe(t *testing.T) { Dependencies: []string{"make"}, Recommends: []string{"svn"}, Suggests: []string{"bzr"}, + Replaces: []string{"fish"}, Conflicts: []string{"git"}, EmptyFolders: []string{"/var/log/foobar"}, Release: "10", @@ -607,6 +608,7 @@ func TestMeta(t *testing.T) { Dependencies: []string{"make"}, Recommends: []string{"svn"}, Suggests: []string{"bzr"}, + Replaces: []string{"fish"}, Conflicts: []string{"git"}, EmptyFolders: []string{"/var/log/foobar"}, Release: "10", diff --git a/pkg/config/config.go b/pkg/config/config.go index 8fb2a9b40d0..21814ea1e79 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -399,6 +399,7 @@ type NFPMOverridables struct { Recommends []string `yaml:",omitempty"` Suggests []string `yaml:",omitempty"` Conflicts []string `yaml:",omitempty"` + Replaces []string `yaml:",omitempty"` EmptyFolders []string `yaml:"empty_folders,omitempty"` Files map[string]string `yaml:",omitempty"` ConfigFiles map[string]string `yaml:"config_files,omitempty"` diff --git a/www/docs/customization/nfpm.md b/www/docs/customization/nfpm.md index a906f6198b3..8301733bfe8 100644 --- a/www/docs/customization/nfpm.md +++ b/www/docs/customization/nfpm.md @@ -85,6 +85,10 @@ nfpms: - svn - bash + # Packages it replaces. + replaces: + - fish + # Override default /usr/local/bin destination for binaries bindir: /usr/bin @@ -133,7 +137,7 @@ nfpms: preremove: "scripts/preremove.sh" postremove: "scripts/postremove.sh" - # Some attributes can be overrided per package format. + # Some attributes can be overridden per package format. overrides: deb: conflicts: @@ -144,6 +148,8 @@ nfpms: - gitk recommends: - tig + replaces: + - bash empty_folders: - /var/log/bar rpm: