lib/oe: copyhardlinktree - detect mount points Add function getmount to detect the mount point of the path, as os.stat(path).st_dev in copyhardlinktree fails in lxc containers to detect different paths as separate mounted filesystems (cp -l failure)
PATCH 1/1 lib/oe: copyhardlinktree - detect mount points Add function getmount to detect the mount point of the path, as os.stat(path).st_dev in copyhardlinktree fails in lxc containers to detect different paths as separate mounted filesystems (cp -l failure)
Signed-off-by Jason Plum <[email protected]>
--- meta/lib/oe/path.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
meta/lib/oe/path.py +10 -1
@@ -90,7 +90,7 @@ def copyhardlinktree(src, dst): if os.path.isdir(src) and not len(os.listdir(src)): return - if (os.stat(src).st_dev == os.stat(dst).st_dev): + if (getmount(src) == getmount(dst)): # Need to copy directories only with tar first since cp will error if two # writers try and create a directory at the same time cmd = 'cd %s; find . -type d -print | tar -cf - -C %s -p --files-from - | tar -xf - -C %s' % (src, src, dst)
@@ -259,3 +259,12 @@ def realpath(file, root, use_physdir = True, loop_cnt = 100, assume_dir = False) raise return file + +def getmount(path): + """ Returns the mount point of the path, using realpath """ + path = realpath(path) + while path != os.path.sep: + if os.path.ismount(path): + return path + path = os.path.abspath(os.path.join(path, os.pardir)) + return path
Signature · 1 line
1.8.5.2
Quoted 5 lines · Jason Plum
Signed-off-by Jason Plum <[email protected]>--- meta/lib/oe/path.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
This patch did not apply cleanly, it's possible you patched against an older version of master.
meta/lib/oe/path.py def copyhardlinktree(src, dst): · line 93
Quoted 10 lines
meta/lib/oe/path.py +1
-1@@ -90,7 +90,7 @@ def copyhardlinktree(src, dst): if os.path.isdir(src) and not len(os.listdir(src)): return - if (os.stat(src).st_dev == os.stat(dst).st_dev): + if (getmount(src) == getmount(dst)):
Can you measure the affect on build time with this change?
meta/lib/oe/path.py def realpath(file, root, use_physdir = True, loop_cnt = 100, assume_dir = False) · line 265
Quoted 11 lines
meta/lib/oe/path.py +4
-0# Need to copy directories only with tar first since cp will error if two # writers try and create a directory at the same time cmd = 'cd %s; find . -type d -print | tar -cf - -C %s -p --files-from - | tar -xf - -C %s' % (src, src, dst)@@ -259,3 +259,12 @@ def realpath(file, root, use_physdir = True, loop_cnt = 100, assume_dir = False) raise return file + +def getmount(path): + """ Returns the mount point of the path, using realpath """ + path = realpath(path)
In current master, realpath() seems to need 2 args:
Exception: TypeError: realpath() takes at least 2 arguments (1 given)
Sau!
Quoted 6 lines
meta/lib/oe/path.py +5
-0+ while path != os.path.sep: + if os.path.ismount(path): + return path + path = os.path.abspath(os.path.join(path, os.pardir)) + return path