KDE Updater Applet Extended
From openSUSE
This article is about extending opensuseupdater for kde.
The opensuseupdater is the applet in kde's task bar that informs about availiable updates. It is meant as a lightweight application, therefore not every feature request can be realized. Fortunately opensuseupdater is designed to be extendable.
This document shows two different approaches how to modify your updater. The first one is to create a new backend-plugin. That is the way if you want to use the same user interface and want connect to a different package management system. The second approach is to create your own user interface - for example a text based interface - and you want to use the existing infrastructure to connect to the package management.
Extend the Updater and write your own Backend-plugin
Perhaps you want to use opensuseupdater with a package management system different from zypp.
If you want to write your own backend-plugin you should have some experience in writing qt/kde applications. If not, it's no problem. It isn't that hard and simply copying and pasting code lines might help you to create your own backend-plugin. :-) The source code is located here: http://svn.opensuse.org/svn/zypp/trunk/updater-kde
You only need to implement constructor, destructor and following member functions:
void populateLists(QListView *patchList, QListView *packageList, bool silent)
When this function is called you need to search for updates and provide a list with patches and a list with packages. The silent flag tells whether the user wants to see a progress window or not. Afterwards emit populateDone().
void resolvableSelected(QListViewItem *item, int resolvableType)
The user has selected a resolvable. Please provide a description via:
emit returnDescription("dummy description", resolvableType)
void startInstall()
Start the installation of the selected packages.
void configureUpdater()
This function is called when the user wants to add or remove repositories.
Write your own Updater and use the Updater's Mechanism to connect to the Package Management
If you want to write your own update program or an update script you can use the opensuseupdater's way to read the updates list and install updates. This paragraph shows how to get a list of available updates and how to install updates.
There is a simple command to get information about available patches and packages. Just call /usr/sbin/zypp-checkpatches-wrapper, its output is xml that contains everything your program needs to know about available patches and packages. When your program has shown available updates and the user has selected some of them you want to install them. The task of patch and package installation is provided by zypper. You can call zypper -q --terse --non-interactive in -t patch <name_0> <name_1> ... <name_n> to install patches and zypper -q --terse --non-interactive in -t package <name_0> <name_1> ... <name_n>
to install packages as user root. If you your updater runs with user priviliges you might want to use sudo or kdesu.
Zypper's output is xml that contains status und error messages that your program can parse and give feedback to the user.
Note: The next version of zypper will provide an easier way to install updates.

