Snapcraft, the package management system fighting for its spot at the Linux table, re-imagines how you can deliver your software. A new set of cross-distro tools are available to help you build and publish “Snaps”. We’ll cover how to use CircleCI 2.0 to power this process and some potential gotchas along the way.

What Are Snap Packages? And Snapcraft?

Snaps are software packages for Linux distributions. They’re designed with lessons learned from delivering software on mobile platforms such as Android as well Internet of Things devices. Snapcraft is the name that encompasses Snaps and the command-line tool that builds them, the website, and pretty much the entire ecosystem around the technologies that enable this.

Snap packages are designed to isolate and encapsulate an entire application. This concept enables Snapcraft’s goal of increasing security, stability, and portability of software, allowing a single “snap” to be installed on not just multiple versions of Ubuntu, but Debian, Fedora, Arch, and more. Per Snapcraft’s website:

Package any app for every Linux desktop, server, cloud or device, and deliver updates directly.

Resources

Building Snaps on CircleCI

Snap packages can be built quickly and seamlessly on CircleCI. We have a doc on how to build snap packages on CircleCI here. Snapcraft’s own Docs Website is a valuable resource as well.

Docker Images

The Snapcraft CLI snapcraft works extremely well in Ubuntu. However, if you’re trying to build snaps in other distros, a lot more work can be involved. In a similar spirit to snaps themselves, the Snapcraft Team has created Docker images that allow building snap packages regardless of Linux distro (macOS and Windows too). This means you can build snaps locally on Debian or Fedora, or on Ubuntu with a completely clean environment separate from the rest of your filesystem.

I have created a 2nd-party set of Docker images, based on the official Snapcraft images, that are designed to work well in Continuous Integration (CI) environments such as CircleCI. Both Docker images can be found below.

Snapcraft Docker Images:

CircleCI Local CLI

The CircleCI Local CLI is time-saving tool that allows you to run a CI build locally, right on your own machine. This is most useful as an alternative to SSHing into a build for troubleshooting purposes. Another winning feature is the ability to validate your CircleCI config file before committing and pushing to GitHub. No more getting an email about a failed build because you accidentally left a “tab” in .circleci/config.yml.

Using the build process described in CircleCI Docs, the Local CLI is now packaged as a snap package and available via the Snap Store right away. The install instructions can be found here but the gist of it is, for Ubuntu 16.04+ users:

sudo snap install docker circleci
sudo snap connect circleci:docker docker

Package Management & Open-Source

Is your team is planning on packaging software using other tools? Are there open-source processes and workflows you’d like to see covered? If you want to see more blog posts and documentation on these topics, please let us know in CircleCI Discuss or even give me a shout on Twitter: @FelicianoTech.