The groupmems command does to support the --prefix option, which is
being used since commit a7b846ba7d6d63a5e59939d75d9c5fe3e4cbb0e9.
However, the groupmems command can easily be emulated using the usermod
command.

[YOCTO#16277]

Signed-off-by: Peter Kjellerstedt <[email protected]>
---
 meta/classes/useradd_base.bbclass | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/meta/classes/useradd_base.bbclass 
b/meta/classes/useradd_base.bbclass
index 5e1c699118..93c648f8c4 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -56,13 +56,14 @@ perform_groupmems () {
        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) }'`
-       bbnote "${PN}: Running groupmems command with group $groupname and user 
$username"
+       local prefix=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == 
"--prefix") print $(i+1) }'`
+       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 groupmems 
\$opts\" || true
+               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 did not succeed."
+                       bbfatal "${PN}: groupmems command (emulated using 
usermod) did not succeed."
                fi
        else
                bbnote "${PN}: group $groupname already contains $username, not 
re-adding it"
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#236906): 
https://lists.openembedded.org/g/openembedded-core/message/236906
Mute This Topic: https://lists.openembedded.org/mt/119284989/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to