title: Generate a file and deploy it to image, inside a yocto recipe
body: <p>I need to generate some kind of manifest, based on the contents of the recipe. This file needs to be deployed to the image as well.</p>
  
  <p>To generate a file, I have seen in many <em>bbclasses</em> that python code functions are used in a similar way such as:</p>
  
  <pre class="lang-py prettyprint-override"><code>      python do_create_manifest () {
            [...]
            filename = d.expand("${D}${LOC}/${MANIFEST_NAME}")
            [...]
            with open (filename,'w') as manifest_file:
               json.dump(manifest_dict, manifest_file, indent=True)
            os.chmod(filename, 0o644)
        }
  </code></pre>
  
  <ul>
  <li>Is there any other preferred way?</li>
  </ul>
  
  <p>The file is created after adding the task dependency, however when such file is packaged, the <strong>host-user-contaminated</strong> warning arises in the file.</p>
  
  <p>Despite I have seen in many recipes the use of:</p>
  
  <pre><code>        chown -R root:root ${D}${...}/${...}
  </code></pre>
  
  <p>This fails, as chown needs to be run by root, and bitbake is ran by current user:</p>
  
  <pre><code>Log data follows:
  | DEBUG: Executing shell function do_uncontaminate
  | chown: changing ownership of '/mnt/thud/build-r0w/[...]/manifest.json': Operation not permitted
  | WARNING: exit code 1 from a shell command.
  </code></pre>
  
  <ul>
  <li>How would I fix the <strong>host-user-contaminated</strong> warning in this case?</li>
  </ul>
  
  <hr>
  
  <p><strong>Note:</strong> I know this would prevent the warning from appearing, but not solving the problem.</p>
  
  <pre><code>    INSANE_SKIP_${PN} = "host-user-contaminated"
  </code></pre>