[jhbuild/desrt/master: 2/35] sysdeps: support for 'xml' and 'python2' sysdeps



commit aa38aaaa4af66ae0071cb9885765d362c32bcb9b
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Dec 14 19:15:42 2014 -0500

    sysdeps: support for 'xml' and 'python2' sysdeps
    
    Add support for two new types of system dependencies.
    
    An 'xml' dependency names a uri that must exist in the local xml catalog.  We
    discover the path of the xml catalog using the same logic that gtk-doc uses
    (which is appropriate since gtk-doc is the only program requiring xml depends
    at the moment).
    
    A 'python2' dependency names a python module that should be available for use
    with 'import' in python 2.
    
    There is not currently support in any of the 'sysdep --install' backends for
    installing these sysdeps if they are missing, but at least now we can report
    them as missing instead of just waiting for the build to fail.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691394

 jhbuild/utils/systeminstall.py |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 6986393..4235e51 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -23,6 +23,7 @@ import logging
 import shlex
 import subprocess
 import pipes
+import imp
 from StringIO import StringIO
 
 import cmds
@@ -144,6 +145,28 @@ def systemdependencies_met(module_name, sysdeps, config):
                     break
             if not found:
                 return False
+
+        elif dep_type == 'python2':
+            try:
+                imp.find_module(value)
+            except:
+                return False
+
+        elif dep_type == 'xml':
+            for d in os.environ['XDG_DATA_DIRS'].split(':'):
+                xml_catalog = os.path.join(d, 'xml', 'catalog')
+                if os.path.exists(xml_catalog):
+                    break
+            else:
+                xml_catalog = '/etc/xml/catalog'
+
+            try:
+                # no xmlcatalog installed will (correctly) fail the check
+                subprocess.check_output(['xmlcatalog', xml_catalog, value])
+
+            except:
+                return False
+
     return True
 
 class SystemInstall(object):


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