[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. eda668423fa87898c59d1075118693714aa5a053

Holger Levsen holger at layer-acht.org
Fri Dec 23 10:27:56 UTC 2011


The following commit has been merged in the master branch:
commit cf0e87cadf9fd04ce541c63ab345d3a554e29f9c
Merge: ae307587f51f2e572a33e9cc734270c35fbd8ec6 673e16464e2396ba9e0beff7741d50bbd16855ff
Author: Holger Levsen <holger at layer-acht.org>
Date:   Fri Dec 2 14:05:09 2011 +0100

    Merge branch 'fix/handling-virtual-packages' into develop

diff --combined piuparts-report.py
index 875c264,60f8ff4..81c8a02
--- a/piuparts-report.py
+++ b/piuparts-report.py
@@@ -445,6 -445,7 +445,7 @@@ def emphasize_reason(reason)
          "dependency-cannot-be-tested",
          "dependency-does-not-exist",
          "circular-dependency",
+         "does-not-exist",
          "unknown",
          "unknown-preferred-alternative",
          "no-dependency-from-alternatives-exists",
@@@ -661,7 -662,7 +662,7 @@@ class Section
          return link
  
      def link_to_state_page(self, section, package_name, link_target):
-         state = self._binary_db.state_by_name(package_name)
+         state = self._binary_db.get_package_state(package_name)
          if state != "unknown":
              link = "<a href=\"/%s/%s\">%s</a>" % (
                  section,
@@@ -782,7 -783,7 +783,7 @@@
          failed = False
          binaryrows = ""
          for binary in sorted(binaries.split(", ")):
-           state = self._binary_db.state_by_name(binary)
+           state = self._binary_db.get_package_state(binary)
            if state == "unknown":
              # Don't track udebs and binary packages on other archs. 
              # The latter is a FIXME which needs parsing the Packages files from other archs too
@@@ -1006,7 -1007,7 +1007,7 @@@
                      for dep in package.dependencies():
                          vlist += "<li>dependency %s is %s</li>\n" % \
                                    (self.link_to_state_page(self._config.section,dep,dep), 
-                                   emphasize_reason(html_protect(self._binary_db.state_by_name(dep))))
+                                   emphasize_reason(html_protect(self._binary_db.get_package_state(dep))))
                      vlist += "</ul>\n"
                  vlist += "</li>\n"
              htmlpage = string.Template(HTML_HEADER + STATE_BODY_TEMPLATE + HTML_FOOTER)
@@@ -1019,25 -1020,6 +1020,25 @@@
                                          "list": vlist
                                         }))
  
 +
 +    def archive_logfile(self, vdir, log):
 +        archivedir = os.path.join("archive", vdir)
 +        if not os.path.exists(archivedir):
 +            os.makedirs(archivedir)
 +        os.rename(os.path.join(vdir, log), os.path.join("archive", vdir, log))
 +
 +
 +    def cleanup_removed_packages(self, logs_by_dir):
 +        for vdir in logs_by_dir.keys():
 +            for log in sorted(logs_by_dir[vdir]):
 +                if log.endswith(".log"):
 +                    package, version = log[:-len(".log")].split("_")
 +                    if not self._binary_db.has_package(package):
 +                        logging.debug("Package %s was removed, archiving %s/%s" % (package, vdir, log))
 +                        self.archive_logfile(vdir, log)
 +                        logs_by_dir[vdir].remove(log)
 +
 +
      def generate_html(self):
          logging.debug("Finding log files")
          dirs = ["pass", "fail", "bugged", "reserved", "untestable"]
@@@ -1045,9 -1027,6 +1046,9 @@@
          for vdir in dirs:
              logs_by_dir[vdir] = find_files_with_suffix(vdir, ".log")
  
 +        logging.debug("Archiving logs of obsolete packages")
 +        self.cleanup_removed_packages(logs_by_dir)
 +
          logging.debug("Copying log files")
          copy_logs(logs_by_dir, self._output_directory)
  
@@@ -1088,7 -1067,6 +1089,7 @@@
          self.generate_html()
          os.chdir(oldcwd)
  
 +
  def main():
      setup_logging(logging.DEBUG, None)
  
diff --combined piupartslib/packagesdb.py
index 11a908f,36c5231..175d547
--- a/piupartslib/packagesdb.py
+++ b/piupartslib/packagesdb.py
@@@ -194,6 -194,7 +194,7 @@@ class LogDB
  
  class PackagesDB:
  
+     # keep in sync with piuparts-report.py: emphasize_reason()
      _states = [
          "successfully-tested",
          "failed-testing",
@@@ -205,6 -206,7 +206,7 @@@
          "dependency-cannot-be-tested",
          "dependency-does-not-exist",
          "circular-dependency",
+         #"does-not-exist",  # can only happen as query result for a dependency
          "unknown",
          "unknown-preferred-alternative",
          "no-dependency-from-alternatives-exists",
@@@ -219,6 -221,7 +221,7 @@@
          "dependency-cannot-be-tested": "dependency-cannot-be-tested",
          "dependency-does-not-exist": "dependency-does-not-exist",
          "circular-dependency": "circular-dependency",
+         "does-not-exist": "dependency-does-not-exist",
          "unknown-preferred-alternative": "unknown-preferred-alternative",
          "no-dependency-from-alternatives-exists": "dependency-cannot-be-tested",
      }
@@@ -268,13 -271,16 +271,16 @@@
      def _find_all_packages(self):
          if self._packages is None:
              self._packages = {}
+             self._virtual_packages = {}
              for pf in self._packages_files:
                  for p in pf.values():
                      self._packages[p["Package"]] = p
              for p in self._packages.values():
                  for provided in p.provides():
-                     if provided not in self._packages:
-                         self._packages[provided] = p
+                     if provided != p["Package"]:
+                         if provided not in self._virtual_packages:
+                             self._virtual_packages[provided] = []
+                         self._virtual_packages[provided].append(p["Package"])
  
      def _get_recursive_dependencies(self, package, break_circles=True):
          assert self._packages is not None
@@@ -287,6 -293,8 +293,8 @@@
                  deps.append(dep)
                  if dep in self._packages:
                      more += self._packages[dep].dependencies()
+                 elif dep in self._virtual_packages:
+                     more += self._packages[self._virtual_packages[dep][0]].dependencies()
  
          # Break circular dependencies
          if break_circles and package["Package"] in deps:
@@@ -331,9 -339,9 +339,9 @@@
                      prefer_alt = None
                      for alternative in alt_deps[d]:
                          dep = alternative.name
-                         if dep in self._package_state:
+                         altdep_state = self.get_package_state(dep)
+                         if altdep_state != "does-not-exist":
                              alt_found += 1
-                             altdep_state = self._package_state[dep]
                              if prefer_alt_score < 3 and altdep_state == "essential-required":
                                  prefer_alt = alternative
                                  prefer_alt_idx = d
@@@ -370,18 -378,15 +378,15 @@@
               return state
  
          for dep in package.dependencies():
-             if dep not in self._package_state:
-                 return "dependency-does-not-exist"
-             dep_state = self._package_state[dep]
-             if dep_state is None:
-                 return "unknown"
-             elif dep_state in self._dep_state_to_state:
+             dep_state = self.get_package_state(dep)
+             if dep_state in self._dep_state_to_state:
                  return self._dep_state_to_state[dep_state]
  
          state = "waiting-to-be-tested"
          for dep in package.dependencies():
-             if self._package_state[dep] not in \
-                ["successfully-tested", "essential-required"]:
+             dep_state = self.get_package_state(dep)
+             if dep_state not in \
+                     ["successfully-tested", "essential-required"]:
                  state = "unknown"
                  break
          if state == "waiting-to-be-tested":
@@@ -393,20 -398,21 +398,21 @@@
              if pkg in deps:
                  deps.remove(pkg)
          if package["Package"] in deps:
-             return "circular-dependency" # actually, it's a unknown circular-dependency
+             return "circular-dependency"  # actually, it's an unknown circular-dependency
  
          # treat circular-dependencies as testable (for the part of the circle)
          state = "unknown" 
          if package["Package"] in self._known_circular_depends:
-           for dep in package.dependencies():
-             if dep not in self._known_circular_depends and self._package_state[dep] not in \
-                ["successfully-tested", "essential-required"]:
-                 state = "unknown"
-                 break
-             if dep in self._known_circular_depends and self._package_state[dep] not in \
-                ["failed-testing","dependency-failed-testing"]:
-                 state = "waiting-to-be-tested"
-                 continue
+             for dep in package.dependencies():
+                 dep_state = self.get_package_state(dep)
+                 if dep not in self._known_circular_depends and dep_state not in \
+                         ["successfully-tested", "essential-required"]:
+                     state = "unknown"
+                     break
+                 if dep in self._known_circular_depends and dep_state not in \
+                         ["failed-testing", "dependency-failed-testing"]:
+                     state = "waiting-to-be-tested"
+                     continue
          return state
  
      def _compute_package_states(self):
@@@ -454,6 -460,8 +460,8 @@@
  
          self._in_state["unknown"] = todo
          self._in_state["unknown-preferred-alternative"] = unpreferred_alt
+         for package_name in unpreferred_alt:
+             self._package_state[package_name] = "unknown-preferred-alternative"
  
          for state in self._states:
              self._in_state[state].sort()
@@@ -466,12 -474,16 +474,17 @@@
          return set(self._in_state[state])
  
      def has_package(self, name):
 +        self._find_all_packages()
          return name in self._packages
  
      def get_package(self, name):
          return self._packages[name]
  
+     def get_providers(self, name):
+         if name in self._virtual_packages:
+             return self._virtual_packages[name]
+         return []
+ 
      def get_all_packages(self):
          self._find_all_packages()
          return self._packages
@@@ -502,14 -514,16 +515,16 @@@
          else:
            return self._packages[package_name][header]
  
-     def get_package_state(self, package_name):
-         return self._package_state[package_name]
- 
-     def state_by_name(self, package_name):
+     def get_package_state(self, package_name, resolve_virtual=True):
          if package_name in self._package_state:
              return self._package_state[package_name]
-         else:
-             return "unknown"
+         if package_name in self._virtual_packages:
+             if resolve_virtual:
+                 provider = self._virtual_packages[package_name][0]
+                 return self._package_state[provider]
+             else:
+                 return "virtual"
+         return "does-not-exist"
  
      def _find_packages_ready_for_testing(self):
          return self.get_pkg_names_in_state("waiting-to-be-tested")

-- 
piuparts git repository



More information about the Piuparts-commits mailing list