<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>4739</bug_id>
          
          <creation_ts>2013-06-17 16:02:51 +0000</creation_ts>
          <short_desc>useradd.bbclass: useradd_sysroot not run per-MACHINE</short_desc>
          <delta_ts>2013-09-07 08:50:11 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>configuration</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>1.5</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Thomas Fitzsimmons">fitzsim</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>jessica.zhang</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>33932</commentid>
    <comment_count>0</comment_count>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-06-17 16:02:51 +0000</bug_when>
    <thetext>We use Yocto to build multiple MACHINE images that all use the same
TUNE_PKGARCH.  We have a TUNE_PKGARCH &quot;users-and-groups&quot; package that installs
custom users and groups, and MACHINE_ARCH &quot;application&quot; packages that have
DEPENDS on &quot;users-and-groups&quot;.  We build each machine image with a separate bitbake invocation but starting in the same build directory, e.g.:

$ MACHINE=machine1 bitbake machine1-image
[...]
$ MACHINE=machine2 bitbake machine2-image
[...]

I&apos;m seeing a problem where sysroots/$machine/etc/passwd is properly updated
with our custom users (i.e., &quot;users-and-groups&quot; is properly staged) on the
first machine build, but not on subsequent machine builds.  This causes build
problems in the per-MACHINE &quot;application&quot; packages in the later builds.

I&apos;ve tracked the problem down to do_package stamp files not being handled on a
per-machine basis for packages that use useradd.bbclass, so only
do_populate_sysroot_setscene is run for the later machines, not
do_package_setscene.  So for these machines, useradd_sysroot is never run,
leaving the sysroot /etc/passwd unmodified.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33938</commentid>
    <comment_count>1</comment_count>
      <attachid>1282</attachid>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-06-17 16:20:34 +0000</bug_when>
    <thetext>Created attachment 1282
useradd.bbclass: Run do_package_setscene per-MACHINE

Here is an RFC patch that fixes the issue for my builds.  I&apos;ve also tested it against libnss-mdns/avahi in openembedded-core to confirm that staging of the avahi user still works correctly.  I don&apos;t think our multi-MACHINE configuration is represented in openembedded-core so I don&apos;t think I can provide a better upstream test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33939</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-06-17 16:22:13 +0000</bug_when>
    <thetext>I think this is a use case we&apos;re not currently supported or tested (recipe A using users and groups setup by recipe B).

do_package is certainly not meant to be machine specific, that would make no sense and cause untold other problems.

I&apos;m wondering if this is as simple to fix as changing useradd_sysroot() in useradd.bbclass to list both package_setscene and populate_sysroot_setscene in the conditional?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33940</commentid>
    <comment_count>3</comment_count>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-06-17 16:38:12 +0000</bug_when>
    <thetext>Yeah, my first workaround (in the &quot;users-and-groups&quot; recipe) was:

useradd_sysroot_sstate () {
	if [ &quot;${BB_CURRENTTASK}&quot; = &quot;populate_sysroot_setscene&quot; ]
	then
		useradd_sysroot
	fi
}

do_populate_sysroot_setscene[depends] = &quot;${USERADDSETSCENEDEPS}&quot;

but that conflicted with a change you had made to check &quot;package_setscene&quot; instead, so I wasn&apos;t sure if manipulating do_populate_sysroot_setscene was a good idea.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33941</commentid>
    <comment_count>4</comment_count>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-06-17 16:46:35 +0000</bug_when>
    <thetext>I could test a patch like:

diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index 1b419bd..fe64b7f 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -129,7 +129,7 @@ useradd_sysroot () {
 }
 
 useradd_sysroot_sstate () {
-	if [ &quot;${BB_CURRENTTASK}&quot; = &quot;package_setscene&quot; ]
+	if [ &quot;${BB_CURRENTTASK}&quot; = &quot;package_setscene&quot; -o &quot;${BB_CURRENTTASK}&quot; = &quot;populate_sysroot_setscene&quot; ]
 	then
 		useradd_sysroot
 	fi

and resubmit if this is a use-case you think is worth supporting.  Otherwise I can maintain it locally; I filed here in case others are seeing this in their configurations.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33942</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-06-17 16:50:01 +0000</bug_when>
    <thetext>Give it a go and see if it works?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33943</commentid>
    <comment_count>6</comment_count>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-06-17 16:59:29 +0000</bug_when>
    <thetext>OK, will do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33979</commentid>
    <comment_count>7</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-06-19 13:49:04 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; OK, will do.

Any update on whether this worked out of interest?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33981</commentid>
    <comment_count>8</comment_count>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-06-19 15:03:37 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #6)
&gt; &gt; OK, will do.
&gt; 
&gt; Any update on whether this worked out of interest?

Yes, sorry for the delay.  Our builds take a long time, and I got caught by the Python 2.7 update on oe-core master.  I&apos;ll be upgrading my RHEL-5.5-based environment to something more modern soon.  For these tests I went back to testing bitbake master and openembedded-core master as of 2013-06-13.  But I want to test the patch against tip too, so I&apos;ll probably end up building Python 2.7 from source.

As for preliminary results, the patch in comment #4 worked for our build, but in oe-core it caused a do_configure error in avahi:

NOTE: Executing glib-gettextize --force --copy
/distro/build/pure-oe-master-sstate/tmp-eglibc/work/i586-oe-linux/avahi/0.6.31-r6.1/temp/run.do_configure.1288: line 143: glib-gettextize: command not found
ERROR: Function failed: do_configure (log file is located at /distro/build/pure-oe-master-sstate/tmp-eglibc/work/i586-oe-linux/avahi/0.6.31-r6.1/temp/log.do_configure.1288)

Adding the do_populate_sysroot_setscene[depends] line seems to fix the error.  I can&apos;t explain why though:

diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index e50c889..1aafe06 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -129,7 +129,7 @@ useradd_sysroot () {
 }
 
 useradd_sysroot_sstate () {
-	if [ &quot;${BB_CURRENTTASK}&quot; = &quot;package_setscene&quot; ]
+	if [ &quot;${BB_CURRENTTASK}&quot; = &quot;package_setscene&quot; -o &quot;${BB_CURRENTTASK}&quot; = &quot;populate_sysroot_setscene&quot; ]
 	then
 		useradd_sysroot
 	fi
@@ -151,6 +151,7 @@ USERADDSETSCENEDEPS_virtclass-cross = &quot;&quot;
 USERADDSETSCENEDEPS_class-native = &quot;&quot;
 USERADDSETSCENEDEPS_class-nativesdk = &quot;&quot;
 do_package_setscene[depends] += &quot;${USERADDSETSCENEDEPS}&quot;
+do_populate_sysroot_setscene[depends] += &quot;${USERADDSETSCENEDEPS}&quot;
 
 # Recipe parse-time sanity checks
 def update_useradd_after_parse(d):</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>33985</commentid>
    <comment_count>9</comment_count>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-06-19 22:21:09 +0000</bug_when>
    <thetext>Without the extra do_populate_sysroot_setscene[depends] line, avahi&apos;s do_populate_sysroot_setscene task fails:

[...]
Running useradd commands...
grep: /distro/build/pure-oe-master-sstate/tmp-eglibc/sysroots/qemux86/etc/passwd: No such file or directory
pseudo: pseudo: can&apos;t run useradd: Permission denied
[...]

and so avahi&apos;s do_configure task is attempted:

  12019:WARNING: Setscene task 61 (/distro/sources/openembedded-core/meta/recipes-connectivity/avahi/avahi_0.6.31.bb, do_populate_sysroot_setscene) failed with exit code &apos;1&apos; - real task will be run instead

but glib-2.0-native hasn&apos;t been staged by the time it&apos;s run, so glib-gettextize isn&apos;t available.

I still have to retest the dependency addition on my build and on oe-core master.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>34396</commentid>
    <comment_count>10</comment_count>
      <attachid>1320</attachid>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-07-08 17:48:39 +0000</bug_when>
    <thetext>Created attachment 1320
useradd.bbclass: Run useradd_sysroot during populate_sysroot_setscene

I set up a Python 2.7-based environment and tested this new patch by building libnss-mdns normally and then with shared state, checking the state of avahi users in the sysroot, and comparing with logs from an unpatched build.

The patch introduces two changes to the build process: 1) the ordering of avahi _setscene tasks is slightly different to accomodate avahi:do_populate_sysroot_setscene&apos;s base-passwd/shadow-native/shadow-sysroot task dependencies. 2) the avahi users are staged immediately by do_populate_sysroot_setscene instead of on-demand by do_package_setscene (e.g. when libnss-mdns is rev-bumped).  I think these changes should be harmless.

I also tested the patch against our internal distro and it enables the desired use case, where one recipe uses users and groups set up by another recipe, even across multiple MACHINE builds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36356</commentid>
    <comment_count>11</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-09-05 22:40:20 +0000</bug_when>
    <thetext>Sorry for the delayed reply. I&apos;m going to test this patch a little locally and post it on the OE-Core mailing list for review. I think it should be reasonable to merge it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36383</commentid>
    <comment_count>12</comment_count>
    <who name="Thomas Fitzsimmons">fitzsim</who>
    <bug_when>2013-09-06 19:41:31 +0000</bug_when>
    <thetext>Thanks Richard, I&apos;ll watch for discussion on the mailing list.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36393</commentid>
    <comment_count>13</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2013-09-07 08:50:11 +0000</bug_when>
    <thetext>Patch merged to master, thanks! http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=f24dda3de90696c5dc33170bcdaa83137cafff9d</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>1282</attachid>
            <date>2013-06-17 16:20:34 +0000</date>
            <delta_ts>2013-07-08 17:48:39 +0000</delta_ts>
            <desc>useradd.bbclass: Run do_package_setscene per-MACHINE</desc>
            <filename>0001-useradd.bbclass-Run-do_package_setscene-per-MACHINE.patch</filename>
            <type>text/plain</type>
            <size>1095</size>
            <attacher name="Thomas Fitzsimmons">fitzsim</attacher>
            
              <data encoding="base64">RnJvbSAwYTIyZGE3Njg2OGY4ZDc1NDk4MDgwMTY0ZDU3ODI0YzZjNWVjM2Q1IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBUaG9tYXMgRml0enNpbW1vbnMgPGZpdHpzaW1AY2lzY28uY29t
PgpEYXRlOiBTdW4sIDE2IEp1biAyMDEzIDAxOjQ4OjI3IC0wNDAwClN1YmplY3Q6IF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0gIiR7VVNFUkFERFNFVFNDRU5FREVQU30iCitkb19w
YWNrYWdlW3N0YW1wLWV4dHJhLWluZm9dID0gIiR7TUFDSElORX0iCiAKICMgUmVjaXBlIHBhcnNl
LXRpbWUgc2FuaXR5IGNoZWNrcwogZGVmIHVwZGF0ZV91c2VyYWRkX2FmdGVyX3BhcnNlKGQpOgot
LSAKMS42LjAuNgoK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>1320</attachid>
            <date>2013-07-08 17:48:39 +0000</date>
            <delta_ts>2013-07-08 17:48:39 +0000</delta_ts>
            <desc>useradd.bbclass: Run useradd_sysroot during populate_sysroot_setscene</desc>
            <filename>0001-useradd.bbclass-Run-useradd_sysroot-during-populate.patch</filename>
            <type>text/plain</type>
            <size>1496</size>
            <attacher name="Thomas Fitzsimmons">fitzsim</attacher>
            
              <data encoding="base64">RnJvbSAyNjQzMmRhNmQzNmYwNjg0MDgwOWYyZmU5YmYwNjY5ZTkwYWE1NjUyIE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBUaG9tYXMgRml0enNpbW1vbnMgPGZpdHpzaW1AY2lzY28uY29t
PgpEYXRlOiBNb24sIDggSnVsIDIwMTMgMTM6MTc6MDIgLTA0MDAKU3ViamVjdDogW1BBVENIXSB1
c2VyYWRkLmJiY2xhc3M6IFJ1biB1c2VyYWRkX3N5c3Jvb3QgZHVyaW5nIHBvcHVsYXRlX3N5c3Jv
b3Rfc2V0c2NlbmUKCkVuYWJsZSBhIG5ldyB1c2VyYWRkIHVzZS1jYXNlOiBvbmUgcmVjaXBlIHVz
aW5nIHVzZXJzIGFuZCBncm91cHMgc2V0IHVwIGJ5IGEKYW5vdGhlciByZWNpcGUuCgpXaGVuIG11
bHRpcGxlIE1BQ0hJTkUgYnVpbGRzIHVzZSB0aGUgc2FtZSBUVU5FX1BLR0FSQ0ggYW5kIGJ1aWxk
IGRpcmVjdG9yeSwKdXNlcmFkZ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