diff mbox series

memory-control: fix build failure on non-systemd distros

Message ID 20260713150121.3809558-1-Ishaan.Desai@ibm.com
State Changes Requested
Headers show
Series memory-control: fix build failure on non-systemd distros | expand

Commit Message

Ishaan Desai July 13, 2026, 3:01 p.m. UTC
The recipe unconditionally declared RDEPENDS on 'systemd', which is an
init manager, not an installable package. On distros like poky that do
not enable the systemd DISTRO_FEATURE, the dependency resolver cannot
satisfy this, causing the recipe and anything that inherits
memory-control.bbclass to become unbuildable in a world build:

  ERROR: Nothing RPROVIDES 'systemd'
  NOTE: Runtime target 'memory-control' is unbuildable

Fix by adding 'inherit features_check' and REQUIRED_DISTRO_FEATURES =
"systemd" to the recipe so it is cleanly skipped on non-systemd distros,
removing 'systemd' from RDEPENDS:${PN} in the recipe (the tool shells out
to systemctl at runtime, but systemd is an init manager present on the
running system, not a package dependency to install), and guarding the
RDEPENDS injection in memory-control.bbclass with bb.utils.contains so
recipes that inherit the class do not pull in the memory-control package
on non-systemd distros. Also add the missing RECIPE_MAINTAINER entry to
maintainers.inc.

Reported-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
AI-Generated: Uses IBM Bob

Signed-off-by: Ishaan Desai <Ishaan.Desai@ibm.com>
---
 meta/classes-recipe/memory-control.bbclass                | 4 +++-
 meta/conf/distro/include/maintainers.inc                  | 1 +
 meta/recipes-support/memory-control/memory-control_1.0.bb | 6 ++++--
 3 files changed, 8 insertions(+), 3 deletions(-)

Comments

Mathieu Dubois-Briand July 13, 2026, 5:18 p.m. UTC | #1
On Mon Jul 13, 2026 at 5:01 PM CEST, Ishaan Desai wrote:
> The recipe unconditionally declared RDEPENDS on 'systemd', which is an
> init manager, not an installable package. On distros like poky that do
> not enable the systemd DISTRO_FEATURE, the dependency resolver cannot
> satisfy this, causing the recipe and anything that inherits
> memory-control.bbclass to become unbuildable in a world build:
>
>   ERROR: Nothing RPROVIDES 'systemd'
>   NOTE: Runtime target 'memory-control' is unbuildable
>
> Fix by adding 'inherit features_check' and REQUIRED_DISTRO_FEATURES =
> "systemd" to the recipe so it is cleanly skipped on non-systemd distros,
> removing 'systemd' from RDEPENDS:${PN} in the recipe (the tool shells out
> to systemctl at runtime, but systemd is an init manager present on the
> running system, not a package dependency to install), and guarding the
> RDEPENDS injection in memory-control.bbclass with bb.utils.contains so
> recipes that inherit the class do not pull in the memory-control package
> on non-systemd distros. Also add the missing RECIPE_MAINTAINER entry to
> maintainers.inc.
>
> Reported-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
> AI-Generated: Uses IBM Bob
>
> Signed-off-by: Ishaan Desai <Ishaan.Desai@ibm.com>
> ---

Hi Ishaan,

The first version was not merged, so please squash your changes in it.

Thanks,
Mathieu
diff mbox series

Patch

diff --git a/meta/classes-recipe/memory-control.bbclass b/meta/classes-recipe/memory-control.bbclass
index 4b45720a1d..ebde5ed46b 100644
--- a/meta/classes-recipe/memory-control.bbclass
+++ b/meta/classes-recipe/memory-control.bbclass
@@ -25,7 +25,9 @@  MEMORY_LIMIT ?= ""
 MEMORY_LIMIT_SERVICE ?= "${PN}.service"
 MEMORY_OOM_POLICY ?= "reboot"
 
-RDEPENDS:${PN} += "memory-control"
+# Only inject the runtime dependency when the distro actually has systemd;
+# memory-control itself requires the systemd DISTRO_FEATURE.
+RDEPENDS:${PN} += "${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'memory-control', '', d)}"
 
 python memory_control_do_install() {
     import os
diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index 4c6307086c..8589a67fa4 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -520,6 +520,7 @@  RECIPE_MAINTAINER:pn-matchbox-wm = "Ross Burton <ross.burton@arm.com>"
 RECIPE_MAINTAINER:pn-mc = "Ross Burton <ross.burton@arm.com>"
 RECIPE_MAINTAINER:pn-mdadm = "Ross Burton <ross.burton@arm.com>"
 RECIPE_MAINTAINER:pn-menu-cache = "Ross Burton <ross.burton@arm.com>"
+RECIPE_MAINTAINER:pn-memory-control = "Ishaan Desai <Ishaan.Desai@ibm.com>"
 RECIPE_MAINTAINER:pn-mesa = "Unassigned <unassigned@yoctoproject.org>"
 RECIPE_MAINTAINER:pn-mesa-demos = "Unassigned <unassigned@yoctoproject.org>"
 RECIPE_MAINTAINER:pn-mesa-gl = "Unassigned <unassigned@yoctoproject.org>"
diff --git a/meta/recipes-support/memory-control/memory-control_1.0.bb b/meta/recipes-support/memory-control/memory-control_1.0.bb
index 3740b783b6..56b156be4b 100644
--- a/meta/recipes-support/memory-control/memory-control_1.0.bb
+++ b/meta/recipes-support/memory-control/memory-control_1.0.bb
@@ -7,7 +7,9 @@  BUGTRACKER = "https://bugzilla.yoctoproject.org"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
 
-inherit systemd
+inherit systemd features_check
+
+REQUIRED_DISTRO_FEATURES = "systemd"
 
 SRC_URI = " \
     file://memory-control.sh \
@@ -18,7 +20,7 @@  SRC_URI = " \
 SYSTEMD_SERVICE:${PN} = ""
 SYSTEMD_AUTO_ENABLE = "disable"
 
-RDEPENDS:${PN} = "bash systemd"
+RDEPENDS:${PN} = "bash"
 
 do_install() {
     install -d ${D}${bindir}