Bug 10835

Summary: WIC should not rely on hddimg creation for finding all needed artifacts
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Saul Wold <sgw>
Component: Scripts and ToolsAssignee: Ed Bartosh <eduard.bartosh>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: brian.avery, mikko.ylinen, ross.burton
Version: 2.2   
Target Milestone: 2.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)

Description Saul Wold 2016-12-20 20:14:38 UTC
We would like to deprecate the hddimg and iso FSTYPE in favor of wic, to do this we would need to remove the dependency on hddimg which currently creates the artifacts needed to construct the FAT boot partition.
Comment 1 Saul Wold 2016-12-20 20:21:04 UTC
I actually have a WIP to create a bootpart replacement for bootimg, but still need to work out the details of not using the image-live infrastructure.
Comment 3 Ed Bartosh 2017-01-26 13:15:49 UTC
Sent v2 as v1 conflicts with master due to rss merge.
http://lists.openembedded.org/pipermail/openembedded-core/2017-January/131813.html
Comment 4 Ed Bartosh 2017-01-27 20:46:00 UTC
sent v3: http://lists.openembedded.org/pipermail/openembedded-core/2017-January/131937.html

removed patches that add tasks
fixed test cases,
rebased on top of patches that make use of artifacts from DEPLOY_DIR_IMAGE
Comment 5 Mikko Ylinen 2017-01-30 09:58:15 UTC
(In reply to comment #4)
> sent v3:
> http://lists.openembedded.org/pipermail/openembedded-core/2017-January/
> 131937.html
> 
> removed patches that add tasks
> fixed test cases,
> rebased on top of patches that make use of artifacts from DEPLOY_DIR_IMAGE

v3 feedback:

- with this approach, a custom source plugin would be needed if user wants to add custom artifacts (meta-intel has one case where an "rmc" database needs to be installed in ESP). 
- use "inherit "${@bb.utils.contains_any('IMAGE_FSTYPES', 'wic ' + ' '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), 'image-wic', '', d)}"" or via IMAGE_CLASSES?
- you'd need to remove 'live' from IMAGE_FSTYPES to see this is working
- what needs to change to avoid building all three bootloaders in wic-tools.bb? 

Overall, I believe the best approach with the artifacts would be that they are prepared outside wic and the output would be the final /boot dir somewhere. It'd also make the source plugins simpler and easier to maintain.

note about build artifacts in general: some update mechanisms, like the one with meta-swupd depend on build artifacts to be present in do_rootfs (and /boot).
Comment 6 Ed Bartosh 2017-01-30 11:24:47 UTC
> - with this approach, a custom source plugin would be needed if user wants to add custom artifacts (meta-intel has one case where an "rmc" database needs to be installed in ESP). 

How is this different from previous approach?

> - use "inherit "${@bb.utils.contains_any('IMAGE_FSTYPES', 'wic ' + ' '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), 'image-wic', '', d)}"" or via IMAGE_CLASSES?

Can you elaborate a bit more? I'm not sure I understand this.

> - you'd need to remove 'live' from IMAGE_FSTYPES to see this is working

Why?

> - what needs to change to avoid building all three bootloaders in wic-tools.bb? 

So far I don't have a good idea how to solve it. It was a quick urgent change to support recipe-specific sysroots. Now we need to think how to do it better.

One idea could be to expect that all wic dependencies are present in image sysroot. This would work, but can be hard to maintain as if .wks file starts using new plugin user will have to modify list of dependencies in image recipe.

> Overall, I believe the best approach with the artifacts would be that they are prepared outside wic and the output would be the final /boot dir somewhere. It'd also make the source plugins simpler and easier to maintain.

I 100% agree and support this point of view. However, considering that in some cases wic needs to add root device to the kernel command line it's not that simple. Another thing is a legacy - there are a lot of boilerplate code in wic codebase that writes bootloader configuration files. That code need to be removed carefully, without breaking existing functionality.

BTW, I'm going to work on refactoring wic codebase (bug 10619). Feel free to join me there.
Comment 7 Mikko Ylinen 2017-01-30 12:49:06 UTC
(In reply to comment #6)
> > - with this approach, a custom source plugin would be needed if user wants to add custom artifacts (meta-intel has one case where an "rmc" database needs to be installed in ESP). 
> 
> How is this different from previous approach?

scratch my comment above, I was wrong about that.

> 
> > - use "inherit "${@bb.utils.contains_any('IMAGE_FSTYPES', 'wic ' + ' '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), 'image-wic', '', d)}"" or via IMAGE_CLASSES?
> 
> Can you elaborate a bit more? I'm not sure I understand this.

there was an unconditional 'inherit image-wic'. This comment was about making it conditional to check whether wic is used.

> 
> > - you'd need to remove 'live' from IMAGE_FSTYPES to see this is working
> 
> Why?

The goal is to get rid of do_bootimg task as a dependency too. It's pointless to build, e.g., rootfs.img if a raw image is created by wic.

> 
> > - what needs to change to avoid building all three bootloaders in wic-tools.bb? 
> 
> So far I don't have a good idea how to solve it. It was a quick urgent
> change to support recipe-specific sysroots. Now we need to think how to do
> it better.

OK

> One idea could be to expect that all wic dependencies are present in image
> sysroot. This would work, but can be hard to maintain as if .wks file starts
> using new plugin user will have to modify list of dependencies in image
> recipe.

To me this sounds obvious. It'd be the image recipe maintainers to decide what wic needs to build the image.

> 
> > Overall, I believe the best approach with the artifacts would be that they are prepared outside wic and the output would be the final /boot dir somewhere. It'd also make the source plugins simpler and easier to maintain.
> 
> I 100% agree and support this point of view. However, considering that in
> some cases wic needs to add root device to the kernel command line it's not

Could it modify the existing bootloader configs?


> that simple. Another thing is a legacy - there are a lot of boilerplate code
> in wic codebase that writes bootloader configuration files. That code need
> to be removed carefully, without breaking existing functionality.
> 
> BTW, I'm going to work on refactoring wic codebase (bug 10619). Feel free to
> join me there.

I'll have a look.
Comment 8 Ed Bartosh 2017-01-30 13:08:58 UTC
> > > - use "inherit "${@bb.utils.contains_any('IMAGE_FSTYPES', 'wic ' + ' '.join('wic.%s' % c for c in '${CONVERSIONTYPES}'.split()), 'image-wic', '', d)}"" or via IMAGE_CLASSES?
> > 
> > Can you elaborate a bit more? I'm not sure I understand this.
> 
> there was an unconditional 'inherit image-wic'. This comment was about
> making it conditional to check whether wic is used.
>

I tried this and then decided not to go this way as it can cause not easily understandable errors when user would want to build wic image without adding wic to IMAGE_TYPES, e.g. bitbake sic-image-minimal would produce something like that.
 
> > > - you'd need to remove 'live' from IMAGE_FSTYPES to see this is working
> > 
> > Why?
> 
> The goal is to get rid of do_bootimg task as a dependency too. It's
> pointless to build, e.g., rootfs.img if a raw image is created by wic.
> 

The goal stated in this bug is to get rid of hddimg usage in wic code. Please create new bug if we need to get rid of live as well.

> > One idea could be to expect that all wic dependencies are present in image
> > sysroot. This would work, but can be hard to maintain as if .wks file starts
> > using new plugin user will have to modify list of dependencies in image
> > recipe.
> 
> To me this sounds obvious. It'd be the image recipe maintainers to decide
> what wic needs to build the image.
> 

Unfortunately this is true for the usage scenario when wic uses -e option, i.e. when it uses artefacts provided by the image build. I'd love to make it the only mode available, but it's not the case. Some users use wic manually and point to kernel, bootloaders and rootfs without using image recipe. This case would fail if wic doesn't have a recipe that contains native tools, which is quite tricky to achieve without wic-tools or similar recipe.  

> > I 100% agree and support this point of view. However, considering that in
> > some cases wic needs to add root device to the kernel command line it's not
> 
> Could it modify the existing bootloader configs?
>
Sure it can, but those configs can be quite different, especially if wic is pointed out to some custom bootloader build.
Comment 9 Mikko Ylinen 2017-01-30 14:11:48 UTC
(In reply to comment #8)


> > > > - you'd need to remove 'live' from IMAGE_FSTYPES to see this is working
> > > 
> > > Why?
> > 
> > The goal is to get rid of do_bootimg task as a dependency too. It's
> > pointless to build, e.g., rootfs.img if a raw image is created by wic.
> > 
> 
> The goal stated in this bug is to get rid of hddimg usage in wic code.
> Please create new bug if we need to get rid of live as well.


Most of my feedback has the assumption that do_bootimg is dropped as well. I'll leave it to Saul to clarify what

"we would need to remove the dependency on hddimg which currently creates the artifacts needed to construct the FAT boot partition."

and 

"to create a bootpart replacement for bootimg"

mean.
Comment 10 Ed Bartosh 2017-02-01 10:06:12 UTC
The patchset has been merged to master.
Comment 11 Mikko Ylinen 2017-02-01 10:13:56 UTC
(In reply to comment #10)
> The patchset has been merged to master.

It's still open whether they fix the bug.
Comment 12 Ed Bartosh 2017-02-02 10:52:43 UTC
not for me :)
otherwise I'd not set its status to RESOLVED/FIXED

I still don't know what else needs to be done here. Can you elaborate? And please provide practical evidence (breakages, tracebacks, error messages) that bug is not fixed.