[jhbuild] Allow systemmodules to not specify a version (GNOME bug 681342)



commit 3419755dad95cce0a528fdff1f06d4a77cb25617
Author: Craig Keogh <cskeogh adam com au>
Date:   Mon Sep 3 16:36:59 2012 +0930

    Allow systemmodules to not specify a version (GNOME bug 681342)

 jhbuild/commands/__init__.py     |   35 ++++++++++++--------
 jhbuild/commands/sysdeps.py      |   63 ++++++++++++++++++++------------------
 jhbuild/moduleset.py             |    9 +++--
 jhbuild/versioncontrol/system.py |    9 ++---
 4 files changed, 64 insertions(+), 52 deletions(-)
---
diff --git a/jhbuild/commands/__init__.py b/jhbuild/commands/__init__.py
index 972c04f..0ad9fd4 100644
--- a/jhbuild/commands/__init__.py
+++ b/jhbuild/commands/__init__.py
@@ -76,11 +76,20 @@ class BuildCommand(Command):
 
     def print_system_dependencies(self, module_state):
 
-        def fmt_pkg_config(pkg_config):
-            if pkg_config is None:
-                return ''
+        def fmt_details(pkg_config, req_version, installed_version):
+            fmt_list = []
+            if pkg_config:
+                fmt_list.append(pkg_config)
+            if req_version:
+                fmt_list.append(_('required=%s') % req_version)
+            if installed_version and installed_version != 'unknown':
+                fmt_list.append(_('installed=%s') % installed_version)
+            # Translators: This is used to separate items of package metadata
+            fmt_str = _(', ').join(fmt_list)
+            if fmt_str:
+                return _('(%s)') % fmt_str
             else:
-                return '%s ' % pkg_config
+                return ''
 
         print _('Required packages:')
         print _('  System installed packages which are too old:')
@@ -88,12 +97,10 @@ class BuildCommand(Command):
         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 (_("    %(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}))
+                print ('    %s %s' % (module.name,
+                                      fmt_details(module.pkg_config,
+                                                  req_version,
+                                                  installed_version)))
         if not have_too_old:
             print _('    (none)')
 
@@ -102,10 +109,10 @@ class BuildCommand(Command):
         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})
+                print ('    %s %s' % (module.name,
+                                      fmt_details(module.pkg_config,
+                                                  req_version,
+                                                  installed_version)))
         if not have_missing:
             print _('    (none)')
 
diff --git a/jhbuild/commands/sysdeps.py b/jhbuild/commands/sysdeps.py
index 5b38d79..47fdb7d 100644
--- a/jhbuild/commands/sysdeps.py
+++ b/jhbuild/commands/sysdeps.py
@@ -39,11 +39,20 @@ class cmd_sysdeps(cmd_build):
 
     def run(self, config, options, args, help=None):
 
-        def fmt_pkg_config(pkg_config):
-            if pkg_config is None:
-                return ''
+        def fmt_details(pkg_config, req_version, installed_version):
+            fmt_list = []
+            if pkg_config:
+                fmt_list.append(pkg_config)
+            if req_version:
+                fmt_list.append(_('required=%s') % req_version)
+            if installed_version and installed_version != 'unknown':
+                fmt_list.append(_('installed=%s') % installed_version)
+            # Translators: This is used to separate items of package metadata
+            fmt_str = _(', ').join(fmt_list)
+            if fmt_str:
+                return _('(%s)') % fmt_str
             else:
-                return '%s ' % pkg_config
+                return ''
 
         config.set_from_cmdline_options(options)
 
@@ -59,12 +68,10 @@ class cmd_sysdeps(cmd_build):
         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 (_("    %(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}))
+                print ('    %s %s' % (module.name,
+                                      fmt_details(module.pkg_config,
+                                                  req_version,
+                                                  installed_version)))
         if not have_new_enough:
             print _('  (none)')
 
@@ -73,12 +80,10 @@ class cmd_sysdeps(cmd_build):
         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 (_("    %(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}))
+                print ('    %s %s' % (module.name,
+                                      fmt_details(module.pkg_config,
+                                                  req_version,
+                                                  installed_version)))
         if not have_too_old:
             print _('    (none)')
 
@@ -86,10 +91,10 @@ class cmd_sysdeps(cmd_build):
         uninstalled = []
         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})
+                print ('    %s %s' % (module.name,
+                                      fmt_details(module.pkg_config,
+                                                  req_version,
+                                                  installed_version)))
                 if module.pkg_config is not None:
                     uninstalled.append(module.pkg_config[:-3]) # remove .pc
         if len(uninstalled) == 0:
@@ -103,22 +108,20 @@ class cmd_sysdeps(cmd_build):
             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 (_("    %(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}))
+                    print ('    %s %s' % (module.name,
+                                          fmt_details(module.pkg_config,
+                                                      req_version,
+                                                      installed_version)))
             if not have_too_old:
                 print _('    (none)')
 
             print _('  No matching system package installed:')
             for module,(req_version, installed_version, new_enough, systemmodule) in module_state.iteritems():
                 if installed_version is None and (not new_enough) 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})
+                    print ('    %s %s' % (module.name,
+                                          fmt_details(module.pkg_config,
+                                                      req_version,
+                                                      installed_version)))
                     if module.pkg_config is not None:
                         uninstalled.append(module.pkg_config[:-3]) # remove .pc
             if len(uninstalled) == 0:
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index 5c4ea04..ce69144 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -202,14 +202,17 @@ class ModuleSet:
                     module_pkg = module.pkg_config[:-3]
                     if module_pkg in installed_pkgconfig:
                         installed_version = installed_pkgconfig[module_pkg]
-                        new_enough = compare_version(installed_version,
-                                                     required_version)
+                        if required_version is None:
+                            new_enough = True
+                        else:
+                            new_enough = compare_version(installed_version,
+                                                         required_version)
                 elif systemmodule:
                     new_enough = systeminstall.systemdependencies_met \
                                      (module.name, module.systemdependencies,
                                       self.config)
                     if new_enough:
-                        installed_version = _('unknown')
+                        installed_version = 'unknown'
                 module_state[module] = (required_version, installed_version,
                                         new_enough, systemmodule)
         return module_state
diff --git a/jhbuild/versioncontrol/system.py b/jhbuild/versioncontrol/system.py
index 3454299..13a49c4 100644
--- a/jhbuild/versioncontrol/system.py
+++ b/jhbuild/versioncontrol/system.py
@@ -24,9 +24,8 @@ class SystemRepository(Repository):
 
     branch_xml_attrs = ['version']
 
-    def branch(self, name, version, module = None,
-               checkoutdir = None):
-        instance = SystemBranch(self, module, version, checkoutdir)
+    def branch(self, name, version = None):
+        instance = SystemBranch(self, version)
         return instance
 
     def to_sxml(self):
@@ -34,8 +33,8 @@ class SystemRepository(Repository):
 
 class SystemBranch(Branch):
 
-    def __init__(self, repository, module, version, checkoutdir):
-        Branch.__init__(self, repository, module, checkoutdir)
+    def __init__(self, repository, version):
+        Branch.__init__(self, repository, module = None, checkoutdir = None)
         self.version = version
 
     def to_sxml(self):



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