We want to enable all kinds of developers to quickly make applications and devices using Snappy as their basis. A quick way to make compelling user interfaces is by using QML, so it seemed like a natural fit to get QML working in snapcraft to eliminate complex setups, and just get things working. There is an Introduction to Snapcraft, I'm going to assume you've already read that.
To get started with an interesting demo I went and stole the Qt photoviewer demo and pulled it into its' own repository, then added a couple simple configuration files. This is a great demo because it is graphical and fun, but also shows pulling data from the network as all the photos are based on Flickr tags.
parts: qml: plugin: qml photoviewer: plugin: copy files: main.qml: main.qml PhotoViewerCore: PhotoViewerCore snappy-metadata: meta
The snapcraft.yaml file includes two parts. The first part is the QML plug in which includes all the pieces needed to run QML programs from the Ubuntu archive. The second is the copy plugin which copies our QML files into the snap. We don't have a build system in this example so copy is all we need, more complex examples could use the cmake or autotools plugins instead.
The last item in the snapcraft.yaml tells Snapcraft where to find the packaging information for Snappy. In the meta directory we have a packages.yaml that is a standard Snappy package file.
name: photoviewer version: 0.1 vendor: Ted Gould <[email protected]> frameworks: [mir] binaries: - name: photoviewer exec: qmlscene main.qml -- caps: - mir_client - network-client
It configures a binary that will be set up by Snappy, which is simply a call to qmlscene with our base QML file. This will then get wrapped up into a single binary in /apps/bin that we can execute.
We need to now turn this directory into a snap. You should follow the instructions to install snapcraft, and then you can just call it in that directory:
There are a few ways to set up a Snappy system, the one that I've used here is with QEMU on my development system. That makes it easy to develop and test with, and currently the Mir snap is only available for amd64. After getting snappy setup you'll need to grab the Mir framework from the store and install the snap we just built.
$ sudo snappy install mir $ sudo snappy install --allow-unauthenticated photoviewer_1.0_amd64.snap
You can then run the photoviewer:
And you should have something like this on your display:
While this is a simple demo of what can be done with QML, it can be expanded to enable all kinds of devices from displaying information on a network service or providing UI for a small IoT device.
posted Aug 6, 2015 | permanent link