[jhbuild] sysdeps: Refactor to not instantiate systeminstall unless we sysdeps --install
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [jhbuild] sysdeps: Refactor to not instantiate systeminstall unless we sysdeps --install
- Date: Fri, 29 Jul 2011 15:44:37 +0000 (UTC)
commit b7e88abcec8c293beaccd17f622eb06cbaa05a89
Author: Colin Walters <walters verbum org>
Date: Fri Jul 29 11:44:27 2011 -0400
sysdeps: Refactor to not instantiate systeminstall unless we sysdeps --install
This makes the core work on Ubuntu even if we don't have a backend.
https://bugzilla.gnome.org/show_bug.cgi?id=655546
jhbuild/commands/sysdeps.py | 8 +++---
jhbuild/moduleset.py | 4 +-
jhbuild/utils/systeminstall.py | 45 +++++++++++++++++++--------------------
3 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/jhbuild/commands/sysdeps.py b/jhbuild/commands/sysdeps.py
index 7f8e66b..e7a525c 100644
--- a/jhbuild/commands/sysdeps.py
+++ b/jhbuild/commands/sysdeps.py
@@ -47,10 +47,6 @@ class cmd_sysdeps(cmd_build):
def run(self, config, options, args, help=None):
config.set_from_cmdline_options(options)
- installer = SystemInstall.find_best()
- if installer is None:
- raise FatalError(_("Don't know how to install packages on this system"))
-
if not config.partial_build:
raise FatalError(_("Partial build is not enabled; add partial_build = True to ~/.jhbuildrc"))
@@ -93,6 +89,10 @@ class cmd_sysdeps(cmd_build):
print _(' (none)')
if options.install:
+ installer = SystemInstall.find_best()
+ if installer is None:
+ raise FatalError(_("Don't know how to install packages on this system"))
+
if len(uninstalled) == 0:
logging.info(_("No uninstalled system dependencies to install for modules: %r" % (modules, )))
else:
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index 3c214b8..411ac82 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -40,7 +40,7 @@ from jhbuild.utils import packagedb
from jhbuild.utils.cmds import compare_version, get_output
from jhbuild.modtypes.testmodule import TestModule
from jhbuild.versioncontrol.tarball import TarballBranch
-from jhbuild.utils.systeminstall import SystemInstall
+from jhbuild.utils import systeminstall
__all__ = ['load', 'load_tests', 'get_default_repo']
@@ -256,7 +256,7 @@ class ModuleSet:
def get_system_modules(self, modules):
assert self.config.partial_build
- installed_pkgconfig = SystemInstall.get_installed_pkgconfigs()
+ installed_pkgconfig = systeminstall.get_installed_pkgconfigs()
# pkgconfig -> (required_version, installed_verison)
module_state = {}
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 684ca0d..5fad0bb 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -26,6 +26,28 @@ from StringIO import StringIO
import cmds
+def get_installed_pkgconfigs():
+ """Returns a dictionary mapping pkg-config names to their current versions on the system."""
+ 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]
+ proc.wait()
+ pkgs = []
+ for line in StringIO(stdout):
+ pkg, rest = line.split(None, 1)
+ pkgs.append(pkg)
+ args = ['pkg-config', '--modversion']
+ args.extend(pkgs)
+ proc = subprocess.Popen(args, stdout=subprocess.PIPE, close_fds=True)
+ stdout = proc.communicate()[0]
+ proc.wait()
+ pkgversions = {}
+ for pkg,verline in zip(pkgs, StringIO(stdout)):
+ pkgversions[pkg] = verline.strip()
+ return pkgversions
+
class SystemInstall(object):
def __init__(self):
pass
@@ -35,29 +57,6 @@ class SystemInstall(object):
raise NotImplementedError()
@classmethod
- def get_installed_pkgconfigs(cls):
- """Returns a dictionary mapping pkg-config names to their current versions on the system."""
- 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]
- proc.wait()
- pkgs = []
- for line in StringIO(stdout):
- pkg, rest = line.split(None, 1)
- pkgs.append(pkg)
- args = ['pkg-config', '--modversion']
- args.extend(pkgs)
- proc = subprocess.Popen(args, stdout=subprocess.PIPE, close_fds=True)
- stdout = proc.communicate()[0]
- proc.wait()
- pkgversions = {}
- for pkg,verline in zip(pkgs, StringIO(stdout)):
- pkgversions[pkg] = verline.strip()
- return pkgversions
-
- @classmethod
def find_best(cls):
global _classes
for possible_cls in _classes:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]