diff options
| author | Manuel Huber <Manuel.h87@gmail.com> | 2016-06-11 09:50:02 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-15 18:05:22 +0100 |
| commit | 66c5a4ad6232d7892fa893f596f4e8526ac83dc9 (patch) | |
| tree | c4fc206ae5a90dc69ffa398c650522bc9ce49c2d /meta/classes/license.bbclass | |
| parent | 4f8f3f6cb4ff06c8d40cd4d0f93eca38fc0c03d7 (diff) | |
| download | poky-66c5a4ad6232d7892fa893f596f4e8526ac83dc9.tar.gz | |
classes/license: handle EXDEV if hard link to license fails
Hard links can still fail even if st_dev is the same for source
and destination. In case of EXDEV error, fall back to copying.
(From OE-Core rev: c00423d6bab9849e331beadf4d3cee90e04fe295)
Signed-off-by: Manuel Huber <manuel.h87@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/license.bbclass')
| -rw-r--r-- | meta/classes/license.bbclass | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index 10d6ed853a..c543637294 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass | |||
| @@ -342,6 +342,7 @@ def add_package_and_files(d): | |||
| 342 | 342 | ||
| 343 | def copy_license_files(lic_files_paths, destdir): | 343 | def copy_license_files(lic_files_paths, destdir): |
| 344 | import shutil | 344 | import shutil |
| 345 | import errno | ||
| 345 | 346 | ||
| 346 | bb.utils.mkdirhier(destdir) | 347 | bb.utils.mkdirhier(destdir) |
| 347 | for (basename, path) in lic_files_paths: | 348 | for (basename, path) in lic_files_paths: |
| @@ -350,12 +351,21 @@ def copy_license_files(lic_files_paths, destdir): | |||
| 350 | dst = os.path.join(destdir, basename) | 351 | dst = os.path.join(destdir, basename) |
| 351 | if os.path.exists(dst): | 352 | if os.path.exists(dst): |
| 352 | os.remove(dst) | 353 | os.remove(dst) |
| 353 | if os.access(src, os.W_OK) and (os.stat(src).st_dev == os.stat(destdir).st_dev): | 354 | canlink = os.access(src, os.W_OK) and (os.stat(src).st_dev == os.stat(destdir).st_dev) |
| 354 | os.link(src, dst) | 355 | if canlink: |
| 355 | try: | 356 | try: |
| 356 | os.chown(dst,0,0) | 357 | os.link(src, dst) |
| 358 | except OSError as err: | ||
| 359 | if err.errno == errno.EXDEV: | ||
| 360 | # Copy license files if hard-link is not possible even if st_dev is the | ||
| 361 | # same on source and destination (docker container with device-mapper?) | ||
| 362 | canlink = False | ||
| 363 | else: | ||
| 364 | raise | ||
| 365 | try: | ||
| 366 | if canlink: | ||
| 367 | os.chown(dst,0,0) | ||
| 357 | except OSError as err: | 368 | except OSError as err: |
| 358 | import errno | ||
| 359 | if err.errno in (errno.EPERM, errno.EINVAL): | 369 | if err.errno in (errno.EPERM, errno.EINVAL): |
| 360 | # Suppress "Operation not permitted" error, as | 370 | # Suppress "Operation not permitted" error, as |
| 361 | # sometimes this function is not executed under pseudo. | 371 | # sometimes this function is not executed under pseudo. |
| @@ -364,7 +374,7 @@ def copy_license_files(lic_files_paths, destdir): | |||
| 364 | pass | 374 | pass |
| 365 | else: | 375 | else: |
| 366 | raise | 376 | raise |
| 367 | else: | 377 | if not canlink: |
| 368 | shutil.copyfile(src, dst) | 378 | shutil.copyfile(src, dst) |
| 369 | except Exception as e: | 379 | except Exception as e: |
| 370 | bb.warn("Could not copy license file %s to %s: %s" % (src, dst, e)) | 380 | bb.warn("Could not copy license file %s to %s: %s" % (src, dst, e)) |
