summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2016-10-31 08:48:58 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-06 23:35:32 +0000
commitd31d1ad4e566e42d0bbcf1f41ac25e33181fb517 (patch)
treeb5476168f3651906951e8f5dac2efeebd1b9525a /meta/lib/oe
parentef1fa14260b98fde89ad82a211461c7ccfe63d2d (diff)
downloadpoky-d31d1ad4e566e42d0bbcf1f41ac25e33181fb517.tar.gz
oe/copy_buildsystem.py: dereference symlink
When there is a relative symlink in the layer, for example: symA -> ../out/of/layer/file symA will be invalid fater copied, it would be invalid from build time if it points to a relative path, and would be invalid after extracted the sdk if it points to a absolute py. Dereference symlink when copy will fix the problem. Use tar rather than shutil.copytree() to copy is because: 1) shutil.copytree(symlinks=Fasle) has bugs when dereference symlinks: https://bugs.python.org/issue21697 And Ubunutu 1404 doesn't upgrade python3 to fix the problem. 2) shutil.copytree(symlinks=False) raises errors when there is a invalid symlink, and tar just prints a warning, tar is preferred here since the real world is unpredicatable 3) tar is faster than shutil.copytree() as said by oe.path.copytree() So use tar to copy. (From OE-Core rev: f4d70bb0882eec4fb46cd942f2796fad57c72982) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe')
-rw-r--r--meta/lib/oe/copy_buildsystem.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/meta/lib/oe/copy_buildsystem.py b/meta/lib/oe/copy_buildsystem.py
index afaff68598..29ac6d418f 100644
--- a/meta/lib/oe/copy_buildsystem.py
+++ b/meta/lib/oe/copy_buildsystem.py
@@ -4,11 +4,15 @@ import stat
4import shutil 4import shutil
5 5
6def _smart_copy(src, dest): 6def _smart_copy(src, dest):
7 import subprocess
7 # smart_copy will choose the correct function depending on whether the 8 # smart_copy will choose the correct function depending on whether the
8 # source is a file or a directory. 9 # source is a file or a directory.
9 mode = os.stat(src).st_mode 10 mode = os.stat(src).st_mode
10 if stat.S_ISDIR(mode): 11 if stat.S_ISDIR(mode):
11 shutil.copytree(src, dest, symlinks=True, ignore=shutil.ignore_patterns('.git')) 12 bb.utils.mkdirhier(dest)
13 cmd = "tar --exclude='.git' --xattrs --xattrs-include='*' -chf - -C %s -p . \
14 | tar --xattrs --xattrs-include='*' -xf - -C %s" % (src, dest)
15 subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
12 else: 16 else:
13 shutil.copyfile(src, dest) 17 shutil.copyfile(src, dest)
14 shutil.copymode(src, dest) 18 shutil.copymode(src, dest)