diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-09-03 15:56:15 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-09-03 15:56:15 +0200 |
| commit | 153e0ff362dfe7e0dbd6bf045a4aa1225d12b743 (patch) | |
| tree | 360971bf2da8db8cabed61af3c9ccac97617317f | |
| parent | bad4ccc67b4fb538498550ff48aef0e40bbb065c (diff) | |
| parent | 7acb16fc4baa43cf2cbbc4de948973bdc099d878 (diff) | |
| download | python-apt-153e0ff362dfe7e0dbd6bf045a4aa1225d12b743.tar.gz | |
* apt/cache.py:
- re-work the logic in commit() to fail if installArchives() returns
a unexpected result
* apt/progress/__init__.py:
- catch exceptions in pm.DoInstall()
* apt/package.py:
- Export if a package is an essential one (Closes: #543428)
| -rw-r--r-- | apt/cache.py | 6 | ||||
| -rw-r--r-- | apt/package.py | 5 | ||||
| -rw-r--r-- | apt/progress/__init__.py | 23 | ||||
| -rw-r--r-- | debian/changelog | 16 |
4 files changed, 45 insertions, 5 deletions
diff --git a/apt/cache.py b/apt/cache.py index 828b167b..bb944041 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -314,8 +314,12 @@ class Cache(object): res = self.installArchives(pm, installProgress) if res == pm.ResultCompleted: break - if res == pm.ResultFailed: + elif res == pm.ResultFailed: raise SystemError("installArchives() failed") + elif res == pm.ResultIncomplete: + pass + else: + raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res) # reload the fetcher for media swaping fetcher.Shutdown() return (res == pm.ResultCompleted) diff --git a/apt/package.py b/apt/package.py index d639f31f..27e0dc90 100644 --- a/apt/package.py +++ b/apt/package.py @@ -652,6 +652,11 @@ class Package(object): This returns the same value as ID, which is unique.""" return self._pkg.ID + @property + def essential(self): + """Return True if the package is an essential part of the system.""" + return self._pkg.Essential + @DeprecatedProperty def installedVersion(self): """Return the installed version as string. diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 337bd161..ca60810f 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -284,7 +284,11 @@ class InstallProgress(DumbInstallProgress): return os.fork() def waitChild(self): - """Wait for child progress to exit.""" + """Wait for child progress to exit. + + The return values is the full status returned from os.waitpid() + (not only the return code). + """ while True: try: select.select([self.statusfd], [], [], self.selectTimeout) @@ -304,11 +308,22 @@ class InstallProgress(DumbInstallProgress): return res def run(self, pm): - """Start installing.""" + """Start installing. + + Returns the PackageManager status: + (pm.ResultCompleted, pm.ResultFailed, pm.ResultIncomplete) + """ pid = self.fork() if pid == 0: - # child - res = pm.DoInstall(self.writefd) + # pm.DoInstall might raise a exception, + # when this happens, we need to catch + # it, otherwise os._exit() is not run + # and the execution continues in the + # parent code leading to very confusing bugs + try: + res = pm.DoInstall(self.writefd) + except Exception, e: + os._exit(pm.ResultFailed) os._exit(res) self.child_pid = pid res = self.waitChild() diff --git a/debian/changelog b/debian/changelog index 16efbb88..87d7441a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,19 @@ +python-apt (0.7.13.2ubuntu2) UNRELEASEDkarmic; urgency=low + + [ Michael Vogt ] + * apt/cache.py: + - re-work the logic in commit() to fail if installArchives() returns + a unexpected result + * apt/progress/__init__.py: + - catch exceptions in pm.DoInstall() + + [ Sebastian Heinlein ] + * apt/package.py: + - Export if a package is an essential one (Closes: #543428) + + + -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 03 Sep 2009 15:36:56 +0200 + python-apt (0.7.13.2ubuntu1) karmic; urgency=low * merged from the debian-sid bzr branch |
