I am working on a snap of a bigger piece of software and building the snap, removing the old one, installing the new one just takes a very long time.
I would like to iterate over creating the snap and testing things out more quickly. I know that the snap builds just fine, now I'm interested in testing things like launching the app and its integration. Is there a way to do this?
Best Answer
Preface
One way to go about this is to use
snap try
. From its--help
message:It also comes with an option:
This is particularly helpful if you want to test confinement bits and getting the use of interfaces right.
Usage
The way to use this is simple, just run:
In the first step you tell
snapcraft
to do theAnd in the second step
snapd
makes use of the contents of the directory to "install" the snap. Now you can play around with the package while still being able to make changes to it.Example
Let's use an example from the Snappy Playpen to show how to use this.
We are using consul as it's relatively quick to build and use:
Now let's make sure that we don't have another version installed of it and then proceed with the installation.
So far so good. It seems to work just fine. Now let's replace it with
/bin/echo
just to see how things work:As you can see, we can make changes to the live system in
prime
while still running things under confinement. This is generally a good way to get the snap up and running and fully tested quickly.Note: With
snapd
before 2.0.10 (2016-07-09), you had to temove the snap before runningsnapcraft clean
orsnapd
would get into a bad state and whine about being unable to find mounted snaps. Some more fixes are lined up for 2.0.11, which should land in a few days as well.