[jhbuild] Display package name and pkg-config (GNOME bug 681886)



commit c7d55e5f93c7591be87286cbe0f64886f8075828
Author: Craig Keogh <cskeogh adam com au>
Date:   Tue Aug 14 17:13:00 2012 +0930

    Display package name and pkg-config (GNOME bug 681886)
    
    Display package name and pkg-config to sysdeps command and the missing
    dependencies message. Includes a rewrite of get_system_modules and
    renaming to get_module_state.

 jhbuild/commands/__init__.py  |   42 +++++++++++++++--------
 jhbuild/commands/base.py      |    2 +-
 jhbuild/commands/sysdeps.py   |   74 ++++++++++++++++++++++++++--------------
 jhbuild/commands/tinderbox.py |    2 +-
 jhbuild/moduleset.py          |   45 +++++++++++--------------
 5 files changed, 97 insertions(+), 68 deletions(-)
---
diff --git a/jhbuild/commands/__init__.py b/jhbuild/commands/__init__.py
index 4e34f8d..972c04f 100644
--- a/jhbuild/commands/__init__.py
+++ b/jhbuild/commands/__init__.py
@@ -68,33 +68,45 @@ class BuildCommand(Command):
     def required_system_dependencies_installed(self, module_state):
         '''Returns true if all required system dependencies are installed for
         modules in module_state.'''
-        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-            if required_sysdep:
-                if installed_version is None or not new_enough:
+        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+            if systemmodule:
+                if not new_enough:
                     return False
         return True
 
     def print_system_dependencies(self, module_state):
+
+        def fmt_pkg_config(pkg_config):
+            if pkg_config is None:
+                return ''
+            else:
+                return '%s ' % pkg_config
+
         print _('Required packages:')
         print _('  System installed packages which are too old:')
         have_too_old = False
-        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-            if (installed_version is not None) and (not new_enough) and required_sysdep:
+        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+            if (installed_version is not None) and (not new_enough) and systemmodule:
                 have_too_old = True
-                print (_("    %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
-                                                                                      'req': req_version,
-                                                                                      'installed': installed_version}))
+                print (_("    %(module)s (%(pkg_config)srequired=%(req)s, "
+                         "installed=%(installed)s)" % \
+                             {'module'     : module.name,
+                              'pkg_config' : fmt_pkg_config(module.pkg_config),
+                              'req'        : req_version,
+                              'installed'  : installed_version}))
         if not have_too_old:
             print _('    (none)')
 
         print _('  No matching system package installed:')
-        uninstalled = []
-        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-            if installed_version is None and required_sysdep:
-                print (_("    %(pkg)s (required=%(req)s)") % {'pkg': pkg_config,
-                                                              'req': req_version})
-                uninstalled.append(pkg_config)
-        if len(uninstalled) == 0:
+        have_missing = False
+        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+            if installed_version is None and (not new_enough) and systemmodule:
+                have_missing = True
+                print (_("    %(module)s (%(pkg_config)srequired=%(req)s)") % \
+                       {'module'     : module.name,
+                        'pkg_config' : fmt_pkg_config(module.pkg_config),
+                        'req': req_version})
+        if not have_missing:
             print _('    (none)')
 
 
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index 6c7f720..c2514a7 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -254,7 +254,7 @@ class cmd_build(BuildCommand):
             return 0
 
         if config.check_sysdeps:
-            module_state = module_set.get_system_modules(full_module_list)
+            module_state = module_set.get_module_state(full_module_list)
             if not self.required_system_dependencies_installed(module_state):
                 self.print_system_dependencies(module_state)
                 raise FatalError(_('Required system dependencies not installed.'
diff --git a/jhbuild/commands/sysdeps.py b/jhbuild/commands/sysdeps.py
index 76ab2a1..b3fc450 100644
--- a/jhbuild/commands/sysdeps.py
+++ b/jhbuild/commands/sysdeps.py
@@ -38,44 +38,60 @@ class cmd_sysdeps(cmd_build):
                         help=_('Install pkg-config modules via system'))])
 
     def run(self, config, options, args, help=None):
+
+        def fmt_pkg_config(pkg_config):
+            if pkg_config is None:
+                return ''
+            else:
+                return '%s ' % pkg_config
+
         config.set_from_cmdline_options(options)
 
         module_set = jhbuild.moduleset.load(config)
         modules = args or config.modules
         module_list = module_set.get_full_module_list(modules)
-        module_state = module_set.get_system_modules(module_list)
+        module_state = module_set.get_module_state(module_list)
 
         have_new_enough = False
         have_too_old = False
 
         print _('System installed packages which are new enough:')
-        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-            if (installed_version is not None) and new_enough and (config.partial_build or required_sysdep):
+        for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+            if (installed_version is not None) and new_enough and (config.partial_build or systemmodule):
                 have_new_enough = True
-                print (_("    %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
-                                                                                      'req': req_version,
-                                                                                      'installed': installed_version}))
+                print (_("    %(module)s (%(pkg_config)srequired=%(req)s, "
+                         "installed=%(installed)s)" % \
+                             {'module'     : module.name,
+                              'pkg_config' : fmt_pkg_config(module.pkg_config),
+                              'req'        : req_version,
+                              'installed'  : installed_version}))
         if not have_new_enough:
             print _('  (none)')
 
         print _('Required packages:')
         print _('  System installed packages which are too old:')
-        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-            if (installed_version is not None) and (not new_enough) and required_sysdep:
+        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+            if (installed_version is not None) and (not new_enough) and systemmodule:
                 have_too_old = True
-                print (_("    %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
-                                                                                      'req': req_version,
-                                                                                      'installed': installed_version}))
+                print (_("    %(module)s (%(pkg_config)srequired=%(req)s, "
+                         "installed=%(installed)s)" % \
+                             {'module'     : module.name,
+                              'pkg_config' : fmt_pkg_config(module.pkg_config),
+                              'req'        : req_version,
+                              'installed'  : installed_version}))
         if not have_too_old:
             print _('    (none)')
 
         print _('  No matching system package installed:')
         uninstalled = []
-        for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-            if installed_version is None and required_sysdep:
-                print (_("    %(pkg)s (required=%(req)s)") % {'pkg': pkg_config,
-                                                              'req': req_version})
-                uninstalled.append(pkg_config)
+        for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+            if installed_version is None and (not new_enough) and systemmodule:
+                print (_("    %(module)s (%(pkg_config)srequired=%(req)s)") % \
+                       {'module'     : module.name,
+                        'pkg_config' : fmt_pkg_config(module.pkg_config),
+                        'req': req_version})
+                if module.pkg_config is not None:
+                    uninstalled.append(module.pkg_config[:-3]) # remove .pc
         if len(uninstalled) == 0:
             print _('    (none)')
 
@@ -84,21 +100,27 @@ class cmd_sysdeps(cmd_build):
         if config.partial_build:
             print _('Optional packages: (JHBuild will build the missing packages)')
             print _('  System installed packages which are too old:')
-            for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-                if (installed_version is not None) and (not new_enough) and (not required_sysdep):
+            for module, (req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+                if (installed_version is not None) and (not new_enough) and (not systemmodule):
                     have_too_old = True
-                    print (_("    %(pkg)s (required=%(req)s, installed=%(installed)s)" % {'pkg': pkg_config,
-                                                                                          'req': req_version,
-                                                                                          'installed': installed_version}))
+                    print (_("    %(module)s (%(pkg_config)srequired=%(req)s, "
+                             "installed=%(installed)s)" % \
+                                 {'module'     : module.name,
+                                  'pkg_config' : fmt_pkg_config(module.pkg_config),
+                                  'req'        : req_version,
+                                  'installed'  : installed_version}))
             if not have_too_old:
                 print _('    (none)')
 
             print _('  No matching system package installed:')
-            for pkg_config,(module, req_version, installed_version, new_enough, required_sysdep) in module_state.iteritems():
-                if installed_version is None and (not required_sysdep):
-                    print (_("    %(pkg)s (required=%(req)s)") % {'pkg': pkg_config,
-                                                                  'req': req_version})
-                    uninstalled.append(pkg_config)
+            for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
+                if installed_version is None and (not systemmodule):
+                    print (_("    %(module)s (%(pkg_config)srequired=%(req)s)") % \
+                           {'module'     : module.name,
+                            'pkg_config' : fmt_pkg_config(module.pkg_config),
+                            'req': req_version})
+                    if module.pkg_config is not None:
+                        uninstalled.append(module.pkg_config[:-3]) # remove .pc
             if len(uninstalled) == 0:
                 print _('  (none)')
 
diff --git a/jhbuild/commands/tinderbox.py b/jhbuild/commands/tinderbox.py
index 84b3706..eda864c 100644
--- a/jhbuild/commands/tinderbox.py
+++ b/jhbuild/commands/tinderbox.py
@@ -91,7 +91,7 @@ class cmd_tinderbox(BuildCommand):
                 raise FatalError(_('%s not in module list') % options.startat)
 
         if config.check_sysdeps:
-            module_state = module_set.get_system_modules(full_module_list)
+            module_state = module_set.get_module_state(full_module_list)
             if not self.required_system_dependencies_installed(module_state):
                 self.print_system_dependencies(module_state)
                 raise FatalError(_('Required system dependencies not installed.'
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index d9cdbeb..eb69472 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -184,37 +184,32 @@ class ModuleSet:
                     test_modules.append(mod)
         return test_modules
 
-    def get_system_modules(self, modules):
-
+    def get_module_state(self, modules):
         installed_pkgconfig = systeminstall.get_installed_pkgconfigs(self.config)
         
-        # pkgconfig -> (required_version, installed_verison)
         module_state = {}
         for module in modules:
-            if (isinstance(module.branch, TarballBranch)
-                or isinstance(module, SystemModule)):
+            # only consider SystemModules or modules with <pkg-config>
+            if (isinstance(module, SystemModule) or
+                (isinstance(module.branch, TarballBranch) and
+                 module.pkg_config is not None)):
                 required_version = module.branch.version
-                if module.pkg_config is None:
-                    module_pkg = module.name
-                else: # Strip off the .pc
+                installed_version = None
+                new_enough = False
+                systemmodule = isinstance(module, SystemModule)
+                if module.pkg_config is not None:
+                    # strip off the .pc
                     module_pkg = module.pkg_config[:-3]
-
-                if module.systemdependencies:
-                    if not systeminstall.systemdependencies_met \
-                               (module.name, module.systemdependencies,
-                                self.config):
-                        module_state[module_pkg] = (module, required_version,
-                                                    None, False,
-                                                    isinstance(module,
-                                                               SystemModule))
-                if module.pkg_config is None:
-                    continue
-                if not module_pkg in installed_pkgconfig:
-                    module_state[module_pkg] = (module, required_version, None, False, isinstance(module, SystemModule))
-                else:
-                    installed_version = installed_pkgconfig[module_pkg]
-                    new_enough = compare_version(installed_version, required_version)
-                    module_state[module_pkg] = (module, required_version, installed_version, new_enough, isinstance(module, SystemModule))
+                    if module_pkg in installed_pkgconfig:
+                        installed_version = installed_pkgconfig[module_pkg]
+                        new_enough = compare_version(installed_version,
+                                                     required_version)
+                elif systemmodule:
+                    new_enough = systeminstall.systemdependencies_met \
+                                     (module.name, module.systemdependencies,
+                                      self.config)
+                module_state[module] = (required_version, installed_version,
+                                        new_enough, systemmodule)
         return module_state
 
     def remove_system_modules(self, modules):



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