diff --git a/config/config.go b/config/config.go index f043e4e2c..ba2d6bebd 100644 --- a/config/config.go +++ b/config/config.go @@ -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"` diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index b9806547c..8fc5ce3f7 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -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)) } diff --git a/pipeline/fpm/fpm_test.go b/pipeline/fpm/fpm_test.go index ad9cbe4e9..5c1c72776 100644 --- a/pipeline/fpm/fpm_test.go +++ b/pipeline/fpm/fpm_test.go @@ -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)) +} diff --git a/pipeline/fpm/testdata/testfile.txt b/pipeline/fpm/testdata/testfile.txt new file mode 100644 index 000000000..68a4528a6 --- /dev/null +++ b/pipeline/fpm/testdata/testfile.txt @@ -0,0 +1 @@ +this is a test file \ No newline at end of file