[jhbuild/external-deps: 15/19] If moduleset tells us a minimum version needed to do this build, use that.



commit 7fabec0a0aa1059e8ffd078587d6a5ec38d0433e
Author: John Carr <john carr unrouted co uk>
Date:   Mon Jun 1 10:21:27 2009 +0100

    If moduleset tells us a minimum version needed to do this build, use that.
---
 jhbuild/commands/builddeps.py   |    6 ++++--
 jhbuild/modtypes/__init__.py    |   18 ++++++++++++++++++
 jhbuild/moduleset.py            |    5 +++--
 jhbuild/utils/systempackages.py |   12 ++++++++----
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/jhbuild/commands/builddeps.py b/jhbuild/commands/builddeps.py
index b3bb6b8..bcc8b21 100644
--- a/jhbuild/commands/builddeps.py
+++ b/jhbuild/commands/builddeps.py
@@ -48,8 +48,10 @@ class cmd_builddeps(Command):
 
         to_install = []
 
-        for module in module_set.get_module_list(args or config.modules):
-            if pkgs.satisfiable(module.name, module) and not pkgs.satisfied(module.name, module):
+        modules = module_set.get_module_list(args or config.modules)
+        for module in modules:
+            min_version = module.get_minimum_version(modules)
+            if pkgs.satisfiable(module, min_version) and not pkgs.satisfied(module, min_version):
                 to_install.append(pkgs.get_pkgname(module.name))
 
         if options.dryrun:
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index 107656c..d29f065 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -135,6 +135,24 @@ class Package:
     after = property(lambda self: self._after.keys())
     suggests = property(lambda self: self._suggests.keys())
 
+    def get_reverse_dependencies(self, modules):
+        """ Given a list of modules, which of those modules have dependencies on us """
+        rdeps = []
+        for mod in modules:
+            if self in mod.dependencies:
+                rdeps.append(mod)
+        return rdeps
+
+    def get_minimum_version(self, modules):
+        """ Given a list of modules, find ones that depend on this module and return what
+            is the earliest version we need """
+        min_version = None
+        for rdep in self.get_reverse_dependencies(modules):
+            min, rec = rdep._dependencies[self.name]
+            if not min_version or min > min_version:
+                min_version = min
+        return min_version
+
     def __repr__(self):
         return "<%s '%s'>" % (self.__class__.__name__, self.name)
 
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index b9cfcab..1c1b1da 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -120,7 +120,8 @@ class ModuleSet:
 
         if should_skip:
             for name, module in self.modules.iteritems():
-                if should_skip(name, module):
+                min_version = module.get_minimum_version(all_modules)
+                if should_skip(module, min_version):
                     self._state[module] = 'processed'
 
         def order(modules, module, mode = 'dependencies'):
@@ -212,7 +213,7 @@ class ModuleSet:
                 if test_app in mod.tested_pkgs:
                     test_modules.append(mod)
         return test_modules
-    
+
     def write_dot(self, modules=None, fp=sys.stdout, suggests=False, clusters=False):
         from jhbuild.modtypes import MetaModule
         from jhbuild.modtypes.autotools import AutogenModule
diff --git a/jhbuild/utils/systempackages.py b/jhbuild/utils/systempackages.py
index c1271ac..0a000f2 100644
--- a/jhbuild/utils/systempackages.py
+++ b/jhbuild/utils/systempackages.py
@@ -44,21 +44,25 @@ class SystemPackages(object):
             return self.aliases[name]
         return name
 
-    def satisfiable(self, name, module):
+    def satisfiable(self, module, version=None):
         """ Returns true if a module is satisfiable by installing a system package """
         if isinstance(module, MetaModule):
             return False
+        if version:
+            return self.is_available(self.get_pkgname(module.name), version)
         if not isinstance(module.branch, TarballBranch):
             return False
-        return self.is_available(self.get_pkgname(name), module.branch.version)
+        return self.is_available(self.get_pkgname(module.name), module.branch.version)
 
-    def satisfied(self, name, module):
+    def satisfied(self, module, version=None):
         """ Returns true if module is satisfied by an already installed system package """
         if isinstance(module, MetaModule):
             return False
+        if version:
+            return self.is_available(self.get_pkgname(module.name), version)
         if not isinstance(module.branch, TarballBranch):
             return False
-        return self.is_installed(self.get_pkgname(name), module.branch.version)
+        return self.is_installed(self.get_pkgname(module.name), module.branch.version)
 
     def is_installed(self, name, version=None):
         return False



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]