[jhbuild/wip/sysdeps] Add new partial_build key



commit 850cbd2771ad3eb1ce01a6513f6f057f9955a3b4
Author: Colin Walters <walters verbum org>
Date:   Fri Jun 24 16:41:22 2011 -0400

    Add new partial_build key
    
    Basically, when the partial_build key is set (which it is by default),
    when we're gathering a module list (for say "jhbuild build", or just
    "jhbuild list"), we look at the installed pkg-config files.  If there
    is a local module which matches the id of the tarball, we skip it.
    
    We should still be comparing versions.
    
    But, this allows me to skip building e.g. cairo and nspr if I have
    them on the system.

 jhbuild/config.py              |    2 +-
 jhbuild/defaults.jhbuildrc     |    5 ++++-
 jhbuild/moduleset.py           |   20 ++++++++++++++++++++
 jhbuild/utils/systeminstall.py |   14 ++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/jhbuild/config.py b/jhbuild/config.py
index bcf5a9a..0488a16 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -40,7 +40,7 @@ _defaults_file = os.path.join(os.path.dirname(__file__), 'defaults.jhbuildrc')
 _default_jhbuildrc = os.path.join(os.environ['HOME'], '.jhbuildrc')
 
 _known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 'prefix',
-                'checkoutroot', 'buildroot', 'top_builddir',
+                'partial_build', 'checkoutroot', 'buildroot', 'top_builddir',
                 'autogenargs', 'makeargs',
                 'installprog', 'repos', 'branches', 'noxvfb', 'xvfbargs',
                 'builddir_pattern', 'module_autogenargs', 'module_makeargs',
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 9041028..9381d26 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -21,6 +21,9 @@ modules = [ 'meta-gnome-core', 'meta-gnome-apps-tested' ]
 #    have changed.
 build_policy = 'updated-deps'
 
+# If True, ignore tarball modules already installed while building
+partial_build = True
+
 # Skip modules installed more recently than the specified relative time.
 # min_age can only be specified via the command-line. Setting min_age within
 # the configuration file has no effect.
@@ -172,4 +175,4 @@ dvcs_mirror_dir = None
 
 # A string displayed before JHBuild executes a command. String may contain the
 # variables %(command)s, %(cwd)s
-print_command_pattern = '%(command)s'
\ No newline at end of file
+print_command_pattern = '%(command)s'
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index aacd4a9..69cda28 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -38,6 +38,8 @@ from jhbuild.versioncontrol import get_repo_type
 from jhbuild.utils import httpcache
 from jhbuild.utils.cmds import get_output
 from jhbuild.modtypes.testmodule import TestModule
+from jhbuild.versioncontrol.tarball import TarballBranch
+from jhbuild.utils.systeminstall import SystemInstall
 
 __all__ = ['load', 'load_tests', 'get_default_repo']
 
@@ -79,6 +81,11 @@ class ModuleSet:
 
         asked_modules = all_modules[:]
 
+        if self.config.partial_build:
+            installed_pkgconfig = SystemInstall.get_installed_pkgconfig()
+        else:
+            installed_pkgconfig = []
+
         # 1st: get all modules that will be needed
         # note this is only needed to skip "after" modules that would not
         # otherwise be built
@@ -99,6 +106,7 @@ class ModuleSet:
                                     'invalid': modname})
                     dep_missing = True
                     continue
+
                 if not depmod in all_modules:
                     all_modules.append(depmod)
 
@@ -125,6 +133,18 @@ class ModuleSet:
             # mark skipped modules as already processed
             self._state[self.modules.get(modname)] = 'processed'
 
+        if self.config.partial_build:
+            skipped = set()
+            for module in all_modules:
+                if (module.pkg_config 
+                    and isinstance(module.branch, TarballBranch)
+                    and module.pkg_config in installed_pkgconfig):
+                    skipped.add(module)
+            for module in skipped:
+                logging.debug(_("Skipping already installed module module %(module)s from system pkg-config %(pkg)s"),
+                              modname, depmod.pkg_config)
+                self._state[module] = 'processed'
+
         if tags:
             for modname in self.modules:
                 for tag in tags:
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 13c2c89..671ee0f 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -21,6 +21,7 @@ import os
 import sys 
 import logging
 import subprocess
+from StringIO import StringIO
 
 import cmds
 
@@ -35,6 +36,19 @@ class SystemInstall(object):
         raise NotImplementedError()
 
     @classmethod
+    def get_installed_pkgconfig(cls):
+        env = dict(os.environ)
+        if 'PKG_CONFIG_PATH' in env:
+            del env['PKG_CONFIG_PATH']
+        proc = subprocess.Popen(['pkg-config', '--list-all'], stdout=subprocess.PIPE, env=env, close_fds=True)
+        stdout = proc.communicate()[0]
+        pkgs = []
+        for line in StringIO(stdout):
+            pkg, rest = line.split(None, 1)
+            pkgs.append(pkg + '.pc')
+        return pkgs
+
+    @classmethod
     def find_best(cls):
         for possible_cls in _classes:
             if possible_cls.detect():



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