[OE-core] [oe-core][PATCH] lib.oe.path: "copyhardlinktree" should be able to copy folder containng hidden files only

Ivan Efimov i.efimov at inango-systems.com
Fri Jan 31 10:46:57 UTC 2020


Note: file is "hidden" if it's name starts with dot (.)

sstate.bbclass uses "copyhardlinktree" function to install sstate cache
content. Function "copyhardlinktree" uses "cp" command line which fail on copy
directories with hidden files only.  As a result folder containing only hidden files
cannot be installed from sstate cache.

"cp" source file glob argument has been changed from
  ./.??* ./*
to
  <source>/./

Steps for reproduce:

* Add next lines into some recipe ...

    inherit deploy
    do_deploy() {
        touch ${DEPLOYDIR}/.hidden
    }
    addtask deploy
* ... and try to build it

Error like next will occur:

    Exception: subprocess.CalledProcessError: Command 'cp -afl --preserve=xattr ./.??* ./* /path/to/deploy/images/machine' returned non-zero exit status 1.

    Subprocess output:
    cp: cannot stat './*': No such file or directory

Signed-off-by: Ivan Efimov <i.efimov at inango-systems.com>
---
 meta/lib/oe/path.py | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index fa209b9795..49e13225d0 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -104,17 +104,11 @@ def copyhardlinktree(src, dst):
         # writers try and create a directory at the same time
         cmd = "cd %s; find . -type d -print | tar --xattrs --xattrs-include='*' -cf - -S -C %s -p --no-recursion --files-from - | tar --xattrs --xattrs-include='*' -xhf - -C %s" % (src, src, dst)
         subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
-        source = ''
+        source = src
         if os.path.isdir(src):
-            if len(glob.glob('%s/.??*' % src)) > 0:
-                source = './.??* '
-            source += './*'
-            s_dir = src
-        else:
-            source = src
-            s_dir = os.getcwd()
+            source += '/./'
         cmd = 'cp -afl --preserve=xattr %s %s' % (source, os.path.realpath(dst))
-        subprocess.check_output(cmd, shell=True, cwd=s_dir, stderr=subprocess.STDOUT)
+        subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)
     else:
         copytree(src, dst)
 
-- 
2.17.1



More information about the Openembedded-core mailing list