From patchwork Tue Aug 5 11:26:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 68089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5487DC87FD2 for ; Tue, 5 Aug 2025 11:26:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.19480.1754393181327837991 for ; Tue, 05 Aug 2025 04:26:21 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 988AD339 for ; Tue, 5 Aug 2025 04:26:12 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4AC913F673 for ; Tue, 5 Aug 2025 04:26:20 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH v3 1/2] dbus: use the systemd class to handle the unit files Date: Tue, 5 Aug 2025 12:26:13 +0100 Message-ID: <20250805112614.594165-1-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 05 Aug 2025 11:26:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221470 Originally, the dbus recipe couldn't use the systemd class because there was a circular dependency between systemd and dbus. However, since systemd v209 in 2014[1] systemd hasn't needed libdbus, as it has it's own implementation of the client library. DBus does not use the systemd libraries, so there is no circular dependency. The dbus build was already was installing the service and socket files, so we are installing them again. Remove the installation of the units. Manually mask dbus-1.service by simply creating a symlink, instead of depending on systemctl and using an postinstall script. Signed-off-by: Ross Burton [1] dbus: 718db96199 ("core: convert PID 1 to libsystemd-bus") --- meta/recipes-core/dbus/dbus_1.16.2.bb | 32 +++++++-------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/meta/recipes-core/dbus/dbus_1.16.2.bb b/meta/recipes-core/dbus/dbus_1.16.2.bb index 1876ea8a944..4fc590eb39e 100644 --- a/meta/recipes-core/dbus/dbus_1.16.2.bb +++ b/meta/recipes-core/dbus/dbus_1.16.2.bb @@ -46,16 +46,11 @@ DEPENDS = "expat virtual/libintl" RDEPENDS:${PN} += "${PN}-common ${PN}-tools" RDEPENDS:${PN}:class-native = "" -inherit useradd update-rc.d +inherit systemd useradd update-rc.d INITSCRIPT_NAME = "dbus-1" INITSCRIPT_PARAMS = "start 02 5 3 2 . stop 20 0 1 6 ." -python __anonymous() { - if not bb.utils.contains('DISTRO_FEATURES', 'sysvinit', True, False, d): - d.setVar("INHIBIT_UPDATERCD_BBCLASS", "1") -} - PACKAGES =+ "${PN}-lib ${PN}-common ${PN}-tools" USERADD_PACKAGES = "dbus-common" @@ -103,16 +98,7 @@ FILES:${PN}-dev += "${libdir}/dbus-1.0/include ${bindir}/dbus-test-tool ${datadi RDEPENDS:${PN}-ptest += "bash make dbus" -PACKAGE_WRITE_DEPS += "${@bb.utils.contains('DISTRO_FEATURES','systemd sysvinit','systemd-systemctl-native','',d)}" pkg_postinst:dbus() { - # If both systemd and sysvinit are enabled, mask the dbus-1 init script - 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 - if [ -z "$D" ] && [ -e /etc/init.d/populate-volatile.sh ] ; then /etc/init.d/populate-volatile.sh update fi @@ -134,22 +120,20 @@ do_install:append:class-target() { 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 - if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then - for i in dbus.target.wants sockets.target.wants multi-user.target.wants; do \ - install -d ${D}${systemd_system_unitdir}/$i; done - install -m 0644 ${B}/bus/dbus.service ${B}/bus/dbus.socket ${D}${systemd_system_unitdir}/ - ln -fs ../dbus.socket ${D}${systemd_system_unitdir}/dbus.target.wants/dbus.socket - ln -fs ../dbus.socket ${D}${systemd_system_unitdir}/sockets.target.wants/dbus.socket - ln -fs ../dbus.service ${D}${systemd_system_unitdir}/multi-user.target.wants/dbus.service + if ${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'true', 'false', d)}; then + # symlink dbus-1.service to /dev/null to "mask" the service, This ensures + # that if systemd and sysv init systems are both enabled, systemd doesn't + # start two system buses (one from init.d/dbus-1, one from dbus.service). + ln -s /dev/null ${D}${systemd_system_unitdir}/dbus-1.service + fi 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" ] From patchwork Tue Aug 5 11:26:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 68090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5384CC87FCB for ; Tue, 5 Aug 2025 11:26:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.19130.1754393181713373236 for ; Tue, 05 Aug 2025 04:26:21 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 400DE1424 for ; Tue, 5 Aug 2025 04:26:13 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E82093F673 for ; Tue, 5 Aug 2025 04:26:20 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH v3 2/2] dbus: add message-bus PACKAGECONFIG Date: Tue, 5 Aug 2025 12:26:14 +0100 Message-ID: <20250805112614.594165-2-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250805112614.594165-1-ross.burton@arm.com> References: <20250805112614.594165-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 05 Aug 2025 11:26:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/221471 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. This means we can merge the overridden do_install appends, as native and nativesdk don't have the message bus enabled so they don't install dbus-launch. Signed-off-by: Ross Burton --- meta/recipes-core/dbus/dbus_1.16.2.bb | 56 ++++++++++++--------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/meta/recipes-core/dbus/dbus_1.16.2.bb b/meta/recipes-core/dbus/dbus_1.16.2.bb index 4fc590eb39e..abe4196d9ad 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 = "" @@ -115,26 +116,31 @@ systemctl = '${bindir}/systemctl' 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 +do_install:append() { + 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 + 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', 'systemd', 'true', 'false', d)}; then - # symlink dbus-1.service to /dev/null to "mask" the service, This ensures - # that if systemd and sysv init systems are both enabled, systemd doesn't - # start two system buses (one from init.d/dbus-1, one from dbus.service). - ln -s /dev/null ${D}${systemd_system_unitdir}/dbus-1.service + if ${@bb.utils.contains('PACKAGECONFIG', 'systemd', 'true', 'false', d)}; then + # symlink dbus-1.service to /dev/null to "mask" the service, This ensures + # that if systemd and sysv init systems are both enabled, systemd doesn't + # start two system buses (one from init.d/dbus-1, one from dbus.service). + ln -s /dev/null ${D}${systemd_system_unitdir}/dbus-1.service + fi fi - fi - mkdir -p ${D}${localstatedir}/lib/dbus - chown messagebus:messagebus ${D}${localstatedir}/lib/dbus + mkdir -p ${D}${localstatedir}/lib/dbus + chown messagebus:messagebus ${D}${localstatedir}/lib/dbus + else + # This gets installed even if the bus is disabled + rm -rf ${D}${localstatedir} + fi if [ "${@bb.utils.contains('PACKAGECONFIG', 'traditional-activation', '1', '0', d)}" = "1" ] then @@ -146,20 +152,6 @@ do_install:append:class-target() { rm -rf ${D}${runtimedir} } -do_install:append:class-native() { - # dbus-launch has no X support so lets not install it in case the host - # has a more featured and useful version - rm -f ${D}${bindir}/dbus-launch -} - -do_install:append:class-nativesdk() { - # dbus-launch has no X support so lets not install it in case the host - # has a more featured and useful version - rm -f ${D}${bindir}/dbus-launch - - # Remove /run to avoid QA error - rm -rf ${D}${runtimedir} -} BBCLASSEXTEND = "native nativesdk" CVE_PRODUCT += "d-bus_project:d-bus freedesktop:dbus freedesktop:libdbus"