About a year on, here are updated patches for #631275 and #642292,
and a version of Wookey's patch for #650298 that applies on top of those
(also available from the multiarch2 branch in my Alioth repository, gitweb at
<http://anonscm.debian.org/gitweb/?p=users/smcv/multiarch/pkg-config.git;a=shortlog;h=refs/heads/multiarch2>).
Tollef, Steve, Wookey, anyone else interested: any thoughts on these?
In particular, Tollef, if these changes look OK to you, an upload to
experimental would be great. Any project depending on libraries that rely
on pkg-config to set search paths (such as dbus and glib2.0) can't usefully
be cross-built without something like this.
On Wed, 21 Sep 2011 at 22:36:18 -0700, Steve Langasek wrote:
> So my suggestion would be to make the script special-case i386, instead of
> adding a runtime dependency on dpkg-dev for dpkg-architecture.
I can do this if you feel strongly about it, but as Wookey pointed out,
dpkg-dev is build-essential. The version in my repository ignores
errors from dpkg-architecture; on non-Debian systems it'll skip the
Debian-style multiarch paths (because $multiarch is empty),
and only use the traditional /usr/TRIPLET-style paths.
> Ah; my patch had gone by the manpage and as a result, I overlooked the fact
> that the multiarch paths were part of this variable. Yes, we certainly
> don't want to search in multiarch directories for the native architecture as
> part of the cross tools!
I've checked (via pkg-config --debug) that my version does not do this.
> > One subtle departure from Steve's patch here is that if you run
> > armv5tel-linux-gnueabi-pkg-config on an i386 system, it will never search
> > /usr/lib/pkgconfig - which I think is desirable.
>
> Keeping /usr/lib/pkgconfig on the path was quite deliberate on my part.
> Certainly any library shipping in /usr/lib/pkgconfig is not a multiarch
> library, but that doesn't actually mean it has to be a *native* library: it
> will be possible to cross-install many -dev packages for a while before it's
> possible to co-install them together with the native versions.
Fair enough. My second patch attached to this mail does what you asked.
> > I attach a patch to give the semantics I suggest, plus a patch to put
> > pkg-config-crosswrapper into a directory that complies with the FHS (with
> > a compatibility symlink).
>
> By my reading of the FHS, there is no requirement to move it.
I've dropped that patch from the multiarch2 branch.
On Mon, 28 Nov 2011 at 22:06:42 +0000, Wookey wrote:
> Protoecting its use with a test -x would probably be wise.
I'm running it with 2>/dev/null; if it isn't executable, ${multiarch}
will be "" and the multiarch directories will be ignored altogether.
That seems somewhat simpler than playing with "command -v" to find out
whether there is an executable dpkg-architecture on $PATH.
> When the multiarch transition is 'complete' (however we define that)
> we can remove /usr/lib/pkgconfig from the search path and
> cross-building within your main rootfs will work nicely.
When the time comes, reverting the second patch here will have that effect.
Regards,
S
>From c0ae63630dcbb8789f6fe2e546f29f827918d504 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Wed, 21 Sep 2011 14:29:59 +0100
Subject: [PATCH 1/3] Search multiarch directories in pkg-config-crosswrapper
We use PKG_CONFIG_LIBDIR, not PKG_CONFIG_PATH, so that we don't search
/usr/lib/pkgconfig (legacy path likely to contain wrong-arch libraries),
and so that the user can prepend paths in /opt or whatever by using
PKG_CONFIG_PATH in the usual way.
If the user has set PKG_CONFIG_LIBDIR, the cross-wrapper does nothing -
the user is assumed to know best, just as they are with native pkg-config.
This leaves the search path as something like this (if you invoke
armv5tel-linux-gnueabi-pkg-config):
if PKG_CONFIG_PATH is set:
the elements of PKG_CONFIG_PATH
if PKG_CONFIG_LIBDIR is set:
the elements of PKG_CONFIG_LIBDIR
else:
/usr/local/lib/arm-linux-gnueabi/pkgconfig (site multiarch)
/usr/local/share/pkg-config (site arch-indep)
/usr/local/armv5tel-linux-gnueabi/lib/pkgconfig (site pre-MA cross)
/usr/lib/arm-linux-gnueabi/pkgconfig (distro multiarch)
/usr/share/pkg-config (distro arch-indep)
/usr/armv5tel-linux-gnueabi/lib/pkgconfig (distro pre-MA cross)
Signed-off-by: Simon McVittie <[email protected]>
---
debian/changelog | 18 ++++++++++++++++++
debian/control | 1 +
debian/pkg-config-crosswrapper | 30 ++++++++++++++++++++++++++++--
3 files changed, 47 insertions(+), 2 deletions(-)
mode change 100644 => 100755 debian/pkg-config-crosswrapper
diff --git a/debian/changelog b/debian/changelog
index b6adc3c..07814f7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,21 @@
+pkg-config (0.26-1+multiarch) UNRELEASED; urgency=low
+
+ [ Steve Langasek ]
+ * debian/control: mark pkg-config Multi-Arch: foreign; it provides an
+ executable interface which points to architecture-dependent paths, but
+ those paths only need to be overridden in a cross-build environment, in
+ which case it's the responsibility of the cross-toolchain packages to
+ provide the appropriate glue.
+
+ [ Simon McVittie ]
+ * In pkg-config-crosswrapper, search the multiarch directory (using the
+ multiarch tuple), the traditional cross-compilation directory (using the
+ GNU tuple), /usr/share/pkgconfig and their /usr/local counterparts.
+ Based on patches from Steve Langasek and Vincent Danjean.
+ Closes: #631275, #642292.
+
+ -- Simon McVittie <[email protected]> Wed, 21 Sep 2011 12:46:26 +0100
+
pkg-config (0.26-1) unstable; urgency=low
* New upstream release
diff --git a/debian/control b/debian/control
index 2c9bf46..d4f1707 100644
--- a/debian/control
+++ b/debian/control
@@ -8,6 +8,7 @@ Standards-Version: 3.8.4
Package: pkg-config
Architecture: any
+Multi-Arch: foreign
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: manage compile and link flags for libraries
pkg-config is a system for managing library compile and link flags that
diff --git a/debian/pkg-config-crosswrapper b/debian/pkg-config-crosswrapper
old mode 100644
new mode 100755
index ab38abb..15e9e2f
--- a/debian/pkg-config-crosswrapper
+++ b/debian/pkg-config-crosswrapper
@@ -2,5 +2,31 @@
# pkg-config wrapper for cross-building
# Sets pkg-config search path to target arch path only.
-triplet=`basename $0 | sed -e 's:-pkg-config::'`
-PKG_CONFIG_LIBDIR=/usr/${triplet}/lib/pkgconfig pkg-config $@
+# If the user has already set PKG_CONFIG_LIBDIR, believe it: it's documented
+# to be an override
+if [ -z "$PKG_CONFIG_LIBDIR" ]; then
+ # GNU triplet for the compiler, e.g. i486-linux-gnu for Debian i386,
+ # i686-linux-gnu for Ubuntu i386
+ triplet="`basename $0 | sed -e 's:-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`"
+
+ PKG_CONFIG_LIBDIR="/usr/local/${triplet}/lib/pkgconfig"
+ # For a native build we would also want to append /usr/local/lib/pkgconfig
+ # at this point; but this is a cross-building script, so don't
+ PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/local/share/pkgconfig"
+
+ if [ -n "$multiarch" ]; then
+ PKG_CONFIG_LIBDIR="/usr/local/lib/${multiarch}/pkgconfig:$PKG_CONFIG_LIBDIR"
+ PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/lib/${multiarch}/pkgconfig"
+ fi
+
+ PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/${triplet}/lib/pkgconfig"
+ # For a native build we would also want to append /usr/lib/pkgconfig
+ # at this point; but this is a cross-building script, so don't
+ PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/share/pkgconfig"
+
+ export PKG_CONFIG_LIBDIR
+fi
+
+exec pkg-config $@
--
1.7.10.4
>From b500fd5ee94fe3755c63500f56e9406ed48a750e Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Mon, 1 Oct 2012 18:24:24 +0100
Subject: [PATCH 2/3] Search /usr/lib/pkgconfig and /usr/local/lib/pkgconfig
in the cross-wrapper
In <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=642292#30>,
Steve Langasek argues that this is advantageous: if you have
a foreign library that hasn't yet had its .pc file moved from /usr/lib
to /usr/lib/TUPLE, then you can't co-install it with the same native
library, but you might not need to have the native version anyway.
This allows cross-compiling against more libraries, sooner.
---
debian/changelog | 9 +++++----
debian/pkg-config-crosswrapper | 6 ++----
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 07814f7..c7eedf9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-pkg-config (0.26-1+multiarch) UNRELEASED; urgency=low
+pkg-config (0.26-1+multiarch2) UNRELEASED; urgency=low
[ Steve Langasek ]
* debian/control: mark pkg-config Multi-Arch: foreign; it provides an
@@ -10,9 +10,10 @@ pkg-config (0.26-1+multiarch) UNRELEASED; urgency=low
[ Simon McVittie ]
* In pkg-config-crosswrapper, search the multiarch directory (using the
multiarch tuple), the traditional cross-compilation directory (using the
- GNU tuple), /usr/share/pkgconfig and their /usr/local counterparts.
- Based on patches from Steve Langasek and Vincent Danjean.
- Closes: #631275, #642292.
+ GNU tuple), /usr/lib/pkgconfig (for foreign packages whose .pc file
+ has not moved to the multiarch directory), /usr/share/pkgconfig and their
+ /usr/local counterparts. Based on patches from Steve Langasek and
+ Vincent Danjean. Closes: #631275, #642292.
-- Simon McVittie <[email protected]> Wed, 21 Sep 2011 12:46:26 +0100
diff --git a/debian/pkg-config-crosswrapper b/debian/pkg-config-crosswrapper
index 15e9e2f..2c10d38 100755
--- a/debian/pkg-config-crosswrapper
+++ b/debian/pkg-config-crosswrapper
@@ -12,8 +12,7 @@ if [ -z "$PKG_CONFIG_LIBDIR" ]; then
multiarch="`dpkg-architecture -t"${triplet}" -qDEB_HOST_MULTIARCH 2>/dev/null`"
PKG_CONFIG_LIBDIR="/usr/local/${triplet}/lib/pkgconfig"
- # For a native build we would also want to append /usr/local/lib/pkgconfig
- # at this point; but this is a cross-building script, so don't
+ PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/local/lib/pkgconfig"
PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/local/share/pkgconfig"
if [ -n "$multiarch" ]; then
@@ -22,8 +21,7 @@ if [ -z "$PKG_CONFIG_LIBDIR" ]; then
fi
PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/${triplet}/lib/pkgconfig"
- # For a native build we would also want to append /usr/lib/pkgconfig
- # at this point; but this is a cross-building script, so don't
+ PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/lib/pkgconfig"
PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:/usr/share/pkgconfig"
export PKG_CONFIG_LIBDIR
--
1.7.10.4
>From caeefebd90435e000292054702722220f5d1c745 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Mon, 1 Oct 2012 18:57:00 +0100
Subject: [PATCH 3/3] Harden pkg-config-crosswrapper against paths containing
spaces, and avoid an unnecesary use of sed. Closes:
#650298.
---
debian/changelog | 4 ++++
debian/pkg-config-crosswrapper | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index c7eedf9..d799e5f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,6 +15,10 @@ pkg-config (0.26-1+multiarch2) UNRELEASED; urgency=low
/usr/local counterparts. Based on patches from Steve Langasek and
Vincent Danjean. Closes: #631275, #642292.
+ [ Wookey ]
+ * Harden pkg-config-crosswrapper against paths containing spaces,
+ and avoid an unnecesary use of sed. Closes: #650298.
+
-- Simon McVittie <[email protected]> Wed, 21 Sep 2011 12:46:26 +0100
pkg-config (0.26-1) unstable; urgency=low
diff --git a/debian/pkg-config-crosswrapper b/debian/pkg-config-crosswrapper
index 2c10d38..2e0b399 100755
--- a/debian/pkg-config-crosswrapper
+++ b/debian/pkg-config-crosswrapper
@@ -5,9 +5,10 @@
# If the user has already set PKG_CONFIG_LIBDIR, believe it: it's documented
# to be an override
if [ -z "$PKG_CONFIG_LIBDIR" ]; then
+ basename="`basename "$0"`"
# GNU triplet for the compiler, e.g. i486-linux-gnu for Debian i386,
# i686-linux-gnu for Ubuntu i386
- triplet="`basename $0 | sed -e 's:-pkg-config::'`"
+ 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`"
--
1.7.10.4