summaryrefslogtreecommitdiffstats
path: root/meta/classes/license.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/license.bbclass')
-rw-r--r--meta/classes/license.bbclass20
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
343def copy_license_files(lic_files_paths, destdir): 343def 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))