<?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>13887</bug_id>
          
          <creation_ts>2020-04-30 03:02:34 +0000</creation_ts>
          <short_desc>[wic - rootfs plugin] Using IMAGE_ROOTFS variable in --rootfs-dir= causes an odd error</short_desc>
          <delta_ts>2020-05-18 06:49:33 +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>Scripts and Tools</component>
          <version>unspecified</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>normal</bug_severity>
          <target_milestone>3.2 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Diego">diego.ml</reporter>
          <assigned_to name="Ricardo Ribalda">ricardo.ribalda</assigned_to>
          <cc>ricardo.ribalda</cc>
    
    <cc>richard.purdie</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>87109</commentid>
    <comment_count>0</comment_count>
    <who name="Diego">diego.ml</who>
    <bug_when>2020-04-30 03:02:34 +0000</bug_when>
    <thetext>The same error has been reported here:
https://www.yoctoproject.org/pipermail/yocto/2019-July/046023.html

The proposed solution / workaround of renaming wks to wks.in doesn&apos;t work for me and isn&apos;t documented.


Description:
It should be possible to use the --rootfs-dir= parameter to specify a subtree as root of the partition. This works if an absolute path is provided, but not if the IMAGE_ROOTFS variable is used like this:
part /opt/app --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/opt/app
This usage is shown also in:
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/wic/canned-wks/efi-bootdisk.wks.in?h=dunfell#n2
but it doesn&apos;t seem to (always?) work, as reported here are well:
https://www.yoctoproject.org/pipermail/yocto/2018-November/043184.html

When the __get_rootfs_dir function gets called, the rootfs_dir variable is not expanded, its value is for example:
${IMAGE_ROOTFS}/opt/app
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source/rootfs.py?h=dunfell#n70
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/wic/plugins/source/rootfs.py?h=dunfell#n39
and then misc.get_var looks for a unexpanded path:
... /imgdata/${IMAGE_ROOTFS}/opt/app.env
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/scripts/lib/wic/misc.py?h=dunfell#n199</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87111</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2020-04-30 07:41:09 +0000</bug_when>
    <thetext>Ricardo, we wondered if you had any insight into this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87120</commentid>
    <comment_count>2</comment_count>
    <who name="Ricardo Ribalda">ricardo.ribalda</who>
    <bug_when>2020-04-30 08:17:50 +0000</bug_when>
    <thetext>variables can only be used on .wks.in files, and they have to be run by bitbake NOT by wic.

The wks.in to wks conversion is done by bitbake on
https://git.openembedded.org/openembedded-core/tree/meta/classes/image_types_wic.bbclass#n62

If you were to use directly wic you cannot add any variable.

BUT, there is an alternative, since https://git.openembedded.org/openembedded-core/commit/?id=2265d089a58e1f78f26d623ee667c420cb1c3bd4

You can use this syntax:

part / --source rootfs --ondisk sda --fstype=ext4 --exclude-path=etc/   
part /etc --source rootfs --fstype=ext4 --change-directory=etc

It is compatible with both bitbake and wic and keep the right permissions on the destination folder.

I would suggest to check if there is other usercase for wks.in than expanding ${IMAGE_ROOTFS}, because if that is the case I would suggest to deprecate it, as now we have a better solution.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87178</commentid>
    <comment_count>3</comment_count>
    <who name="Ricardo Ribalda">ricardo.ribalda</who>
    <bug_when>2020-05-12 06:31:50 +0000</bug_when>
    <thetext>Diego, do you need more help regarding this? Can I close the issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87201</commentid>
    <comment_count>4</comment_count>
    <who name="Diego">diego.ml</who>
    <bug_when>2020-05-15 00:15:26 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Diego, do you need more help regarding this? Can I close the issue?

Thank you Ricardo, I got confused by the wks.in vs wks.inc subtle but substantial difference: the main wks file referenced by the WKS_FILE var should actually be a &quot;wks.in&quot;.

I think that the only missing thing is a bit of documentation in the manual.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87237</commentid>
    <comment_count>5</comment_count>
    <who name="Ricardo Ribalda">ricardo.ribalda</who>
    <bug_when>2020-05-18 06:49:33 +0000</bug_when>
    <thetext>Thanks, I close this bug then.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>