LWN.net Logo

Ubuntu's app store and package format

By Nathan Willis
September 5, 2013

As Ubuntu continues its march toward Ubuntu-based mobile devices, it has undertaken a number of efforts designed to attract third-party mobile app developers. The latest development is the beta launch of the project's mobile app store, which is tied with an app-development contest slated to run through September 15. Perhaps more interesting in the long run, though, is the publication of the specifications for how the platform's mobile apps are to be packaged. The format is called Click, and it is related to the .deb package format used for standard Ubuntu packages—but with a few key changes.

Martin Albisetti announced the opening of the app store and the publication of the package format documentation in an August 30 blog post. The Ubuntu Touch store is only accessible by registered developers for the time being; they can upload packages to the Ubuntu "MyApps" service. Uploads are then subject to a manual review process before they are published.

The process is much the same as the one offered to third-party developers of desktop applications seeking publication in the Ubuntu Software Center service, except that mobile apps can only be written for the APIs supported by the Ubuntu SDK. At the moment, just two app frameworks are supported—QML and HTML5—with HTML5 support relying on the Apache Cordova library layer.

Support for compiled apps is apparently under discussion, although no clear timetable has been publicized. One open question on that front is how to encourage app developers to license their code under GPL-compatible terms; for the contest, this is important because the winning entries will be included in subsequent Ubuntu Touch builds. Since apps written in QML and HTML are (at least in theory) their own source code, not handling binary apps neatly sidesteps the question. For the time being, the app store does not support selling apps, although that feature is expected to arrive eventually as well.

Click, here

To put an app store in place, of course, one must have some idea of what format apps will take. The format defined for Ubuntu Touch is called "Click," using the .click file extension—although there are copious caveats that the actual name of the format could still change before the Ubuntu Touch app store opens to the public. Click is derived from the .deb Debian package format, and in most ways a .click file is a valid .deb file too. Consequently, the distinct file extension helps to make it less likely that a user will attempt to install a .click app using dpkg or Apt.

There is HTML documentation on the format available, but a newer revision of the specification can be found in the Click source repository on Launchpad. There was a lengthy debate on the ubuntu-devel mailing list about the suitability of existing package formats, such as Android's .apk and cross-platform efforts like Listaller. In the end, Colin Watson said that:

[...] existing app packaging systems are more of a reflection of the system they were built for than anything else. If you look at, say, Android's APK format, it's essentially a zip file with a manifest and some conventions about Dalvik class installation and the like. Most of the other mobile app formats are similar.

Similarly, by basing Click on the Debian package format already in use, many of the existing package tools can be reused. Like a .deb, a .click package is an ar archive, which itself contains "control" and "data" tar archives. The control archive includes package management information, while the data archive holds the app's filesystem.

Click apps are designed to be self-contained; the directory tree in the package's data archive is unpacked into a single directory and cannot access the filesystem above its own root. The app filesystem is uncompressed and stays on disk, though—as opposed to being stored as a compressed image and loop-mounted.

The control archive must contain both a control file and a manifest.json file. The manifest includes several required fields like app name, app version, and installed size, and may include several optional fields as well (such as maintainer information, a reference to the app's icon, or descriptions in various languages). The control file duplicates some of this manifest information for use by the package-management tools, and it also includes a field listing the version number of the Click format used.

Because Click apps are meant to be stand-alone entities, some of the manifest and control fields diverge somewhat from their equivalents in a standard Debian package. The app name is specified in reverse-network-domain name format like com.example.catpictures, which is the same scheme used in D-Bus, in Android app naming, and in plenty of other places. The "framework" field is a simplified version of the Debian package format's way to specify dependencies. Click apps cannot have dependencies on anything other than base system services. In other words, they cannot introduce dependencies on other apps or on components installed through other means, and they cannot depend on specific versions of system libraries (which in the worst-case scenario could make dependencies unresolvable). As such, for now the only valid value for "framework" is the current Ubuntu Touch SDK framework. Perhaps in the future, different versions of the framework will need to be designated, or non-phone form factors will require separate frameworks, but this has not been explored in the documentation.

But the fact that Click apps cannot have dependencies has benefits beyond simply avoiding dependency hell. Since Click apps are isolated from system packages, the app installer can install them without querying or searching the system's dpkg database—which can be quite slow relative to unpacking a tar archive to disk.

Another—perhaps major—distinction from the Debian package format is that maintainer scripts (such as preinst, postinst, or prerm) are forbidden. This is to isolate Click apps from the system; since they are intended to be self-contained, they should not generally trigger any system-level events which could potentially be exploited. Not allowing them makes the task of auditing app submissions considerably simpler. There is one exception to the general maintainer-script moratorium: apps can include a preinst script that prevents the package from being installed directly with dpkg.

Hook 'em

On the downside, however, one useful feature lost in disabling maintainer scripts is the ability to easily hook into system services at install time. Even for self-contained apps, there are a number of system packages that need to be informed of the installation, such as updating the icon cache to include the new app's icon, locating the .desktop launcher to add to the app menu, or registering a service with D-Bus.

But Ubuntu Touch still needs to alert system services to the app-installation event somehow. Currently the plan is to use a "hook" mechanism inspired by dpkg's triggers. Triggers are calls out to other programs that are generally placed in a Debian package's postinst script. A trigger mechanism could, for example, tell Fontconfig to update the font info cache and pick up a newly-installed font. The problem with this approach is that Click packages can be installed to any directory on the system. That is to say, there is no fixed location for them; the directory name for an app is created based on a hash. This approach enables the updating of apps by installing the new version in a separate directory, then garbage-collecting the old one. The unpleasant side-effect is that, in this example, Fontconfig needs some way to learn which directory it should scan to update its cache. Dpkg triggers cannot pass user data, so apps cannot simply report their location through the trigger mechanism.

The "hooks" solution works by enumerating a stable, well-known set of services that need to perform such post-app-installation updates. Each app is responsible for listing the hooks that it needs to call in its manifest file. The hooks field lists the hooks used and the relative pathname of each new resource (e.g., fonts, icons, or .desktop files) within the app's filesystem. The app installer is then responsible for creating a symlink from the newly-installed app resource to the canonical location for such resources. Based on the examples in the hook documentation, there will be separate directories for these symlinks, so that new .desktop entries might be placed in /opt/click.ubuntu.com/.click/desktop-files/ as opposed to /usr/share/applications/.

Still to come

The Click format is still in rapid development; although the current app store contest ends in mid-September, there is no indication when the mobile app store itself will go live to the public. But that probably matters little while there are no Ubuntu Touch devices in widespread distribution.

There are still several unanswered questions, such as how best to support "fat" packages built for multiple architectures, and how to implement security signatures. For now, the selected approach to signatures is to use debsigs. Developers will sign their uploads to the app store, and the store maintainers will verify those signatures. When the app is pushed out to users, it will carry the store's signature, which is all that end-user devices are expected to verify.

The format may still undergo significant changes before any Ubuntu Touch devices hit the market, as may the upload and review processes used for Click apps. However, it does seem likely that the format will retain its roots in the .deb package format; the Click installer reuses dpkg code in a number of places, even if third-party apps are destined to remain in total isolation from the rest of an Ubuntu Touch system.


(Log in to post comments)

Ubuntu's app store and package format

Posted Sep 6, 2013 7:08 UTC (Fri) by michaeljt (subscriber, #39183) [Link]

> On the downside, however, one useful feature lost in disabling maintainer scripts is the ability to easily hook into system services at install time. Even for self-contained apps, there are a number of system packages that need to be informed of the installation, such as updating the icon cache to include the new app's icon, locating the .desktop launcher to add to the app menu, or registering a service with D-Bus.

In my limited experience, OS X applications tend to solve this by doing any integration - per user - the first time they are started. (That works of course because it is pretty clear how to start them after copying them onto the system.)

Ubuntu's app store and package format

Posted Sep 6, 2013 7:15 UTC (Fri) by dlang (✭ supporter ✭, #313) [Link]

forbidding maintainer scripts sure simplifies things, but since those are the places where data conversion and cleanups take place, I hope that their exclusion doesn't lead to too many problems later.

installing applications in their own directory and forbidding any access outside of that directory is another wonderful simplification, but it only works for simple apps, or apps that you are ok with them having their own private (effectively proprietary) file format. any app that deals with a standard file format is a poor candidate for such packaging as you are sure to end up with a case where you want to open a file created by one app in a different app.

Ubuntu's app store and package format

Posted Sep 6, 2013 9:31 UTC (Fri) by nhippi (subscriber, #34640) [Link]

Data conversions can be handled when the upgraded app starts the first time. dpkg/apt reacts badly if maintainer scripts fail, assuming the user will want to repair dpkg/apt state manually - a no go for consumer devices.

Opening files is probably done with a separate API. Something similar to Android Intent, dunno if ubuntu touch already has or it is under plans.

I think click is a wonderful simplification for simple apps. It still needs native code to become useful, and hopefully it could be adopted by others as well.

Ubuntu's app store and package format

Posted Sep 6, 2013 14:34 UTC (Fri) by dashesy (subscriber, #74652) [Link]

But what sort of app is not simple? Ubuntu click (app bundle) can handle the most complicated scenarios just fine, please let me know if you have example to the contrary.

Ubuntu's app store and package format

Posted Sep 10, 2013 5:14 UTC (Tue) by lsl (subscriber, #86508) [Link]

To allow an app access to data files created by other programs you plan to use some kind of file picker, right? Is it possible to choose whole hierarchies with it?

If not, we certainly won't see a logrotate or tmpwatch app. Even a grep app would be a pain to use. 😉

Ubuntu's app store and package format

Posted Sep 10, 2013 17:22 UTC (Tue) by mathstuf (subscriber, #69389) [Link]

I don't think the programs you listed are intended to be packaged up as apps.

Source != GPL

Posted Sep 6, 2013 21:40 UTC (Fri) by jmorris42 (subscriber, #2203) [Link]

> One open question on that front is how to encourage app developers to
> license their code under GPL-compatible terms; for the contest, this is
> important because the winning entries will be included in subsequent
> Ubuntu Touch builds. Since apps written in QML and HTML are (at least in
> theory) their own source code, not handling binary apps neatly sidesteps
> the question.

Huh? It is 2013, if LWN editors still make this mistake it isn't a shock that most of the corporate world is still confused.

The availability of source is totally orthogonal to GPL compatibility. Microsoft could include a source DVD in the full retail box and still license it under exactly the same EULA.

I have been saying for years we should push to modify the copyright laws to require exactly that. The reasoning being that copyright is only permitted to advance science and the useful arts and that can't happen without release of the source. Only source code should be eligible for a copyright and binaries only considered as derived works only made available to owners of the copyrighted work.

Source != GPL

Posted Sep 10, 2013 15:29 UTC (Tue) by n8willis (editor, #43041) [Link]

Microsoft could include a source DVD in the full retail box and still license it under exactly the same EULA.

Perhaps they could, but that is not relevant. Canonical, however, could not ship a compiled GPL app created by a third-party developer as part of an Ubuntu Touch image without also making the corresponding source available, which is the issue here.

Nate

Source != GPL

Posted Sep 10, 2013 16:15 UTC (Tue) by jmorris42 (subscriber, #2203) [Link]

Why not? The GPL hasn't stopped compiled binaries from legally being in the Play Store. All you have to do is make source available, you aren't required to ship it to every person who downloads the binary. A simple link on the description page would satisfy the GPL.

Source != GPL

Posted Sep 10, 2013 17:37 UTC (Tue) by n8willis (editor, #43041) [Link]

A simple link on the description page would satisfy the GPL.

That would be "making the corresponding source available." Perhaps that's precisely what they'll do; we don't know yet.

Nate

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds