Bug 9748 - [PATCH] license.bbclass: try copyfile() as fallback when link() fails
Summary: [PATCH] license.bbclass: try copyfile() as fallback when link() fails
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Undecided normal
Target Milestone: ---
Assignee: Ross Burton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-06-09 17:11 UTC by Enrico Scholz
Modified: 2016-06-16 14:35 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
patch (1.97 KB, patch)
2016-06-09 17:11 UTC, Enrico Scholz
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Enrico Scholz 2016-06-09 17:11:41 UTC
Created attachment 3230 [details]
patch

link() will fail with EXDEV when source and destination are on different mountpoints.
Unfortunately, stat().st_dev does not identify the mountpoint so that copy_license_files()
fails in bind-mount environments.

E.g.:

| # mkdir /tmp/a /tmp/b /tmp/X /tmp/X/a /tmp/X/b
| # touch /tmp/a/foo
| # mount --bind /tmp/a /tmp/X/a
| # mount --bind /tmp/b /tmp/X/b
|
| # python -c 'import os;
| print(os.stat("/tmp/X/a")).st_dev;
| print(os.stat("/tmp/X/b")).st_dev;
| os.link("/tmp/X/a/foo", "/tmp/X/b/foo")'
| 62
| 62
| Traceback (most recent call last):
|   File "<string>", line 1, in <module>
| OSError: [Errno 18] Invalid cross-device link

Patch catches errno EXDEV and tries a plain copy then.


Without this patch, I see

| WARNING: Could not copy license file generic_MIT: [Errno 18] Invalid cross-device link
| WARNING: Could not copy license file generic_MIT-style: [Errno 18] Invalid cross-device link

messages.
Comment 1 Ross Burton 2016-06-16 14:35:38 UTC
Looks like Manuel beat you to a patch.  Fixed in oe-core c00423d6bab9849e331beadf4d3cee90e04fe295.