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

Bug#960445: libsndfile1-dev: not multi-arch co-installable



Package: libsndfile1-dev
Version: 1.0.28-7
Severity: normal
Tags: patch

While working on a Debian-based Flatpak-style runtime/SDK environment for
games, I noticed that libsndfile1-dev was one of only a few non-multiarch
-dev packages in my initial package set.

It isn't completely multiarch-compatible (or, strictly speaking,
Policy-compliant) because it installs config.h into
/usr/share/doc/libsndfile1-dev/examples, and that file is different on
different architectures. However, after decoupling the examples from
config.h (they include it, but don't appear to use it), it is possible to
make the package fully multiarch.

While testing this out, I added an autopkgtest. I've found that tests
like this are a useful way to automate checks that development files are
packaged correctly: even though they don't have significant coverage of
the actual library code, they can detect common mistakes like missing
header files, wrong search paths, and missing dependencies on other -dev
packages referenced by the pkg-config file.

    smcv
>From 4b5309b5e9d4e2426365db2205a50b4656e9bd72 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 12 May 2020 16:09:59 +0100
Subject: [PATCH 1/3] examples: Decouple from config.h

This allows them to be built standalone, without the rest of the
libsndfile source tree. This is useful because config.h is
architecture-dependent, preventing multi-arch co-installation.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 debian/examples/Makefile                      |  2 +-
 debian/libsndfile1-dev.examples               |  3 --
 .../examples-Decouple-from-config.h.patch     | 39 +++++++++++++++++++
 debian/patches/series                         |  1 +
 4 files changed, 41 insertions(+), 4 deletions(-)
 create mode 100644 debian/patches/examples-Decouple-from-config.h.patch

diff --git a/debian/examples/Makefile b/debian/examples/Makefile
index 82d9a97..89dc9c9 100644
--- a/debian/examples/Makefile
+++ b/debian/examples/Makefile
@@ -7,7 +7,7 @@ SNDLIBS=$(LIBS) $(shell pkg-config --cflags --libs sndfile) -lm
 default: $(APPS)
 
 %: %.c
-	$(CC) -Icommon $(CPPFLAGS) $(CFLAGS) -o $@ $< $(SNDLIBS)
+	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(SNDLIBS)
 
 clean:
 	rm -f $(APPS)
diff --git a/debian/libsndfile1-dev.examples b/debian/libsndfile1-dev.examples
index 12bd6a0..6722afb 100644
--- a/debian/libsndfile1-dev.examples
+++ b/debian/libsndfile1-dev.examples
@@ -1,5 +1,2 @@
 examples/*.c
 debian/examples/Makefile
-src/common.h
-src/sfconfig.h
-src/config.h
diff --git a/debian/patches/examples-Decouple-from-config.h.patch b/debian/patches/examples-Decouple-from-config.h.patch
new file mode 100644
index 0000000..d6360ff
--- /dev/null
+++ b/debian/patches/examples-Decouple-from-config.h.patch
@@ -0,0 +1,39 @@
+From: Simon McVittie <smcv@collabora.com>
+Date: Tue, 12 May 2020 16:09:19 +0100
+Subject: examples: Decouple from config.h
+
+This allows them to be built standalone, without the rest of the
+libsndfile source tree.
+
+Signed-off-by: Simon McVittie <smcv@collabora.com>
+---
+ examples/generate.c        | 2 --
+ examples/sndfile-loopify.c | 2 --
+ 2 files changed, 4 deletions(-)
+
+diff --git a/examples/generate.c b/examples/generate.c
+index 884e8d7..dade7d9 100644
+--- a/examples/generate.c
++++ b/examples/generate.c
+@@ -30,8 +30,6 @@
+ ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+-#include "sfconfig.h"
+-
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+diff --git a/examples/sndfile-loopify.c b/examples/sndfile-loopify.c
+index f0ceb6d..b0aded4 100644
+--- a/examples/sndfile-loopify.c
++++ b/examples/sndfile-loopify.c
+@@ -44,8 +44,6 @@
+ 
+ #include <sndfile.h>
+ 
+-#include "common.h"
+-
+ #define BUFFER_LEN		(1 << 14)
+ 
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 5fb4b24..64496ee 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -10,3 +10,4 @@ a-ulaw-fix-multiple-buffer-overflows-432.patch
 double64_init-Check-psf-sf.channels-against-upper-bo.patch
 src-wav.c-Fix-heap-read-overflow.patch
 Check-MAX_CHANNELS-in-sndfile-deinterleave.patch
+examples-Decouple-from-config.h.patch
-- 
2.26.2

>From 86ac458b3b5a0d05aa54836564ba6321afb2b016 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 12 May 2020 15:15:53 +0100
Subject: [PATCH 2/3] Mark libsndfile1-dev as Multi-Arch: same

Now that config.h isn't included, everything in a
non-architecture-specific directory is the same across architectures.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 debian/control | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/control b/debian/control
index e095391..c53975e 100644
--- a/debian/control
+++ b/debian/control
@@ -19,6 +19,7 @@ Standards-Version: 4.5.0
 Package: libsndfile1-dev
 Section: libdevel
 Architecture: any
+Multi-Arch: same
 Depends:
  ${misc:Depends},
  libsndfile1 (= ${binary:Version}),
-- 
2.26.2

>From e8289f9d192aa56d66f6ee9c8f1f639c19cc4ad8 Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@collabora.com>
Date: Tue, 12 May 2020 15:22:38 +0100
Subject: [PATCH 3/3] Add a superficial compile/link/execute autopkgtest

This verifies that libsndfile1-dev contains all the necessary files.

Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 debian/tests/control         |  3 +++
 debian/tests/libsndfile1-dev | 26 ++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 debian/tests/control
 create mode 100755 debian/tests/libsndfile1-dev

diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..06d9b45
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,3 @@
+Tests: libsndfile1-dev
+Restrictions: allow-stderr, superficial
+Depends: build-essential, libsndfile1-dev
diff --git a/debian/tests/libsndfile1-dev b/debian/tests/libsndfile1-dev
new file mode 100755
index 0000000..4eb0aef
--- /dev/null
+++ b/debian/tests/libsndfile1-dev
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright 2020 Collabora Ltd.
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+set -eux
+
+if [ -n "${AUTOPKGTEST_ARTIFACTS-}" ]; then
+	WORKDIR="$AUTOPKGTEST_ARTIFACTS"
+else
+	WORKDIR="$(mktemp -d)"
+	trap 'cd /; rm -fr "$WORKDIR"' 0 INT QUIT ABRT PIPE TERM
+fi
+
+if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
+    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
+else
+    CROSS_COMPILE=
+fi
+
+cp examples/make_sine.c "$WORKDIR"
+cd "$WORKDIR"
+
+# Deliberately word-splitting pkg-config's output:
+# shellcheck disable=SC2046
+"${CROSS_COMPILE}gcc" -omake_sine make_sine.c -lm $("${CROSS_COMPILE}pkg-config" --cflags --libs sndfile)
+./make_sine
-- 
2.26.2


Reply to: