diff --git a/internal/pipe/nfpm/nfpm.go b/internal/pipe/nfpm/nfpm.go index 8055e0309..56bc695d2 100644 --- a/internal/pipe/nfpm/nfpm.go +++ b/internal/pipe/nfpm/nfpm.go @@ -186,7 +186,9 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries } var contents files.Contents - copy(overridden.Contents, contents) + for _, f := range overridden.Contents { + contents = append(contents, f) + } // FPM meta package should not contain binaries at all if !fpm.Meta { @@ -202,7 +204,7 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries } } - log.WithField("files", contents).Debug("all archive files") + log.WithField("files", destinations(contents)).Debug("all archive files") var info = &nfpm.Info{ Arch: arch, @@ -318,6 +320,14 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries return nil } +func destinations(contents files.Contents) []string { + var result = make([]string, 0, len(contents)) + for _, f := range contents { + result = append(result, f.Destination) + } + return result +} + func getPassphraseFromEnv(ctx *context.Context, packager string, nfpmID string) string { var passphrase string diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go index 7591d7670..447f8fda3 100644 --- a/internal/pipe/nfpm/nfpm_test.go +++ b/internal/pipe/nfpm/nfpm_test.go @@ -158,9 +158,15 @@ func TestRunPipe(t *testing.T) { require.NotEmpty(t, format) require.Equal(t, pkg.Name, "mybin_1.0.0_Tux_"+pkg.Goarch+"-10-20."+format) require.Equal(t, pkg.ExtraOr("ID", ""), "someid") + require.ElementsMatch(t, []string{ + "/usr/share/testfile.txt", + "/etc/nope.conf", + "/etc/nope-rpm.conf", + "/etc/nope2.conf", + "/usr/bin/mybin", + }, destinations(pkg.ExtraOr("Files", files.Contents{}).(files.Contents))) } require.Len(t, ctx.Config.NFPMs[0].Contents, 4, "should not modify the config file list") - } func TestInvalidNameTemplate(t *testing.T) { @@ -725,17 +731,12 @@ func TestMeta(t *testing.T) { require.NotEmpty(t, format) require.Equal(t, pkg.Name, "mybin_1.0.0_Tux_"+pkg.Goarch+"-10-20."+format) require.Equal(t, pkg.ExtraOr("ID", ""), "someid") + for _, f := range pkg.ExtraOr("Files", files.Contents{}).(files.Contents) { + require.NotEqual(t, "/usr/bin/mybin", f.Destination, "binary file should not have been added") + } } require.Len(t, ctx.Config.NFPMs[0].Contents, 3, "should not modify the config file list") - - // ensure that no binaries added - for _, pkg := range packages { - contents := pkg.ExtraOr("Files", files.Contents{}).(files.Contents) - for _, f := range contents { - require.NotEqual(t, "/usr/bin/mybin", f.Destination, "binary file should not be added") - } - } } func TestSkipSign(t *testing.T) { diff --git a/pkg/config/config.go b/pkg/config/config.go index 143ada66c..85eac5b2f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -339,8 +339,8 @@ type NFPMRPM struct { Summary string `yaml:"summary,omitempty"` Group string `yaml:"group,omitempty"` Compression string `yaml:"compression,omitempty"` - ConfigNoReplaceFiles map[string]string `yaml:"config_noreplace_files,omitempty"` // depreacated: use contents instead - GhostFiles []string `yaml:"ghost_files,omitempty"` // depreacated: use contents instead + ConfigNoReplaceFiles map[string]string `yaml:"config_noreplace_files,omitempty"` // deprecated: use contents instead + GhostFiles []string `yaml:"ghost_files,omitempty"` // deprecated: use contents instead Signature NFPMRPMSignature `yaml:"signature,omitempty"` }