mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
4f8f3f6cb4
commit
66c5a4ad62
@@ -342,6 +342,7 @@ def add_package_and_files(d):
|
|||||||
|
|
||||||
def copy_license_files(lic_files_paths, destdir):
|
def copy_license_files(lic_files_paths, destdir):
|
||||||
import shutil
|
import shutil
|
||||||
|
import errno
|
||||||
|
|
||||||
bb.utils.mkdirhier(destdir)
|
bb.utils.mkdirhier(destdir)
|
||||||
for (basename, path) in lic_files_paths:
|
for (basename, path) in lic_files_paths:
|
||||||
@@ -350,12 +351,21 @@ def copy_license_files(lic_files_paths, destdir):
|
|||||||
dst = os.path.join(destdir, basename)
|
dst = os.path.join(destdir, basename)
|
||||||
if os.path.exists(dst):
|
if os.path.exists(dst):
|
||||||
os.remove(dst)
|
os.remove(dst)
|
||||||
if os.access(src, os.W_OK) and (os.stat(src).st_dev == os.stat(destdir).st_dev):
|
canlink = os.access(src, os.W_OK) and (os.stat(src).st_dev == os.stat(destdir).st_dev)
|
||||||
os.link(src, dst)
|
if canlink:
|
||||||
try:
|
try:
|
||||||
os.chown(dst,0,0)
|
os.link(src, dst)
|
||||||
|
except OSError as err:
|
||||||
|
if err.errno == errno.EXDEV:
|
||||||
|
# Copy license files if hard-link is not possible even if st_dev is the
|
||||||
|
# same on source and destination (docker container with device-mapper?)
|
||||||
|
canlink = False
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
try:
|
||||||
|
if canlink:
|
||||||
|
os.chown(dst,0,0)
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
import errno
|
|
||||||
if err.errno in (errno.EPERM, errno.EINVAL):
|
if err.errno in (errno.EPERM, errno.EINVAL):
|
||||||
# Suppress "Operation not permitted" error, as
|
# Suppress "Operation not permitted" error, as
|
||||||
# sometimes this function is not executed under pseudo.
|
# sometimes this function is not executed under pseudo.
|
||||||
@@ -364,7 +374,7 @@ def copy_license_files(lic_files_paths, destdir):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
else:
|
if not canlink:
|
||||||
shutil.copyfile(src, dst)
|
shutil.copyfile(src, dst)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
bb.warn("Could not copy license file %s to %s: %s" % (src, dst, e))
|
bb.warn("Could not copy license file %s to %s: %s" % (src, dst, e))
|
||||||
|
|||||||
Reference in New Issue
Block a user