Snaps are an incredible new packaging format for Linux from Canonical.[1] They offer application confinement and increased portability while also simplifying the development workflow. Recently I submitted a pull-request to extend the Sublime Merge snap with support for arm64 so that I could use it on my Pinebook Pro. Testing the snap locally required I figure out the process on the arm64 architecture. There is a little bit of tweaking required as its still early days for this, but that’s why I made this tutorial!

Tutorial

This tutorial is run on Armbian’s release of Ubuntu 20.04 Focal Fossa for the Pinebook Pro.[2] Your mileage may vary a little bit on other distributions. You should be comfortable using the command-line on Linux, managing Unix group membership, executing privileged commands with Sudo, packaging and installing snaps, and obtaining source with Git. That was a mouthful, wasn’t it? If you made it this far you probably know all of that stuff anyways, so let’s jump right into it!

  1. Install Snapcraft.

    sudo snap install --classic snapcraft
  2. It’s still early days for LXD on the 64-bit ARM architecture, so install the latest candidate release.

    sudo snap install lxd --channel candidate
  3. To avoid having to use root for LXD, add your user to the lxd group.

    sudo usermod -a -G lxd $USER
    Only place users you trust with root access in the lxd group.[3]
  4. Now that LXD is installed, it must be initialized.

    lxd init --auto
  5. Get the snapcraft YAML file for an application that supports building on the arm64 architecture, such as the hello-snapcraftio example project.

    git clone https://github.com/ubuntu-core/hello-snapcraftio.git
  6. Change into the project root or the directory containing the Snapcraft YAML file, usually located in a snap directory.

    cd hello-snapcraftio
  7. Build the snap, using LXD to drive the containers.

    snapcraft --use-lxd

    Snapcraft usually manages containers with Multipass. Unfortunately, Multipass has outstanding issues on the 64-bit ARM architecture. This can be worked around by using LXD to handle the underlying containers.

    If you run into issues with LXD here, you might try a good old fashioned restart.
  8. Now, install the .snap file created in the current directory by the previous command.

    sudo snap install --devmode --dangerous hello_*.snap
    hello 2.10 installed
  9. And the magic moment, run your new snap!

    snap run hello
    Hello, world!
  10. To clean things up, remove the hello snap.

    sudo snap remove hello

Conclusion

Now you know how to get up and running with building your snap packages locally on a 64-bit ARM device. Happy snapping!


1. Yes, Flatpaks are great too.
2. This isn’t legitimate Ubuntu, as the kernel is maintained by the Armbian project, fyi.