Package - snapcore/snapcraft

Build Status Coverage Status

Snapcraft

Snapcraft is a delightful packaging tool

Snapcraft helps you assemble a whole project in a single tree out of many pieces. It can drive a very wide range of build and packaging systems, so that you can simply list all the upstream projects you want and have them built and installed together as a single tree.

For example, say you want to make a product that includes PyPI packages, Node.js packages from NPM, Java, and a bunch of daemons written in C and C++ that are built with autotools, snapcraft would make assembling the final tree very easy.

Snapcraft allows easy crafting of snap packages for the snappy Ubuntu Core transactional update system.

More Information

  • Introduction to all the details about the concepts behind snapcraft.
  • Hacking guide to contribute if you're interested in developing Snapcraft.
  • Launchpad to submit bugs or issues.

Get in touch

We're friendly! Talk to us on Rocket Chat or on our forums.

Get news and stay up to date on Twitter, Google+ or Facebook.

Github

link
Stars: 434

Advertisement

Releases

2.35 - Nov 16, 2017

Hello snapcrafters! The snapcraft team is pleased to announce that version 2.35 has been released.

Contributions

This release saw some excellent contributions from outside the snapcraft core team, and we want to give a shout out to those folks. A team thank you to:

New in this release

Core

Containers

Each build instance created now correctly works out isolated temporary folder locations for those users running many builds in parallel. There is also better detection of existing or missing lxd installations so first time users can better understand any problems with the host they are currently trying to use.

When running snapcraft from the snap, snapcraft now injects itself into the actual snap instead of apt installing the deb (for the case of today of only supporting one base), providing parity with the local environment at hand.

Work has been added to get rid of all the corner cases and provide useful feedback to users and making the experience feel more native. Additionally, support has been added for using remote lxd instances.

To enable the persistent build containers feature the SNAPCRAFT_CONTAINER_BUILDS environment variable needs to be set.

Here's an example of using a remote lxd instance:

asciicast

Recording

On this new version we added more information to the build manifest, like the contents of lock files, the debs and snaps installed in the machine, information from uname and the fingerprint of the container used for the build. To record the build manifest, set the environment variable SNAPCRAFT_BUILD_INFO. The manifest will be saved and distributed inside the snap. After the build, you can inspect it in the prime/snap/manifest.yaml.

asciicast

Command Line Interface

new command: pack

This new pack command replaces the now deprecated use of snap <snap-dir> with the goal of decoupling the concept of working on an actual snapcraft project and packing up a directory layout into a snap.

new command: refresh

This command is only available when persistent build containers are enabled and exists to make the environment feel as native as possible. Prior to the existence of this command, building continuously in a container triggered a refresh of the packaging archive every time, now this refresh only takes place on container creation or when called through snapcraft refresh.

new command: edit-collaborators

OS Support

Solus

Ubuntu 14.04

Snapcraft currently only really runs well on Ubuntu 16.04, but we're working on adding support for other releases and Linux distributions. This is the first release where you can use the Snapcraft snap on Ubuntu 14.04 (Trusty). This is particularly important for snaps based on ROS (Robot Operating System) Indigo, which targets Trusty. Here's a demo of just that:

asciicast

Plugins

dotnet

This plugin developed by Rajesh, a .NET developer at Microsoft, allows you to create .NET 2.x based snaps, currently embedding the runtime with plans to enhance it to understand content snaps of .NET runtimes which could be leveraged by projects.

The syntax is pretty straightforward and builds on language understood by upstream so getting started for a current .NET developer should feel like a pleasant journey.

Here is the plugin in action: asciicast

ruby

This release sees the addition of a Ruby plugin, written by James Beedy. It supports a number of different Ruby versions by building them from source, which takes a little while but makes it pretty versatile. It could definitely use some exercise! Here's an example of building a snap of the Travis gem:

asciicast

catkin

The Catkin plugin has long supported rosdep to resolve and fetch system dependencies (i.e. Debian packages). However, rosdep also supports resolving pip dependencies. This release adds support for those, so they don't need to specified elsewhere in the snapcraft.yaml.

kbuild

Final notes

To get the source for this release, check it out on github.

A great place to collaborate and discuss features, bugs and ideas on snapcraft are the forums. Please also feel free to file a bug.

Happy snapcrafting! -- Sergio and the team

2.34 - Sep 19, 2017

Hello snapcrafters!

We are pleased to announce the release of snapcraft 2.34:

  • Available on all supported Ubuntu releases (Ubuntu 16.04 LTS and 17.04), and the development release (Artful Aardvark).
  • A windows MSI preview installer for snapcraft on Windows.
  • brew installabled on OS X by running brew install snapcraft (store interaction and cleanbuild are supported).
  • pip installable from PyPI (with caveats when setting up apt bindings) by running pip install snapcraft.
  • View the full list of merged PRs.
  • Specific bug fixes can be seen on the Launchpad milestone.

Contributions

This release saw some excellent contributions from outside the snapcraft core team, and we want to give a shout out to those folks. A team thank you to:

New in this release

Core

types

A new snap type was added: base, this opens the door to start producing base snaps.

Containers

Each build instance created now correctly works out isolated temporary folder locations for those users running many builds in parallel. There is also better detection of existing or missing lxd installations so first time users can better understand any problems with the host they are currently trying to use.

When running snapcraft from the snap, snapcraft now injects itself into the actual snap instead of apt installing the deb (for the case of today of only supporting one base), providing parity with the local environment at hand.

Additionally, when cleaning projects making use of persistent project containers, snapcraft destroys the container that was assigned for this work as well.

To enable the persistent build containers feature the SNAPCRAFT_CONTAINER_BUILDS environment variable needs to be set.

build-snaps

They work in a similar fashion to build-packages, build-snaps takes leverage of snaps in the store to create your snaps. This release exposes the feature through

build-packages

While build-packages have been around for a while, it is only now that they have gained the support for advanced grammar, just as what is provided for stage-packages. Support for grammar-powered build-packages, both at the part-level and global are here to stay.

source caching

Logic has been added to cache source entries that provide a source-checksum entry for parts, this would behave like:

Cleanup

Release detection

Snapcraft used the deprecated linux_distribution method from the platform module, it now correctly handles the host it is running on through parsing of /etc/os-release.

Tour removal

The tour has been sunset in favour of the tutorial which can be currently found here.

Errors

Many new exceptions have been created to handle the many potential errors that can occur when running snapcraft. In addition to that, proper snapcraft generated and understood errors will produce a nice user friendly error message while situations that were not thought of in the code base will provide proper tracebacks. This will provide a faster turnaround time for fixes and a more apparent situation of wrongness to the users of snapcraft. The errors codes for these two situations are also different, being1for the former and2` for the latter.

Plugins

nodejs

Catching up to yarn's latest developments, the snapcraft plugin now supports the latest release of yarn.

This plugin has also gained recording capabilities by means of running snapcraft with the environment variable SNAPCRAFT_BUILD_INFO set.

jhbuild

This is a new plugin which uses jhbuild to build mostly gnome projects

python

The python plugin now records the assets it used to build, to get a glimpse of this feature you need to run snapcraft with the environment variable SNAPCRAFT_BUILD_INFO set.

catkin

Support for multiple dependency types was added. The catkin plugin now supports a new API which raises an exception if the dependency type is anything other than apt. This is paving the way for support of pip dependencies coming from rosdep.

The plugin now properly defaults to creating a release build, to enable a debug build, edit the part as follows:

kbuild

This plugin has gained the crosscompiling logic that existed for the kernel plugin, unifying the code bases more with the side effect of having cross compilation support for kbuild

Support for Makefiles without install targets is now also of declarative nature, to set it as such here is an example:

ant & gradle

Support for authenticated proxies has been added, this should be transparent to the snapcraft author through means of consumption of the already existing environment variables for proxy management (http_proxy, https_proxy, ...).

Here's an example recording:

Final notes

To get the source for this release, check it out on github.

A great place to collaborate and discuss features, bugs and ideas on snapcraft are the forums. Please also feel free to file a bug.

Happy snapcrafting! -- Sergio and the team

2.33 - Aug 7, 2017

Hello snapcrafters!

We are pleased to announce the release of snapcraft 2.33:

  • Available on all supported Ubuntu releases (xenial, zesty) and the development release (zesty).
  • brew installabled on OS X by running brew install snapcraft (store interaction and cleanbuild are supported).
  • pip installable from PyPI (with caveats when setting up apt bindings) by running pip install snapcraft.
  • View the full list of merged PRs.
  • Specific bug fixes can be seen on the Launchpad milestone.

Contributions

This release saw some excellent contributions from outside the snapcraft core team, and we want to give a shout out to those folks. A team thank you to:

New in this release

Core

Containers

The experience of using persistent build containers has become much more pleasant with this release as snapcraft now takes care of:

  • containers that have no use any more such as when a project is cleaned.
  • file handling an exposing to and fro the container does not leak container specific assets onto the host.
  • use of --debug and cleanbuild now properly enters into a shell inside the container for inspection.
  • the clean command now properly handles corner case scenarios that weren't handled before.
  • id mappings for the namespace are now correctly set depending on the uid of the user calling snapcraft

Yaml Merge tags

Yaml merge tags are now supported in snapcraft.yaml, allowing for advanced use of yaml in snapcraft.yaml if needed.

Bash completion

Support for bash completion in snapcraft has arrived, it is just a matter of defining completer for your app entry under apps with a script which would deal with such completions. As an illustrative example:

apps:
    my-application:
        command: runme
        completer: completion.sh

Where completion.sh would be found under the root of prime. For all this to work a recent version of snapd is required like 2.27.

reload-command for daemons

App entries under apps in snapcraft.yaml now support reload-command as an entry which defines how to deal with configuration reloads for daemons.

Plugins

kernel

Handling of default make targets depending on the architecture is now supported for all architectures.

nodejs

Support has been added for newer releases for nodejs/npm for special cases where in tree builds are done and npm generates a symlink farm. This should now just work with no hassle.

Cross compilation

Cross compilation support is now enabled for:

  • autotools
  • waf

Final notes

To get the source for this release, check it out on github.

A great place to collaborate and discuss features, bugs and ideas on snapcraft are the forums and the snapcraft channel on Rocket Chat. Please also feel free to file a bug.

Happy snapcrafting! -- Sergio and the team

2.32 - Jun 27, 2017

Hello snapcrafters!

We are pleased to announce the release of snapcraft 2.32:

  • This is a snap-only release, available in the candidate channel: sudo snap install --candidate snapcraft
  • View the full list of merged PRs.
  • Specific bug fixes can be seen on the Launchpad milestone.

Contributions

This release saw some excellent contributions from outside the snapcraft core team, and we want to give a shout out to those folks. A team thank you to:

New in this release

Core

Who am I?

Several operations in the snap world require one’s account ID out of the store (e.g. creating model assertions). It gets old having to login to the web dashboard to get that ID, so we introduced a snapcraft whoami command that returns information about the account which is currently logged in.

Sources

Snapcraft has always supported local sources (i.e. sources sitting alongside the snapcraft.yaml), but has always used them as a fallback, i.e. if it was determined that it wasn’t another source, then it assumed it was local. This release includes the ability to actually specify that a given source is local, even if it’s e.g. a git repo.

Plugins

catkin

Support was added to the Catkin plugin for the newest ROS distro, Lunar.

rust

Support has been added for cross-compiling Rust parts by using snapcraft --target-arch=<arch>. Note that we’re still working on support for cross-compiling with stage-packages-- stay tuned for multi-arch support.

autotools

The autotools plugin supports a configflags option to supply flags to use when running ./configure. However, it was enforcing uniqueness on these flags, which prevented some projects from building successfully. This release stops enforcing uniqueness on configflags.

Final notes

To get the source for this release, check it out on github.

A great place to collaborate and discuss features, bugs and ideas on snapcraft are the forums and the snapcraft channel on Rocket Chat. Please also feel free to file a bug.

Happy snapcrafting! -- Kyle and the team

2.31 - Jun 13, 2017

Hello snapcrafters!

We are pleased to announce the release of snapcraft 2.31:

Contributions

This release saw some excellent contributions from outside the snapcraft core team, and we want to give a shout out to those folks. A team thank you to:

New in this release

Core

CLI

The move to the new argument parser caused the CLI to regress slightly by duplicating error messages in some circumstances and changing how it handled arguments to the snap command. That has been fixed in this release.

Resume snap downloads

Snapcraft supports downloading the core snap when building classic snaps. This release adds the ability to resume the download of that snap if an error is encountered when trying to fetch it. This feature is really used more in CI than anywhere else, particularly in our own tests, where downloading the snap fails all the time with connection resets. This change did not help quite as much as we’d hoped in that situation, but it’s nice to have nonetheless.

Sources

The git source-type was using --remote when updating submodules, which updated each submodule rather than using the commit recorded in the super project. That’s fixed in this release.

Better build-packages asset tracking

In this release, build-packages asset tracking has been extracted into a project-wide state area instead of being tracked individually in each part’s state. This fixes some awkward behavior when attempting to walk the dependency tree.

Plugins

qmake

The qmake plugin previously required one to specify the Qt version being used. In this release, it’s started defaulting to Qt5.

Go

Support has been added for cross-compiling Go parts by using snapcraft --target-arch=<arch>. This supports use of cgo as well. We’re currently working on support for cross-compiling with stage-packages-- if you’re using stage-packages, please wait to use this feature. We’re implementing it in phases.

Catkin

Larger Catkin projects often keep track of their components by utilizing one or more rosinstall files. This release adds support for those files to the Catkin plugin, allowing an entire ROS project to be built from a single file.

Store integration

Header change

This release changes away from using X-Ubuntu-Release to X-Ubuntu-Series for communication with the store.

Final notes

To get the source for this release, check it out on github.

A great place to collaborate and discuss features, bugs and ideas on snapcraft are the forums and the snapcraft channel on Rocket Chat. Please also feel free to file a bug.

Happy snapcrafting! -- Kyle and the team