1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-19 20:57:53 +02:00

Merge pull request #330 from lox/add-fpm-path-mappings

Add fpm path mappings
This commit is contained in:
Carlos Alexandro Becker 2017-08-09 10:16:53 -03:00 committed by GitHub
commit 658d46397f
5 changed files with 41 additions and 8 deletions

View File

@ -456,6 +456,11 @@ fpm:
conflicts: conflicts:
- svn - svn
- bash - bash
# Files or directories to add to your package (beyond the binary)
files:
"scripts/etc/init.d/": "/etc/init.d"
``` ```
Note that GoReleaser will not install `fpm` nor any of its dependencies for you. Note that GoReleaser will not install `fpm` nor any of its dependencies for you.

View File

@ -110,14 +110,15 @@ type Release struct {
// FPM config // FPM config
type FPM struct { type FPM struct {
Formats []string `yaml:",omitempty"` Formats []string `yaml:",omitempty"`
Dependencies []string `yaml:",omitempty"` Dependencies []string `yaml:",omitempty"`
Conflicts []string `yaml:",omitempty"` Conflicts []string `yaml:",omitempty"`
Vendor string `yaml:",omitempty"` Vendor string `yaml:",omitempty"`
Homepage string `yaml:",omitempty"` Homepage string `yaml:",omitempty"`
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"`

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 { if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
return errors.New(string(out)) return errors.New(string(out))
} }

View File

@ -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
View File

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