[packagekit] packagekit: Branch 'master' - 6 commits

Richard Hughes hughsient at kemper.freedesktop.org
Mon Oct 29 12:01:21 PDT 2007


 backends/box/pk-backend-box.c      |   76 +++++++++++-
 backends/yum/helpers/yumBackend.py |  220 +++++++++++++++++++++++++++++++++++--
 html/pk-faq.html                   |    6 -
 libpackagekit/pk-enum.c            |    4 
 libpackagekit/pk-enum.h            |    4 
 python/packagekit/backend.py       |   17 ++
 6 files changed, 309 insertions(+), 18 deletions(-)

New commits:
commit edaa8b189b97f8266b71156c53908484f087f8ff
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Oct 29 18:51:14 2007 +0000

    add cleanup and obsoleting into the API

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index d74f28b..e57efe9 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -49,6 +49,8 @@ static PkEnumMatch enum_status[] = {
 	{PK_STATUS_ENUM_DOWNLOAD,		"download"},
 	{PK_STATUS_ENUM_INSTALL,		"install"},
 	{PK_STATUS_ENUM_UPDATE,			"update"},
+	{PK_STATUS_ENUM_CLEANUP,		"cleanup"},
+	{PK_STATUS_ENUM_OBSOLETE,		"obsolete"},
 	{0, NULL},
 };
 
@@ -167,6 +169,8 @@ static PkEnumMatch enum_info[] = {
 	{PK_INFO_ENUM_UPDATING,			"updating"},
 	{PK_INFO_ENUM_INSTALLING,		"installing"},
 	{PK_INFO_ENUM_REMOVING,			"removing"},
+	{PK_INFO_ENUM_CLEANUP,			"cleanup"},
+	{PK_INFO_ENUM_OBSOLETING,		"obsoleting"},
 	{0, NULL},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 51ad133..31d35db 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -69,6 +69,8 @@ typedef enum {
 	PK_STATUS_ENUM_DOWNLOAD,
 	PK_STATUS_ENUM_INSTALL,
 	PK_STATUS_ENUM_UPDATE,
+	PK_STATUS_ENUM_CLEANUP,
+	PK_STATUS_ENUM_OBSOLETE,
 	PK_STATUS_ENUM_UNKNOWN
 } PkStatusEnum;
 
@@ -161,6 +163,8 @@ typedef enum {
 	PK_INFO_ENUM_UPDATING,
 	PK_INFO_ENUM_INSTALLING,
 	PK_INFO_ENUM_REMOVING,
+	PK_INFO_ENUM_CLEANUP,
+	PK_INFO_ENUM_OBSOLETING,
 	PK_INFO_ENUM_UNKNOWN
 } PkInfoEnum;
 
commit 58e60d833513fd93e3f5bb10a100e5f13fd7467c
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Mon Oct 29 18:19:46 2007 +0000

    [box] implemented repo_set_data()

diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index b5d22fd..4c2ef09 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -669,6 +669,21 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
         pk_backend_finished (backend);
 }
 
+/**
+ * backend_repo_set_data:
+ */
+static void
+backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parameter, const gchar *value)
+{
+	g_return_if_fail (backend != NULL);
+
+	if (!box_repos_set_param (rid, parameter, value))
+	{
+		pk_warning ("Cannot set PARAMETER '%s' TO '%s' for REPO '%s'", parameter, value, rid);
+	}
+
+	pk_backend_finished (backend);
+}
 
 
 PK_BACKEND_OPTIONS (
@@ -700,6 +715,6 @@ PK_BACKEND_OPTIONS (
 	backend_update_system,			/* update_system */
 	backend_get_repo_list,			/* get_repo_list */
 	backend_repo_enable,			/* repo_enable */
-	NULL					/* repo_set_data */
+	backend_repo_set_data			/* repo_set_data */
 );
 
diff --git a/html/pk-faq.html b/html/pk-faq.html
index 764a787..e1f733c 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -44,7 +44,7 @@ get-files         |        |  X  |     |  X  |      |       |      |
 get-update-detail |        |     |     |     |      |       |      |
 get-repo-list     |        |  X  |     |  X  |  X   |   X   |   X  |
 repo-enable       |        |  X  |     |  X  |      |   X   |      |
-repo-set-data     |        |     |     |     |      |       |   X  |
+repo-set-data     |        |     |     |  X  |      |       |   X  |
 cancel-transaction|        |     |     |     |      |       |   X  |
 </pre>
 
commit 6fd27b2341ee62b1311e4b89890cca0fb70c60c9
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Mon Oct 29 18:00:34 2007 +0000

    get-files is implemented by box backend

diff --git a/html/pk-faq.html b/html/pk-faq.html
index 691fb9c..764a787 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -40,7 +40,7 @@ update-package    |        |  X  |     |  X  |      |   X   |   X  |
 get-depends       |        |  X  |     |  X  |      |       |   X  |
 get-requires      |   X    |     |     |  X  |      |       |   X  |
 get-description   |   X    |  X  |  X  |  X  |      |   X   |   X  |
-get-files         |        |  X  |     |     |      |       |      |
+get-files         |        |  X  |     |  X  |      |       |      |
 get-update-detail |        |     |     |     |      |       |      |
 get-repo-list     |        |  X  |     |  X  |  X   |   X   |   X  |
 repo-enable       |        |  X  |     |  X  |      |   X   |      |
commit 96f84167ab0dbe706145dba8443ba626273e0784
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Mon Oct 29 17:58:47 2007 +0000

    [box] implemented get_files()

diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 397865a..b5d22fd 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -269,7 +269,6 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 	PackageSearch *ps;
 	GList *list;
 	ThreadData *d = (ThreadData*) data;
-	gchar *files;
 	sqlite3 *db;
 
 	db = db_open();
@@ -299,15 +298,46 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 	}
 	ps = (PackageSearch*) list->data;
 
-	files = box_db_repos_get_files_string (db, pi->name, pi->version);
-
-	pk_backend_description (backend, pi->name, "unknown", PK_GROUP_ENUM_OTHER, ps->description, "", 0, files);
+	pk_backend_description (backend, pi->name, "unknown", PK_GROUP_ENUM_OTHER, ps->description, "", 0, NULL);
 
 	pk_package_id_free (pi);
 	box_db_repos_package_list_free (list);
 
 	db_close(db);
 
+	g_free (d->package_id);
+	g_free (d);
+
+	return TRUE;
+}
+
+static gboolean
+backend_get_files_thread (PkBackend *backend, gpointer data)
+{
+	PkPackageId *pi;
+	ThreadData *d = (ThreadData*) data;
+	gchar *files;
+	sqlite3 *db;
+
+	db = db_open();
+
+	pi = pk_package_id_new_from_string (d->package_id);
+	if (pi == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+		pk_package_id_free (pi);
+		db_close (db);
+		g_free (d->package_id);
+		g_free (d);
+		return FALSE;
+	}
+
+	files = box_db_repos_get_files_string (db, pi->name, pi->version);
+        pk_backend_files (backend, d->package_id, files);
+
+	pk_package_id_free (pi);
+
+	db_close(db);
+
 	g_free (files);
 	g_free (d->package_id);
 	g_free (d);
@@ -427,6 +457,25 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 }
 
 /**
+ * backend_get_files:
+ */
+static void
+backend_get_files (PkBackend *backend, const gchar *package_id)
+{
+	ThreadData *data = g_new0(ThreadData, 1);
+
+	g_return_if_fail (backend != NULL);
+
+	if (data == NULL) {
+		pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory");
+		pk_backend_finished (backend);
+	} else {
+		data->package_id = g_strdup(package_id);
+		pk_backend_thread_helper (backend, backend_get_files_thread, data);
+	}
+}
+
+/**
  * backend_get_requires:
  */
 static void
@@ -633,7 +682,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* cancel */
 	backend_get_depends,			/* get_depends */
 	backend_get_description,		/* get_description */
-	NULL,					/* get_files */
+	backend_get_files,			/* get_files */
 	backend_get_requires,			/* get_requires */
 	NULL,					/* get_update_detail */
 	backend_get_updates,			/* get_updates */
commit 4a95ab0e61ee84d18cd5e4198ef0aff48cf61732
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Mon Oct 29 13:03:22 2007 +0100

    yum: implemented search-group

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 34980db..034920a 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -44,6 +44,149 @@ from packagekit.backend import PackagekitProgress
 yumbase = None
 progress = PackagekitProgress()  # Progress object to store the progress
 
+groupMap = {          
+'desktops;gnome-desktop'                      : GROUP_SYSTEM, 
+'desktops;window-managers'                    : GROUP_SYSTEM, 
+'desktops;kde-desktop'                        : GROUP_SYSTEM, 
+'desktops;xfce-desktop'                       : GROUP_SYSTEM, 
+'apps;authoring-and-publishing'               : GROUP_OFFICE, 
+'apps;office'                                 : GROUP_OFFICE, 
+'apps;sound-and-video'                        : GROUP_MULTIMEDIA, 
+'apps;editors'                                : GROUP_OFFICE, 
+'apps;engineering-and-scientific'             : GROUP_OTHER, 
+'apps;games'                                  : GROUP_GAMES, 
+'apps;graphics'                               : GROUP_GRAPHICS, 
+'apps;text-internet'                          : GROUP_INTERNET, 
+'apps;graphical-internet'                     : GROUP_INTERNET, 
+'apps;education'                              : GROUP_EDUCATION, 
+'development;kde-software-development'        : GROUP_PROGRAMMING, 
+'development;gnome-software-development'      : GROUP_PROGRAMMING, 
+'development;development-tools'               : GROUP_PROGRAMMING, 
+'development;eclipse'                         : GROUP_PROGRAMMING, 
+'development;development-libs'                : GROUP_PROGRAMMING, 
+'development;x-software-development'          : GROUP_PROGRAMMING, 
+'development;web-development'                 : GROUP_PROGRAMMING, 
+'development;legacy-software-development'     : GROUP_PROGRAMMING, 
+'development;ruby'                            : GROUP_PROGRAMMING, 
+'development;java-development'                : GROUP_PROGRAMMING, 
+'development;xfce-software-development'       : GROUP_PROGRAMMING, 
+'servers;clustering'                          : GROUP_OTHER, 
+'servers;dns-server'                          : GROUP_OTHER, 
+'servers;server-cfg'                          : GROUP_OTHER, 
+'servers;news-server'                         : GROUP_OTHER, 
+'servers;web-server'                          : GROUP_OTHER, 
+'servers;smb-server'                          : GROUP_OTHER, 
+'servers;sql-server'                          : GROUP_OTHER, 
+'servers;ftp-server'                          : GROUP_OTHER, 
+'servers;printing'                            : GROUP_OTHER, 
+'servers;mysql'                               : GROUP_OTHER, 
+'servers;mail-server'                         : GROUP_OTHER, 
+'servers;network-server'                      : GROUP_OTHER, 
+'servers;legacy-network-server'               : GROUP_OTHER, 
+'base-system;java'                            : GROUP_SYSTEM, 
+'base-system;base-x'                          : GROUP_SYSTEM, 
+'base-system;system-tools'                    : GROUP_SYSTEM, 
+'base-system;fonts'                           : GROUP_SYSTEM, 
+'base-system;hardware-support'                : GROUP_SYSTEM, 
+'base-system;dial-up'                         : GROUP_SYSTEM, 
+'base-system;admin-tools'                     : GROUP_SYSTEM, 
+'base-system;legacy-software-support'         : GROUP_SYSTEM, 
+'base-system;base'                            : GROUP_SYSTEM, 
+'base-system;virtualization'                  : GROUP_SYSTEM, 
+'base-system;legacy-fonts'                    : GROUP_SYSTEM, 
+'language-support;khmer-support'              : GROUP_OTHER, 
+'language-support;persian-support'            : GROUP_OTHER, 
+'language-support;georgian-support'           : GROUP_OTHER, 
+'language-support;malay-support'              : GROUP_OTHER, 
+'language-support;tonga-support'              : GROUP_OTHER, 
+'language-support;portuguese-support'         : GROUP_OTHER, 
+'language-support;japanese-support'           : GROUP_OTHER, 
+'language-support;hungarian-support'          : GROUP_OTHER, 
+'language-support;somali-support'             : GROUP_OTHER, 
+'language-support;punjabi-support'            : GROUP_OTHER, 
+'language-support;bhutanese-support'          : GROUP_OTHER, 
+'language-support;british-support'            : GROUP_OTHER, 
+'language-support;korean-support'             : GROUP_OTHER, 
+'language-support;lao-support'                : GROUP_OTHER, 
+'language-support;inuktitut-support'          : GROUP_OTHER, 
+'language-support;german-support'             : GROUP_OTHER, 
+'language-support;hindi-support'              : GROUP_OTHER, 
+'language-support;faeroese-support'           : GROUP_OTHER, 
+'language-support;swedish-support'            : GROUP_OTHER, 
+'language-support;tsonga-support'             : GROUP_OTHER, 
+'language-support;russian-support'            : GROUP_OTHER, 
+'language-support;serbian-support'            : GROUP_OTHER, 
+'language-support;latvian-support'            : GROUP_OTHER, 
+'language-support;samoan-support'             : GROUP_OTHER, 
+'language-support;sinhala-support'            : GROUP_OTHER, 
+'language-support;catalan-support'            : GROUP_OTHER, 
+'language-support;lithuanian-support'         : GROUP_OTHER, 
+'language-support;turkish-support'            : GROUP_OTHER, 
+'language-support;arabic-support'             : GROUP_OTHER, 
+'language-support;vietnamese-support'         : GROUP_OTHER, 
+'language-support;mongolian-support'          : GROUP_OTHER, 
+'language-support;tswana-support'             : GROUP_OTHER, 
+'language-support;irish-support'              : GROUP_OTHER, 
+'language-support;italian-support'            : GROUP_OTHER, 
+'language-support;slovak-support'             : GROUP_OTHER, 
+'language-support;slovenian-support'          : GROUP_OTHER, 
+'language-support;belarusian-support'         : GROUP_OTHER, 
+'language-support;northern-sotho-support'     : GROUP_OTHER, 
+'language-support;kannada-support'            : GROUP_OTHER, 
+'language-support;malayalam-support'          : GROUP_OTHER, 
+'language-support;swati-support'              : GROUP_OTHER, 
+'language-support;breton-support'             : GROUP_OTHER, 
+'language-support;romanian-support'           : GROUP_OTHER, 
+'language-support;greek-support'              : GROUP_OTHER, 
+'language-support;tagalog-support'            : GROUP_OTHER, 
+'language-support;zulu-support'               : GROUP_OTHER, 
+'language-support;tibetan-support'            : GROUP_OTHER, 
+'language-support;danish-support'             : GROUP_OTHER, 
+'language-support;afrikaans-support'          : GROUP_OTHER, 
+'language-support;southern-sotho-support'     : GROUP_OTHER, 
+'language-support;bosnian-support'            : GROUP_OTHER, 
+'language-support;brazilian-support'          : GROUP_OTHER, 
+'language-support;basque-support'             : GROUP_OTHER, 
+'language-support;welsh-support'              : GROUP_OTHER, 
+'language-support;thai-support'               : GROUP_OTHER, 
+'language-support;telugu-support'             : GROUP_OTHER, 
+'language-support;low-saxon-support'          : GROUP_OTHER, 
+'language-support;urdu-support'               : GROUP_OTHER, 
+'language-support;tamil-support'              : GROUP_OTHER, 
+'language-support;indonesian-support'         : GROUP_OTHER, 
+'language-support;gujarati-support'           : GROUP_OTHER, 
+'language-support;xhosa-support'              : GROUP_OTHER, 
+'language-support;chinese-support'            : GROUP_OTHER, 
+'language-support;czech-support'              : GROUP_OTHER, 
+'language-support;venda-support'              : GROUP_OTHER, 
+'language-support;bulgarian-support'          : GROUP_OTHER, 
+'language-support;albanian-support'           : GROUP_OTHER, 
+'language-support;galician-support'           : GROUP_OTHER, 
+'language-support;armenian-support'           : GROUP_OTHER, 
+'language-support;dutch-support'              : GROUP_OTHER, 
+'language-support;oriya-support'              : GROUP_OTHER, 
+'language-support;maori-support'              : GROUP_OTHER, 
+'language-support;nepali-support'             : GROUP_OTHER, 
+'language-support;icelandic-support'          : GROUP_OTHER, 
+'language-support;ukrainian-support'          : GROUP_OTHER, 
+'language-support;assamese-support'           : GROUP_OTHER, 
+'language-support;bengali-support'            : GROUP_OTHER, 
+'language-support;spanish-support'            : GROUP_OTHER, 
+'language-support;hebrew-support'             : GROUP_OTHER, 
+'language-support;estonian-support'           : GROUP_OTHER, 
+'language-support;french-support'             : GROUP_OTHER, 
+'language-support;croatian-support'           : GROUP_OTHER, 
+'language-support;filipino-support'           : GROUP_OTHER, 
+'language-support;finnish-support'            : GROUP_OTHER, 
+'language-support;norwegian-support'          : GROUP_OTHER, 
+'language-support;southern-ndebele-support'   : GROUP_OTHER, 
+'language-support;polish-support'             : GROUP_OTHER, 
+'language-support;gaelic-support'             : GROUP_OTHER, 
+'language-support;marathi-support'            : GROUP_OTHER, 
+'language-support;ethiopic-support'           : GROUP_OTHER 
+}
+
+
 class GPGKeyNotImported(exceptions.Exception):
     pass
 
@@ -194,6 +337,25 @@ class PackageKitYumBackend(PackageKitBaseBackend):
 
         searchlist = ['name', 'summary', 'description', 'group']
         self._do_search(searchlist, filters, key)
+        
+    def _buildGroupDict(self):
+        pkgGroups= {}
+        cats = self.yumbase.comps.categories
+        for cat in cats:
+            grps = map( lambda x: self.yumbase.comps.return_group( x ), 
+               filter( lambda x: self.yumbase.comps.has_group( x ), cat.groups ) )
+            grplist = []
+            for group in grps:
+                for pkg in group.mandatory_packages.keys():
+                    pkgGroups[pkg] = "%s;%s" % (cat.categoryid,group.groupid)                
+                for pkg in group.default_packages.keys():
+                    pkgGroups[pkg] = "%s;%s" % (cat.categoryid,group.groupid)
+                for pkg in group.optional_packages.keys():
+                    pkgGroups[pkg] = "%s;%s" % (cat.categoryid,group.groupid)
+                for pkg in group.conditional_packages.keys():
+                    pkgGroups[pkg] = "%s;%s" % (cat.categoryid,group.groupid)
+        return pkgGroups 
+        
 
     def search_group(self,filters,key):
         '''
@@ -201,9 +363,34 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
-        
-        self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+        pkgGroupDict = self._buildGroupDict()
+        self.yumbase.conf.cache = 1 # Only look in cache.
+        fltlist = filters.split(';')
+        found = {}
 
+        if not FILTER_NON_INSTALLED in fltlist:
+            # Check installed for group
+            for pkg in self.yumbase.rpmdb:
+                group = GROUP_OTHER                    # Default Group
+                if pkgGroupDict.has_key(pkg.name):     # check if pkg name exist in package / group dictinary
+                    cg = pkgGroupDict[pkg.name]
+                    if groupMap.has_key(cg):
+                        group = groupMap[cg]           # use the pk group name, instead of yum 'category/group' 
+                if group == key:
+                    if self._do_extra_filtering(pkg, fltlist):
+                        self._show_package(pkg, INFO_INSTALLED)
+        if not FILTER_INSTALLED in fltlist:
+            # Check available for group
+            for pkg in self.yumbase.pkgSack:
+                group = GROUP_OTHER
+                if pkgGroupDict.has_key(pkg.name):
+                    cg = pkgGroupDict[pkg.name]
+                    if groupMap.has_key(cg):
+                        group = groupMap[cg]
+                if group == key:
+                    if self._do_extra_filtering(pkg, fltlist):
+                        self._show_package(pkg, INFO_AVAILABLE)
+        
     def search_file(self,filters,key):
         '''
         Implement the {backend}-search-file functionality
diff --git a/html/pk-faq.html b/html/pk-faq.html
index 8457b88..691fb9c 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -32,7 +32,7 @@ update-system     |   X    |  X  |     |  X  |      |   X   |   X  |
 search-name       |   X    |  X  |  X  |  X  |  X   |   X   |   X  |
 search-details    |        |  X  |  X  |  X  |      |       |      |
 search-file       |        |  X  |     |  X  |      |       |      |
-search-group      |        |     |     |     |      |       |      |
+search-group      |        |  X  |     |     |      |       |      |
 install-package   |   X    |  X  |     |  X  |  X   |   X   |   X  |
 install-file      |        |  X  |     |  X  |      |       |   X  |
 remove-package    |   X    |  X  |     |  X  |  X   |   X   |   X  |
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index f1b5037..de0e4e6 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -77,6 +77,19 @@ FILTER_NON_GUI = "~gui"
 FILTER_DEVEL = "devel"
 FILTER_NON_DEVEL = "~devel"
 
+GROUP_ACCESSIBILITY     = "accessibility"
+GROUP_ACCESSORIES       = "accessories"
+GROUP_EDUCATION         = "education"
+GROUP_GAMES             = "games"
+GROUP_GRAPHICS          = "graphics"
+GROUP_INTERNET          = "internet"
+GROUP_OFFICE            = "office"
+GROUP_OTHER             = "other"
+GROUP_PROGRAMMING       = "programming"
+GROUP_MULTIMEDIA        = "multimedia"
+GROUP_SYSTEM            = "system"
+
+
 # Classes
 
 class PackageKitBaseBackend:
commit 76056a672ca1db2a8cf4883afd09b0dd33da7e31
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Mon Oct 29 11:04:34 2007 +0100

    yum: make it show the right actions (install/update/remove/cleanup/obsolete) when processing the transaction

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 8acf9ab..34980db 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -890,6 +890,26 @@ class PackageKitCallback(RPMBaseCallback):
         self.curpkg = None
         self.startPct = 50
         self.numPct = 50
+        # Map yum transactions with pk info enums
+        self.info_actions = { TS_UPDATE : INFO_UPDATING, 
+                        TS_ERASE: INFO_REMOVING,
+                        TS_INSTALL: INFO_INSTALLING, 
+                        TS_TRUEINSTALL : INFO_INSTALLING,
+                        TS_OBSOLETED: INFO_OBSOLETE,
+                        TS_OBSOLETING: INFO_INSTALLING,
+                        TS_UPDATED: INFO_CLEANUP}
+
+        # Map yum transactions with pk state enums
+        self.state_actions = { TS_UPDATE : STATE_UPDATE, 
+                        TS_ERASE: STATE_REMOVE,
+                        TS_INSTALL: STATE_INSTALL, 
+                        TS_TRUEINSTALL : STATE_INSTALL,
+                        TS_OBSOLETED: STATE_OBSOLETE,
+                        TS_OBSOLETING: STATE_INSTALL,
+                        TS_UPDATED: STATE_CLEANUP}
+
+
+        
 
     def _calcTotalPct(self,ts_current,ts_total):
         bump = float(self.numPct)/ts_total
@@ -908,13 +928,8 @@ class PackageKitCallback(RPMBaseCallback):
     def event(self, package, action, te_current, te_total, ts_current, ts_total):
         if str(package) != str(self.curpkg):
             self.curpkg = package
-            if action in TS_INSTALL_STATES:
-                self.base.status(STATE_INSTALL)
-                status = INFO_INSTALLING
-            elif action in TS_REMOVE_STATES:
-                self.base.status(STATE_REMOVE)
-                status = INFO_REMOVING
-            self._showName(status)
+            self.base.status(self.state_actions[action])
+            self._showName(self.info_actions[action])
             pct = self._calcTotalPct(ts_current, ts_total)
             self.base.percentage(pct)
         val = (ts_current*100L)/ts_total
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index b0a0ce2..f1b5037 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -50,6 +50,8 @@ STATE_INSTALL = "install"
 STATE_UPDATE = "update"
 STATE_REMOVE = "remove"
 STATE_WAIT = "wait"
+STATE_CLEANUP = "cleanup"
+STATE_OBSOLETE = "obsolete"
 
 RESTART_SYSTEM = "system"
 RESTART_APPLICATION = "application"
@@ -65,6 +67,8 @@ INFO_DOWNLOADING = "downloading"
 INFO_UPDATING = "updating"
 INFO_INSTALLING = "installing"
 INFO_REMOVING = "removing"
+INFO_CLEANUP = "cleanup"
+INFO_OBSOLETE = "obsoleting"
 
 FILTER_INSTALLED = "installed"
 FILTER_NON_INSTALLED = "~installed"



More information about the PackageKit mailing list