From ce69ee5316f394a8ed7192663fbccb74f60c8020 Mon Sep 17 00:00:00 2001 From: Simon Barendse Date: Tue, 9 Apr 2019 14:14:28 +0200 Subject: [PATCH] fix: use the filename of the binary in snapcraft (#1001) * fix: use the filename of the binary in snapcraft When builds.binary is a path, only use the filename as the name of the snapcraft app and as the command, instead of the full path. * docs: use a path in the binary name --- internal/pipe/snapcraft/snapcraft.go | 8 +++++--- www/content/build.md | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/pipe/snapcraft/snapcraft.go b/internal/pipe/snapcraft/snapcraft.go index a98b096b2..94cd0f483 100644 --- a/internal/pipe/snapcraft/snapcraft.go +++ b/internal/pipe/snapcraft/snapcraft.go @@ -152,11 +152,12 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err } for _, binary := range binaries { + _, name := filepath.Split(binary.Name) log.WithField("path", binary.Path). WithField("name", binary.Name). Debug("passed binary to snapcraft") appMetadata := AppMetadata{ - Command: binary.Name, + Command: name, } if configAppMetadata, ok := ctx.Config.Snapcraft.Apps[binary.Name]; ok { appMetadata.Plugs = configAppMetadata.Plugs @@ -166,7 +167,7 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err configAppMetadata.Args, }, " ") } - metadata.Apps[binary.Name] = appMetadata + metadata.Apps[name] = appMetadata metadata.Plugs = ctx.Config.Snapcraft.Plugs destBinaryPath := filepath.Join(primeDir, filepath.Base(binary.Path)) @@ -182,7 +183,8 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err } if _, ok := metadata.Apps[metadata.Name]; !ok { - metadata.Apps[metadata.Name] = metadata.Apps[binaries[0].Name] + _, name := filepath.Split(binaries[0].Name) + metadata.Apps[metadata.Name] = metadata.Apps[name] } out, err := yaml.Marshal(metadata) diff --git a/www/content/build.md b/www/content/build.md index 69f44e9c4..c8bc469a2 100644 --- a/www/content/build.md +++ b/www/content/build.md @@ -22,6 +22,7 @@ builds: main: ./cmd/main.go # Binary name. + # Can be a path (e.g. `bin/app`) to wrap the binary in a directory. # Default is the name of the project directory. binary: program