Skip to contentSkip to conversation

useradd.bbclass: Remove support for the GROUPMEMS_PARAM variable

PATCH In review Peter Kjellerstedt 3 participants 7 messages Aug 25 – Aug 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 useradd.bbclass: Remove support for the GROUPMEMS_PARAM variable

Support for the groupmems command was removed from shadow 4.20. While the suport for GROUPMEMS_PARAM was changed to use usermod instead in commit cec67e24ac94554e092f8ab18b42e09b4feba77e, it makes sense to remove it completely now that it has been removed from shadow. Instead rely on using USERMOD_PARAM for adding users to groups, e.g.:

  USERMOD_PARAM:${PN} = "--append --groups group1,group2 user1"
---
 meta/classes/useradd.bbclass | 52 +++++-------------------------------
 1 file changed, 7 insertions(+), 45 deletions(-)
meta/classes/useradd.bbclass +7 -45
index 4a07394a56..ca6462edd0 100644
@@ -49,7 +49,6 @@ if test "x$UA_SYSROOT" = "x"; then
 	GROUPADD_PARAM="${GROUPADD_PARAM}"
 	USERADD_PARAM="${USERADD_PARAM}"
 	USERMOD_PARAM="${USERMOD_PARAM}"
-	GROUPMEMS_PARAM="${GROUPMEMS_PARAM}"
 fi
 
 # Perform group additions first, since user additions may depend
@@ -101,22 +100,6 @@ if test "x`echo $USERMOD_PARAM | tr -d '[:space:]'`" != "x"; then
 		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
 	done
 fi
-
-if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then
-	echo "Running groupmems commands..."
-	# Invoke multiple instances of groupmems for parameter lists
-	# separated by ';'
-	opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
-	remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
-	while test "x$opts" != "x"; do
-		perform_groupmems "$SYSROOT" "$OPT $opts"
-		if test "x$opts" = "x$remaining"; then
-			break
-		fi
-		opts=`echo "$remaining" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
-		remaining=`echo "$remaining" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
-	done
-fi
 }
 
 groupadd_sysroot() {
@@ -131,10 +114,6 @@ usermod_sysroot() {
 	common_useradd_sysroot usermod
 }
 
-groupmems_sysroot() {
-	common_useradd_sysroot groupmems
-}
-
 common_useradd_sysroot() {
 	# Pseudo may (do_prepare_recipe_sysroot) or may not (do_populate_sysroot_setscene) be running
 	# at this point so we're explicit about the environment so pseudo can load if
@@ -155,25 +134,18 @@ common_useradd_sysroot() {
 		exit 0
 	fi
 
-	cmd=$1
-
 	# Add groups and users defined for all recipe packages
 	case "$1" in
 		groupadd) GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}";;
 		useradd) USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}";;
 		usermod) USERMOD_PARAM="${@get_all_cmd_params(d, 'usermod')}";;
-		groupmems)
-			GROUPMEMS_PARAM="${@get_all_cmd_params(d, 'groupmems')}"
-			# groupmems is emulated using usermod
-			cmd=usermod
-			;;
 	esac
 
 	# It is also possible we may be in a recipe which doesn't have useradd dependencies and hence the
 	# useradd/groupadd tools are unavailable. If there is no dependency, we assume we don't want to
 	# create users in the sysroot
-	if ! command -v "$cmd"; then
-		bbwarn "The $cmd command could not be found!"
+	if ! command -v "$1"; then
+		bbwarn "The $1 command could not be found!"
 		exit 0
 	fi
 
@@ -190,7 +162,7 @@ common_useradd_sysroot() {
 EXTRA_STAGING_FIXMES += "PSEUDO_SYSROOT PSEUDO_LOCALSTATEDIR LOGFIFO"
 
 python useradd_sysroot_sstate() {
-    for cmd, sort_prefix in [("groupadd", "01"), ("useradd", "02"), ("usermod", "03"), ("groupmems", "04")]:
+    for cmd, sort_prefix in [("groupadd", "01"), ("useradd", "02"), ("usermod", "03")]:
         scriptfile = None
         task = d.getVar("BB_CURRENTTASK")
         if task == "package_setscene":
@@ -244,9 +216,9 @@ def update_useradd_after_parse(d):
         bb.fatal("%s inherits useradd but doesn't set USERADD_PACKAGES" % d.getVar('FILE', False))
 
     for pkg in useradd_packages.split():
-        d.appendVarFlag("do_populate_sysroot", "vardeps", f" USERADD_PARAM:{pkg} GROUPADD_PARAM:{pkg} USERMOD_PARAM:{pkg} GROUPMEMS_PARAM:{pkg}")
-        if not any(d.getVar(f"{name}_PARAM:{pkg}") for name in ["USERADD", "GROUPADD", "USERMOD", "GROUPMEMS"]):
-            bb.fatal("%s inherits useradd but doesn't set USERADD_PARAM, GROUPADD_PARAM, USERMOD_PARAM or GROUPMEMS_PARAM for package %s" % (d.getVar('FILE', False), pkg))
+        d.appendVarFlag("do_populate_sysroot", "vardeps", f" USERADD_PARAM:{pkg} GROUPADD_PARAM:{pkg} USERMOD_PARAM:{pkg}")
+        if not any(d.getVar(f"{name}_PARAM:{pkg}") for name in ["USERADD", "GROUPADD", "USERMOD"]):
+            bb.fatal("%s inherits useradd but doesn't set USERADD_PARAM, GROUPADD_PARAM or USERMOD_PARAM for package %s" % (d.getVar('FILE', False), pkg))
 
 python __anonymous() {
     if not bb.data.inherits_class('nativesdk', d) \
@@ -289,10 +261,9 @@ fakeroot python populate_packages:prepend() {
         preinst += 'perform_groupadd () {\n%s}\n' % d.getVar('perform_groupadd')
         preinst += 'perform_useradd () {\n%s}\n' % d.getVar('perform_useradd')
         preinst += 'perform_usermod () {\n%s}\n' % d.getVar('perform_usermod')
-        preinst += 'perform_groupmems () {\n%s}\n' % d.getVar('perform_groupmems')
         preinst += d.getVar('useradd_preinst')
         # Expand out the *_PARAM variables to the package specific versions
-        for rep in ["GROUPADD_PARAM", "USERADD_PARAM", "USERMOD_PARAM", "GROUPMEMS_PARAM"]:
+        for rep in ["GROUPADD_PARAM", "USERADD_PARAM", "USERMOD_PARAM"]:
             val = d.getVar(rep + ":" + pkg) or ""
             preinst = preinst.replace("${" + rep + "}", val)
         d.setVar('pkg_preinst:%s' % pkg, preinst)
@@ -314,15 +285,6 @@ fakeroot python populate_packages:prepend() {
             update_useradd_package(pkg)
 }
 
-do_recipe_qa[postfuncs] += "recipe_qa_deprecate_groupmems_param"
-python recipe_qa_deprecate_groupmems_param() {
-    useradd_packages = d.getVar('USERADD_PACKAGES') or ""
-    for pkg in useradd_packages.split():
-        if d.getVar(f"GROUPMEMS_PARAM:{pkg}"):
-            bb.warn("The GROUPMEMS_PARAM variable is deprecated. Please use USERMOD_PARAM instead.")
-            return
-}
-
 # Use the following to extend the useradd with custom functions
 USERADDEXTENSION ?= ""
 
#1 lore raw

PATCH 2/5 useradd_base.bbclass: Remove perform_groupmems()

It is no longer used after support for GROUPMEMS_PARAM was removed from useradd.bbclass.

---
 meta/classes/useradd_base.bbclass | 26 --------------------------
 1 file changed, 26 deletions(-)
meta/classes/useradd_base.bbclass +0 -26
index 5e12880b64..efc9d0a096 100644
@@ -50,32 +50,6 @@ perform_useradd () {
 	fi
 }
 
-perform_groupmems () {
-	local rootdir="$1"
-	local opts="$2"
-	bbnote "${PN}: Performing groupmems with [$opts]"
-	local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'`
-	local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'`
-	local prefix=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-P" || $i == "--prefix") print $(i+1) }'`
-	if test "x$groupname" = "x"; then
-		bbfatal "${PN}: groupmems: No user specified using --add."
-
-	elif test "x$username" = "x"; then
-		bbfatal "${PN}: groupmems: No group specified using --group."
-	fi
-	bbnote "${PN}: Emulating groupmems command using usermod with group $groupname and user $username"
-	local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*$" $rootdir/etc/group || true`"
-	if test "x$mem_exists" = "x"; then
-		eval flock -x $rootdir${sysconfdir} -c \"$PSEUDO usermod \${prefix:+--prefix \$prefix} --append --groups \$groupname \$username\" || true
-		mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*$" $rootdir/etc/group || true`"
-		if test "x$mem_exists" = "x"; then
-			bbfatal "${PN}: groupmems command (emulated using usermod) did not succeed."
-		fi
-	else
-		bbnote "${PN}: group $groupname already contains $username, not re-adding it"
-	fi
-}
-
 perform_groupdel () {
 	local rootdir="$1"
 	local opts="$2"
#2 lore raw

PATCH 3/5 useradd-staticids.bbclass: Remove references to GROUPMEMS_PARAM

In reply to Peter Kjellerstedt

The GROUPMEMS_PARAM variable has been removed.

---
 meta/classes/useradd-staticids.bbclass | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
meta/classes/useradd-staticids.bbclass +3 -4
index 1dbcba2bf1..f6bfe1bfb1 100644
@@ -211,8 +211,8 @@ def update_useradd_static_config(d):
             # If a field is left blank, the original value will be used. The 'groupname' field
             # is required.
             #
-            # Note: similar to the passwd file, the 'password' filed is ignored
-            # Note: group_members is ignored, group members must be configured with the GROUPMEMS_PARAM
+            # Note: similar to the passwd file, the 'password' field is ignored
+            # Note: the group_members field is ignored, group members must be configured with USERMOD_PARAM
             if not groups:
                 files, table_var, table_value = get_table_list(d, 'USERADD_GID_TABLES', 'files/group')
                 groups = merge_files(files, 4)
@@ -265,8 +265,7 @@ def update_useradd_static_config(d):
     useradd_packages = d.getVar('USERADD_PACKAGES') or ""
 
     for pkg in useradd_packages.split():
-        # Groupmems doesn't have anything we might want to change, so simply validating
-        # is a bit of a waste -- only process useradd/groupadd
+        # Only process useradd/groupadd parameters.
         useradd_param = d.getVar('USERADD_PARAM:%s' % pkg)
         if useradd_param:
             #bb.warn("Before: 'USERADD_PARAM:%s' - '%s'" % (pkg, useradd_param))
#3 lore raw

PATCH 4/5 package.bbclass: Remove GROUPMEMS_PARAM from PACKAGEVARS

In reply to Peter Kjellerstedt

The GROUPMEMS_PARAM variable has been removed.

---
 meta/classes-global/package.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-global/package.bbclass +1 -1
index 3d293dead7..1dd30fe8b8 100644
@@ -438,7 +438,7 @@ python package_depchains() {
 
 # Since bitbake can't determine which variables are accessed during package
 # iteration, we need to list them here:
-PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm pkg_postinst_ontarget INITSCRIPT_NAME INITSCRIPT_PARAMS DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR USERADD_PARAM GROUPADD_PARAM USERMOD_PARAM CONFFILES SYSTEMD_SERVICE LICENSE SECTION pkg_preinst pkg_prerm RREPLACES GROUPMEMS_PARAM SYSTEMD_AUTO_ENABLE SKIP_FILEDEPS PRIVATE_LIBS PACKAGE_ADD_METADATA"
+PACKAGEVARS = "FILES RDEPENDS RRECOMMENDS SUMMARY DESCRIPTION RSUGGESTS RPROVIDES RCONFLICTS PKG ALLOW_EMPTY pkg_postinst pkg_postrm pkg_postinst_ontarget INITSCRIPT_NAME INITSCRIPT_PARAMS DEBIAN_NOAUTONAME ALTERNATIVE PKGE PKGV PKGR USERADD_PARAM GROUPADD_PARAM USERMOD_PARAM CONFFILES SYSTEMD_SERVICE LICENSE SECTION pkg_preinst pkg_prerm RREPLACES SYSTEMD_AUTO_ENABLE SKIP_FILEDEPS PRIVATE_LIBS PACKAGE_ADD_METADATA"
 
 def gen_packagevar(d, pkgvars="PACKAGEVARS"):
     ret = []
#4 lore raw

PATCH 5/5 documentation.conf: Remove the documentation of GROUPMEMS_PARAM

In reply to Peter Kjellerstedt

The GROUPMEMS_PARAM variable has been removed.

---
 meta/conf/documentation.conf | 1 -
 1 file changed, 1 deletion(-)
meta/conf/documentation.conf +0 -1
index 72513296e2..7b6df903bc 100644
@@ -178,7 +178,6 @@ FULL_OPTIMIZATION[doc] = "The options to pass in TARGET_CFLAGS and CFLAGS when c
 #G
 
 GROUPADD_PARAM[doc] = "When a recipe inherits the useradd class, this variable specifies for a package what parameters should be passed to the groupadd command if you wish to add a group to the system when the package is installed."
-GROUPMEMS_PARAM[doc] = "When a recipe inherits the useradd class, this variable specifies for a package what parameters should be passed to the groupmems command if you wish to modify the members of a group when the package is installed."
 GRUB_GFXSERIAL[doc] = "Configures the GNU GRand Unified Bootloader (GRUB) to have graphics and serial in the boot menu."
 GRUB_OPTS[doc] = "Additional options to add to the GNU GRand Unified Bootloader (GRUB) configuration."
 GRUB_TIMEOUT[doc] = "Specifies the timeout before executing the default LABEL in the GNU GRand Unified Bootloader (GRUB)."
#5 lore raw

Re: [OE-core] [PATCH 5/5] documentation.conf: Remove the documentation of GROUPMEMS_PARAM

Quoted 6 lines · Peter Kjellerstedt via lists.openembedded.org

The GROUPMEMS_PARAM variable has been removed.

---
 meta/conf/documentation.conf | 1 -
 1 file changed, 1 deletion(-)

Hello,

I think there is one last reference to GROUPMEMS_PARAM:
❯ git grep GROUPMEMS_PARAM origin/master-next
origin/master-next:scripts/contrib/convert-overrides.py: "pkg_prerm", "RREPLACES", "GROUPMEMS_PARAM", "SYSTEMD_AUTO_ENABLE", "SKIP_FILEDEPS", "PRIVATE_LIBS", "PACKAGE_ADD_METADATA",

This won't hold the series but maybe consider a followup patch?

Thanks!

Signature · 2 lines
Yoann Congal
Smile ECS
#6 lore raw

RE: [OE-core] [PATCH 5/5] documentation.conf: Remove the documentation of GROUPMEMS_PARAM

Quoted 24 lines

-----Original Message-----
From: Yoann Congal <[email protected]>
Sent: den 27 augusti 2026 11:24
To: Peter Kjellerstedt <[email protected]>; openembedded- [email protected]
Subject: Re: [OE-core] [PATCH 5/5] documentation.conf: Remove the documentation of GROUPMEMS_PARAM

Quoted 6 lines · Peter Kjellerstedt via lists.openembedded.org

The GROUPMEMS_PARAM variable has been removed.

---
 meta/conf/documentation.conf | 1 -
 1 file changed, 1 deletion(-)

Hello,

I think there is one last reference to GROUPMEMS_PARAM:
❯ git grep GROUPMEMS_PARAM origin/master-next origin/master-next:scripts/contrib/convert-overrides.py:
"pkg_prerm", "RREPLACES", "GROUPMEMS_PARAM", "SYSTEMD_AUTO_ENABLE", "SKIP_FILEDEPS", "PRIVATE_LIBS", "PACKAGE_ADD_METADATA",

Quoted 6 lines

This won't hold the series but maybe consider a followup patch?

Thanks!
--
Yoann Congal
Smile ECS

Yes, I know. I considered it and figured it makes no sense to modify that script. I think it would make more sense to remove it altogether as I expect everyone to be updated to the new override syntax since years ago. And if you aren't, then I doubt you upgrade directly to Blacksail anyway...

//Peter