Welcome to Part II of this three-part mini-series on embedded Linux development on Ubuntu. In Part I, we set the stage for the remainder of the series and gave an overview of snaps, the packaging format at the heart of embedded devices running Ubuntu.
Snaps are a secure, confined, dependency-free, cross-platform Linux packaging format. Software publishers often want to manage their application components using containers. Whereas one can achieve this with various runtimes, the Snap ecosystem provides a security-focused approach to containerisation with strict privilege and capability separation between containers. If you missed it, head over to Part I to review the role of snaps in embedded Linux development.
If you are already familiar with snaps and do not wish to refresh your memory, keep reading.
Developers can build containerised, isolated snap applications on their machine using Snapcraft, access them from anywhere and farm from the global, public Snap Store. Snapcraft and the Snap Store are the focus of this blog post.
Without much further ado, let’s dive straight in.
Snapcraft for embedded Linux development
Snapcraft is the framework and command-line packaging tool used to simplify embedded Linux development. Snapcraft builds and publishes snaps by orchestrating disparate components and build systems into one cohesive distributable package. Snapcraft helps you assemble a whole project in a single tree out of many pieces, including source or existing debs.
When doing embedded Linux development via Snapcraft, you can bundle components and build systems directly into your application for a fully orchestrated package. Snapcraft is extensible and able to understand other build systems and software. Continuous development and integration of new plugins like Java, Python, Catkin (ROS), Go, CMake, qmake and make, enable developers to leverage the latest technologies for their software.
Furthermore, Snapcraft improves embedded Linux development by easily integrating into existing CI systems. After receiving a PR on GitHub, you can test it with e.g. Travis or another CI system, and the code lands on your GitHub master. Seamless integration with Travis, Jenkins, GitLab and TeamCity can generate automatic snap builds on every Git commit.
Snap the format for embedded Linux development
Snapcraft levels the embedded Linux development playing field: any developer can build a snap by putting their software into a YAML file.
The YAML format to define applications is simple and declarative. It is a compressed filesystem with a single metadata file describing the security profile and desired snap integrations. The snap format uses only three stanzas to declare the metadata, confinement, and build definition, ensuring the security of the system a snap is running on and enabling the software to behave as expected.
Such a structure facilitates developers to extend a snap by adding shell commands and plugins for popular build systems and languages in the YAML. Developers can further bundle all dependencies inside the snap for predictable behaviour and make artefacts like databases more accessible and secure.
Snap Store for embedded Linux development
In Part I, we overviewed the pain points of finding new software for embedded Linux devices.
The key takeaway was that discovering new software on Linux is difficult, as publishers need to be on the hunt for PPAs and GitHub repositories with daily builds of all kinds of new software.
Snaps ease the process via the Snap Store, a central repository where developers publish their apps and users discover new software. It’s a universal app store for any Linux distribution to upload, browse, install, distribute and deploy applications in the cloud, on desktop or to IoT devices. The free enterprise-level capabilities of the Store solve the traditional software distribution challenges on Linux.
Managing software and updates across a huge number of devices can be challenging, especially if subsets of hardware require different applications to run on them. Delivering automatic updates and handling software across machines is one of the key features of the IoT App Store. This custom, enterprise store allows you to cherry-pick the optimal combination of applications you want your devices to use, including software published in the global Snap Store and custom software developed internally for a specific use case.
Community-backed snaps for every use case
Besides being a repository of snaps backed by the biggest, growing Linux developer community, the Snap Store has additional features. For one, developers can push updates to their apps at their cadence and not wait for distribution maintainers to catch up. Also, the store can host multiple versions of the same snap on different risk levels, with users picking the one they prefer.
Snaps use channels to represent software maturity, enabling end-users to subscribe and switch between a track/risk/branch scheme. Embedded Linux devices can track software across their chosen channel and will automatically update to the latest revision of that software. The release channels strengthen embedded Linux development by promoting a standardised way of tracking deployments and enforcing rigorous iterative testing and stable releases.
Continuous software delivery with snaps
Developers can use tracks to publish multiple supported snap releases under the same snap name (for instance, a released snap may be on the “latest” track for external users and an ”insider” for an internal QA team).
Risk levels represent a progressive potential trade-off between stability and new features. The Store modernises embedded Linux development by promoting snaps between Edge, Beta, Candidate and Stable channels, facilitating continuous software delivery. For instance, publishers can request users to participate in beta testing and, once the beta programme is over, move consumers back to stable, while users can pick which maturity level is most appealing to them.
And finally, branches are optional and hold temporary releases intended to help with bug-fixing.
Final considerations for embedded Linux development
Snapcraft is a powerful and easy to use command-line tool for building snaps. It helps embedded Linux developers reach a wider audience by building and publishing snaps on the Snap Store.
Snapcraft raises the bar for embedded Linux development by using channels, tracks and branches to control updates and releases, and secures it by building and debugging snaps within a confined environment. Snapcraft also simplifies embedded Linux development in that it uses a single declarative YAML file to define a snap. Developers who previously created packages for Linux distros will find it is similar to rpm spec files, Debian/control files or Arch Linux pkgbuild files, but one difference: it is much simpler.
Furthermore, the build and publish life cycle can be automated by integrating Snapcraft into an existing CI/CD pipeline. If your embedded Linux project does not already have a CI/CD process, you can connect your GitHub projects directly to our free build service. It will build a new snap on every commit and publish them to the edge channel in the Snap Store.
Now that you have a better understanding of snaps, Snapcraft and the Snap Store, jump to the last blog of this series to learn about the final, revolutionary step in the world of Linux. In the concluding chapter, we will connect all the concepts mentioned throughout this series and introduce Ubuntu Core. The combination of a hardened OS, snap packages and Store, gives developers a platform for secure, open-source embedded software development and deployment.
Are you evaluating Ubuntu Linux for your embedded device?
Get in touch
Further reading for embedded Linux development
Why is Linux the OS of choice for embedded systems? Check out the official guide to Linux for embedded applications in whitepaper or webinar form.
Interested in a detailed comparison of Yocto and Ubuntu Core? Watch the Yocto or Ubuntu Core for your embedded Linux project? webinar.
Did you hear the news? Real-time Ubuntu 22.04 LTS Ubuntu is now available. Check out the latest webinar on real-time Linux to find out more.
Do you have a question, feedback, or news worth sharing? Join the conversation on IoT Discourse to discuss everything related to the Internet of Things and tightly connected, embedded devices.