[jhbuild] Handle missing pkg-config in get_installed_pkgconfigs (GNOME bug 683832)



commit a34a0bfc063d028c34896115c6e63498e05627a3
Author: Craig Keogh <cskeogh adam com au>
Date:   Sun Sep 30 21:54:16 2012 +0930

    Handle missing pkg-config in get_installed_pkgconfigs (GNOME bug 683832)

 jhbuild/utils/systeminstall.py |   35 +++++++++++++++++++----------------
 1 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index b82f334..9ddf4a2 100755
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -29,25 +29,28 @@ import cmds
 
 def get_installed_pkgconfigs(config):
     """Returns a dictionary mapping pkg-config names to their current versions on the system."""
-    proc = subprocess.Popen(['pkg-config', '--list-all'], stdout=subprocess.PIPE, env=config.get_original_environment(), close_fds=True)
-    stdout = proc.communicate()[0]
-    proc.wait()
-    pkgs = []
-    for line in StringIO(stdout):
-        pkg, rest = line.split(None, 1)
-        pkgs.append(pkg)
-    # We have to rather inefficiently repeatedly fork to work around
-    # broken pkg-config installations - if any package has a missing
-    # dependency pkg-config will fail entirely.
     pkgversions = {}
-    for pkg in pkgs:
-        args = ['pkg-config', '--modversion']
-        args.append(pkg)
-        proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-                                close_fds=True, env=config.get_original_environment())
+    try:
+        proc = subprocess.Popen(['pkg-config', '--list-all'], stdout=subprocess.PIPE, env=config.get_original_environment(), close_fds=True)
         stdout = proc.communicate()[0]
         proc.wait()
-        pkgversions[pkg] = stdout.strip()
+        pkgs = []
+        for line in StringIO(stdout):
+            pkg, rest = line.split(None, 1)
+            pkgs.append(pkg)
+        # We have to rather inefficiently repeatedly fork to work around
+        # broken pkg-config installations - if any package has a missing
+        # dependency pkg-config will fail entirely.
+        for pkg in pkgs:
+            args = ['pkg-config', '--modversion']
+            args.append(pkg)
+            proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+                                    close_fds=True, env=config.get_original_environment())
+            stdout = proc.communicate()[0]
+            proc.wait()
+            pkgversions[pkg] = stdout.strip()
+    except OSError: # pkg-config not installed
+        pass
     return pkgversions
 
 def systemdependencies_met(module_name, sysdeps, config):



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