Package: libwaffle-dev
Version: 1.8.0-1
Severity: serious
Tags: patch
Justification: can easily cause FTBFS in related packages

waffle-1.pc now has a dependency on libdrm.pc, but the -dev package that
contains waffle-1.pc does not depend on libdrm-dev, leading to a build
failure similar to #987940, #987879, #986517 in locally-developed software
(in my case the steam-runtime-tools package in Valve's Steam Runtime,
I haven't verified whether piglit has the same problem).

Steps to reproduce
------------------

In a minimal chroot/container (I used podman), install libwaffle-dev
and try to link a trivial binary to it:

$ podman pull debian:sid-slim
$ podman run --rm -it debian:sid-slim
# apt install build-essential libwaffle-dev pkgconf
# cat > trivial.c <<'EOF'
#undef NDEBUG
#include <assert.h>
#include <waffle.h>
int main (void)
{
  assert (waffle_enum_to_string (WAFFLE_DONT_CARE) != NULL);
  return 0;
}
EOF
# gcc -otrivial trivial.c $(pkgconf --cflags --libs waffle-1)
# ./trivial

Expected result
---------------

The test binary compiles, links and runs successfully.

Actual result
-------------

> Package libdrm was not found in the pkg-config search path.
> Perhaps you should add the directory containing `libdrm.pc'
> to the PKG_CONFIG_PATH environment variable
> Package 'libdrm', required by 'waffle-1', not found
> trivial.c:3:10: fatal error: waffle.h: No such file or directory

Workaround
----------

Install libdrm-dev, or explicitly build-depend on it in packages that
use waffle.

Solution
--------

libwaffle-dev should depend on libdrm-dev: see attached patch 0001-*
(it should be amended to fill in the bug number, which I can't know
in advance).

However, it no longer needs to depend on libudev-dev: 0002-*.

I would suggest adding some superficial autopkgtests, which are a
surprisingly effective way to detect this sort of packaging issue: if run
before upload, they would also have detected #987940, #987879 and #986517.
The attached patch 0003-* adds some tests that I originally developed
for the Steam Runtime - sorry I didn't get round to upstreaming these
until now.

Thanks,
    smcv

-- System Information:
Debian Release: trixie/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'stable-security'), (500, 
'buildd-unstable'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, arm64

Kernel: Linux 6.5.0-2-amd64 (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libwaffle-dev depends on:
ii  libegl-dev      1.6.0-1
ii  libgbm-dev      23.2.1-1
ii  libgl-dev       1.6.0-1
ii  libudev-dev     254.5-1
ii  libwaffle-1-0   1.8.0-1
ii  libwayland-dev  1.22.0-2.1
ii  libx11-xcb-dev  2:1.8.7-1

libwaffle-dev recommends no packages.

Versions of packages libwaffle-dev suggests:
pn  libwaffle-doc  <none>

-- no debconf information
>From 11a871f2a49939b00f0e36173c6adeaeec6b551a Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Thu, 12 Oct 2023 12:47:39 +0100
Subject: [PATCH 1/3] d/control: Add missing dependency libwaffle-dev ->
 libdrm-dev

libwaffle-dev contains waffle-1.pc, which has a Requires on libdrm;
therefore libwaffle-dev should depend on the package that contains
libdrm.pc, which is libdrm-dev.

I've verified that this is sufficient to allow a simple test program
to be linked to libwaffle in an otherwise minimal container.

Fixes: 5ab2d5a2 "d/control: Upstream replaced libudev dep with libdrm"
Closes: #-1
Signed-off-by: Simon McVittie <s...@collabora.com>
---
 debian/control | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index 5e9470a..6d7279f 100644
--- a/debian/control
+++ b/debian/control
@@ -40,7 +40,8 @@ Package: libwaffle-dev
 Architecture: any
 Multi-Arch: same
 Section: libdevel
-Depends: libegl-dev,
+Depends: libdrm-dev,
+         libegl-dev,
          libgbm-dev,
          libgl-dev,
          libudev-dev,
-- 
2.42.0

>From c07071db1f68bdc17738115c4b106dfcc5c03896 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Thu, 12 Oct 2023 12:49:53 +0100
Subject: [PATCH 2/3] d/control: libwaffle-dev no longer needs to depend on
 libudev-dev

waffle-1.pc no longer depends on udev.pc.

Fixes: 5ab2d5a2 "d/control: Upstream replaced libudev dep with libdrm"
Signed-off-by: Simon McVittie <s...@collabora.com>
---
 debian/control | 1 -
 1 file changed, 1 deletion(-)

diff --git a/debian/control b/debian/control
index 6d7279f..1dcb1b6 100644
--- a/debian/control
+++ b/debian/control
@@ -44,7 +44,6 @@ Depends: libdrm-dev,
          libegl-dev,
          libgbm-dev,
          libgl-dev,
-         libudev-dev,
          libwaffle-1-0 (= ${binary:Version}),
          libwayland-dev,
          libx11-xcb-dev,
-- 
2.42.0

>From f58220bc366d3c4660febf782baf4ac8eebc23ed Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@collabora.com>
Date: Thu, 12 Oct 2023 12:35:02 +0100
Subject: [PATCH 3/3] d/tests: Add superficial autopkgtests

Even superficial tests like these are surprisingly good at detecting
packaging issues, like a missing dependency on libdrm-dev.

Signed-off-by: Simon McVittie <s...@collabora.com>
---
 debian/tests/build   | 44 ++++++++++++++++++++++++++++++++++++++++++++
 debian/tests/control | 11 +++++++++++
 debian/tests/info    | 12 ++++++++++++
 3 files changed, 67 insertions(+)
 create mode 100755 debian/tests/build
 create mode 100644 debian/tests/control
 create mode 100755 debian/tests/info

diff --git a/debian/tests/build b/debian/tests/build
new file mode 100755
index 0000000..54f684c
--- /dev/null
+++ b/debian/tests/build
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright © 2019-2023 Collabora Ltd.
+# SPDX-License-Identifier: BSD-2-Clause
+# (see debian/copyright)
+
+# Check that the library can be linked by using pkgconf in the most
+# obvious way.
+
+set -e
+set -u
+set -x
+
+if [ -n "${DEB_HOST_GNU_TYPE:-}" ]; then
+    CROSS_COMPILE="$DEB_HOST_GNU_TYPE-"
+else
+    CROSS_COMPILE=
+fi
+
+CC="${CROSS_COMPILE}gcc"
+PKG_CONFIG="${CROSS_COMPILE}pkgconf"
+
+tempdir="$(mktemp -d)"
+cd "$tempdir"
+
+cat > trivial.c <<'EOF'
+#undef NDEBUG
+#include <assert.h>
+
+#include <waffle.h>
+
+int main (void)
+{
+  assert (waffle_enum_to_string (WAFFLE_DONT_CARE) != NULL);
+  return 0;
+}
+EOF
+
+# Deliberately word-splitting pkgconf output
+# shellcheck disable=SC2046
+"$CC" -o trivial trivial.c $("$PKG_CONFIG" --cflags --libs waffle-1)
+test -x trivial
+./trivial
+
+rm -fr "$tempdir"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..bb5ae64
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,11 @@
+Tests: build
+Restrictions: allow-stderr, superficial
+Depends:
+ build-essential,
+ libwaffle-dev,
+ pkgconf,
+
+Tests: info
+Restrictions: superficial
+Depends:
+ waffle-utils,
diff --git a/debian/tests/info b/debian/tests/info
new file mode 100755
index 0000000..58f3d7a
--- /dev/null
+++ b/debian/tests/info
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Copyright © 2019-2021 Collabora Ltd.
+# SPDX-License-Identifier: BSD-2-Clause
+# (see debian/copyright)
+
+set -eu
+
+# We don't actually check for a GL context here, because there's no
+# guarantee that the test system has working GL: we just check that
+# an executable linked to the shared library can run at all.
+wflinfo --help
-- 
2.42.0

Reply via email to