summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/devtool/standard.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index b8435ae701..e4e90a7160 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -174,6 +174,13 @@ def _check_compatible_recipe(pn, d):
174 "from working. You will need to disable this " 174 "from working. You will need to disable this "
175 "first." % pn) 175 "first." % pn)
176 176
177def _move_file(src, dst):
178 """Move a file. Creates all the directory components of destination path."""
179 dst_d = os.path.dirname(dst)
180 if dst_d:
181 bb.utils.mkdirhier(dst_d)
182 shutil.move(src, dst)
183
177def _ls_tree(directory): 184def _ls_tree(directory):
178 """Recursive listing of files in a directory""" 185 """Recursive listing of files in a directory"""
179 ret = [] 186 ret = []
@@ -330,9 +337,8 @@ def _extract_source(srctree, keep_temp, devbranch, d):
330 crd.setVar('S', srcsubdir) 337 crd.setVar('S', srcsubdir)
331 # Move source files to S 338 # Move source files to S
332 for path in src_files: 339 for path in src_files:
333 tgt_dir = os.path.join(srcsubdir, os.path.dirname(path)) 340 _move_file(os.path.join(workdir, path),
334 bb.utils.mkdirhier(tgt_dir) 341 os.path.join(srcsubdir, path))
335 shutil.move(os.path.join(workdir, path), tgt_dir)
336 elif os.path.dirname(srcsubdir) != workdir: 342 elif os.path.dirname(srcsubdir) != workdir:
337 # Handle if S is set to a subdirectory of the source 343 # Handle if S is set to a subdirectory of the source
338 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) 344 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0])
@@ -893,8 +899,8 @@ def reset(args, config, basepath, workspace):
893 for root, dirs, files in os.walk(origdir): 899 for root, dirs, files in os.walk(origdir):
894 for fn in files: 900 for fn in files:
895 logger.warn('Preserving %s in %s' % (fn, preservepath)) 901 logger.warn('Preserving %s in %s' % (fn, preservepath))
896 bb.utils.mkdirhier(preservepath) 902 _move_file(os.path.join(origdir, fn),
897 shutil.move(os.path.join(origdir, fn), os.path.join(preservepath, fn)) 903 os.path.join(preservepath, fn))
898 for dn in dirs: 904 for dn in dirs:
899 os.rmdir(os.path.join(root, dn)) 905 os.rmdir(os.path.join(root, dn))
900 os.rmdir(origdir) 906 os.rmdir(origdir)