<?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>5360</bug_id>
          
          <creation_ts>2013-10-16 15:29:50 +0000</creation_ts>
          <short_desc>change file ownership in do_install() is not reflected in final rootfs</short_desc>
          <delta_ts>2013-10-18 13:35:53 +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>BitBake</product>
          <component>bitbake</component>
          <version>1.5</version>
          <rep_platform>Other</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Davide Soldan">davide.soldan</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</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>37986</commentid>
    <comment_count>0</comment_count>
    <who name="Davide Soldan">davide.soldan</who>
    <bug_when>2013-10-16 15:29:50 +0000</bug_when>
    <thetext>branch: dora
commit id (meta-yocto): 56f39bcf2237c11508d82238b6292e4bfbfed764
          (meta-fsl-arm): 00f0cf377224829f450d99bdc4664ffe96623996
          (meta-fsl-arm-extra): 12af63db7719877fd191ed2aa921a455a04f677b
          (meta-fsl-demos): 393b0119d513f9abf7b0570ab0d32b81583dedca

Hi,
in my recipe I want to change owner and permission of a file, so I wrote:

do_install() {
        ls -la ${D}/opt/user
        chown -R user ${D}/opt/user
        chgrp -R user ${D}/opt/user
        ls -la ${D}/opt/user
        chmod 754 ${D}/opt/user/user.sh
        ls -la ${D}/opt/user
}

the output of ls commands is: 

drwxr-xr-x 8 root root   4096 Oct 15 11:13 .
drwxr-xr-x 3 root root   4096 Oct 15 11:13 ..
-rw-r--r-- 1 *root root*  55753 Aug  2 08:48 user.sh

drwxr-xr-x 8 user user   4096 Oct 15 11:13 .
drwxr-xr-x 3 root     root       4096 Oct 15 11:13 ..
-rw-r--r-- 1 *user user*  55753 Aug  2 08:48 user.sh

drwxr-xr-x 8 user user   4096 Oct 15 11:13 .
drwxr-xr-x 3 root     root       4096 Oct 15 11:13 ..
*-rwxr-xr--* 1 user user  55753 Aug  2 08:48 user.sh

So the change of owner and permission works fine in do_install phase.
Opening the final rootfs tarball, however, the file user.sh has still 754 permission but root not user as owner...

The only workaround found to change file ownership is to run a postinstall script at board boot:

pkg_postinst_${PN}() {
        #!/bin/sh -e
        if [ x&quot;$D&quot; = &quot;x&quot; ]; then
          chown -R user /opt/user
          chgrp -R user /opt/user
        else
          exit 1
        fi
}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38035</commentid>
    <comment_count>1</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2013-10-18 10:06:15 +0000</bug_when>
    <thetext>You haven&apos;t mentioned above how you&apos;re actually creating the &quot;user&quot; user. Assuming it&apos;s the same as in the mailing list thread, i.e. adding DEPENDS on another recipe which adds the user via useradd, as mentioned in my follow-up reply on the mailing list I don&apos;t think this is expected to work. 

Typically, recipes that need a specific user to exist use useradd.bbclass themselves rather than depending upon another recipe that does it. However, if you do need to do it in a separate recipe (e.g. because multiple recipes use the same user account), just adding the other recipe to DEPENDS wouldn&apos;t be the right thing to do because that won&apos;t guarantee that the user will exist at runtime - the actual package generated by the other recipe (usually the same name) would need to be added to RDEPENDS_${PN}. Even then though this may not currently work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38043</commentid>
    <comment_count>2</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2013-10-18 13:35:53 +0000</bug_when>
    <thetext>Marking resolved after discussion on the mailing list.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>