Snapcraft plugin for gnome-builder

I’ve been working on adding support for developing Snapcraft projects using the IDE gnome-builder, and have gotten to the point where I’ve got something that other people might be interested in testing.

I have put together a PPA with packages for Ubuntu 17.10 (artful) here:

If there is interest, I can try building packages for older releases. I can’t promise anyting, since I don’t want to go down the dependency backport rabbit hole.

Here’s a list of what currently works:

  1. You can open an existing Snapcraft project by selecting Open... and then picking your snapcraft.yaml file in the file chooser.

  2. Clicking the “build” button (looks like a stack of bricks) will invoke snapcraft build, with the output displayed at the bottom of the window.

  3. If you click on the project name at the top of the window, it will show an overlay with a Clean button, that will invoke snapcraft clean.

  4. In the application menu at the top right of the window, selecting Snapcraft -> Export snap package will run the package build to completion. If it succeeds, a file manager window should open pointing at the new snap package.

Here are some things that don’t work, or haven’t been tested:

  1. Snapcraft will error out if it tries to install new packages as part of the build. We aren’t invoking it in a terminal, so sudo doesn’t work.

  2. I haven’t really tested how the plugin interacts if you are an upstream developer with a snapcraft.yaml checked into your tree, but want to build directly without Snapcraft.

This is fairly bare bones at the moment, so there are a few areas for further development:

  1. Add a template to allow creating a new Snapcraft project.
  2. Add support for testing a snap via snap try.
  3. Make the “build” button execute more build steps?

If anyone is interested in the source to the plugin, it can be found here:

https://github.com/jhenstridge/gnome-builder/tree/snap-plugin/plugins/snap

And here’s a screenshot for anyone curious about what this looks like:

6 Likes

This is great news :slight_smile: I’ll have a play over the weekend. I’ve also put out a call for testing on the Snapcraft social networks.

We can add some environment for preferred way to escalate privs_ where you can add the necessary stanza that would replace sudo. Would that work?

Alternatively, This could potentially always build in a lxd container as well, with independent steps and all. I would prefer this path.

There are a few places where gnome-builder installs packages: these are done via PackageKit, so it isn’t just a case of swapping in a different sudo implementation.

As far as containerised builds, there is support for having multiple “runtimes”, and performing a build inside the runtime. Writing a runtime implementation that used LXD containers is probably possible. It looks like the runtimes are expected to be somewhat persistent, so I’m not sure whether snapcraft cleanbuild's use of ephemeral containers would be the right fit or not.

We are also supporting persistent containers, today hidden with an environment variable (SNAPCRAFT_CONTAINER_BUILDS).

Installation of packages in a container via PackageKit would seem like the wrong approach then, but with user namespaced containers the sudo problem should just go away if you choose this as the only path.

Hello @jamesh!

I’ve sent you an email to see if we can continue this work. We want to finish soon anything that might be missing on the snapcraft side to finish this integration.

This is really interesting. It’d be great to have plug-ins for some of the other editors like vs code and atom.