[Piuparts-commits] [piuparts] 02/02: lib/db: resolving "outdated" needs a second pass of initialization after dep dbs

Holger Levsen holger at layer-acht.org
Wed Mar 15 11:11:01 UTC 2017


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

holger pushed a commit to branch develop
in repository piuparts.

commit be3053e66250f678b551638fec2c30c0120a6923
Author: Andreas Beckmann <anbe at debian.org>
Date:   Wed Mar 15 00:14:04 2017 +0100

    lib/db: resolving "outdated" needs a second pass of initialization after dep dbs
    
    To resolve "outdated" packages, the dependency databases must be
    initialized, but (partial) dependency databases may have (circular)
    dependencies on ourselves ... therefore we initialize ourselves
    from quick lookups initially from existing "pass" and "fail" logs.
    This may assign an unwanted "failed-testing" or "successfully-tested"
    state to a package that should be actually "outdated" (and ignored for
    further resolution).
    
    Make the lookup of "outdated" packages conditional and move it into
    _lookup_package_state().
    
    Therefore, after the dependency databases are initialized, we discard
    the previously looked up package states and run a second pass of
    _initialize_package_states() with enabled detection of "outdated"
    packages.
    
    Full distros that have no dependency databases (e.g. stable/main)
    cannot have "outdated" packages and are only initialized once.
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 piupartslib/packagesdb.py | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/piupartslib/packagesdb.py b/piupartslib/packagesdb.py
index 0373a90..6f04178 100644
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@ -447,7 +447,13 @@ class PackagesDB:
                 return True
         return False
 
-    def _lookup_package_state(self, package, use_cached_success):
+    def _lookup_package_state(self, package, use_cached_success, check_outdated):
+        if check_outdated:
+            # Check if dependency databases have a newer version of this package.
+            for db in self._dependency_databases:
+                v = db.get_version(package["Package"])
+                if v is not None and apt_pkg.version_compare(package["Version"], v) < 0:
+                    return "outdated";
         if self._recycle_mode and self._logdb.log_exists(package, [self._recycle]):
             return "unknown"
         if self._logdb.log_exists(package, [self._ok]):
@@ -468,12 +474,6 @@ class PackagesDB:
         return "unknown"
 
     def _compute_package_state(self, package):
-        # Check if dependency databases have a newer version of this package.
-        for db in self._dependency_databases:
-            v = db.get_version(package["Package"])
-            if v is not None and apt_pkg.version_compare(package["Version"], v) < 0:
-                return "outdated";
-
         # First attempt to resolve (still-unresolved) multiple alternative depends
         # Definitely sub-optimal, but improvement over blindly selecting first one
         # Select the first alternative in the highest of the following states:
@@ -562,7 +562,7 @@ class PackagesDB:
 
         return "unknown"
 
-    def _initialize_package_states(self, use_cached_success):
+    def _initialize_package_states(self, use_cached_success, check_outdated):
         self._find_all_packages()
 
         self._package_state = {}
@@ -572,7 +572,7 @@ class PackagesDB:
         todo = []
 
         for package_name, package in self._packages.iteritems():
-            state = self._lookup_package_state(package, use_cached_success)
+            state = self._lookup_package_state(package, use_cached_success, check_outdated)
             assert state in self._states
             self._package_state[package_name] = state
             if state == "unknown":
@@ -591,11 +591,15 @@ class PackagesDB:
         for subdir in self._all:
             self._logdb.bulk_load_dir(subdir)
 
-        todo = self._initialize_package_states(use_cached_success=use_cached_success)
+        todo = self._initialize_package_states(use_cached_success=use_cached_success, check_outdated=False)
 
         for db in self._dependency_databases:
             db._compute_package_states(use_cached_success=True)
 
+        if self._dependency_databases:
+            # redo the initialization to properly resolve "outdated" packages after the dependency databases have been initialized
+            todo = self._initialize_package_states(use_cached_success=use_cached_success, check_outdated=True)
+
         while todo:
             package_names = todo
             todo = []

-- 
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