Development/Tutorials/PackageKit Session Interface

From KDE TechBase
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

What is PackageKit

PackageKit is an abstraction layer for basic package managing. Whether by basic it means providing what non technical users really need (searching/installing/removing/updating...). I is not intended to replace your package management, but to provide a single way of doing things. It's API is exported through a DBus interface, having glib, qt and python bindings. PolicyKit is also used so that you have a fine grained policy for your users.

This project is held by the free desktop umbrella, and has backends for several package managers (http://www.packagekit.org/pk-matrix.html). But although this API is abstracts enough the package manager it is still too complex for applications that just want fonts, drivers, plugins etc.

What is PackageKit Session Interface

PackageKit Session Interface is the interface to be used by applications that don't want to know how package managing is done. They will care only about on checking if a package is installed or installing packages.

This topic raised a lot of discussions on KDE mailing lists, because random applications can ask users to install softwares. In the end this interface does not allow you to install random software, since it can only install things from your repositories. I will not enter in the merit of this discussion, since it's pointless as some like this approach and others do not.

If you don't like you can just disable it on your distribution, if you like use it :D

And it is available from the two GUI KPackageKit (Apper) and GNOME-PackageKit.

What this Tutorial is about then

Well as the title says PackageKit Session Interface, I'll cover the API details so that you can make your application use it.

DBus has basically two connections types the Session and the System. System interfaces normally run as root (otherwise they need rights to use it), on the other hand the session connections runs on the user session. These two connections do not talk to each other.

As your application will be running as user (otherwise you could just install it yourself :P), then we export this interface on the user session. Also there is no binding to this API, it's just exposed on the bus in the examples I will be using QtDBus but you can use perl, python...


Interfaces

There are two DBus interfaces exposed on the session. Query and Modify, as their names suggests query is used for querying packages and modify used to modify packages (i.e install)

Query

IsInstalled
Used to query if an specific package is installed
SearchFile
Used to find out if an specific file is inside some package be it installed or available.

Modify

InstallPackageFiles
Installs local package files or service packs.
InstallProvideFiles
Installs packages that provide the files.
InstallCatalogs
Installs specified package catalogs.
InstallPackageNames
Installs packages from a configured software source.
InstallMimeTypes
Installs mimetype handlers from a configured software source.
InstallFontconfigResources
Installs fontconfig resources (usually fonts) from a configured software source.
InstallGStreamerResources
Installs GStreamer fontconfig resources (usually codecs) from a configured software source.
RemovePackageByFile
Removes packages that provide the given local files.
InstallPrinterDrivers
Installs printer drivers from a configured software source.