PackageKitPackagekit is an open source and free suite of software applications designed to provide a consistent and high-level front end for a number of different package management systems. PackageKit itself is a system activated daemon called packagekitd, that abstracts out differences between the different systems. The actual nuts-and-bolts distro tool (yum, apt, conary, etc) is used by PackageKit using compiled and scripted helpers. Those tools (yum, apt, conary, etc) are called the backend for PackageKit. PackageKit isn't meant to replace these tools, instead providing a common set of abstractions that can be used by standard GUI and text mode package managers. It provides C++, python APIs which actually at this currently are not well documented and everything presented here is derived from my studying of the code. InstallationThe recent version of PackageKit is 0.6.6, this is not available in repositories and it should be compiled from sources, which can be found here http://www.packagekit.org/releases/PackageKit-0.6.6.tar.gz . Please check if newer versions are available. While configuring PackageKit dont forget to configure it with following flags ./configure --with-default-backend=yum --enable-yum --prefix=/usr --sysconfdir=/etc --disable-static --disable-local PackageKit daemon is a system activated daemon so you have to point dbus the location of the packagekit's daemon by configuring following file /usr/share/dbus-1/system-services/org.freedesktop.PackageKit.service Restart dbus service sudo /etc/init.d/messagebus restart PackageKit daemon location is /usr/libexec/packagekitd IssueThe attached script failed installing packages with "wetab" user privileges, the reason is not clear yet. That to run script successfully launch it with "sudo". Raw Dbus APIIssuesThe DBus API is defined by PackageKit but it's up to the backends themselves to do the right thing, and support all the different ways of using it. Depending on platform/packagekit version Dbus API may differ, for instance Dbus API in Ubuntu for the same version of PackageKit differed from the Dbus API under MeeGo, as authorof PackageKit said "Ubuntu really needs to update PackageKit to something more up to date." APIObject path : /org/freedesktop/PackageKit Interfaces :
API description can be found here The latest interface is available in the source tree or on-line. HelpThat to see Dbus API on current platform install Dbus debugger called "d-feet". If after launching "d-feet" does not show /org/freedom/PackageKit object path then launch packagekitd daemon manually with super user privilages: sudo /usr/sbin/packagekitd Connect to "unix:path=/var/run/dbus/system_bus_socket" to debug SystemBus
High Level Python APIThere an python class called "PackageKitClient" located in /usr/lib/python2.6/site-packages/packagekit/client.py file, which provides high level interface for package management. Unfortunatelly the class is not well documented and some functions are not working OK. Because of this the packagekit-wrapper-meego.py was implemented, which contains PackageKitClient wrapper class similiar to PackageKitClient implemented in /usr/lib/python2.6/site-packages/packagekit/client.py file. The packagekit-wrapper-meego.py is modifcation/addition of Canonicals packagekit wrapper for MeeGo. Run script with superuser privilegies as currently there is an issue decribed in PackageKit installation section. The PackageKitClient (Attached) Class is written in python and contains methods described below. Also it contains the usage of all described functionalities. The PackageKitClient class provides following methods: Resolve(filter, package) : returns list of matched packages GetDetails(package) : returns the details of the packages SearchName(filter, name) : searches and returnes availlable packages InstallPackage(package, RemovePackage(package, The packagekit-wrapper-meego.py is attached. The mechanisms that are used in class for implementing the methods are same for implementing the same methods in C++ as well. Sample of retrieving Transaction's status using python:
High Level C++ API, using libpackagekitThe libpackagekit gobject librarywraps 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: Code sample
More info can be found here http://packagekit.org/gtk-doc/PkClient.html Mechanism of retrieving progress informationThe org.freedesktop.PackageKit.Transaction interface containes transaction properties (status, percentage, etc) and signal Changed() which is invoked if one of the parameters is changed. So that to get installation/removal progres just connect to the Changed() signal and read off the properties. PolicyKit and PackageKitRunning DBus methods like InstallPacakges, RemovePackages, UpdateSystem and others requires authorization with root account. That to change authorization policies for this and other DBus methods PolicyKit should be configured. How to configure PolicyKit can be found in this blog. That to set policy the action name for the appropriate name should be known for example "InstallPackages" methods action name is "org.freedesktop.packagekit.install-untrusted". Action names can be found the packagekit DBus API description here http://www.packagekit.org/gtk-doc/api-reference.html IssueDepending on configured policies, platform there might be need to set addtional policies for example that authorize SystemUpdate without root password "sudo" also "org.freedesktop.packagekit.install-untrusted" action should be setResultActive=yes . SolutionThat to see the required action names install package "polkit-gnome" which is available in meego repositories. Polkit-gnome will launch a pop-up window if the application requries the autorization. Under details you can see the action which required authorization. Here is a sample which shows action name for package removal
References |
Thursday, August 12, 2010
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment