Bug 9663 - do_populate_lic assumes that license basenames are unique
Summary: do_populate_lic assumes that license basenames are unique
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Medium normal
Target Milestone: 2.2
Assignee: Markus Lehtonen
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-05-23 17:58 UTC by Christopher Larson
Modified: 2016-08-11 06:25 UTC (History)
2 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 Christopher Larson 2016-05-23 17:58:18 UTC
When using NO_GENERIC_LICENSE, we're using license files from the source tree, which aren't guaranteed to have unique basenames. We can have 12 different files named LICENSE in different locations, and this is an entirely reasonable thing to do.

Not only does the logic hardcode the assumption that the basename is unique in *multiple* places, it doesn't bother to check for the situation. It blindly removes any existing file of that name, even if it was written by a previous copy in this task. Further, some of the code is flawed and racy, though it likely doesn't cause huge issues yet (do *not* check for a file existing and then remove it if so, the file can easily have been removed between the two lines. remove it, and ignore a failure due to the file not existing).
Comment 1 Markus Lehtonen 2016-08-04 13:39:27 UTC
Hmm, this is a bit trickier than I thought at first. The issue is not just about NO_GENERIC_LICENSE but any package that has multiple overlapping "basenames" in LIC_FILES_CHKSUM. All files listed in LIC_FILES_CHKSUM get copied and if there are multiple files with the same basename only the last prevails. That is a problem if the files differ in content, but, it is the right thing to do if all of them are identical (i.e. have the same checksum).

Thus, I see two cases that need to be solved:
1. If there are multiple identical (same checksum) license files with the same basename we should only copy one file
2. If there are multiple different license files with the same basename we should rename and copy all of them

I'm not that concerned about a possible race, though. My reasoning being that do_populate_lic copies data to a recipe-specific directory and only gets run once with no parallelism.
Comment 2 Markus Lehtonen 2016-08-08 13:08:13 UTC
A patch sent for review:
https://patchwork.openembedded.org/patch/128541/