useradd.bbclass: Fix delete user/group when more than one item

Currently when a recipe adds more than one user/group, the
cleansstate task will delete only the first user/group. This
will solve this behavior and delete all users/groups.

[YOCTO #9943]

(From OE-Core rev: da191d5c139a6b400d1b8fe246912b081dd18176)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Mariano Lopez 2016-07-25 13:31:25 +00:00 committed by Richard Purdie
parent aa2d945423
commit be68ef5129
1 changed files with 13 additions and 7 deletions

View File

@ -137,15 +137,21 @@ if test "x${STAGING_DIR_TARGET}" != "x"; then
GROUPADD_PARAM="${@get_all_cmd_params(d, 'groupadd')}"
USERADD_PARAM="${@get_all_cmd_params(d, 'useradd')}"
if test "x`echo $USERADD_PARAM | tr -d '[:space:]'`" != "x"; then
user=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
user=`echo "$USERADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
remaining=`echo "$USERADD_PARAM" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
while test "x$user" != "x"; do
perform_userdel "${STAGING_DIR_TARGET}" "$OPT $user"
fi
user=`echo "$remaining" | cut -d ';' -f 1 | awk '{ print $NF }'`
remaining=`echo "$remaining" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
done
if test "x`echo $GROUPADD_PARAM | tr -d '[:space:]'`" != "x"; then
group=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
perform_groupdel "${STAGING_DIR_TARGET}" "$OPT $group"
fi
user=`echo "$GROUPADD_PARAM" | cut -d ';' -f 1 | awk '{ print $NF }'`
remaining=`echo "$GROUPADD_PARAM" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
while test "x$user" != "x"; do
perform_groupdel "${STAGING_DIR_TARGET}" "$OPT $user"
user=`echo "$remaining" | cut -d ';' -f 1 | awk '{ print $NF }'`
remaining=`echo "$remaining" | cut -d ';' -f 2- -s | sed -e 's#[ \t]*$##'`
done
fi
fi