diff mbox series

[1/2] useradd.bbclass: allow inheriting with only USERADD_DEPENDS set

Message ID 20260408150003.18063-2-zizuzacker@gmail.com
State New
Headers show
Series useradd.bbclass: fix parse error when only USERADD_DEPENDS is set | expand

Commit Message

Zk47T April 8, 2026, 3 p.m. UTC
When a recipe inherits useradd and only sets USERADD_DEPENDS (to depend
on users/groups created by another recipe), without creating any
users/groups itself, the parse-time sanity check incorrectly throws a
fatal error about missing USERADD_PACKAGES.

Skip the USERADD_PACKAGES/USERADD_PARAM validation when USERADD_DEPENDS
is set but USERADD_PACKAGES is not, since the recipe only needs build
dependency tracking, not user/group creation.

Fixes [YOCTO #15863]

Signed-off-by: Zk47T <zizuzacker@gmail.com>
---
 meta/classes/useradd.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 16a65ac323..9d857a4555 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -212,6 +212,11 @@  def update_useradd_after_parse(d):
     useradd_packages = d.getVar('USERADD_PACKAGES')
 
     if not useradd_packages:
+        # It's valid to inherit useradd and only set USERADD_DEPENDS to
+        # depend on users/groups created by another recipe, without
+        # creating any users/groups in this recipe.
+        if d.getVar('USERADD_DEPENDS'):
+            return
         bb.fatal("%s inherits useradd but doesn't set USERADD_PACKAGES" % d.getVar('FILE', False))
 
     for pkg in useradd_packages.split():