[OE-core] [PATCH] useradd_base: Make perform_groupmems work with native

Fabrice Coulon fabrice.coulon at axis.com
Mon Dec 7 10:39:04 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.

The solution for me was to replace instances of $rootdir${sysconfdir}
with $rootdir/etc under perform_groupmems.

Signed-off-by: Fabrice Coulon <fabrice.coulon at axis.com>
---
 meta/classes/useradd_base.bbclass | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index ab3cd35..0c5ba67 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -76,11 +76,11 @@ perform_groupmems () {
 	bbnote "${PN}: Running groupmems command with group $groupname and user $username"
 	# groupmems fails if /etc/gshadow does not exist
 	local gshadow=""
-	if [ -f $rootdir${sysconfdir}/gshadow ]; then
+	if [ -f $rootdir/etc/gshadow ]; then
 		gshadow="yes"
 	else
 		gshadow="no"
-		touch $rootdir${sysconfdir}/gshadow
+		touch $rootdir/etc/gshadow
 	fi
 	local mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
 	if test "x$mem_exists" = "x"; then
@@ -96,8 +96,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 $rootdir/etc/gshadow
+					rm -f $rootdir/etc/gshadow-
 				fi
 				bbfatal "${PN}: Tried running groupmems command $retries times without success, giving up"
 			fi
@@ -107,8 +107,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 $rootdir/etc/gshadow
+		rm -f $rootdir/etc/gshadow-
 	fi
 }
 
-- 
1.9.1




More information about the Openembedded-core mailing list