I've been trying snappy Ubuntu core on a Raspberry Pi 2 device, and I've heard I can use Snapcraft to do development on it. Now I hear that snaps are available on the desktop and server for Ubuntu 16.04 and other distros.
What is Snapcraft and how can I use it?
Snapcraft is a set of tools bundled under the
snapcraft
command to easily create (craft) packages for multiple Linux distributions. These .snap packages generally contain self-contained apps, provide secure isolation and are installable either from the Ubuntu Software Store or manually via thesnap install <snap-name>.snap
command.In a nutshell, as a developer you would write code using your regular tools, and let Snapcraft take care of assembling it for distribution. Snapcraft also excels in enabling developers port their existing apps to any snap-enabled Linux platform.
Snapcraft:
snapcraft.yaml
file that specifies the parts and plugins required to create the packageThe 3-minute Snapcraft tour
Install Snapcraft on Ubuntu
You will need Ubuntu 16.04 LTS to use Snapcraft. Open a terminal with Ctrl+Alt+t and simply install Snapcraft with this command:
If you are using another distro, check out the alternative installation instructions >
Test-drive Snapcraft
The following example crafts a package that contains a service that allows you to paste and share. Once finished, you can install it manually on your snappy device for testing purposes or upload it to the Store for other users.
First of all we open a terminal and download the example from the examples repository:
Notice the
snapcraft.yaml
file in that directory, which specifies a service and the parts required to assemble the final .snap. You can optionally examine it with a text editor.Now run the
snapcraft
command on the terminal. This will cause all snapcraft subcommands to run in sequence to build the parts and put the results in the final .snap package. During development, you would normally run the steps separately until you are confident that the whole build and assembly works.On the output of the command you can see the steps snapcraft runs for you:
Notes:
gopaste_1.0_amd64.snap
(notice in my case I built it on my amd64 desktop, e.g. Raspberry Pi 2 packages would have the_armhf
architecture suffix).snapcraft pull
,snapcraft build
,snapcraft stage
orsnapcraft snap
snapcraft -h
for a quick overview of all commands available.And that's it for a quick glimpse of what Snapcraft can do! Learn more about Snapcraft >