[OE-core] [PATCH 5/6] devtool: extract: always import local files to srctree
Markus Lehtonen
markus.lehtonen at linux.intel.com
Thu Apr 30 09:16:11 UTC 2015
Import all non-compressed/non-arcived local files from the SRC_URI
(excluding patches) to the srctree repository. The files will be placed
in 'local-files' subdirectory. However, in case S=WORKDIR, the files are
imported into root ot srctree (and not under 'local-files', as before.
[YOCTO #7602]
Signed-off-by: Markus Lehtonen <markus.lehtonen at linux.intel.com>
---
scripts/lib/devtool/standard.py | 56 ++++++++++++++++++++++++++++++++---------
1 file changed, 44 insertions(+), 12 deletions(-)
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 8a2783b..1e81919 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -253,10 +253,11 @@ def _extract_source(srctree, keep_temp, devbranch, d):
logger.info('Unpacking...')
exec_task_func('do_unpack', False)
srcsubdir = crd.getVar('S', True)
+
+ recipe_patches = [os.path.basename(patch) for patch in
+ oe.recipeutils.get_recipe_patches(crd)]
if srcsubdir == workdir:
# Find non-patch sources that were "unpacked" to srctree directory
- recipe_patches = [os.path.basename(patch) for patch in
- oe.recipeutils.get_recipe_patches(crd)]
src_files = [fname for fname in _ls_tree(workdir) if
os.path.basename(fname) not in recipe_patches]
# Force separate S so that patch files can be left out from srctree
@@ -312,6 +313,23 @@ def _extract_source(srctree, keep_temp, devbranch, d):
bb.process.run('git tag -f devtool-patched', cwd=srcsubdir)
+ # Add unpacked local files (in case of S=WORKDIR these were already
+ # moved to S) into srctree
+ local_files = oe.recipeutils.get_recipe_local_files(crd)
+ local_files = [fname for fname in local_files if
+ os.path.basename(fname) not in recipe_patches and
+ os.path.exists(os.path.join(workdir, fname))]
+ if local_files:
+ logger.info('Adding local files...')
+ for fname in local_files:
+ localf_subdir = os.path.join(srcsubdir, 'local-files',
+ os.path.dirname(fname))
+ bb.utils.mkdirhier(localf_subdir)
+ shutil.move(os.path.join(workdir, fname), localf_subdir)
+ bb.process.run(['git', 'add', 'local-files'], cwd=srcsubdir)
+ bb.process.run(['git', 'commit', '-q', '-m', 'Add local files'],
+ cwd=srcsubdir)
+
if os.path.exists(patchdir):
shutil.rmtree(patchdir)
if haspatches:
@@ -538,17 +556,31 @@ def update_recipe(args, config, basepath, workspace):
tempdir = tempfile.mkdtemp(prefix='devtool')
try:
# Copy local files from srctree HEAD to "recipe space"
- # Local files might be "all over the place", need recursive ls-tree
- git_files = set(_git_ls_tree(srctree, recursive=True))
- copy_files = git_files.intersection(set(local_files.keys()))
- patch_include_paths = git_files.difference(set(local_files.keys()))
- bb.process.run(['git', 'checkout', 'HEAD', '--'] + list(copy_files),
- cwd=srctree,
- env=dict(os.environ, GIT_WORK_TREE=tempdir))
+ if os.path.isdir(os.path.join(srctree, 'local-files')):
+ # Local files are in 'local-files' only list root of git repo
+ git_files = set(_git_ls_tree(srctree))
+ patch_include_paths = git_files.difference(set(['local-files']))
+ bb.process.run(['git', 'checkout', 'HEAD', '--', 'local-files'],
+ cwd=srctree,
+ env=dict(os.environ, GIT_WORK_TREE=tempdir))
+ local_src_dir = os.path.join(tempdir, 'local-files')
+ else:
+ # Local files might be "all over the place", need recursive ls-tree
+ git_files = set(_git_ls_tree(srctree, recursive=True))
+ copy_files = git_files.intersection(set(local_files.keys()))
+ patch_include_paths = git_files.difference(set(local_files.keys()))
+ bb.process.run(['git', 'checkout', 'HEAD', '--'] + list(copy_files),
+ cwd=srctree,
+ env=dict(os.environ, GIT_WORK_TREE=tempdir))
+ local_src_dir = tempdir
+
for fname in _ls_tree(local_src_dir):
- logger.info('Updating file %s' % fname)
- shutil.copy2(os.path.join(local_src_dir, fname),
- local_files[fname])
+ if fname in local_files:
+ logger.info('Updating file %s' % fname)
+ shutil.copy2(os.path.join(local_src_dir, fname),
+ local_files[fname])
+ else:
+ logger.warning('File %s not in SRC_URI, skipping it' % fname)
finally:
shutil.rmtree(tempdir)
--
2.1.4
More information about the Openembedded-core
mailing list