1
diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
2
index da1fad2..4d6a623 100755
3
--- a/backends/apt/aptDBUSBackend.py
4
+++ b/backends/apt/aptDBUSBackend.py
5
@@ -121,19 +121,23 @@ class PackageKitFetchProgress(apt.progress.FetchProgress):
6
#FIXME: use the Message method to notify the user
7
self._backend.error(ERROR_UNKNOWN,
8
"Medium change needed")
10
class PackageKitInstallProgress(apt.progress.InstallProgress):
12
Handle the installation and removal process. Bits taken from
13
DistUpgradeViewNonInteractive.
16
+ # a insanly long timeout to be able to kill hanging maintainer
20
def __init__(self, backend, prange=(0,100)):
21
apt.progress.InstallProgress.__init__(self)
22
self._backend = backend
24
self.pstart = prange[0]
27
+ self.conffile_prompts = set()
29
def statusChange(self, pkg, percent, status):
30
progress = self.pstart + percent/100 * (self.pend - self.pstart)
31
@@ -146,12 +150,33 @@ class PackageKitInstallProgress(apt.progress.InstallProgress):
32
self._backend.StatusChanged(STATUS_INSTALL)
33
self.last_activity = time.time()
36
+ pklog.debug("fork()")
37
+ (pid, self.master_fd) = pty.fork()
40
def updateInterface(self):
41
- pklog.debug("Updating interface")
42
+ #pklog.debug("Updating interface")
43
apt.progress.InstallProgress.updateInterface(self)
45
+ pklog.debug("%s" % os.read(self.master_fd, 512))
46
+ except Exception, e:
47
+ pklog.debug("ioerror: %s" % e)
48
+ # we timed out, send ctrl-c
49
+ if self.last_activity + self.TIMEOUT < time.time():
50
+ pklog.critical("no activity for %s time sending ctrl-c" % self.TIMEOUT)
51
+ os.write(self.master_fd, 3)
53
def conffile(self, current, new):
54
- pklog.critical("Config file prompt: '%s'" % current)
55
+ pklog.warning("Config file prompt: '%s' (sending no)" % current)
56
+ i = os.write(self.master_fd, "n\n")
57
+ pklog.debug("wrote n, send %i bytes" % i)
58
+ self.conffile_prompts.add(new)
60
+ def finishUpdate(self):
61
+ pklog.debug("finishUpdate()")
62
+ if self.conffile_prompts:
63
+ self._backend.Message(MESSAGE_NOTICE, "The following conffile prompts were found and need investiagtion: %s" % "\n".join(self.conffile_prompts))
65
def sigquit(signum, frame):
66
pklog.error("Was killed")
67
@@ -413,6 +438,59 @@ class PackageKitAptBackend(PackageKitBaseBackend):
71
+ def doUpdatePackages(self, ids):
73
+ Implement the {backend}-update functionality
75
+ pklog.info("Updating package with id %s" % ids)
76
+ self.StatusChanged(STATUS_INSTALL)
77
+ self.AllowCancel(False)
78
+ self.PercentageChanged(0)
79
+ self.StatusChanged(STATUS_RUNNING)
82
+ pkg = self._find_package_by_id(id)
84
+ self.ErrorCode(ERROR_PACKAGE_NOT_FOUND,
85
+ "Package %s isn't available" % id)
86
+ self.Finished(EXIT_FAILED)
88
+ if not pkg.isUpgradable:
89
+ self.ErrorCode(ERROR_PACKAGE_ALREADY_INSTALLED,
90
+ "Package %s is already installed" % pkg.name)
91
+ self.Finished(EXIT_FAILED)
93
+ pkgs.append(pkg.name[:])
97
+ self._open_cache(prange=(90,100))
98
+ self.ErrorCode(ERROR_UNKNOWN, "%s could not be queued for "
99
+ "installation" % pkg.name)
100
+ self.Finished(EXIT_FAILED)
103
+ self._cache.commit(PackageKitFetchProgress(self, prange=(10,50)),
104
+ PackageKitInstallProgress(self, prange=(50,90)))
105
+ except Exception, e:
106
+ pklog.warning("exception %s during commit()" % e)
107
+ self._open_cache(prange=(90,100))
108
+ self.ErrorCode(ERROR_UNKNOWN, "Installation failed")
109
+ self.Finished(EXIT_FAILED)
111
+ self._open_cache(prange=(90,100))
112
+ self.PercentageChanged(100)
113
+ pklog.debug("Checking success of operation")
115
+ if not self._cache.has_key(p) or not self._cache[p].isInstalled:
116
+ self.ErrorCode(ERROR_UNKNOWN, "%s was not installed" % p)
117
+ self.Finished(EXIT_FAILED)
119
+ pklog.debug("Sending success signal")
120
+ self.Finished(EXIT_SUCCESS)
124
def doInstallPackages(self, ids):
126
Implement the {backend}-install functionality
127
@@ -447,7 +525,8 @@ class PackageKitAptBackend(PackageKitBaseBackend):
129
self._cache.commit(PackageKitFetchProgress(self, prange=(10,50)),
130
PackageKitInstallProgress(self, prange=(50,90)))
132
+ except Exception, e:
133
+ pklog.warning("exception %s during commit()" % e)
134
self._open_cache(prange=(90,100))
135
self.ErrorCode(ERROR_UNKNOWN, "Installation failed")
136
self.Finished(EXIT_FAILED)