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:
parent
7c9e1ee5f6
commit
5193680e76
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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),
|
||||
))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user