From 95eb81467c76a380dcebe68c7502cf56fa2ce3c5 Mon Sep 17 00:00:00 2001 From: Ian Johnson Date: Wed, 27 Jun 2018 01:08:57 -0500 Subject: [PATCH] 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. --- .gitignore | 6 ++++++ build.go | 9 ++++++--- snapcraft.yaml.template | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 91d33d107..fb67d5733 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,9 @@ RELEASE deb lib/auto/gui.files.go snapcraft.yaml +prime/ +snap/ +parts/ +stage/ +*.snap +*.bz2 diff --git a/build.go b/build.go index 3db31c0a9..dc7b99877 100644 --- a/build.go +++ b/build.go @@ -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) diff --git a/snapcraft.yaml.template b/snapcraft.yaml.template index 0b9783f04..a07b58e00 100644 --- a/snapcraft.yaml.template +++ b/snapcraft.yaml.template @@ -6,15 +6,24 @@ description: | trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet. -architectures: [{{.Architecture}}] +architectures: + - build-on: [{{.HostArchitecture}}] + run-on: [{{.TargetArchitecture}}] grade: {{.Grade}} confinement: strict apps: syncthing: - command: env HOME="$SNAP_USER_COMMON" XDG_CONFIG_HOME="$SNAP_USER_COMMON" "$SNAP/syncthing" - plugs: [home, network, network-bind] + command: syncthing + environment: + HOME: ${SNAP_USER_COMMON} + XDG_CONFIG_HOME: ${SNAP_USER_COMMON} + plugs: + - home + - network + - network-bind + - removable-media parts: syncthing: