[jhbuild] skip system-installed modules during bootstrap phase



commit c896c93407551a239cbcd261d4d5e4d452028a74
Author: Frederic Peters <fpeters 0d be>
Date:   Fri Apr 24 23:10:03 2009 +0200

    skip system-installed modules during bootstrap phase
    
    JHBuild will now check for system-installed modules (with sufficient
    version number) and add those it finds to the skip list, as it makes
    little sense for potential contributors to be stopped by an error
    compiling gettext. There is an --ignore-system flag to get the old
    "build everything" behaviour.
---
 jhbuild/commands/bootstrap.py |   48 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 47 insertions(+), 1 deletions(-)

diff --git a/jhbuild/commands/bootstrap.py b/jhbuild/commands/bootstrap.py
index 2453e7a..42e88f4 100644
--- a/jhbuild/commands/bootstrap.py
+++ b/jhbuild/commands/bootstrap.py
@@ -18,28 +18,74 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 import os
+import sys
 import urllib
+from optparse import make_option
 
 import jhbuild.moduleset
 import jhbuild.frontends
 from jhbuild.commands import Command, register_command
 import jhbuild.commands.base
 from jhbuild.commands.base import cmd_build
+from jhbuild.utils.cmds import check_version
 
 class cmd_bootstrap(cmd_build):
     doc = _('Build required support tools')
 
     name = 'bootstrap'
 
+    def __init__(self):
+        cmd_build.__init__(self)
+        self.options.append(
+            make_option('--ignore-system',
+                        action='store_true', dest='ignore_system', default=False,
+                        help=_('do not use system installed modules')))
+
     def run(self, config, options, args):
         config.moduleset = 'bootstrap'
         # load the bootstrap module set
         if not args:
             args = ['meta-bootstrap']
 
+        for item in options.skip:
+            config.skip += item.split(',')
+        options.skip = []
+
+        ignored_modules = []
+        if not options.ignore_system:
+            # restore system PATH to check for system-installed programs
+            path = os.environ.get('PATH')
+            os.environ['PATH'] = path.replace(
+                    os.path.join(config.prefix, 'bin'), '')
+
+            module_set = jhbuild.moduleset.load(config)
+            modules = args or config.modules
+            module_list = module_set.get_module_list(modules)
+
+            for module in module_list:
+                if module.type == 'meta':
+                    continue
+                for version_regex in (r'.*?[ \(]([\d.]+)', r'^([\d.]+)'):
+                    if check_version([module.name, '--version'],
+                            version_regex, module.branch.version):
+                        ignored_modules.append(module.name)
+                        break
+
+            os.environ['PATH'] = path
+            config.skip.extend(ignored_modules)
+
         # cancel the bootstrap updateness check as it has no sense (it *is*
         # running bootstrap right now)
         jhbuild.commands.base.check_bootstrap_updateness = lambda x: x
-        return cmd_build.run(self, config, options, args)
+        rc = cmd_build.run(self, config, options, args)
+
+        if ignored_modules:
+            print >> sys.stderr, uencode(
+                    _('I: some modules (%s) were automatically ignored as a '
+                      'sufficient enough version was found installed on '
+                      'your system. Use --ignore-system if you want to build '
+                      'them nevertheless.' % ', '.join(ignored_modules)))
+
+        return rc
 
 register_command(cmd_bootstrap)



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