Control: tags -1 + patch

On Tue, 04 Feb 2014 at 01:34:19 +0900, Osamu Aoki wrote:
> I recently packaged a package with custom *-config and hit by multiarch
> bug for -dev package like this one
[...]
> Since this was caused by hardcoding @libdir@ path into shell code, 
> I replaced that @libdir@ part of code with 
> 
>   /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)

While looking at this bug as a result of a package I maintain (ostree)
gaining a direct dependency on libgpg-error, it occurred to me that for
the special case of Debian, there's no reason why the -config script
needs to know about @libdir@ at all: passing -L/usr/lib/x86_64-linux-gnu
to the linker is unnecessary, because that's in our version of gcc's
search path anyway.

This is probably the only reason why it's possible to cross-compile
packages that depend on libgpg-error, in fact.

gpg-error-config does include another architecture-dependent string,
which is its response to the --host command-line argument. However,
that command-line argument is undocumented, and only seems to be used
by gpg-error.m4 (and its clone gpgrt.m4), which copes gracefully if
it's rejected: a gpg-error-config for which --host fails is treated
as potentially being from any architecture.

So perhaps the attached would be suitable? It seems to work.

    smcv
>From 460fb6dc7fcfb2058becd3a55c269526271f84ba Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Wed, 25 Jul 2018 11:56:39 +0100
Subject: [PATCH 1/2] Add a simple compile/link/execute autopkgtest for
 libgpg-error

---
 debian/tests/build   | 37 +++++++++++++++++++++++++++++++++++++
 debian/tests/control |  3 +++
 2 files changed, 40 insertions(+)
 create mode 100755 debian/tests/build

diff --git a/debian/tests/build b/debian/tests/build
new file mode 100755
index 0000000..611deff
--- /dev/null
+++ b/debian/tests/build
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+set -e
+exec 2>&1
+set -u
+
+: "${AUTOPKGTEST_TMP:="${ADTTMP}"}"
+
+if [ -z "${HOME-}" ] || ! [ -w "${HOME}" ]; then
+    export HOME="${AUTOPKGTEST_TMP}"
+fi
+
+cd "$AUTOPKGTEST_TMP"
+
+cat > use-lib.c <<'EOF'
+#include <stdio.h>
+
+#include <gpg-error.h>
+
+int main (void)
+{
+    printf ("# %s\n", gpg_strerror (GPG_ERR_NO_ERROR));
+    return 0;
+}
+EOF
+
+gcc -o use-lib use-lib.c $(gpg-error-config --cflags --libs)
+test -x use-lib
+./use-lib
+echo "ok 1 - normal build"
+
+gcc -o use-lib-mt use-lib.c $(gpg-error-config --mt --cflags --libs)
+test -x use-lib-mt
+./use-lib-mt
+echo "ok 2 - thread-safe build"
+
+echo "1..2"
diff --git a/debian/tests/control b/debian/tests/control
index 4218b49..fc1ec54 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,3 +1,6 @@
+Tests: build
+Depends: build-essential, libgpg-error-dev
+
 Test-Command: ./libgpg-error-mingw-w64 i686
 Depends: libgpg-error-mingw-w64-dev, wine, wine32, libgpg-error-dev
 
-- 
2.18.0

>From a69ce1aad22c798e8f332ca65d6317d07a82b415 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Wed, 25 Jul 2018 12:06:04 +0100
Subject: [PATCH 2/2] Modify /usr/bin/foo-config to be architecture-independent

To do this, I've made use of some convenient properties:

* The libdir hard-codes a multiarch-varying path, but for Debian
  systems, -L$libdir is unnecessary anyway, because we install
  libgpg-error.so into the compiler's default search path for all
  architectures.
* The gpg-error-config --host option is also multiarch-varying, but
  is undocumented, and its use in gpgrt.m4 and gpg-error.m4 is
  robust against a nonzero exit status, so we can just make it fail.
* Nothing else in this script is architecture-varying.

Closes: #643341
---
 debian/control                                |  1 +
 ...-foo-config-architecture-independent.patch | 63 +++++++++++++++++++
 debian/patches/series                         |  1 +
 3 files changed, 65 insertions(+)
 create mode 100644 debian/patches/Make-usr-bin-foo-config-architecture-independent.patch

diff --git a/debian/control b/debian/control
index 1ff8e2e..13e8482 100644
--- a/debian/control
+++ b/debian/control
@@ -20,6 +20,7 @@ Rules-Requires-Root: no
 Package: libgpg-error-dev
 Section: libdevel
 Architecture: any
+Multi-Arch: same
 Depends:
  libgpg-error0 (= ${binary:Version}),
  ${misc:Depends},
diff --git a/debian/patches/Make-usr-bin-foo-config-architecture-independent.patch b/debian/patches/Make-usr-bin-foo-config-architecture-independent.patch
new file mode 100644
index 0000000..756e6cf
--- /dev/null
+++ b/debian/patches/Make-usr-bin-foo-config-architecture-independent.patch
@@ -0,0 +1,63 @@
+From: Simon McVittie <s...@debian.org>
+Date: Wed, 25 Jul 2018 20:50:04 +0100
+Subject: Make /usr/bin/foo-config architecture-independent
+
+The libdir hard-codes a multiarch-varying path, but for Debian
+systems, -L$libdir is unnecessary anyway, because we install
+libgpg-error.so into the compiler's default search path for all
+architectures.
+
+The gpg-error-config --host option is also multiarch-varying, but
+is undocumented, and its use in gpgrt.m4 and gpg-error.m4 is
+robust against a nonzero exit status, so we can just make it fail.
+
+Nothing else in this script is architecture-varying.
+
+Bug-Debian: https://bugs.debian.org/643341
+Origin: vendor, Debian
+Forwarded: no, Debian-specific
+---
+ src/gpg-error-config.in | 17 ++++++++---------
+ 1 file changed, 8 insertions(+), 9 deletions(-)
+
+diff --git a/src/gpg-error-config.in b/src/gpg-error-config.in
+index aa7cb67..c680215 100644
+--- a/src/gpg-error-config.in
++++ b/src/gpg-error-config.in
+@@ -13,7 +13,6 @@
+ prefix=@prefix@
+ exec_prefix=@exec_prefix@
+ includedir=@includedir@
+-libdir=@libdir@
+ isubdirafter="@GPG_ERROR_CONFIG_ISUBDIRAFTER@"
+ 
+ if echo "$0" | grep gpg-error-config 2>/dev/null >/dev/null; then
+@@ -83,20 +82,20 @@ while test $# -gt 0; do
+             fi
+ 	    ;;
+ 	--libs)
+-	    case "$libdir" in
+-		/usr/lib|/usr/lib64|/lib|/lib64) ;;
+-		*)
+-		    output="$output -L$libdir"
+-		    ;;
+-	    esac
++	    # Debian-specific: we do not add -L, because we install
++	    # libgpg-error to a directory on the default search path
++
+ 	    output="$output @GPG_ERROR_CONFIG_LIBS@"
+             if test $mt = yes ; then
+                 output="$output @GPG_ERROR_CONFIG_MT_LIBS@"
+             fi
+ 	    ;;
+         --host)
+-            echo "@GPG_ERROR_CONFIG_HOST@"
+-            exit 0
++            # Debian-specific: we do not support the undocumented --host
++            # option, because it would make gpg-error-config differ between
++            # architectures, and our gpg-error-config is otherwise
++            # identical for any Debian architecture
++            usage 1 1>&2
+             ;;
+ 	*)
+             usage 1 1>&2
diff --git a/debian/patches/series b/debian/patches/series
index 8bc2aad..147d645 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 0001-Remove-upstream-git-fanciness.patch
+Make-usr-bin-foo-config-architecture-independent.patch
-- 
2.18.0

Reply via email to