How do I use PackageKit?

Back to the main page

How do I use PackageKit?

If you are writing an application that wants to install packages on demand, and don't care about the low level details, there's a session helper API that you should use. It's much simpler than using PackageKit directly.

Using the command line

The pkcon text-mode program allows you to interact with PackageKit on the command line. For example:

[hughsie@laptop ~]$ pkcon get-updates
[hughsie@hughsie-work PackageKit]$ pkcon get-updates
security    	bluez-utils-3.35-3.fc9                  	Bluetooth utilities
bugfix      	xterm-236-1.fc9                         	Terminal emulator for the X Window System
bugfix      	kernel-devel-          	Development package for building kernel modules to match the kernel
enhancement 	kde-filesystem-4-17.fc9                 	KDE filesystem layout
enhancement 	subversion-1.5.1-1.fc9                  	Modern Version Control System designed to replace CVS


[hughsie@hughsie-work PackageKit]$ pkcon --filter=~devel search name power
installed   	DeviceKit-power-001-0.8.20080811git.fc9 	Power Management Service
installed   	gnome-power-manager-2.23.4-1.118.20080801svn.fc9.hughsie	GNOME Power Manager
installed   	powerman-2.1-1.fc9                      	PowerMan - Power to the Cluster
installed   	powertop-1.9-3.fc9                      	Power consumption monitor
available   	gnome-power-manager-2.22.1-1.fc9        	GNOME Power Manager
available   	kadu-powerkadu-0.6.0-3.fc9              	PowerKadu
available   	kadu-powerkadu-            	PowerKadu
available   	kpowersave-0.7.3-3.fc9                  	KPowersave is the KDE frontend for powermanagement
available   	powerman-1.0.32-5.fc9                   	PowerMan - Power to the Cluster
available   	powermanga-0.90-3                       	Arcade 2D shoot-them-up game

The pkmon program allows you to monitor what PackageKit is doing on the command line and is mainly used for debugging.

The pkgenpack program allows you to generate Service Packs with a package and its dependencies.

Using graphical tools:

gnome-packagekit provides a rich set of GTK tools for automatically updating your computer and installing software. See the screenshots page for more details.

Using libpackagekit:

The libpackagekit gobject library wraps the DBUS interface in a nice glib-style API. This makes designing programs that use libpackagekit can concentrate on core functionality rather that the DBUS and PackageKit internals. PkClient in libpackagekit can be used as easily as:

PkClient *client;
client = pk_client_new ();
pk_client_install_package (client, "openoffice-clipart");
g_object_unref (client);

Using the raw DBUS API:

Using the DBUS methods and signals directly means that no glib or gobject dependency is needed, although this means you will have to manage the transaction_id multiplexing in any client program. This is not difficult, although does require more code than just using libpackagekit. The latest interface is available in the source tree or on-line.

Back to the main page