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

Bug#1006570: pkg-config-crosswrapper: misdetects architecture in the presence of dpkg-architecture variables



Package: pkg-config
Version: 0.29.2-1
Tags: patch
User: debian-cross@lists.debian.org
Usertags: ftcbfs
Control: affects -1 + src:sgt-puzzles
X-Debbugs-Cc: benh@debian.org, debian-cross@lists.debian.org

Consider the following interaction on an amd64 root with mipsel as a
foreign architecture:

$ dpkg-architecture -amipsel -f -c pkg-config --cflags glib-2.0
-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
$ dpkg-architecture -amipsel -f -c x86_64-linux-gnu-pkg-config --cflags glib-2.0
-I/usr/include/glib-2.0 -I/usr/lib/mipsel-linux-gnu/glib-2.0/include
$

The first invocation shows that running plain pkg-config is unaffected
by dpkg-architecture environment variables and just prints whatever
architecture pkg-config was installed as (amd64 in this case). The
second invocation however specifically asks for amd64, but gets mipsel
output instead.

This is rooted in how dpkg-architecture is used to resolve the gnu
triplet from the program name to the multiarch dirname. When
dpkg-architecture is called without -f, it will prefer the existing
environment variables over the -t flag. This is not what we want here
and the -f flag should be used.

This happens to trip sgt-puzzles as it performs a build architecture
build before a host architecture build and explicitly uses the
triplet-prefixed build architecture pkg-config.

Please consider applying the attached patch.

Helmut
diff -u pkg-config-0.29.2/debian/changelog pkg-config-0.29.2/debian/changelog
--- pkg-config-0.29.2/debian/changelog
+++ pkg-config-0.29.2/debian/changelog
@@ -1,3 +1,11 @@
+pkg-config (0.29.2-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix crosswrapper to work in the presence of dpkg-architecture variables.
+    Closes: #-1
+
+ -- Helmut Grohne <helmut@subdivi.de>  Sun, 27 Feb 2022 22:18:02 +0100
+
 pkg-config (0.29.2-1) unstable; urgency=medium
 
   * New upstream version.  Closes: #922173
diff -u pkg-config-0.29.2/debian/pkg-config-crosswrapper pkg-config-0.29.2/debian/pkg-config-crosswrapper
--- pkg-config-0.29.2/debian/pkg-config-crosswrapper
+++ pkg-config-0.29.2/debian/pkg-config-crosswrapper
@@ -10,7 +10,7 @@
   basename="$(basename "$0")"
   triplet="${basename%-pkg-config}"
   # Normalized multiarch path if any, e.g. i386-linux-gnu for i386
-  multiarch="$(dpkg-architecture -t"${triplet}" -qDEB_HOST_MULTIARCH 2>/dev/null)"
+  multiarch="$(dpkg-architecture -f -t"${triplet}" -qDEB_HOST_MULTIARCH 2>/dev/null)"
   if [ "$?" != 0 ]; then
       echo "Please install dpkg-dev to use pkg-config when cross-building" >&2
       exit 1

Reply to: