AppStream 0.6.1 released – a quick look at what you can do with the cli tool

Today I released AppStream and libappstream 0.6.1, which feature mostly bugfixes, so nothing incredibly exciting to see there (but this also means no API/ABI breaks). The release clarifies some paragraphs in the spec which people found confusing, and fixes a few issues (like one example in the docs not being valid AppStream metadata). As only spec extension, we introduce a “priority” property in distro metadata to allow metadata from one repository to override data shipped by another one. This is used (although with a similar syntax) in Fedora already to have “placeholder” data for non-free stuff, which gets overridden by the real metadata if a new application was added. In general, the property tag was added to make the answer to the question “which data is preferred” much less magic.

The libappstream library got some new API to query component data in different ways, and I also brought back support for Vala (so if you missed the Vapi file: It’s back now, although you have to manually enable this feature).

The CLI tool also got some extensions to query AppStream data. Here is a brief introduction:

First of all, we need to make sure the database is up-to-date, which should be the case already (it is rebuilt automatically):

Shell

1

$sudo appstream-index refresh

The database will only be rebuilt when necessary, if you want to force a rebuild anyway, use the “–force” parameter.

Now imagine we want to search for an app containing the word “media” (in description, keywords, summary, …):

Shell

1

$appstream-indexsmedia

which will return:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

Identifier:gnome-media-player.desktop[desktop-app]

Name:GNOME Media Player

Summary:Asimple media player forGNOME

Package:gnome-media-player

----

Identifier:mediaplayer-app.desktop[desktop-app]

Name:Media Player

Summary:Media Player

Package:mediaplayer-app

----

Identifier:kde4__plasma-mediacenter.desktop[desktop-app]

Name:Plasma Media Center

Summary:Amediacenter user interfacewritten with the Plasma framework

Package:plasma-mediacenter

----

etc.

If we already know the name if a .desktop-file or the ID of a component, we can have the tool print out information about the application, including which package it was installed from:

Shell

1

$appstream-index getlyx.desktop

If we want to see more details, including e.g. a screenshot URL and a longer description, we can pass “–details” to the tool:

Okay, so far so good. But now it gets really exciting (and this is a feature added with 0.6.1): We can now query a component by the items it provides. For example, I want to know which software provides the library libfoo.2:

Shell

1

appstream-index what-provides lib libfoo.so.2

This also works with binaries, or Python modules:

Shell

1

appstream-index what-provides bin apper

This stuff works distribution-agnostic, and as long as software ships upstream metadata with a valid <provides/> field, or the distributor adds it while generating AppStream distro metadata.
This means that software can – as soon as we have sufficient metadata of this kind – declare it’s dependencies upstream in form of a simple text file, referencing the needed components to build and run it on any Linux distribution. Users can simply install missing stuff by passing that file to their package manager, which can look up the components->packaging mapping and versions and do the right thing in installing the dependencies. So basically, this allows things “pip -r” does for Python, but for any application (not only Python stuff), and based on the distributors package database.

With the provides-items, we can also scan software to detect it’s dependencies automatically (and have it in a distro-agnostic form directly). We can also easily search for missing mimetype-handlers, missing kernel-modules, missing firmware etc. to install it on-demand, making the system much smarter in handling it’s dependencies. And users don’t need to do search orgies to find the right component for a given task.

Also on my todo list for the future, based on this feature: A small tool telling upstream authors which distribution has their application in which version, using just one command (and AppStream data from multiple distros).

Also planned: A cross-distro information page showing which distros ship which library versions, Python modules and application versions (and also the support status of the distro), so developers know which library versions (or GCC versions etc.) they should at least support to make their application easily available on most distributions.

That’s also one of the things I am looking at. If these specialized package-managers look up the distribution-provided data, they can decide to use the distribution package instead of installing their own one, which duplicates code on a machine (and results in the frequent question “which code is my application actually using, and where do I have to apply bugfixes in case of e.g. a security vulnerability).

Please consider adding pkg-config library names for the provides section. libfoo.so.2 names refer to an ABI but when upstream sources declare their dependencies they should refer to the API which pkg-config comes closer to.