<?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>7554</bug_id>
          
          <creation_ts>2015-03-31 17:08:40 +0000</creation_ts>
          <short_desc>Ownership issue in package contents</short_desc>
          <delta_ts>2016-08-19 06:28:22 +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>devtools / tool chain</component>
          <version>1.7</version>
          <rep_platform>All</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>major</bug_severity>
          <target_milestone>2.2 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mario Domenech Goulart">mario</reporter>
          <assigned_to name="Robert Yang">liezhi.yang</assigned_to>
          <cc>joshuagloe</cc>
    
    <cc>mark.hatle</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>otavio</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>seebs</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>Unknown (Hard to categorize)</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>49997</commentid>
    <comment_count>0</comment_count>
    <who name="Mario Domenech Goulart">mario</who>
    <bug_when>2015-03-31 17:08:40 +0000</bug_when>
    <thetext>I&apos;m observing an issue with directory ownership in package contents.  Not sure if I&apos;m overlooking something really basic or if I hit a bug.

Here&apos;s a minimal recipe to illustrate the problem:

$ cat foo.bb
LICENSE = &quot;CLOSED&quot;

inherit useradd

USERADD_PACKAGES =  &quot;${PN}&quot;
USERADD_PARAM_${PN} = &quot;foo&quot;

do_install() {
    install -d -m 755 ${D}${libdir}/foo
    touch ${D}${libdir}/foo/bar
    chown -R foo:foo ${D}${libdir}/foo
}

Here&apos;s the package content:

$ dpkg -c foo_1.0-r0.0_cortexa9hf-vfp-neon.ipk
drwxrwxrwx root/root         0 2015-03-27 13:37 ./
drwxr-xr-x root/root         0 2015-03-27 13:37 ./usr/
drwxr-xr-x root/root         0 2015-03-27 13:37 ./usr/lib/
drwxr-xr-x root/root         0 2015-03-27 13:37 ./usr/lib/foo/
-rw-r--r-- foo/foo           0 2015-03-27 13:37 ./usr/lib/foo/bar


Note that, although I run &quot;chown -R foo:foo ${D}${libdir}/foo&quot; in the recipe, ./usr/lib/foo/ in the package is owned by root. However, its content has the right ownership.

I also generated and checked the rpm package and observed the same issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>49999</commentid>
    <comment_count>1</comment_count>
    <who name="Seebs">seebs</who>
    <bug_when>2015-03-31 18:12:43 +0000</bug_when>
    <thetext>Hmm. Can you reproduce this outside of bitbake? I did a simple test with install/touch/chown with just pseudo, and got the behavior I expected (which for this would have been that both foo and foo/bar would be foo:foo).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50000</commentid>
    <comment_count>2</comment_count>
    <who name="Otavio Salvador">otavio</who>
    <bug_when>2015-03-31 18:14:59 +0000</bug_when>
    <thetext>Mario has tested in Dizzy and I reproduced same issue in Fido. We didn&apos;t test it outside BitBake.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50001</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-03-31 18:23:20 +0000</bug_when>
    <thetext>(copied from email reply)

I&apos;d suggest you look at meta/classes/package.bbclass &quot;fixup_perms&quot; function.

The ${D}${libdir} (and above) are &quot;corrected&quot; to be &apos;root:root&apos; by this function.  I don&apos;t know why &apos;foo&apos; would be, but if it&apos;s a standard defined variable -- or if &apos;directory walking&apos; is enabled it could end up doing this as well.

The control file for this is in meta/files/fs-perms.txt (unless otherwise defined by a distribution or other configuration file.)

Format of the file is:

# The format of this file 
#
#&lt;path&gt; &lt;mode&gt;  &lt;uid&gt;   &lt;gid&gt;   &lt;walk&gt;  &lt;fmode&gt; &lt;fuid&gt;  &lt;fgid&gt;
#
# or
#
#&lt;path&gt; link &lt;target&gt;
#
# &lt;path&gt;: directory path
# &lt;mode&gt;: mode for directory
# &lt;uid&gt;:  uid for directory
# &lt;gid&gt;:  gid for directory
# &lt;walk&gt;: recursively walk the directory?  true or false
# &lt;fmode&gt;: if walking, new mode for files
# &lt;fuid&gt;:  if walking, new uid for files
# &lt;fgid&gt;:  if walking, new gid for files
# &lt;target&gt;: turn the directory into a symlink point to target

The default is:

base_prefix	0755 root root false - - -
prefix		0755 root root false - - -
exec_prefix	0755 root root false - - -
base_bindir	0755 root root false - - -
base_sbindir	0755 root root false - - -
base_libdir	0755 root root false - - -
datadir		0755 root root false - - -
sysconfdir	0755 root root false - - -
servicedir	0755 root root false - - -
sharedstatedir	0755 root root false - - -
localstatedir	0755 root root false - - -
infodir		0755 root root false - - -
mandir		0755 root root false - - -
docdir		0755 root root false - - -
bindir		0755 root root false - - -
sbindir		0755 root root false - - -
libexecdir	0755 root root false - - -
libdir		0755 root root false - - -
includedir	0755 root root false - - -
oldincludedir	0755 root root false - - -

The easiest way to debug all of this is to edit meta/classes/package.bbclass, find the following lines:

    # Debug -- list out in-memory table
    #for dir in fs_perms_table:
    #    bb.note(&quot;Fixup Perms: %s: %s&quot; % (dir, str(fs_perms_table[dir])))

remove the &apos;#&apos; from the &apos;for&apos; and following lines, then inspect the table from the build logs.

Similarly, you can trace the actual fixups, by searching for def fix_perms(path, mode, uid, gid, dir):, and removing the comment from the two bb.note entries.

This should give you an idea if this code is replacing your value with it&apos;s own.

(I give this a VERY low probability that it&apos;s a bug in pseudo.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50002</commentid>
    <comment_count>4</comment_count>
    <who name="Seebs">seebs</who>
    <bug_when>2015-03-31 19:14:02 +0000</bug_when>
    <thetext>In general, given the complexity of bitbake and oe-core, I like to find reproducers just using pseudo directly, since that way I can confirm that it&apos;s actually pseudo doing something wrong, not pseudo correctly doing whatever it was told to do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50093</commentid>
    <comment_count>5</comment_count>
    <who name="Mario Domenech Goulart">mario</who>
    <bug_when>2015-04-06 13:09:58 +0000</bug_when>
    <thetext>The mailing list thread with comments on this issue can be found here: http://lists.openembedded.org/pipermail/openembedded-core/2015-March/103146.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50270</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-04-13 15:38:16 +0000</bug_when>
    <thetext>The mailing list thread ended with a manual fs-perms.txt for the recipe worked around the issue.  I would lower the priority of this issue.. And we should work to improve the implementation in a future version of the Yocto Project.

See the mailing list discussion for general suggestions for refactoring some of the code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50575</commentid>
    <comment_count>7</comment_count>
    <who name="Mark Hatle">mark.hatle</who>
    <bug_when>2015-04-28 18:38:06 +0000</bug_when>
    <thetext>The plan is to refactor some of the code to make using the fs-perms.txt override easier.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65335</commentid>
    <comment_count>8</comment_count>
    <who name="Robert Yang">liezhi.yang</who>
    <bug_when>2016-08-19 06:28:22 +0000</bug_when>
    <thetext>I can&apos;t reproduce the problem with the following cases any more on master branch, so close it, please feel free to reopen it if you can reproduce it.

diff --git a/meta/recipes-core/base-files/base-files_3.0.14.bb b/meta/recipes-core/base-files/base-files_3.0.14.bb
--- a/meta/recipes-core/base-files/base-files_3.0.14.bb
+++ b/meta/recipes-core/base-files/base-files_3.0.14.bb
@@ -155,6 +155,13 @@ do_install_basefilesissue () {
        fi
 }
 
+do_install_append() {
+    mkdir -p ${D}/usr/lib/hello/world/foodir
+    touch ${D}/usr/lib/hello/world/foodir/foofile
+    chown mail:mail -R ${D}/usr/lib/hello
+
+}
+
 do_install_append_linuxstdbase() {
        for d in ${dirs755-lsb}; do
                 install -m 0755 -d ${D}$d

$ bitbake base-files
$ rpm -qpl -vvv tmp/deploy/rpm/qemux86/base-files-3.0.14-r89.qemux86.rpm
[snip]
drwxr-xr-x    2 root    root                        0 Aug 18 23:19 /usr/lib
drwxr-xr-x    2 mail    mail                        0 Aug 18 23:19 /usr/lib/hello
drwxr-xr-x    2 mail    mail                        0 Aug 18 23:19 /usr/lib/hello/world
drwxr-xr-x    2 mail    mail                        0 Aug 18 23:19 /usr/lib/hello/world/foodir
-rw-r--r--    1 mail    mail                        0 Aug 18 23:19 /usr/lib/hello/world/foodir/foofile
[snip]</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>