summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/lib/devtool/standard.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 81a44d4513..3bc84c7418 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -177,6 +177,16 @@ def _parse_recipe(config, tinfoil, pn, appends):
177 return oe.recipeutils.parse_recipe(recipefile, append_files, 177 return oe.recipeutils.parse_recipe(recipefile, append_files,
178 tinfoil.config_data) 178 tinfoil.config_data)
179 179
180
181def _ls_tree(directory):
182 """Recursive listing of files in a directory"""
183 ret = []
184 for root, dirs, files in os.walk(directory):
185 ret.extend([os.path.relpath(os.path.join(root, fname), directory) for
186 fname in files])
187 return ret
188
189
180def extract(args, config, basepath, workspace): 190def extract(args, config, basepath, workspace):
181 import bb 191 import bb
182 192
@@ -196,6 +206,7 @@ def extract(args, config, basepath, workspace):
196 206
197def _extract_source(srctree, keep_temp, devbranch, d): 207def _extract_source(srctree, keep_temp, devbranch, d):
198 import bb.event 208 import bb.event
209 import oe.recipeutils
199 210
200 def eventfilter(name, handler, event, d): 211 def eventfilter(name, handler, event, d):
201 if name == 'base_eventhandler': 212 if name == 'base_eventhandler':
@@ -264,7 +275,21 @@ def _extract_source(srctree, keep_temp, devbranch, d):
264 logger.info('Unpacking...') 275 logger.info('Unpacking...')
265 exec_task_func('do_unpack', False) 276 exec_task_func('do_unpack', False)
266 srcsubdir = crd.getVar('S', True) 277 srcsubdir = crd.getVar('S', True)
267 if srcsubdir != workdir and os.path.dirname(srcsubdir) != workdir: 278 if srcsubdir == workdir:
279 # Find non-patch sources that were "unpacked" to srctree directory
280 recipe_patches = [os.path.basename(patch) for patch in
281 oe.recipeutils.get_recipe_patches(crd)]
282 src_files = [fname for fname in _ls_tree(workdir) if
283 os.path.basename(fname) not in recipe_patches]
284 # Force separate S so that patch files can be left out from srctree
285 srcsubdir = tempfile.mkdtemp(dir=workdir)
286 crd.setVar('S', srcsubdir)
287 # Move source files to S
288 for path in src_files:
289 tgt_dir = os.path.join(srcsubdir, os.path.dirname(path))
290 bb.utils.mkdirhier(tgt_dir)
291 shutil.move(os.path.join(workdir, path), tgt_dir)
292 elif os.path.dirname(srcsubdir) != workdir:
268 # Handle if S is set to a subdirectory of the source 293 # Handle if S is set to a subdirectory of the source
269 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0]) 294 srcsubdir = os.path.join(workdir, os.path.relpath(srcsubdir, workdir).split(os.sep)[0])
270 295