After my last post, praising how easy it is to manually create click packages even if QtCreator doesn’t support that for compiled apps yet, I got requests from various people asking me to share the knowledge. So here is how I did it:
* Build your application for the arm architecture. You can either use a pbuilder environment to create a armhf.deb package and extract it again afterwards or just compile your stuff on the phone (or in an arm chroot). I won’t go into much details on this as I assume everyone writing a C++ app knows how to compile it. Compiling it directly on the phone might be the easiest way to get some binaries for now. Just copy the whole source tree to the phone and just use qmake/cmake and make as used from the desktop.
* Create a new directory and copy all the reqired binaries into that. Also copy QML files, .desktop file and application icon into that directory. In the end, everything required by your application should be in there. Don’t put any stuff in there that shouldn’t end up in the package (e.g. .cpp files, .moc files etc)
* Test running your application from within this directory. Your application should be able to start up from there, not requiring anything to be installed to /usr or similar. In case your C++ code loads QML files, it needs to find them relative to the binary’s location.
* Make sure the .desktop file’s Exec entry starts up the application from the local directory, e.g. calling it as “./myapp” instead of just “myapp”. Also make sure the icon filename is relative to the location of the .desktop file.
* now create a manifest.json. Here’s an example (from uFit) of what it should look like:
"description": "Ubuntu FitBit app",
"maintainer": "Michael Zanetti
* Create <appname>.json file. This one is responsible to request permissions for certain capabilities at AppArmor. This step is the equivalent to the one described here: http://developer.ubuntu.com/publish/packaging-click-apps/
Here’s the example of uFit:
Add any additionally required policy_groups as a comma separated list. Check out the above link for a list of possible values.
* We’re almost done. It’s time to create the package:
# click build <directory>
This should produce the click package ready to be uploaded in the current directory. But wait, you probably want to test it on your phone before actually uploading it, right? So here’s how you do that:
# sudo click install com.ubuntu.developer.<yourID>_<packagename>_<version>.click
# sudo click register --user=phablet com.ubuntu.developer.<yourID>_<packagename> <version>
Now you should be able to find the app by searching the Application lens and you should be able to run it from there. If it doesn’t start, get to a commandline and do this:
# tail -f /home/phablet/.cache/upstart/unity8.log
Watch the output that happens when you try launching the app. It should tell you what’s wrong with it.
Hope this helps!
Very useful tip from Colin in the comments:
You can install and register in one step by passing –user=phablet to click install, but it’s better to just use “pkcon install-local foo.click”.