build: Improve snap generation (fixes #4863, fixes #5000) (#5034)

This makes the environment variables easier to read/change.

Also expand the list so it's not inline, more readable that way.

The new architecture syntax for snapcraft allows specifying both the building architecture and the running architecture of the snap, so if we specify the build-on architecture as the host architecture and the run-on architecture as the target architecture, then snapcraft shouldn't need to install any cross-compilers, etc.
This commit is contained in:
Ian Johnson
2018-06-27 01:08:57 -05:00
committed by Jakob Borg
parent 55ed883648
commit 95eb81467c
3 changed files with 24 additions and 6 deletions

View File

@@ -618,6 +618,8 @@ func buildSnap(target target) {
snaparch := goarch
if snaparch == "armhf" {
goarch = "arm"
} else if snaparch == "i386" {
goarch = "386"
}
snapver := version
if strings.HasPrefix(snapver, "v") {
@@ -628,9 +630,10 @@ func buildSnap(target target) {
snapgrade = "stable"
}
err = tmpl.Execute(f, map[string]string{
"Version": snapver,
"Architecture": snaparch,
"Grade": snapgrade,
"Version": snapver,
"HostArchitecture": runtime.GOARCH,
"TargetArchitecture": snaparch,
"Grade": snapgrade,
})
if err != nil {
log.Fatal(err)