summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2015-09-24 13:03:34 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-10-01 07:43:31 +0100
commita74fa38365ab91d3143d8b7d6414c97cd3862794 (patch)
tree373bc87294c6214b31ed64715da7e514503072a4 /scripts/lib
parent109c09b58f51025627f226e1afca297ad4be053a (diff)
downloadpoky-a74fa38365ab91d3143d8b7d6414c97cd3862794.tar.gz
devtool: file mover function that creates target dir
Helper function for replacing a pattern like: target_dir = os.path.dirname(target) bb.utils.mkdirhier(target_dir) shutil.move(source, target) (From OE-Core rev: c09e5b11225a673534594c3642ceead3eb5653a3) Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-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)