How I built the snap packages for my snappy demo using snapcraft

(This post is part of a series on how to get started with packaging your IoT apps for the snappy Ubuntu Core.)

Inside the lxc container, let’s switch to the “ubuntu” user, and clone my git repo:

root@my-ubuntu:~# su -l ubuntu
ubuntu@my-ubuntu:~$ git clone
Cloning into 'minecraft-minimu9'...
remote: Counting objects: 30, done.
remote: Total 30 (delta 0), reused 0 (delta 0), pack-reused 30
Unpacking objects: 100% (30/30), done.
Checking connectivity... done.
ubuntu@my-ubuntu:~$ cd minecraft-minimu9

The repository contains a snapcraft.yaml file, that tells snapcraft what steps are needed to build it. Let’s try that:

ubuntu@my-ubuntu:~/minecraft-minimu9$ snapcraft
Pulling glue 
Building glue 
cp --preserve=all -R html /home/ubuntu/minecraft-minimu9/parts/glue/install/html
Staging glue 
Snapping glue 
Pulling spjs 
env GOPATH=/home/ubuntu/minecraft-minimu9/parts/spjs/build go get -t -d
Building spjs 
env GOPATH=/home/ubuntu/minecraft-minimu9/parts/spjs/build go build
env GOPATH=/home/ubuntu/minecraft-minimu9/parts/spjs/build go install
env GOPATH=/home/ubuntu/minecraft-minimu9/parts/spjs/build cp -a /home/ubuntu/minecraft-minimu9/parts/spjs/build/bin /home/ubuntu/minecraft-minimu9/parts/spjs/install
Staging spjs 
Snapping spjs 
Generated 'minecraft-minimu9_1_armhf.snap' snap

This will produce a minecraft-minimu9_1_armhf.snap file that we can install in the base system, like this:

(RaspberryPi2)ubuntu@localhost:~$ sudo snappy install --allow-unauthenticated \ ~/my-ubuntu-home/minecraft-minimu9/minecraft-minimu9_1_armhf.snap 
Installing /home/ubuntu/my-ubuntu-home/minecraft-minimu9/minecraft-minimu9_1_armhf.snap
2015/11/14 04:51:20.191703 verify.go:85: Signature check failed, but installing anyway as requested
Name              Date       Version      Developer 
ubuntu-core       2015-11-13 3            ubuntu    
lxd               2015-11-14 0.21-1       stgraber  
minecraft-minimu9 2015-11-14 IFTYLfgMVOad sideload  
webdm             2015-11-13 0.9.4        canonical 
pi2               2015-11-13 0.16         canonical 

Since it’s trying to access the serial port, and everything under snappy runs confined, we can give access to the package like this:

(RaspberryPi2)ubuntu@localhost:~$ sudo snappy hw-assign minecraft-minimu9.sideload \ /dev/ttyACM0
'minecraft-minimu9.sideload' is now allowed to access '/dev/ttyACM0'

And with that we have our snap package installed, running and able to access the hardware port.

We can try our demo by pointing a browser at port 8989 of the raspbi’s IP address, eg: and we should see the minecraft demo page loading and updating as we move the MinIMU-9.