What if you want to use
stage-packages from Ubuntu 17.04 rather than 16.10 or 16.04 (i.e., you want more up-to-date dependencies)? Well the easy answer is to build your Snappy package on 17.04, good job that you can do that really easily using the LXD snap!
[Note, you can now snap using LXD, but only with Ubuntu 16.04 as the container OS, as far as I’m aware, using
SNAPCRAFT_CONTAINER_BUILDS=1 snapcraft for a persistent LXD container or
snapcraft cleanbuild for a non-persistent LXD container]
First, you’ll want to install LXD
sudo snap install lxd
sudo lxd init
Pick the default options if asked
Use the following command to create a 17.04 container (when there’s a 17.10 LXD thing, you’ll want to use 17.10 instead of 17.04)
sudo lxc launch ubuntu-daily:17.04 my-ubuntu-dev
Open a shell in your new container
sudo lxc shell my-ubuntu-dev
(To start your container in future, you’ll want to use
lxc start my-ubuntu-dev)
Make sure it’s updated, you’ll probably want to do this most times you go into your container so you have the latest dependencies to pull into your snap
apt update ; apt upgrade
Make folders to do your Snapcraft development in with
cd. Then go to the folder you want to build your Snap in, use
vi snapcraft.yaml and
i to start typing. Write your
snapcraft.yaml file. Hit Esc and then type
:x and hit Enterwhen you’re done.
Now install Snapcraft in your container
apt install snapcraft
Build your Snap by running
snapcraft in the directory with your
snapcraft.yaml in it.
Check what your snap is called with
If your snapped application only uses the Terminal, you can install it with
snap install mysnap.snap --dangerous and then run it with
snap run mysnap (or just
Exit your container with, um,
Navigate to the directory you want to put your built snap file, use
lxc file pull my-ubuntu-dev/root/DirectoryMySnapIsIn/mysnap.snap . I got a
permission denied error trying to do this before, you might need to reboot or something (remember to relaunch your container with the command given earlier once you log back in).
Then install your Snap with
sudo snap install mysnap.snap --dangerous, and run it with
snap run mysnap or just
mysnap assuming you don’t have a Deb package installed which uses the same command.
If there’s bugs, go back into your container (with the command to open Bash in your container, given before) and edit your
snapcraft.yaml, rebuild, pull it out, install it, test it etc
This message is a wiki, so please feel free to edit and improve it to match reality.