<?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>10060</bug_id>
          
          <creation_ts>2016-08-02 01:07:33 +0000</creation_ts>
          <short_desc>Suggested documentation for fakeroot and Pseudo</short_desc>
          <delta_ts>2016-08-02 20:46:39 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>9</classification_id>
          <classification>Documentation</classification>
          <product>Reference</product>
          <component>handbook</component>
          <version>2.2</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>02 August 2016: RESOLVED</status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>ulfalizer</reporter>
          <assigned_to name="Scott Rifenbark">srifenbark</assigned_to>
          <cc>bluelightning</cc>
    
    <cc>poky.doc.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>srifenbark</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Done (doc changes complete)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>64769</commentid>
    <comment_count>0</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-02 01:07:33 +0000</bug_when>
    <thetext>Hello,

Fakeroot and Pseudo currently seem to be almost completely undocumented. Here&apos;s
some suggested documentation:


Add a new section &apos;4.4. Fakeroot and Pseudo&apos; to the reference manual with the
following contents:

  Some tasks are easier to implement when allowed to perform certain operations
  that are normally reserved for the root user. For example, the [do_install]
  task benefits from being able to set the UID and GID of installed files to
  arbitrary values.
  
  One approach to allowing tasks to perform root-only operations is to require
  BitBake to run as root, but this is cumbersome and has security issues. The
  approach that&apos;s actually used is to run tasks that benefit from root
  privileges in a &quot;fake&quot; root environment. Within this environment, the task
  and its child processes believe that they are running as the root user, and
  see an internally consistent view of the filesystem. As long as generating
  the final output (e.g. a package or an image) does not require root
  privileges, the fact that some earlier steps ran in a fake root environment
  does not cause problems.
  
  The capability to run tasks in a fake root environment is known as
  &quot;fakeroot&quot;, from the BitBake keyword/flag that requests a fake root
  environment for a task. In modern Yocto versions, the program that implements
  fakeroot is known as Pseudo.
  
  Pseudo overrides system calls (through the LD_PRELOAD mechanism) to give the
  illusion of running as root. To keep track of &quot;fake&quot; file ownership and
  permissions resulting from operations that require root permissions, an sqlite3
  database is used. This database is stored in ${WORKDIR}/pseudo/files.db for
  individual recipes and in ${STAGING_DIR_HOST}/var/pseudo/files.db for staging
  sysroots that need it. Storing the database in a file as opposed to in memory
  gives persistence between tasks, and even between builds.
  
  Caution {
  If you add your own task that manipulates the same files or directories as a
  fakeroot task, then that task should also run under fakeroot. Otherwise, it
  won&apos;t be able to run root-only operations, and won&apos;t see the fake file
  ownership and permissions set by the other task.
  
  You should also add a dependency on
  virtual/fakeroot-native:do_populate_sysroot, giving the following:
  
    fakeroot do_mytask () {
        ...
    }
    do_mytask[depends] += &quot;virtual/fakeroot-native:do_populate_sysroot&quot;
  }
  
  For more information, see the
  [FAKEROOT*](https://www.yoctoproject.org/docs/2.2/bitbake-user-manual/bitbake-user-manual.html#var-FAKEROOT)
  variables in the BitBake User Manual, and [this article about
  Pseudo](http://www.ibm.com/developerworks/opensource/library/os-aapseudo1/index.html).



Rewrite the beginning of do_install (before the Caution) in the reference
manual as follows:

  Copies files that are to be packaged into the holding area ${D}. Runs with the
  current working directory set to ${B}, which is the compilation directory.
  
  This task, as well as other tasks that either directly or indirectly depend
  on the installed files (e.g., do_package, do_package_write_*, and do_rootfs),
  run under [fakeroot](link to the new &apos;4.4. Fakeroot and Pseudo&apos; section).



Add the following note to the end of the D glossary entry:

  Caution {
  Tasks that read from or write to this directory should run under
  [fakeroot](link to the new &apos;4.4. Fakeroot and Pseudo&apos; section).
  }


At first I thought of mentioning fakeroot in the description of all tasks that
use it. I think it might be too spammy though, and it&apos;s also easy to miss a
task and accidentally give the impression that it doesn&apos;t use fakeroot.

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64770</commentid>
    <comment_count>1</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-02 01:32:50 +0000</bug_when>
    <thetext>Please remove the following part. It might be based on a misunderstanding.

   ...and in ${STAGING_DIR_HOST}/var/pseudo/files.db for staging sysroots
   that need it.

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64788</commentid>
    <comment_count>2</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-02 16:51:02 +0000</bug_when>
    <thetext>Hi Ulf, 

See http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#fakeroot-and-pseudo for the new section on Fakeroot and Pseudo.

See http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#ref-tasks-install for the changes to the do_install task.

See http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#var-D for the changes to the D variable in the glossary.

Thanks,
Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64791</commentid>
    <comment_count>3</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-02 17:24:43 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Hi Ulf, 
&gt; 
&gt; See
&gt; http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#fakeroot-and-
&gt; pseudo for the new section on Fakeroot and Pseudo.

The following part was meant to be part of the Caution (but I can see how the formatting was confusing). There&apos;s an extra } now too.

 You should also add a dependency on virtual/fakeroot-native:do_populate_sysroot, giving the following:

       fakeroot do_mytask () {
           ...
       }
       do_mytask[depends] += &quot;virtual/fakeroot-native:do_populate_sysroot&quot;

&gt; See
&gt; http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#ref-tasks-
&gt; install for the changes to the do_install task.

Repeating &quot;this task&quot; doesn&apos;t flow very well to me. Note that I also rewrote the second sentence in my version.

No super strong opinions though. :P

&gt; See http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#var-D
&gt; for the changes to the D variable in the glossary.
&gt; 

Looks good to me.

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64792</commentid>
    <comment_count>4</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-02 17:59:18 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; Hi Ulf, 
&gt; &gt; 
&gt; &gt; See
&gt; &gt; http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#fakeroot-and-
&gt; &gt; pseudo for the new section on Fakeroot and Pseudo.
&gt; The following part was meant to be part of the Caution (but I can see how
&gt; the formatting was confusing). There&apos;s an extra } now too.

Ahh... I see.  Yes, I thought that last brace was part of the code and not closing off the Caution.  Fixed - http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#fakeroot-and-pseudo

&gt; 
&gt;  You should also add a dependency on
&gt; virtual/fakeroot-native:do_populate_sysroot, giving the following:
&gt; 
&gt;        fakeroot do_mytask () {
&gt;            ...
&gt;        }
&gt;        do_mytask[depends] += &quot;virtual/fakeroot-native:do_populate_sysroot&quot;
&gt; 
&gt; &gt; See
&gt; &gt; http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#ref-tasks-
&gt; &gt; install for the changes to the do_install task.
&gt; 
&gt; Repeating &quot;this task&quot; doesn&apos;t flow very well to me. Note that I also rewrote
&gt; the second sentence in my version.
&gt; 
&gt; No super strong opinions though. :P

I actually thought that to myself as I was reading it.  That is a good call.  You are a good writer. Fixed. http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#ref-tasks-install

&gt; 
&gt; &gt; See http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#var-D
&gt; &gt; for the changes to the D variable in the glossary.
&gt; &gt; 
&gt; 
&gt; Looks good to me.
&gt; 
&gt; Cheers,
&gt; Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64793</commentid>
    <comment_count>5</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-02 18:08:14 +0000</bug_when>
    <thetext>Thanks! Looks good to me now.

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64794</commentid>
    <comment_count>6</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-02 19:27:22 +0000</bug_when>
    <thetext>Thanks,

Setting to RESOLVED and placing doc flag to &quot;done.&quot;

Scott</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64796</commentid>
    <comment_count>7</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2016-08-02 20:14:40 +0000</bug_when>
    <thetext>Some minor corrections:

&quot;One approach to allowing tasks to perform root-only operations is to require BitBake to run as root.&quot; -&gt; &quot;One approach to allowing tasks to perform root-only operations would be to require BitBake to run as root.&quot; (we&apos;re talking hypothetically here, since this is explicitly disallowed.)

&quot;In recent Yocto versions&quot; -&gt; &quot;In current versions of the OpenEmbedded build system&quot; (Please don&apos;t use &quot;Yocto&quot; to refer to the build system!)

&quot;the BitBake keyword/flag&quot; -&gt; &quot;The BitBake function varflag&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64798</commentid>
    <comment_count>8</comment_count>
    <who name="">ulfalizer</who>
    <bug_when>2016-08-02 20:21:50 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; Some minor corrections:
&gt; 
&gt; &quot;One approach to allowing tasks to perform root-only operations is to
&gt; require BitBake to run as root.&quot; -&gt; &quot;One approach to allowing tasks to
&gt; perform root-only operations would be to require BitBake to run as root.&quot;
&gt; (we&apos;re talking hypothetically here, since this is explicitly disallowed.)
&gt; 
&gt; &quot;In recent Yocto versions&quot; -&gt; &quot;In current versions of the OpenEmbedded build
&gt; system&quot; (Please don&apos;t use &quot;Yocto&quot; to refer to the build system!)

Looks good to me.
 
&gt; &quot;the BitBake keyword/flag&quot; -&gt; &quot;The BitBake function varflag&quot;

I think this would confuse readers. How about &quot;the BitBake keyword/variable flag&quot;?

Cheers,
Ulf</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64802</commentid>
    <comment_count>9</comment_count>
    <who name="Scott Rifenbark">srifenbark</who>
    <bug_when>2016-08-02 20:34:06 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; (In reply to comment #7)
&gt; &gt; Some minor corrections:
&gt; &gt; 
&gt; &gt; &quot;One approach to allowing tasks to perform root-only operations is to
&gt; &gt; require BitBake to run as root.&quot; -&gt; &quot;One approach to allowing tasks to
&gt; &gt; perform root-only operations would be to require BitBake to run as root.&quot;
&gt; &gt; (we&apos;re talking hypothetically here, since this is explicitly disallowed.)

I try to avoid future tense if possible.  However, I see your point in this case. 

&gt; &gt; 
&gt; &gt; &quot;In recent Yocto versions&quot; -&gt; &quot;In current versions of the OpenEmbedded build
&gt; &gt; system&quot; (Please don&apos;t use &quot;Yocto&quot; to refer to the build system!)

Since the original specified &quot;Yocto versions&quot;, I assumed the release in general. I do refer to the build system as the OpenEmbedded build system throughout the manual set.

&gt; 
&gt; Looks good to me.
&gt;  
&gt; &gt; &quot;the BitBake keyword/flag&quot; -&gt; &quot;The BitBake function varflag&quot;
&gt; 
&gt; I think this would confuse readers. How about &quot;the BitBake keyword/variable
&gt; flag&quot;?

Fixed
&gt; 
&gt; Cheers,
&gt; Ulf

See - http://www.yoctoproject.org/docs/2.2/ref-manual/ref-manual.html#fakeroot-and-pseudo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>64807</commentid>
    <comment_count>10</comment_count>
    <who name="Paul Eggleton">bluelightning</who>
    <bug_when>2016-08-02 20:46:39 +0000</bug_when>
    <thetext>&quot;varflag&quot; is an official term we use in a number of other places, however I do note that in other places in the manual we say &quot;variable flag (varflag)&quot; so that it&apos;s clear what we mean. I won&apos;t insist upon using that here though, it doesn&apos;t matter all that much.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>