From ec1ba17102d01aab837a68286a5e8778bfa455f4 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sat, 17 Feb 2018 16:51:18 -0200 Subject: [PATCH] fix: nfpm multiple binaries in the same archive (#564) --- pipeline/nfpm/nfpm.go | 22 +++++++++++++--------- pipeline/nfpm/nfpm_test.go | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/pipeline/nfpm/nfpm.go b/pipeline/nfpm/nfpm.go index d0df79fa5..6b6a7f0e6 100644 --- a/pipeline/nfpm/nfpm.go +++ b/pipeline/nfpm/nfpm.go @@ -87,6 +87,18 @@ func create(ctx *context.Context, format, arch string, binaries []artifact.Artif if err != nil { return err } + var files = map[string]string{} + for k, v := range ctx.Config.NFPM.Files { + files[k] = v + } + var log = log.WithField("package", name+"."+format) + for _, binary := range binaries { + src := binary.Path + dst := filepath.Join(ctx.Config.NFPM.Bindir, binary.Name) + log.WithField("src", src).WithField("dst", dst).Debug("adding binary to package") + files[src] = dst + } + log.WithField("files", files).Debug("all archive files") var info = nfpm.Info{ Arch: arch, @@ -102,19 +114,11 @@ func create(ctx *context.Context, format, arch string, binaries []artifact.Artif Vendor: ctx.Config.NFPM.Vendor, Homepage: ctx.Config.NFPM.Homepage, License: ctx.Config.NFPM.License, - Files: ctx.Config.NFPM.Files, Bindir: ctx.Config.NFPM.Bindir, + Files: files, // ConfigFiles: "" TODO: add this config_files to nfpm settings, } - var log = log.WithField("package", name+"."+format) - for _, binary := range binaries { - src := binary.Path - dst := filepath.Join(ctx.Config.NFPM.Bindir, binary.Name) - log.WithField("src", src).WithField("dst", dst).Info("adding binary to package") - info.Files[src] = dst - } - packager, err := nfpm.Get(format) if err != nil { return err diff --git a/pipeline/nfpm/nfpm_test.go b/pipeline/nfpm/nfpm_test.go index 824efed46..38fd47831 100644 --- a/pipeline/nfpm/nfpm_test.go +++ b/pipeline/nfpm/nfpm_test.go @@ -89,6 +89,7 @@ func TestRunPipe(t *testing.T) { } } assert.NoError(t, Pipe{}.Run(ctx)) + assert.Empty(t, ctx.Config.NFPM.Files, "should not modify the config file list") } func TestInvalidNameTemplate(t *testing.T) {