Bug 13887 - [wic - rootfs plugin] Using IMAGE_ROOTFS variable in --rootfs-dir= causes an odd error
Summary: [wic - rootfs plugin] Using IMAGE_ROOTFS variable in --rootfs-dir= causes an ...
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: Scripts and Tools (show other bugs)
Version: unspecified
Hardware: All Multiple
: Medium+ normal
Target Milestone: 3.2 M1
Assignee: Ricardo Ribalda
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2020-04-30 03:02 UTC by Diego
Modified: 2020-05-18 06:49 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Diego 2020-04-30 03:02:34 UTC
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't work for me and isn'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'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
Comment 1 Richard Purdie 2020-04-30 07:41:09 UTC
Ricardo, we wondered if you had any insight into this?
Comment 2 Ricardo Ribalda 2020-04-30 08:17:50 UTC
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.
Comment 3 Ricardo Ribalda 2020-05-12 06:31:50 UTC
Diego, do you need more help regarding this? Can I close the issue?
Comment 4 Diego 2020-05-15 00:15:26 UTC
(In reply to comment #3)
> 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 "wks.in".

I think that the only missing thing is a bit of documentation in the manual.
Comment 5 Ricardo Ribalda 2020-05-18 06:49:33 UTC
Thanks, I close this bug then.