[oe-commits] [openembedded-core] 42/103: oe.path: preserve xattr in copytree() and copyhardlinktree()

git at git.openembedded.org git at git.openembedded.org
Wed Aug 31 09:02:01 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 634ef99a22b023904e753c2666ad65f9c6a7be09
Author: Joshua Lock <joshua.g.lock at intel.com>
AuthorDate: Tue Aug 30 14:05:10 2016 +0100

    oe.path: preserve xattr in copytree() and copyhardlinktree()
    
    Pass appropriate options to tar invocations in copytree() and
    copyhardlinktree() to ensure that any extended attributes on the files
    are preserved during the copy.
    
    We have to drop the use cpio in "Copy-pass" mode in copyhardlinktree()
    because cpio doesn't support extended attributes on files. Instead we
    revert back to using cp with different patterns depending on whether
    or not the directory contains dot files.
    
    Signed-off-by: Joshua Lock <joshua.g.lock at intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/lib/oe/path.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index 3c07df3..631c3b4 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -65,7 +65,7 @@ def copytree(src, dst):
     # This way we also preserve hardlinks between files in the tree.
 
     bb.utils.mkdirhier(dst)
-    cmd = 'tar -cf - -C %s -p . | tar -xf - -C %s' % (src, dst)
+    cmd = "tar --xattrs --xattrs-include='*' -cf - -C %s -p . | tar --xattrs --xattrs-include='*' -xf - -C %s" % (src, dst)
     subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
 
 def copyhardlinktree(src, dst):
@@ -77,9 +77,14 @@ def copyhardlinktree(src, dst):
     if (os.stat(src).st_dev ==  os.stat(dst).st_dev):
         # 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 --no-recursion --files-from - | tar -xf - -C %s' % (src, src, dst)
+        cmd = "cd %s; find . -type d -print | tar --xattrs --xattrs-include='*' -cf - -C %s -p --no-recursion --files-from - | tar --xattrs --xattrs-include='*' -xf - -C %s" % (src, src, dst)
         subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
-        cmd = 'cd %s; find . -print0 | cpio --null -pdlu %s' % (src, dst)
+        if os.path.isdir(src):
+            import glob
+            if len(glob.glob('%s/.??*' % src)) > 0:
+                src = src + '/.??* '
+            src = src + '/*'
+        cmd = 'cp -afl --preserve=xattr %s %s' % (src, dst)
         subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
     else:
         copytree(src, dst)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list