diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-09-16 20:05:46 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-09-16 20:05:46 +0200 |
| commit | a7217b885beff13462bbb793eac42d28c53752f8 (patch) | |
| tree | e141cd0d0e644e7cf4f79fea34ba9bf8977801b8 | |
| parent | 8600d4c44a5b9f75887da6e12acea622caef8c76 (diff) | |
| parent | be85eeaeadf8b93021413ab7ed79e639b65102a6 (diff) | |
| download | python-apt-a7217b885beff13462bbb793eac42d28c53752f8.tar.gz | |
Merge 0.7.13.0 - 0.7.13.3 from unstable.
* apt/cache.py:
- add actiongroup() method (backport from 0.7.92)
- 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)
* python/depcache.cc:
- Make ActionGroups context managers so apt.Cache.actiongroup() has
the same behavior as in 0.7.92
* apt/cache.py:
- Add raiseOnError option to Cache.update() (Closes: #545474)
* apt/package.py:
- Use the source version instead of the binary version in fetch_source().
* apt/progress/__init__.py:
- Correctly ignore ECHILD by checking before EINTR (Closes: #546007)
* apt/cache.py:
- Convert argument to str in __getitem__() (Closes: #542965).
| -rw-r--r-- | apt/cache.py | 20 | ||||
| -rw-r--r-- | apt/package.py | 13 | ||||
| -rw-r--r-- | apt/progress/base.py | 18 | ||||
| -rw-r--r-- | debian/changelog | 38 |
4 files changed, 77 insertions, 12 deletions
diff --git a/apt/cache.py b/apt/cache.py index eff07ef8..bda08a24 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -71,7 +71,7 @@ class Cache(object): self._check_and_create_required_dirs(rootdir) # Call InitSystem so the change to Dir::State::Status is actually # recognized (LP: #320665) - apt_pkg.InitSystem() + apt_pkg.init_system() self.open(progress) def _check_and_create_required_dirs(self, rootdir): @@ -139,6 +139,7 @@ class Cache(object): return self._weakref[key] except KeyError: if key in self._set: + key = str(key) pkg = self._weakref[key] = Package(self, self._cache[key]) return pkg else: @@ -278,7 +279,8 @@ class Cache(object): return providers @deprecated_args - def update(self, fetch_progress=None, pulse_interval=0): + def update(self, fetch_progress=None, pulse_interval=0, + raise_on_error=True): """Run the equivalent of apt-get update. The first parameter *fetch_progress* may be set to an instance of @@ -294,8 +296,14 @@ class Cache(object): try: if fetch_progress is None: fetch_progress = apt.progress.FetchProgress() - return self._cache.update(fetch_progress, self._list, + res = self._cache.update(fetch_progress, self._list, pulse_interval) + if res == apt_pkg.Acquire.result_cancelled and raise_on_error: + raise FetchCancelledException() + if res == apt_pkg.Acquire.result_failed and raise_on_error: + raise FetchFailedException() + else: + return res finally: os.close(lock) @@ -352,8 +360,12 @@ class Cache(object): res = self.install_archives(pm, install_progress) if res == pm.result_completed: break - if res == pm.result_failed: + elif res == pm.result_failed: raise SystemError("installArchives() failed") + elif res == pm.result_incomplete: + pass + else: + raise SystemError("internal-error: unknown result code from InstallArchives: %s" % res) # reload the fetcher for media swaping fetcher.shutdown() return (res == pm.result_completed) diff --git a/apt/package.py b/apt/package.py index 3b5cfccf..a811dfbb 100644 --- a/apt/package.py +++ b/apt/package.py @@ -521,10 +521,12 @@ class Version(object): acq = apt_pkg.Acquire(progress or apt.progress.text.AcquireProgress()) dsc = None - src.lookup(self.package.name) + record = self._records + src.lookup(record.source_pkg) + try: - while self.version != src.version: - src.lookup(self.package.name) + while record.source_ver != src.version: + src.lookup(record.source_pkg) except AttributeError: raise ValueError("No source for %r" % self) files = list() @@ -692,6 +694,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): #pylint: disable-msg=C0103 """Return the installed version as string. diff --git a/apt/progress/base.py b/apt/progress/base.py index 08d35533..fd6bc475 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -27,6 +27,8 @@ import os import re import select +import apt_pkg + __all__ = ['AcquireProgress', 'CdromProgress', 'InstallProgress', 'OpProgress'] @@ -179,11 +181,19 @@ class InstallProgress(object): """ pid = self.fork() if pid == 0: + # pm.do_install 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: os._exit(obj.do_install(self.writefd.fileno())) except AttributeError: os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", str(self.writefd.fileno()), "-i", obj)) + except Exception: + os._exit(apt_pkg.PackageManager.result_failed) + self.child_pid = pid res = self.wait_child() return os.WEXITSTATUS(res) @@ -236,7 +246,8 @@ class InstallProgress(object): """Wait for child progress to exit. This method is responsible for calling update_interface() from time to - time. It exits once the child has exited. + time. It exits once the child has exited. The return values is the + full status returned from os.waitpid() (not only the return code). """ (pid, res) = (0, 0) while True: @@ -252,10 +263,11 @@ class InstallProgress(object): if pid == self.child_pid: break except OSError, err: - if err[0] != errno.EINTR: - raise if err[0] == errno.ECHILD: break + if err[0] != errno.EINTR: + raise + return res diff --git a/debian/changelog b/debian/changelog index 75590703..7588d35a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ python-apt (0.7.93) experimental; urgency=low - * Merge 0.7.13.0 and 0.7.13.1 from unstable. + * Merge 0.7.13.0 - 0.7.13.3 from unstable. - -- Julian Andres Klode <jak@debian.org> Fri, 21 Aug 2009 16:50:54 +0200 + -- Julian Andres Klode <jak@debian.org> Wed, 16 Sep 2009 19:26:17 +0200 python-apt (0.7.92) experimental; urgency=low @@ -84,6 +84,40 @@ python-apt (0.7.90) experimental; urgency=low -- Julian Andres Klode <jak@debian.org> Wed, 15 Apr 2009 13:47:42 +0200 +python-apt (0.7.13.3) unstable; urgency=low + + [ Michael Vogt ] + * apt/cache.py: + - add actiongroup() method (backport from 0.7.92) + - 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) + + [ Julian Andres Klode ] + * python/depcache.cc: + - Make ActionGroups context managers so apt.Cache.actiongroup() has + the same behavior as in 0.7.92 + * apt/cache.py: + - Add raiseOnError option to Cache.update() (Closes: #545474) + * apt/package.py: + - Use the source version instead of the binary version in fetch_source(). + * apt/progress/__init__.py: + - Correctly ignore ECHILD by checking before EINTR (Closes: #546007) + + -- Julian Andres Klode <jak@debian.org> Tue, 15 Sep 2009 15:18:45 +0200 + +python-apt (0.7.13.2) unstable; urgency=low + + * apt/cache.py: + - Convert argument to str in __getitem__() (Closes: #542965). + + -- Julian Andres Klode <jak@debian.org> Sat, 22 Aug 2009 22:47:30 +0200 + python-apt (0.7.13.1) unstable; urgency=low * apt/package.py: |
