1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-13 13:48:40 +02:00

feat: Allow overriding fpm destination for binaries

Some packagers may want to put binaries in a location other than
/usr/local/bin. This allows one to override the destination for
binaries when using fpm, using the `fpm.bindir` config key.
This commit is contained in:
Joseph Wright 2017-11-06 05:27:44 +00:00 committed by Carlos Alexandro Becker
parent 7c9e1ee5f6
commit 5193680e76
3 changed files with 11 additions and 2 deletions

View File

@ -137,6 +137,7 @@ type FPM struct {
Maintainer string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
License string `yaml:",omitempty"`
Bindir string `yaml:",omitempty"`
Files map[string]string `yaml:",omitempty"`
// Capture all undefined fields and should be empty after loading

View File

@ -43,6 +43,9 @@ fpm:
- svn
- bash
# Override default /usr/local/bin destination for binaries
bindir: /usr/bin
# Files or directories to add to your package (beyond the binary).
# Keys are source paths to get the files from.
# Values are the destination locations of the files in the package.

View File

@ -75,8 +75,13 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
log.WithField("file", file).WithField("workdir", dir).Info("creating fpm archive")
var options = basicOptions(ctx, dir, format, arch, file)
bindir := "/usr/local/bin"
if ctx.Config.FPM.Bindir != "" {
bindir = ctx.Config.FPM.Bindir
}
for _, binary := range binaries {
// This basically tells fpm to put the binary in the /usr/local/bin
// This basically tells fpm to put the binary in the bindir, e.g. /usr/local/bin
// binary=/usr/local/bin/binary
log.WithField("path", binary.Path).
WithField("name", binary.Name).
@ -84,7 +89,7 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
options = append(options, fmt.Sprintf(
"%s=%s",
binary.Path,
filepath.Join("/usr/local/bin", binary.Name),
filepath.Join(bindir, binary.Name),
))
}