[Piuparts-commits] [piuparts] 03/06: lib/db: get_best_package_state(): consider providers as well

Holger Levsen holger at moszumanska.debian.org
Tue Jan 21 02:07:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch develop
in repository piuparts.

commit 2a6a7bd28ee4d56e4a8d923444b040de761c2c54
Author: Andreas Beckmann <anbe at debian.org>
Date:   Mon Jan 20 11:21:35 2014 +0100

    lib/db: get_best_package_state(): consider providers as well
    
    the real package may be uninstallable (e.g. mplayer), but another package
    providing that as a virtual package (e.g. mplayer2 in this case) can be
    used to fulfill a dependency
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
---
 debian/changelog          |  4 ++++
 piupartslib/packagesdb.py | 17 ++++++++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 0e05af7..4b42ac0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,10 @@ piuparts (0.57) UNRELEASED; urgency=low
       python-debianbts and python-yaml.
 
   [ Andreas Beckmann ]
+  * piupartslib/packagesdb.py:
+    - get_best_package_state(): New method that considers successfully tested
+      providers of a virtual package if the real package of the same name
+      failed. Used for dependency resolution.
   * Add more piuparts exceptions.
 
  -- Holger Levsen <holger at debian.org>  Fri, 10 Jan 2014 01:00:43 +0100
diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index 5455917..65e64b2 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -478,7 +478,7 @@ class PackagesDB:
                     if prefer_alt_score >= 0:
                         package.prefer_alt_depends(header, d, prefer_alt)
 
-        dep_states = [(dep, self.get_package_state(dep))
+        dep_states = [(dep, self.get_best_package_state(dep))
                         for dep in package.dependencies()]
 
         for dep, dep_state in dep_states:
@@ -667,6 +667,21 @@ class PackagesDB:
             return "essential-required"
         return "does-not-exist"
 
+    def get_best_package_state(self, package_name, resolve_virtual=True, recurse=True):
+        package_state = self.get_package_state(package_name, resolve_virtual=resolve_virtual, recurse=recurse)
+        if package_state in self._good_states:
+            return package_state
+        providers = []
+        if resolve_virtual:
+            providers = self.get_providers(package_name, recurse=recurse)
+        if not providers:
+            return package_state
+        states = [self.get_package_state(name, resolve_virtual=False, recurse=recurse) for name in [package_name] + providers]
+        for state in self._good_states + self._propagate_waiting_state.keys() + self._propagate_error_state.keys():
+            if state in states:
+                return state
+        return package_state
+
     def _find_packages_ready_for_testing(self):
         if self._candidates_for_testing is None:
             self._candidates_for_testing = [self.get_package(pn)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list