[OE-core] [PATCH] useradd_base: Make perform_groupmems work with native
Fabrice Coulon
fabrice.coulon at axis.com
Mon Dec 14 11:12:50 UTC 2015
I have a problem when using useradd_base.bbclass together with native.
${sysconfdir} is BUILDDIR/tmp/sysroots/x86_64-linux/etc for native,
and ${sysconfdir} is "/etc" for target.
rootdir is BUILDDIR/tmp/sysroots/x86_64-linux for native, so,
$rootdir${sysconfdir} is not correct for native since it contains
a duplication of the path to the sysroots.
The solution was to replace instances of $rootdir${sysconfdir}
with one variable that is correctly set depending if we inherit from
native or not.
Signed-off-by: Fabrice Coulon <fabrice.coulon at axis.com>
---
meta/classes/useradd_base.bbclass | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index ab3cd35..30ae1a8 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -74,20 +74,23 @@ perform_groupmems () {
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 sysroots_sysconfdir="${@'$sysconfdir' if bb.data.inherits_class('native', d) else '$rootdir$sysconfdir'}"
+
# groupmems fails if /etc/gshadow does not exist
local gshadow=""
- if [ -f $rootdir${sysconfdir}/gshadow ]; then
+ if [ -f ${sysroots_sysconfdir}/gshadow ]; then
gshadow="yes"
else
gshadow="no"
- touch $rootdir${sysconfdir}/gshadow
+ touch ${sysroots_sysconfdir}/gshadow
fi
- local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
+ local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" ${sysroots_sysconfdir}/group || true`"
if test "x$mem_exists" = "x"; then
local count=0
while true; do
eval $PSEUDO groupmems $opts || true
- mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
+ mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" ${sysroots_sysconfdir}/group || true`"
if test "x$mem_exists" = "x"; then
bbwarn "${PN}: groupmems command did not succeed. Retrying..."
else
@@ -96,8 +99,8 @@ perform_groupmems () {
count=`expr $count + 1`
if test $count = $retries; then
if test "x$gshadow" = "xno"; then
- rm -f $rootdir${sysconfdir}/gshadow
- rm -f $rootdir${sysconfdir}/gshadow-
+ rm -f ${sysroots_sysconfdir}/gshadow
+ rm -f ${sysroots_sysconfdir}/gshadow-
fi
bbfatal "${PN}: Tried running groupmems command $retries times without success, giving up"
fi
@@ -107,8 +110,8 @@ perform_groupmems () {
bbnote "${PN}: group $groupname already contains $username, not re-adding it"
fi
if test "x$gshadow" = "xno"; then
- rm -f $rootdir${sysconfdir}/gshadow
- rm -f $rootdir${sysconfdir}/gshadow-
+ rm -f ${sysroots_sysconfdir}/gshadow
+ rm -f ${sysroots_sysconfdir}/gshadow-
fi
}
--
1.9.1
More information about the Openembedded-core
mailing list