Skip to content

Commit

Permalink
Add support for building snap packages (#174)
Browse files Browse the repository at this point in the history
* Add support for building snap packages

This branch makes a few changes to support running the exo binary from a
snap package (https://snapcraft.io).


* Don't build with -j2

Turns out our build was running the build step (go build) and the clean
step (go clean) in parallel.

Make sure snapcraft runs Makefile targets with -j1 (like on a default
local machine).

* Make store-mandated changes

Also add comments to the snap file pointing to the forum-based process.
  • Loading branch information
chrisglass committed Sep 9, 2019
1 parent a7919e9 commit a69dbd0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,5 @@ exo
manpage
contrib
cli
*.snap
*.xdelta3
5 changes: 5 additions & 0 deletions cmd/root.go
Expand Up @@ -203,6 +203,11 @@ func initConfig() {
gConfigFolder = path.Join(usr.HomeDir, ".config", "exoscale")
}

// Snap packages use $HOME/.exoscale (as negotiated with the snap store)
if _, snap := os.LookupEnv("SNAP_USER_COMMON"); snap {
gConfigFolder = path.Join(usr.HomeDir, ".exoscale")
}

if gConfigFilePath != "" {
// Use config file from the flag.
viper.SetConfigFile(gConfigFilePath)
Expand Down
45 changes: 45 additions & 0 deletions snap/snapcraft.yaml
@@ -0,0 +1,45 @@
name: exoscale-cli
base: core18
version: git
summary: The Exoscale command line tool
description: |
The Exoscale command line tool.
This snap allows you to use the "exo" command once installed, your
gateway to the Exoscale platform.
Usage: sudo snap install exoscale-cli; exo config; exo vm list
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

plugs:
# This allows us to read/write in $HOME/.exoscale/*
# It was granted via a forum post and is autoconnected.
# Do not change the plug name.
dot-exoscale:
interface: personal-files
write:
- $HOME/.exoscale

apps:
# The app has an alias to "exo" that was granted via forum post.
exoscale-cli:
command: exo
plugs:
- network
- home
- dot-exoscale

parts:
exo:
# See 'snapcraft plugins'
disable-parallel: True
plugin: make
source: .
artifacts:
- exo
build-snaps:
- go
build-packages:
- git

0 comments on commit a69dbd0

Please sign in to comment.