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



commit a0d2a7f0e32defdac068983273eefd96ccf85855
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Tue Sep 10 19:27:05 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                 |  6 +++---
 .gitlab-ci/build-docker.sh     |  2 +-
 jhbuild/utils/systeminstall.py | 24 ++++++++++++++++--------
 3 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 3c6c71ae..3380f855 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,7 +3,7 @@ stages:
   - deploy
 
 test:
-  image: registry.gitlab.gnome.org/gnome/jhbuild/jhbuild:v2
+  image: registry.gitlab.gnome.org/gnome/jhbuild/jhbuild:v3
   script:
     - mkdir _build && cd _build
     - ../autogen.sh
@@ -22,7 +22,7 @@ test:
 
 
 ubuntu-19.04-glib:
-  image: registry.gitlab.gnome.org/gnome/jhbuild/jhbuild:v2
+  image: registry.gitlab.gnome.org/gnome/jhbuild/jhbuild:v3
   script:
     - ./autogen.sh
     - make
@@ -32,7 +32,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/.gitlab-ci/build-docker.sh b/.gitlab-ci/build-docker.sh
index 9affcab0..eee86066 100755
--- a/.gitlab-ci/build-docker.sh
+++ b/.gitlab-ci/build-docker.sh
@@ -2,6 +2,6 @@
 
 set -e
 
-TAG="registry.gitlab.gnome.org/gnome/jhbuild/jhbuild:v2"
+TAG="registry.gitlab.gnome.org/gnome/jhbuild/jhbuild:v3"
 
 sudo docker build --tag "${TAG}" --file "Dockerfile" .
\ No newline at end of file
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index 45c74c4e..77d5d93e 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -453,13 +453,6 @@ class AptSystemInstall(SystemInstall):
             ret_value += "|.*/" + re.escape(path)
         return ret_value
 
-    def _name_match_pkg(self, pkg, apt_file_result, native_packages):
-        for name, path in apt_file_result:
-            if path.endswith("/" + pkg):
-                native_packages.append(name)
-                return True
-        return False
-
     def _name_match_exact(self, exact_path_to_match, apt_file_result, native_packages):
         for name, path in apt_file_result:
             if path == exact_path_to_match:
@@ -470,9 +463,24 @@ class AptSystemInstall(SystemInstall):
     def _append_native_packages_or_warn_pkgconfig(self, pkgconfigs, native_packages):
         if len(pkgconfigs) == 0:
             return
+
+        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 = self._apt_file_result(regexp="\\.pc$")
         for modname, pkg in pkgconfigs:
-            if not self._name_match_pkg(pkg, apt_file_result, native_packages):
+            for name, path in apt_file_result:
+                if path.endswith("/" + pkg) and path.startswith(search_paths):
+                    native_packages.append(name)
+                    break
+            else:
                 logging.info(_('No native package found for %(id)s '
                                '(%(filename)s)') % {'id'       : modname,
                                                     'filename' : pkg})


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