mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-16 03:52:12 +02:00
fix: nfpm not including extra files
closes #1980 Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
parent
c613dd9c95
commit
1195844e47
@ -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
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user