[jhbuild/sysinstall-fix-pc-lookup] sysinstall/apt: Limit .pc search to the pkg-config search paths



commit b3e3fa2871e64e2a7e71e438e6e9df625f96b899
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Sep 7 11:45:06 2019 +0200

    sysinstall/apt: Limit .pc search to the pkg-config search paths
    
    In case of zlib various packages like emscripten and mingw include
    a zlib.pc file and we currently install a random one of them and hope it
    works out.
    
    Instead only look for .pc files in the default pkg-config search paths
    to avoid false positives.

 .gitlab-ci.yml                 |  2 +-
 jhbuild/utils/systeminstall.py | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 31a34886..91477773 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -30,7 +30,7 @@ ubuntu-19.04-glib:
     - echo "use_local_modulesets = True" >> $HOME/.config/jhbuildrc
     - sudo apt-file update
     - jhbuild --no-interact --exit-on-error sysdeps --install --assume-yes glib
-    - sudo apt install -y zlib1g-dev docbook-xml docbook-xsl
+    - sudo apt install -y docbook-xml docbook-xsl
     - jhbuild --no-interact --exit-on-error build glib
 
 pages:
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 5db3e216..ae9bbe8e 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -413,6 +413,17 @@ class AptSystemInstall(SystemInstall):
         SystemInstall.__init__(self)
 
     def _apt_file_result_pkgconfig(self):
+
+        def get_pkg_config_search_paths():
+            output = subprocess.check_output(
+                ["pkg-config", "--variable", "pc_path", "pkg-config"])
+            return output.strip().split(os.pathsep)
+
+        # Various packages include zlib.pc (emscripten, mingw) so look only in
+        # the default pkg-config search paths
+        search_paths = get_pkg_config_search_paths()
+        search_paths = tuple(os.path.join(p, "") for p in search_paths)
+
         apt_file_result = subprocess.check_output(["apt-file", "search", "--regex", "\\.pc$"])
         ret_value = []
         for line in StringIO(apt_file_result):
@@ -421,7 +432,8 @@ class AptSystemInstall(SystemInstall):
                 continue
             name = parts[0]
             path = parts[1].strip()
-            ret_value.append((name, path))
+            if path.startswith(search_paths):
+                ret_value.append((name, path))
         return ret_value
 
     def _apt_file_result_regexp(self, paths):


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