diff options
Diffstat (limited to 'meta/lib/oe/path.py')
-rw-r--r-- | meta/lib/oe/path.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index fa209b9795..082972457b 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py | |||
@@ -99,7 +99,22 @@ def copyhardlinktree(src, dst): | |||
99 | if os.path.isdir(src) and not len(os.listdir(src)): | 99 | if os.path.isdir(src) and not len(os.listdir(src)): |
100 | return | 100 | return |
101 | 101 | ||
102 | if (os.stat(src).st_dev == os.stat(dst).st_dev): | 102 | canhard = False |
103 | testfile = None | ||
104 | for root, dirs, files in os.walk(src): | ||
105 | if len(files): | ||
106 | testfile = os.path.join(root, files[0]) | ||
107 | break | ||
108 | |||
109 | if testfile is not None: | ||
110 | try: | ||
111 | os.link(testfile, os.path.join(dst, 'testfile')) | ||
112 | os.unlink(os.path.join(dst, 'testfile')) | ||
113 | canhard = True | ||
114 | except Exception as e: | ||
115 | bb.debug(2, "Hardlink test failed with " + str(e)) | ||
116 | |||
117 | if (canhard): | ||
103 | # Need to copy directories only with tar first since cp will error if two | 118 | # Need to copy directories only with tar first since cp will error if two |
104 | # writers try and create a directory at the same time | 119 | # writers try and create a directory at the same time |
105 | 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) | 120 | 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) |
@@ -121,12 +136,9 @@ def copyhardlinktree(src, dst): | |||
121 | def copyhardlink(src, dst): | 136 | def copyhardlink(src, dst): |
122 | """Make a hard link when possible, otherwise copy.""" | 137 | """Make a hard link when possible, otherwise copy.""" |
123 | 138 | ||
124 | # We need to stat the destination directory as the destination file probably | 139 | try: |
125 | # doesn't exist yet. | ||
126 | dstdir = os.path.dirname(dst) | ||
127 | if os.stat(src).st_dev == os.stat(dstdir).st_dev: | ||
128 | os.link(src, dst) | 140 | os.link(src, dst) |
129 | else: | 141 | except OSError: |
130 | shutil.copy(src, dst) | 142 | shutil.copy(src, dst) |
131 | 143 | ||
132 | def remove(path, recurse=True): | 144 | def remove(path, recurse=True): |