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

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
This commit is contained in:
Simon Barendse 2019-04-09 14:14:28 +02:00 committed by Carlos Alexandro Becker
parent d24c342ca0
commit ce69ee5316
2 changed files with 6 additions and 3 deletions

View File

@ -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)

View File

@ -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