[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.44-583-ge144d01

Andreas Beckmann debian at abeckmann.de
Fri May 25 12:40:44 UTC 2012


The following commit has been merged in the develop branch:
commit 6c934480ead7560bcc510d49505440d42a6c1c29
Author: Andreas Beckmann <debian at abeckmann.de>
Date:   Sat Mar 10 11:34:28 2012 +0100

    always update preferred alternative
    
    Update the preferred alternative even if we only select a package
    in "waiting-*"/"unknown" state.
    That way the subsequent checks may work on better (non-failed)
    alternatives and circular dependencies involving virtual depends
    and alternative depends can be resolved.
    Keeping the 'unknown' state asks for a later revisit after some
    of the unknown alternative deps may have been resolved.
    
    Signed-off-by: Andreas Beckmann <debian at abeckmann.de>

diff --git a/debian/changelog b/debian/changelog
index e68c6c2..68fc7d4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -23,6 +23,8 @@ piuparts (0.45) UNRELEASED; urgency=low
       'dependency-does-not-exist' instead.
     - Remove 'unknown-preferred-alternative' state as it interferes with
       circular dependencies involving alternatives and virtual packages.
+    - Fix state resolution of package dependencies containing alternatives,
+      virtual packages and circular dependencies.
 
   [ Leo Iannacone ]
   * piuparts.py: add --existing-chroot option, specify a directory as source
diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index b6e5984..9afb962 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -319,16 +319,21 @@ class PackagesDB:
 
         # First attempt to resolve (still-unresolved) multiple alternative depends
         # Definitely sub-optimal, but improvement over blindly selecting first one
-        # 1) Prefer first alternative = "essential-required", prefer it
-        # 2) If no "essential-required", prefer first alternative = "successfully-tested"
-        # 3) Otherwise, prefer first alternative =  "waiting-to-be-tested" IF NO REMAINING
-        #    are "unknown/fail"
+        # Select the first alternative in the highest of the following states:
+        #   1) "essential-required"
+        #   2) "successfully-tested"
+        #   3) "waiting-to-be-tested" / "waiting-for-dependency-to-be-tested"
+        #   4) "unknown" (retry later)
+        # and update the preferred alternative of that dependency.
+        # If no alternative is in any of these states we retry later ("unknown")
+        # or set "dependency-does-not-exist".
         #
         # Problems:
         #   a) We will test and fail when >=1 "successfully-tested" but another
         #      that failed is selected by apt during test run
-        #   b) False positive "Dependency failed/cannot be tested"; however
-        #       more accurately "waiting-for-dependency-to-be-tested"
+        #   b) We may report a status of "waiting-for-dependency-to-be-tested"
+        #      instead of "waiting-to-be-tested" depending on the order the
+        #      package states get resolved.
 
         state = None
         for header in ["Depends", "Pre-Depends"]:
@@ -339,7 +344,7 @@ class PackagesDB:
                     alt_fails = 0
                     alt_unknowns = 0
                     alt_state = None
-                    prefer_alt_score = 0
+                    prefer_alt_score = -1
                     prefer_alt = None
                     for alternative in alt_deps[d]:
                         altdep_state = self.get_package_state(alternative)
@@ -355,6 +360,10 @@ class PackagesDB:
                                  altdep_state in ["waiting-to-be-tested", "waiting-for-dependency-to-be-tested"]:
                                 prefer_alt = alternative
                                 prefer_alt_score = 1
+                            elif prefer_alt_score < 0 and altdep_state == "unknown":
+                                prefer_alt = alternative
+                                prefer_alt_score = 0
+                                alt_unknowns += 1
                             elif altdep_state == "unknown":
                                 alt_unknowns += 1
                             else:
@@ -364,9 +373,7 @@ class PackagesDB:
 
                     if alt_found == 0:
                         return "dependency-does-not-exist"
-                    if prefer_alt_score >= 2:
-                        package.prefer_alt_depends(header, d, prefer_alt)
-                    elif prefer_alt_score == 1 and ((alt_unknowns + alt_fails) == 0):
+                    if prefer_alt_score >= 0:
                         package.prefer_alt_depends(header, d, prefer_alt)
                     else:
                         if alt_state is not None and alt_unknowns == 0:

-- 
piuparts git repository



More information about the Piuparts-commits mailing list