[jhbuild/wip/sysdeps: 4/4] sysdeps: New command



commit 15db5cc1b78811847cbb096eb93f4e3b3de1ebb7
Author: Colin Walters <walters verbum org>
Date:   Thu Jun 23 17:00:40 2011 -0400

    sysdeps: New command
    
    This command parses the moduleset and finds all .pc files that are
    needed by tarballs from the given moduleset, and installs them.
    
    A key use case here is partial jhbuilds; for example, say you know
    you can avoid building gtk+-2.  Simply:
    
    jhbuild sysdeps gtk+-2
    
    https://bugzilla.gnome.org/show_bug.cgi?id=564373

 jhbuild/commands/Makefile.am |    1 +
 jhbuild/commands/sysdeps.py  |   83 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/jhbuild/commands/Makefile.am b/jhbuild/commands/Makefile.am
index d5f3bc9..704fb7d 100644
--- a/jhbuild/commands/Makefile.am
+++ b/jhbuild/commands/Makefile.am
@@ -14,6 +14,7 @@ app_PYTHON = \
 	rdepends.py \
 	sanitycheck.py \
 	snapshot.py \
+	sysdeps.py \
 	tinderbox.py \
 	uninstall.py
 
diff --git a/jhbuild/commands/sysdeps.py b/jhbuild/commands/sysdeps.py
new file mode 100644
index 0000000..dc5e95e
--- /dev/null
+++ b/jhbuild/commands/sysdeps.py
@@ -0,0 +1,83 @@
+# jhbuild - a build script for GNOME 1.x and 2.x
+# Copyright (C) 2011 Colin Walters <walters verbum org>
+#
+#   sysdeps.py: Install system dependencies
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+import os
+import sys
+import urllib
+from optparse import make_option
+import logging
+
+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
+from jhbuild.utils.systeminstall import SystemInstall
+from jhbuild.versioncontrol.tarball import TarballBranch
+
+class cmd_sysdeps(cmd_build):
+    doc = N_('Install system dependencies')
+
+    name = 'sysdeps'
+
+    def __init__(self):
+        cmd_build.__init__(self)
+
+    def _get_pkgconfig_providers(self, pkgd):
+        """Find all modules that provide pkg-config id like 'foo.pc'"""
+        provides = []
+        for (modname, module) in self.modules.iteritems():
+            if module.pkgconfig == pkgconfig:
+                provides.append(module)
+        return provides
+
+    def _get_pkgconfig_provider(self, pkg_config, requiring_pkg):
+        if requiring_pkg is None:
+            requiring_pkg = '<command>'
+        providers = self.get_pkgconfig_providers(pkg_config)
+        if len(providers) > 1:
+            raise FatalError(_('multiple packages provide %(pkg)s (required by %(requiring)s)')
+                             % {'pkg': pkg_config, 'requiring': requiring_pkg})
+        if len(providers) == 0:
+            return None
+        return providers[0]
+
+    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"))
+
+        module_set = jhbuild.moduleset.load(config)
+        modules = args or config.modules
+        module_list = module_set.get_module_list(modules)
+        pkgconfig_ids = []
+        for module in module_list:
+            if module.pkg_config and isinstance(module.branch, TarballBranch):
+                pkgconfig_ids.append(module.pkg_config)
+                
+        if len(pkgconfig_ids) == 0:
+            logging.info(_("No system dependencies to install for modules: %r" % (modules, )))
+        else:
+            logging.info(_("Installing dependencies on system: %s" % (' '.join(pkgconfig_ids), )))
+            installer.install(pkgconfig_ids)         
+
+register_command(cmd_sysdeps)



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