diff mbox series

[5/5] dbus: add message-bus PACKAGECONFIG

Message ID 20250801204928.2580529-5-ross.burton@arm.com
State New
Headers show
Series [1/5] systemd: explicitly disable dbus | expand

Commit Message

Ross Burton Aug. 1, 2025, 8:49 p.m. UTC
There's no need to build an actual message bus in native or nativesdk
environments, as if DBus is needed in those environments then it will be
used to connect to the existing session or system bus.

Add a PACKAGECONFIG for the message bus, and wrap the packaging logic
with a PACKAGECONFIG check.

Expat is only needed by the bus, so this reduces the mandatory build
dependencies in the native case.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/recipes-core/dbus/dbus_1.16.2.bb | 49 +++++++++++++++------------
 1 file changed, 27 insertions(+), 22 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-core/dbus/dbus_1.16.2.bb b/meta/recipes-core/dbus/dbus_1.16.2.bb
index 5de6ba66bc7..ce1cbd856e8 100644
--- a/meta/recipes-core/dbus/dbus_1.16.2.bb
+++ b/meta/recipes-core/dbus/dbus_1.16.2.bb
@@ -27,12 +27,13 @@  EXTRA_OEMESON = "-Dxml_docs=disabled \
                 "
 
 PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'systemd x11', d)} \
-                   traditional-activation user-session \
+                   message-bus traditional-activation user-session \
                   ${@bb.utils.contains('PTEST_ENABLED', '1', 'tests', '', d)} \
                   "
 PACKAGECONFIG:class-native = ""
 PACKAGECONFIG:class-nativesdk = ""
 
+PACKAGECONFIG[message-bus] = "-Dmessage_bus=true,-Dmessage_bus=false,expat"
 PACKAGECONFIG[systemd] = "-Dsystemd=enabled -Dsystemd_system_unitdir=${systemd_system_unitdir},-Dsystemd=disabled,systemd"
 PACKAGECONFIG[x11] = "-Dx11_autolaunch=enabled,-Dx11_autolaunch=disabled, virtual/libx11 libsm"
 PACKAGECONFIG[traditional-activation] = "-Dtraditional_activation=true,-Dtraditional_activation=false"
@@ -42,7 +43,7 @@  PACKAGECONFIG[audit] = "-Dlibaudit=enabled,-Dlibaudit=disabled,audit"
 PACKAGECONFIG[selinux] = "-Dselinux=enabled,-Dselinux=disabled,libselinux"
 PACKAGECONFIG[tests] = "-Dmodular_tests=enabled -Dinstalled_tests=true,-Dmodular_tests=disabled -Dinstalled_tests=false,glib-2.0"
 
-DEPENDS = "expat virtual/libintl"
+DEPENDS = "virtual/libintl"
 RDEPENDS:${PN} += "${PN}-common ${PN}-tools"
 RDEPENDS:${PN}:class-native = ""
 
@@ -99,17 +100,19 @@  FILES:${PN}-dev += "${libdir}/dbus-1.0/include ${bindir}/dbus-test-tool ${datadi
 RDEPENDS:${PN}-ptest += "bash make dbus"
 
 pkg_postinst:dbus() {
-	# If both systemd and sysvinit are enabled, mask the dbus-1 init script as systemd
-	# doesn't know that it matches dbus.service.
-	if ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','true','false',d)}; then
-		if [ -n "$D" ]; then
-			OPTS="--root=$D"
+	if ${@bb.utils.contains('PACKAGECONFIG', 'message-bus', 'true', 'false', d)}; then
+		# If both systemd and sysvinit are enabled, mask the dbus-1 init script as systemd
+		# doesn't know that it matches dbus.service.
+		if ${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','true','false',d)}; then
+			if [ -n "$D" ]; then
+				OPTS="--root=$D"
+			fi
+			systemctl $OPTS mask dbus-1.service
 		fi
-		systemctl $OPTS mask dbus-1.service
-	fi
 
-	if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then
-		/etc/init.d/populate-volatile.sh update
+		if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then
+			/etc/init.d/populate-volatile.sh update
+		fi
 	fi
 }
 
@@ -125,19 +128,21 @@  EOF
 }
 
 do_install:append:class-target() {
-	if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
-		install -d ${D}${sysconfdir}/init.d
-		sed 's:@bindir@:${bindir}:' < ${UNPACKDIR}/dbus-1.init > ${S}/dbus-1.init.sh
-		install -m 0755 ${S}/dbus-1.init.sh ${D}${sysconfdir}/init.d/dbus-1
-		install -d ${D}${sysconfdir}/default/volatiles
-		echo "d messagebus messagebus 0755 /run/dbus none" \
-		     > ${D}${sysconfdir}/default/volatiles/99_dbus
+	if ${@bb.utils.contains('PACKAGECONFIG', 'message-bus', 'true', 'false', d)}; then
+		if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
+			install -d ${D}${sysconfdir}/init.d
+			sed 's:@bindir@:${bindir}:' < ${UNPACKDIR}/dbus-1.init > ${S}/dbus-1.init.sh
+			install -m 0755 ${S}/dbus-1.init.sh ${D}${sysconfdir}/init.d/dbus-1
+			install -d ${D}${sysconfdir}/default/volatiles
+			echo "d messagebus messagebus 0755 /run/dbus none" \
+				> ${D}${sysconfdir}/default/volatiles/99_dbus
+		fi
+
+		mkdir -p ${D}${localstatedir}/lib/dbus
+
+		chown messagebus:messagebus ${D}${localstatedir}/lib/dbus
 	fi
 
-	mkdir -p ${D}${localstatedir}/lib/dbus
-
-	chown messagebus:messagebus ${D}${localstatedir}/lib/dbus
-
 	if [ "${@bb.utils.contains('PACKAGECONFIG', 'traditional-activation', '1', '0', d)}" = "1" ]
 	then
 		chown root:messagebus ${D}${libexecdir}/dbus-daemon-launch-helper