diff --git a/config/config.go b/config/config.go index eeb587a1b..87d6d18a8 100644 --- a/config/config.go +++ b/config/config.go @@ -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 diff --git a/docs/100-fpm.md b/docs/100-fpm.md index d1e721cf6..d5b531a7a 100644 --- a/docs/100-fpm.md +++ b/docs/100-fpm.md @@ -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. diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index 97becb096..09149751e 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -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), )) }