* [PATCH] useradd_base: Make perform_groupmems work with native
@ 2015-12-07 10:39 Fabrice Coulon
2015-12-07 15:30 ` Christopher Larson
0 siblings, 1 reply; 4+ messages in thread
From: Fabrice Coulon @ 2015-12-07 10:39 UTC (permalink / raw)
To: openembedded-core; +Cc: Fabrice Coulon
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@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
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] useradd_base: Make perform_groupmems work with native
2015-12-07 10:39 [PATCH] useradd_base: Make perform_groupmems work with native Fabrice Coulon
@ 2015-12-07 15:30 ` Christopher Larson
2015-12-08 8:50 ` Fabrice Coulon
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Larson @ 2015-12-07 15:30 UTC (permalink / raw)
To: Fabrice Coulon
Cc: Fabrice Coulon, Patches and discussions about the oe-core layer
[-- Attachment #1: Type: text/plain, Size: 790 bytes --]
On Mon, Dec 7, 2015 at 3:39 AM, Fabrice Coulon <fabrice.coulon@axis.com>
wrote:
> 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@axis.com>
>
Hardcoding a path is *not* an appropriate fix.
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
[-- Attachment #2: Type: text/html, Size: 1290 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] useradd_base: Make perform_groupmems work with native
2015-12-07 15:30 ` Christopher Larson
@ 2015-12-08 8:50 ` Fabrice Coulon
0 siblings, 0 replies; 4+ messages in thread
From: Fabrice Coulon @ 2015-12-08 8:50 UTC (permalink / raw)
To: Christopher Larson; +Cc: Patches and discussions about the oe-core layer
On 12/07/2015 04:30 PM, Christopher Larson wrote:
>
> On Mon, Dec 7, 2015 at 3:39 AM, Fabrice Coulon
> <fabrice.coulon@axis.com <mailto:fabrice.coulon@axis.com>> wrote:
>
> 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@axis.com
> <mailto:fabrice.coulon@axis.com>>
>
>
> Hardcoding a path is *not* an appropriate fix.
I agree that hardcoding a path is not OK but maybe you should not see
this as a fix but more like a question/discussion.
The problem is that "/etc" is hardcoded in 13 other places in
meta/classes/useradd_base.bbclass.
Do you know how to solve this so that it will work well for native?
> --
> Christopher Larson
> clarson at kergoth dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Maintainer - Tslib
> Senior Software Engineer, Mentor Graphics
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] useradd_base: Make perform_groupmems work with native
@ 2015-12-14 11:12 Fabrice Coulon
0 siblings, 0 replies; 4+ messages in thread
From: Fabrice Coulon @ 2015-12-14 11:12 UTC (permalink / raw)
To: openembedded-core; +Cc: Fabrice Coulon
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@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-14 11:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-07 10:39 [PATCH] useradd_base: Make perform_groupmems work with native Fabrice Coulon
2015-12-07 15:30 ` Christopher Larson
2015-12-08 8:50 ` Fabrice Coulon
-- strict thread matches above, loose matches on Subject: below --
2015-12-14 11:12 Fabrice Coulon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox