gnome-disk-utility: fix build without x11 in DISTRO_FEATURES

gnome-disk-utility 46.1 fails to build on a wayland-only distro
configuration (no x11 in DISTRO_FEATURES) for three separate reasons,
all of them latent X11 assumptions in the GTK3 code line.

do_configure fails first:

  Run-time dependency libcanberra-gtk3 found: NO (tried pkg-config)
  meson.build:75:18: ERROR: Dependency "libcanberra-gtk3" not found

meson.build requires libcanberra-gtk3 unconditionally, but
libcanberra's gtk3 support is itself X11-only (its configure.ac does
PKG_CHECK_MODULES(GTK3, [gtk+-3.0 ... gdk-3.0 x11]), the sources use
gdk_x11_get_xatom_by_name_for_display()/GDK_WINDOW_XID, and
libcanberra-gtk3.pc links -lX11), so the meta-oe recipe correctly
leaves the gtk3 PACKAGECONFIG off here and the dependency can never be
satisfied. Drop it, along with the three ca_gtk_play_for_widget() sound
effect call sites; upstream removed libcanberra entirely by the same
route after 46.1 was released.

Once that is out of the way do_compile fails on the X11 backend header:

  gdupasswordstrengthwidget.c:14:10: fatal error: 'gdk/gdkx.h' file not found
  gduvolumegrid.c:14:10: fatal error: 'gdk/gdkx.h' file not found
  gduestimator.c:14:10: fatal error: 'gdk/gdkx.h' file not found

gtk+3 only installs gdk/gdkx.h when its X11 backend is enabled. None of
these three files calls any X11-specific GDK API, so the include is
simply dead weight and can be dropped.

Neither fix is available upstream for this code line: the GTK4 /
libadwaita rewrite deleted or renamed the affected files rather than
fixing them, and no in-flight merge request touches the GTK3 sources
that 46.1 still builds. 46.1 remains the latest stable release.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj
2026-09-11 22:47:21 -07:00
parent e43f9ef8c9
commit a682b34999
3 changed files with 194 additions and 1 deletions
@@ -0,0 +1,122 @@
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 10 Sep 2026 06:00:00 +0000
Subject: [PATCH] Drop the libcanberra-gtk3 dependency
libcanberra-gtk3 links -lX11 and its gtk3 module is built only when
X11 is enabled (configure.ac gates HAVE_GTK3 on `gdk-3.0 x11`), so it
is unavailable on wayland-only distro configurations. That makes
gnome-disk-utility's hard `dependency('libcanberra-gtk3', ...)` fail
at meson configure time there:
Run-time dependency libcanberra-gtk3 found: NO (tried pkg-config)
../gnome-disk-utility-46.1/meson.build:75:18: ERROR: Dependency
"libcanberra-gtk3" not found (tried pkg-config)
Upstream reached the same conclusion and dropped libcanberra
entirely ahead of the GTK4/libadwaita port (GNOME/gnome-disk-utility!
efa67dc5, !ecdd9c37, !ec6d8018), disabling the three sound-effect call
sites and removing the dependency; that work landed after 46.1, the
last stable release, so backport the same, minimal change here rather
than carrying libcanberra-gtk3 as a hard requirement.
Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/gnome-disk-utility/-/commit/ec6d801899e440245319cdbb06555783b72808d1]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
meson.build | 1 -
src/disks/gducreatediskimagedialog.c | 12 ++++--------
src/disks/gdurestorediskimagedialog.c | 8 +++-----
src/disks/meson.build | 1 -
4 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/meson.build b/meson.build
index 1111111..2222222 100644
--- a/meson.build
+++ b/meson.build
@@ -72,7 +72,6 @@ dvdread_dep = dependency('dvdread', version: '>= 4.2.0')
gio_unix_dep = dependency('gio-unix-2.0', version: '>= 2.31.0')
gmodule_dep = dependency('gmodule-2.0')
gtk_dep = dependency('gtk+-3.0', version: '>= 3.16.0')
-libcanberra_dep = dependency('libcanberra-gtk3', version: '>= 0.1')
# Keep the version here synchronised with subprojects/libhandy.wrap
libhandy_dep = dependency('libhandy-1', version: '>= 1.5.0', fallback: ['libhandy', 'libhandy_dep'])
liblzma_dep = dependency('liblzma', version: '>= 5.0.5')
diff --git a/src/disks/gducreatediskimagedialog.c b/src/disks/gducreatediskimagedialog.c
index 1111111..2222222 100644
--- a/src/disks/gducreatediskimagedialog.c
+++ b/src/disks/gducreatediskimagedialog.c
@@ -20,8 +20,6 @@
#include <sys/ioctl.h>
#include <linux/fs.h>
-#include <canberra-gtk.h>
-
#include "gduapplication.h"
#include "gduwindow.h"
#include "gducreatediskimagedialog.h"
@@ -304,10 +302,9 @@ play_read_error_sound (DialogData *data)
* CA_PROP_EVENT_DESCRIPTION
*/
sound_message = _("Disk image read error");
- ca_gtk_play_for_widget (GTK_WIDGET (data->window), 0,
- CA_PROP_EVENT_ID, "dialog-warning",
- CA_PROP_EVENT_DESCRIPTION, sound_message,
- NULL);
+ /* libcanberra-gtk3 is X11-only and unavailable on wayland-only builds;
+ * disabled upstream too (GNOME!ec6d8018) ahead of the GTK4 port. */
+ (void) sound_message;
}
/* ---------------------------------------------------------------------------------------------------- */
@@ -407,10 +404,9 @@ play_complete_sound (DialogData *data)
/* Translators: A descriptive string for the 'complete' sound, see CA_PROP_EVENT_DESCRIPTION */
sound_message = _("Disk image copying complete");
- ca_gtk_play_for_widget (GTK_WIDGET (data->window), 0,
- CA_PROP_EVENT_ID, "complete",
- CA_PROP_EVENT_DESCRIPTION, sound_message,
- NULL);
+ /* libcanberra-gtk3 is X11-only and unavailable on wayland-only builds;
+ * disabled upstream too (GNOME!ec6d8018) ahead of the GTK4 port. */
+ (void) sound_message;
}
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/disks/gdurestorediskimagedialog.c b/src/disks/gdurestorediskimagedialog.c
index 1111111..2222222 100644
--- a/src/disks/gdurestorediskimagedialog.c
+++ b/src/disks/gdurestorediskimagedialog.c
@@ -16,8 +16,6 @@
#include <sys/ioctl.h>
#include <linux/fs.h>
-#include <canberra-gtk.h>
-
#include "gduapplication.h"
#include "gduwindow.h"
#include "gdurestorediskimagedialog.h"
@@ -610,10 +608,9 @@ play_complete_sound (DialogData *data)
/* Translators: A descriptive string for the 'complete' sound, see CA_PROP_EVENT_DESCRIPTION */
sound_message = _("Disk image copying complete");
- ca_gtk_play_for_widget (GTK_WIDGET (data->dialog), 0,
- CA_PROP_EVENT_ID, "complete",
- CA_PROP_EVENT_DESCRIPTION, sound_message,
- NULL);
+ /* libcanberra-gtk3 is X11-only and unavailable on wayland-only builds;
+ * disabled upstream too (GNOME!ec6d8018) ahead of the GTK4 port. */
+ (void) sound_message;
if (data->inhibit_cookie > 0)
{
diff --git a/src/disks/meson.build b/src/disks/meson.build
index 1111111..2222222 100644
--- a/src/disks/meson.build
+++ b/src/disks/meson.build
@@ -83,7 +83,6 @@ deps = [
dvdread_dep,
gio_unix_dep,
gmodule_dep,
- libcanberra_dep,
libgdu_dep,
libhandy_dep,
liblzma_dep,
@@ -0,0 +1,68 @@
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 10 Sep 2026 06:40:00 +0000
Subject: [PATCH] disks: drop the unused gdk/gdkx.h include
gdupasswordstrengthwidget.c, gduvolumegrid.c and gduestimator.c all
pull in <gdk/gdkx.h>, GDK's X11 backend header, but none of them call
any X11-specific GDK API (no gdk_x11_*, no GDK_WINDOW_XID, nothing).
The include is dead weight left over from history.
On a wayland-only build (no x11 in DISTRO_FEATURES) the GTK3 recipe is
configured without its X11 backend, so gdk/gdkx.h isn't installed into
the sysroot at all, and do_compile fails:
gdupasswordstrengthwidget.c:14:10: fatal error: 'gdk/gdkx.h' file not found
gduvolumegrid.c:14:10: fatal error: 'gdk/gdkx.h' file not found
gduestimator.c:14:10: fatal error: 'gdk/gdkx.h' file not found
Drop the unused include from all three files so the GTK3 build works
regardless of whether the X11 backend is enabled.
Upstream-Status: Inappropriate [these files were dropped entirely in
the upstream GTK4/libadwaita port (gduvolumegrid.c) or renamed with a
GTK4-only gdkx.h path (gdupasswordstrengthwidget.c, gduestimator.c,
see GNOME/gnome-disk-utility!179aab50); none carries a comparable fix
for the GTK3 code line this recipe still builds]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/disks/gduestimator.c | 1 -
src/disks/gdupasswordstrengthwidget.c | 1 -
src/disks/gduvolumegrid.c | 1 -
3 files changed, 3 deletions(-)
diff --git a/src/disks/gduestimator.c b/src/disks/gduestimator.c
index 1111111..2222222 100644
--- a/src/disks/gduestimator.c
+++ b/src/disks/gduestimator.c
@@ -11,7 +11,6 @@
#include <math.h>
#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>
#include <stdlib.h>
#include "gduestimator.h"
diff --git a/src/disks/gdupasswordstrengthwidget.c b/src/disks/gdupasswordstrengthwidget.c
index 1111111..2222222 100644
--- a/src/disks/gdupasswordstrengthwidget.c
+++ b/src/disks/gdupasswordstrengthwidget.c
@@ -11,7 +11,6 @@
#include <math.h>
#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>
#include <stdlib.h>
#include <pwquality.h>
diff --git a/src/disks/gduvolumegrid.c b/src/disks/gduvolumegrid.c
index 1111111..2222222 100644
--- a/src/disks/gduvolumegrid.c
+++ b/src/disks/gduvolumegrid.c
@@ -11,7 +11,6 @@
#include <math.h>
#include <gdk/gdkkeysyms.h>
-#include <gdk/gdkx.h>
#include <stdlib.h>
#include "gduvolumegrid.h"
@@ -7,7 +7,6 @@ SECTION = "gnome"
DEPENDS = " \
desktop-file-utils-native \
gtk+3 \
libcanberra \
libdvdread \
libnotify \
libsecret \
@@ -28,6 +27,10 @@ PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd', d)}"
# As soon as elogind is of interest this needs rework: meson option is combo
PACKAGECONFIG[systemd] = "-Dlogind=libsystemd,-Dlogind=none,systemd"
SRC_URI += "file://0001-Drop-the-libcanberra-gtk3-dependency.patch \
file://0002-disks-drop-the-unused-gdk-gdkx.h-include.patch \
"
SRC_URI[archive.sha256sum] = "c24e9439a04d70bcfae349ca134c7005435fe2b6f452114df878bff0b89bbffe"
EXTRA_OEMESON = "-Dman=false"