mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +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:
parent
5ce976fafb
commit
c15d4b6821
@ -118,6 +118,7 @@ type FPM struct {
|
|||||||
Maintainer string `yaml:",omitempty"`
|
Maintainer string `yaml:",omitempty"`
|
||||||
Description string `yaml:",omitempty"`
|
Description string `yaml:",omitempty"`
|
||||||
License string `yaml:",omitempty"`
|
License string `yaml:",omitempty"`
|
||||||
|
Files map[string]string `yaml:",omitempty"`
|
||||||
|
|
||||||
// Capture all undefined fields and should be empty after loading
|
// Capture all undefined fields and should be empty after loading
|
||||||
XXX map[string]interface{} `yaml:",inline"`
|
XXX map[string]interface{} `yaml:",inline"`
|
||||||
|
@ -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 {
|
if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
|
||||||
return errors.New(string(out))
|
return errors.New(string(out))
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,24 @@ func TestCreateFileDoesntExist(t *testing.T) {
|
|||||||
Dist: dist,
|
Dist: dist,
|
||||||
FPM: config.FPM{
|
FPM: config.FPM{
|
||||||
Formats: []string{"deb"},
|
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"))
|
ctx.AddBinary("linuxamd64", "mybin", "mybin", filepath.Join(dist, "mybin", "mybin"))
|
||||||
assert.Error(Pipe{}.Run(ctx))
|
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
1
pipeline/fpm/testdata/testfile.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
this is a test file
|
Loading…
x
Reference in New Issue
Block a user