1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

Add a Files stanza to the FPM config

This allows for extra files to be passed into FPM packages.
This commit is contained in:
Lachlan Donald 2017-08-09 11:54:23 +10:00
parent 5ce976fafb
commit c15d4b6821
No known key found for this signature in database
GPG Key ID: 5051ACE0B5289A75
4 changed files with 36 additions and 8 deletions

View File

@ -110,14 +110,15 @@ type Release struct {
// FPM config
type FPM struct {
Formats []string `yaml:",omitempty"`
Dependencies []string `yaml:",omitempty"`
Conflicts []string `yaml:",omitempty"`
Vendor string `yaml:",omitempty"`
Homepage string `yaml:",omitempty"`
Maintainer string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
License string `yaml:",omitempty"`
Formats []string `yaml:",omitempty"`
Dependencies []string `yaml:",omitempty"`
Conflicts []string `yaml:",omitempty"`
Vendor string `yaml:",omitempty"`
Homepage string `yaml:",omitempty"`
Maintainer string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
License string `yaml:",omitempty"`
Files map[string]string `yaml:",omitempty"`
// Capture all undefined fields and should be empty after loading
XXX map[string]interface{} `yaml:",inline"`

View File

@ -112,6 +112,17 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
))
}
for src, dest := range ctx.Config.FPM.Files {
log.WithField("src", src).
WithField("dest", dest).
Info("passed extra file to fpm")
options = append(options, fmt.Sprintf(
"%s=%s",
src,
dest,
))
}
if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
return errors.New(string(out))
}

View File

@ -99,9 +99,24 @@ func TestCreateFileDoesntExist(t *testing.T) {
Dist: dist,
FPM: config.FPM{
Formats: []string{"deb"},
Files: map[string]string{
"testdata/testfile.txt": "/var/lib/test/testfile.txt",
},
},
},
}
ctx.AddBinary("linuxamd64", "mybin", "mybin", filepath.Join(dist, "mybin", "mybin"))
assert.Error(Pipe{}.Run(ctx))
}
func TestRunPipeWithExtraFiles(t *testing.T) {
var assert = assert.New(t)
var ctx = &context.Context{
Config: config.Project{
FPM: config.FPM{
Formats: []string{"deb"},
},
},
}
assert.NoError(Pipe{}.Run(ctx))
}

1
pipeline/fpm/testdata/testfile.txt vendored Normal file
View File

@ -0,0 +1 @@
this is a test file