aboutsummaryrefslogtreecommitdiffstats
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
parent109c09b58f51025627f226e1afca297ad4be053a (diff)
downloadopenembedded-core-contrib-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>
-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):
"from working. You will need to disable this "
"first." % pn)
+def _move_file(src, dst):
+ """Move a file. Creates all the directory components of destination path."""
+ dst_d = os.path.dirname(dst)
+ if dst_d:
+ bb.utils.mkdirhier(dst_d)
+ shutil.move(src, dst)
+
def _ls_tree(directory):
"""Recursive listing of files in a directory"""
ret = []
@@ -330,9 +337,8 @@ def _extract_source(srctree, keep_temp, devbranch, d):
crd.setVar('S', srcsubdir)
# Move source files to S
for path in src_files:
- tgt_dir = os.path.join(srcsubdir, os.path.dirname(path))
- bb.utils.mkdirhier(tgt_dir)
- shutil.move(os.path.join(workdir, path), tgt_dir)
+ _move_file(os.path.join(workdir, path),
+ os.path.join(srcsubdir, path))
elif os.path.dirname(srcsubdir) != workdir:
# Handle if S is set to a subdirectory of the source
srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0])
@@ -893,8 +899,8 @@ def reset(args, config, basepath, workspace):
for root, dirs, files in os.walk(origdir):
for fn in files:
logger.warn('Preserving %s in %s' % (fn, preservepath))
- bb.utils.mkdirhier(preservepath)
- shutil.move(os.path.join(origdir, fn), os.path.join(preservepath, fn))
+ _move_file(os.path.join(origdir, fn),
+ os.path.join(preservepath, fn))
for dn in dirs:
os.rmdir(os.path.join(root, dn))
os.rmdir(origdir)