[packagekit] [PATCH] apt: Emit package signals when installing and removing

James Westby jw+debian at jameswestby.net
Wed May 28 11:25:33 PDT 2008


The apt backend doesn't emit package signals while installing
or removing, so the daemon discards it's finished message,
making it look as though it has hung.

As we loop over the package list checking that the task
was successful emit the package signal for each one.

Signed-off-by: James Westby <jw+debian at jameswestby.net>
---
 backends/apt/aptDBUSBackend.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

  I'm not positive this is the right way to solve it, but it at least
  allows me to install and remove a package.

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index 22eb714..a50721c 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -386,7 +386,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                                "Package %s isn't installed" % pkg.name)
                 self.Finished(EXIT_FAILED)
                 return
-            pkgs.append(pkg.name[:])
+            pkgs.append(pkg)
             try:
                 pkg.markDelete()
             except:
@@ -404,10 +404,12 @@ class PackageKitAptBackend(PackageKitBaseBackend):
             return
         self._open_cache(prange=(90,99))
         for p in pkgs:
-            if self._cache.has_key(p) and self._cache[p].isInstalled:
+            name = p.name
+            if self._cache.has_key(name) and self._cache[name].isInstalled:
                 self.ErrorCode(ERROR_UNKNOWN, "%s is still installed" % p)
                 self.Finished(EXIT_FAILED)
                 return
+            self._emit_package(p)
         self.PercentageChanged(100)
         self.Finished(EXIT_SUCCESS)
 
@@ -435,7 +437,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                                "Package %s is already installed" % pkg.name)
                 self.Finished(EXIT_FAILED)
                 return
-            pkgs.append(pkg.name[:])
+            pkgs.append(pkg)
             try:
                 pkg.markInstall()
             except:
@@ -456,10 +458,13 @@ class PackageKitAptBackend(PackageKitBaseBackend):
         self.PercentageChanged(100)
         pklog.debug("Checking success of operation")
         for p in pkgs:
-            if not self._cache.has_key(p) or not self._cache[p].isInstalled:
+            name = p.name
+            if (not self._cache.has_key(name)
+                or not self._cache[name].isInstalled):
                 self.ErrorCode(ERROR_UNKNOWN, "%s was not installed" % p)
                 self.Finished(EXIT_FAILED)
                 return
+            self._emit_package(p)
         pklog.debug("Sending success signal")
         self.Finished(EXIT_SUCCESS)
 
-- 
1.5.4.3



More information about the PackageKit mailing list