Bug 8779

Summary: update-alternatives.bbclass automatic renaming doesn't happen in sysroots
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Denys Dmytriyenko <denis>
Component: deploymentAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED WONTFIX QA Contact:
Severity: normal    
Priority: Medium CC: richard.purdie
Version: unspecified   
Target Milestone: 2.3   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Denys Dmytriyenko 2015-12-07 15:57:08 UTC
Few years ago, update-alternatives.bbclass was updated with the new interface:

http://cgit.openembedded.org/openembedded-core/commit/?id=309117d26de6a87b16406a44a0cefcbaaf7b5d7a

Among other changes, it supports automatic renaming of files by appending ${BPN}:

# NOTE: If the ALTERNATIVE_LINK_NAME and ALTERNATIVE_TARGET are the same,
# ALTERNATIVE_TARGET will have '.{BPN}' appended to it.  If the file
# referenced has not been renamed, it will also be renamed.  (This avoids
# the need to rename alternative files in the do_install step, but still
# supports it if necessary for some reason.)

But it looks like renaming only happens in the packaging stage and doesn't happen in sysroots, leading to potential clashes between packages providing the same alternative, that both rely on this automatic renaming mechanism. Currently, the workaround is to do the renaming explicitly in do_install.

The error message when both AAAA and BBBB have the same alternative file FFFF and both rely on automatic renaming:


ERROR: The recipe BBBB is trying to install files into a shared area when those files already exist. Those files and their manifest location are:
   FFFF
 Matched in AAAA.populate_sysroot
Please verify which recipe should provide the above files.
The build has stopped as continuing in this scenario WILL break things, if not now, possibly in the future (we've seen builds fail several months later). If the system knew how to recover from this automatically it would however there are several different scenarios which can result in this and we don't know which one this is. It may be you have switched providers of something like virtual/kernel (e.g. from linux-yocto to linux-yocto-dev), in that case you need to execute the clean task for both recipes and it will resolve this error. It may be you changed DISTRO_FEATURES from systemd to udev or vice versa. Cleaning those recipes should again resolve this error however switching DISTRO_FEATURES on an existing build directory is not supported, you should really clean out tmp and rebuild (reusing sstate should be safe). It could be the overlapping files detected are harmless in which case adding them to SSTATE_DUPWHITELIST may be the correct solution. It could also be your build is including two different conflicting versions of things (e.g. bluez 4 and bluez 5 and the correct solution for that would be to resolve the conflict. If in doubt, please ask on the mailing list, sharing the error and filelist above.
ERROR: If the above message is too much, the simpler version is you're advised to wipe out tmp and rebuild (reusing sstate is fine). That will likely fix things in most (but not all) cases.
ERROR: Function failed: sstate_task_postfunc
ERROR: Logfile of failure stored in: BBBB/log.do_populate_sysroot.X
ERROR: Task 3 (BBBB, do_populate_sysroot) failed with exit code '1'
Comment 1 Richard Purdie 2015-12-10 15:51:54 UTC
Denys: Its kind of deliberate that we don't do renaming within the sysroots since we don't install target binaries there, or docs so no conflicting man pages. For natives, we just only install the binaries we want.

The alternative would be to start adding postinstalls to all sstate objects but this introduces huge amounts of complexity to solve a problem which we don't seem to encounter.

Perhaps you could explain the problem you're seeing?
Comment 2 Denys Dmytriyenko 2015-12-18 23:10:18 UTC
Richard,

I was seeing this issue (in Fido) when trying to build and package multiple firmware images, specifically different payloads for DSP. The way the driver works is it expects a file with predefined name in /lib/firmware which gets loaded and executed on DSP core during initialization. Since there could be different payloads, using update-alternatives to manage those seems reasonable. So, initially we tried using automatic renaming and it mostly worked, except during staging step. E.g. bitbake payload1 works, but then bitbake payload2 gives the populate_sysroot error messages above. I ended up doing explicit rename in all payload recipes by adding .${BPN} suffix in do_install for now, due to this issue...

I haven't tested it against master yet, not sure if something improved in the staging handling.
Comment 3 Richard Purdie 2016-12-07 14:43:46 UTC
I have given this more thought and I don't think we can ever expect update-alternatives to work in the sysroot. The sysroots don't have postinstalls, nor do we want to start supporting that. It would simply add too much complication for something which really should be handled in a different way (e.g. the way images have a symlink to the latest image).