Bug 9748

Summary: [PATCH] license.bbclass: try copyfile() as fallback when link() fails
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Enrico Scholz <enrico.scholz>
Component: coreAssignee: Ross Burton <ross.burton>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided CC: meta.mr.watcher, meta.watcher
Version: unspecified   
Target Milestone: ---   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)
Attachments:
Description Flags
patch none

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.